Jump to content

FlorianA

Members
  • Posts

    50
  • Joined

  • Last visited

Everything posted by FlorianA

  1. Hi, I would like to provide an ICS calendar URL for registered users. However, it should be possible to load this URL without the need to login before, since this would be difficult for many calendar apps. That's why I would like to generate an individual URL for each user which contains a kind of authentication token. An implementation could look like this: The token is an MD5 hash of the user name, his encrypted password and maybe something else. Both user name and token are added to the URL as GET params. When calling the template, a token is calculated from user name parameter and compared to the token parameter. If both are identical, the user will be handled as authenticated. What's the easiest way to implement somethin like this in PW? The exact solution above seems not to be possible, as AFAIK the API doesn't provide access to the encrypted password. But I'm sure there's any existing solution for this in PW or any module ?
  2. I still found a weird bug after having changed the default language by SQL: The "Language Support - Tabs" module doesn't work correctly any more. It does show the tabs, but on each tab the fields for both languages are shown, too. Does anybody have a clue why this could be?
  3. Thanks a lot for this solution @mscore! I've just switched successfully my default language from English to German by this. The only remaining step seemed to be moving "German" to the first position of "Languages" in the page tree, then I also get the "German" tab at first position when editing a text. I really can't understand why this is no PW default feature yet -- this feature was essential for finishing my site migration to PW, and my fear of wrecking my content by a dirty workaround delayed my project probably by several months!
  4. It does work with dev version 3.0.93 Thanks a lot for your assistance, @adrian
  5. That's a valuable hint. Up to now my concept was to restrict permissions not only for the "hide_year_of_birth" field but also for other more "private" user fields like street or phone numbers. That's why I didn't want to handle this one field by a global permission. But my plans break down anyway if the restricted fields aren't editable any more even for the user's own profile. So I have to look for another solution ... I think it will be something like a "view_extended_user_data" permission which applies not only to the year of birth but also to some other fields.
  6. Tracy Console? ... <google> ... Tracy Debugger ... Wow! What a wonderful tool! I should have discoverd that earlier. I think it would deserve a place on https://processwire.com/docs/tutorials/ Anyway, my problem persists even when trying the command above. My PW version is 3.0.61
  7. For one role I've tried these four cases, none of them filtered out any user with role "foo": !roles=foo roles!=foo !roles.name=foo roles.name!=foo
  8. It's easy to select all users who have a certain role. E. g.: users('roles=foo|bar') selects all users who have at least one of the roles "foo" or "bar". But I failed doing the opposite: selecting all users who don't have role "foo" or don't have role "bar". I even don't manage the case with only one role. Any ideas?
  9. Not really. Every logged-in user should be able to view day and month of the birthday, but not on the year. If we want to know if the user is also allowed to see the year, we look into the "hide_year_of_birth" field. If we are not allowed to view this field we can't know if the the user wants to expose his age and therefore we assume "no".
  10. In my current project, I've extended the user template by two fields: birthday (Datetime: the user's birthday) and hide_year_of_birth (Checkbox: does the user want his year of birth to be hidden for other users?). Furthermore I'd like to have three groups of users: - Group 1 always sees years of birth for all users. - Group 2 sees only years of birth of these users who have unchecked their hide_year_of_birth flag. - Group 3 can't see a year of birth of any user. For implementing this, the field hide_year_of_birth has view permission only for groups 1 and 2. In the template file, if hide_year_of_birth is not viewable, a value true is assumed. function getBirthday($user) { return $user->hide_year_of_birth || !fields('hide_year_of_birth')->viewable() ? strftime(__('%d.%m.'), $user->getUnformatted('birthday')) : $user->birthday; } Unfortunately, this didn't work as I meant. When I logged in as a user of group 2, I saw the year of birth of another user with hide_year_of_birth checked. The debug output said that $user->hide_year_of_birth was 0, however fields('hide_year_of_birth')->viewable() was true. When I logged in as a user of group 1 or 3, it worked as expected. Edit: No, group1 doesn't work either, but that's why I've just hadn't thought about it in implementation - but it isn't relvant for this question either ;-) Could this be a bug which makes $user->hide_year_of_birth return the "empty" value for unviewable fields although the field is viewable? After I checked the field option "allow access value by API even if not viewable" for hide_year_of_birth, everything worked as expected also for the group 2.
  11. function getSettings() { return pages()->get('/site-settings/'); } $home = $pages->get('/'); foreach ($home->children()->not(getSettings()->menu_filter) as $childPage) { // the not() part has no effect }
  12. In order to hide some pages from my site menu, I've defined a field called 'menu_filter' with field type 'Selector'. In my page editor, I assigned a value to the field by choosing the combo boxes 'template' 'Equals' 'event'. After that I tried to apply this selector to a WireArray in a template file, but the selector string was 'template=45' rather than 'template=event', that means it shows the template's id, not its name. Therefore the selector doesn't work in my code. How can I fix this?
  13. After some further thoughts I wonder if it is a good idea to activate the Multi-Language URLs at all for my site. I have a lot of pages that will probably never be published in an other than the default language, but users with other languages should see untranslated pages nevertheless in the default language - without any additional effort for the page author. Would it be a solution for this to leave the multi-language URL module away and keep only the multi-language fields? One URL for all languages would be sufficient for me. Are there any other drawbacks with this approach?
  14. While it's generally a good idea to avoid globals in PHP I'm wondering what is the easiest way to access the PW API variables like $page, $user, $fields etc. from a function body within a template file. I would like to understand them as a kind of "superglobals", so I find it tediuos to pass them as parameters to every function that needs them. On the other hand, I haven't found a solution to access them as PHP globals within a function (with my humble PHP knowledge). Neither Jonathan's solution nor the $GLOBALS approach seems to work with PW "globals". Are there any best practices how to acces the PW API variables from a function?
  15. Thanks a lot @SiNNuT, it works! Would never have found it out myself - still seeing no API ...
  16. I have exactly the same problem, but I'd like to import my event pages by a command line script from another database. So I need to activate the language specific URLs programmatically, but I haven't found an API function to do this. Can anybody help me?
  17. No template? But a page without template isn't possible, is it? Currently I'm setting the 'entry' page's name to it's ID in order to avoid generated names (timestamps) which seem to be longer.
  18. Hi, is it possible to set a page's date fields "created", "modified" and "published" to arbitrary values programmatically? I have to import some pages from another (non-PW) system and I'd like to preserve at least their modification timestamps.
  19. Thanks a lot for showing me. Looks really nice on first glance, but unfortunately it doesn't meet my requirements completely, since the Matrix can only contain one string in each cell, but in order to port my current solution to PW, I also need for each cell (at least) a second string which holds an optional comment on just that single value a change date for the cell. A more specific type for the actual input value (boolean, number, selection), along with an appropriate backend editor would also be nice, but not essential, since the values could be stored as strings as well, and for editing I'll probably need a more user-friendly front-end solution anyway. After all, a page for each cell might be a not so bad solution. Maybe I can user something like the URL Shortener module in order to keep the names short at least ...?
  20. I've just extended FieldtypeTime and InputFieldTime by support for blank values Failed to add a push request to https://github.com/netcarver/PW-FieldtypeTime, so please find my patch attached ... Works fine at me. PW-FieldtypeTime-Empty-times.patch
  21. For my website, I need to implement a feature similar to Doodle: A table with a list of events as columns and a list of users as rows. The inner table cells show for each PW user at which events he can participate (btw. this "participate" need not to be simply a boolean flag, but can also be a selection (yes/no/maybe), a number or a string, along with a comment). In a classical relational database, this would be easy to implement as a many-to-many relation. With PW, I couldn't find a really satisfying solution so far. My current approach is to insert a page for each "participate" cell whose template has references to both a user and an event page. However, I think it's not really efficient to have a whole page for each cell. The pages will never be needed as an isolated unit but only as parts of other pages. There may be many thousands of these pages which would mess up the page tree in the backend. Each page has several additional fields in the underlying database which will never be needed but increase considerably the needed storage space: name, publish date etc. Maybe this implementation will nevertheless run smoothly in practice, but it simply feels quite cumbersome compared to the plain MySQL implementation of my previous website, so my hope is that there's a smarter PW solution for this. Can anybody give me some hints?
  22. Thanks a lot for the hint, Robin S. I've just joined the thread about the module, since it still has an issue with blank values ... (https://processwire.com/talk/topic/7857-module-fieldtypetime-inputfieldtime)
  23. Why don't you insert a NULL value for the time if it's left blank? This should work perfectly with MySQL. Apart from that, thanks a lot for the module, but the blank problem is also essential for me, so I really would appreciate a solution
  24. A field of type Datetime can be configured to leave the time away, for cases where you are only interested in the date. Unfortunately, I need the opposite: A time field without additional date. But it seems not to be possible to configure Datetime to leave the date away. Is there a possibility to do this? Or any alternative, e. g. a module? Of course I simply could use text fields for time input, but I would prefer the nice time picker and automatic input validation.
×
×
  • Create New...