The usernode module provides an alias of the user table, along with additional fields, filters, and sorts. I've ported these back to the main views_user.inc to give everyone the ability to display, filter, and sort by author information included in the user table. Thanks to fago for the doing the hard work. :-)
This patch adds the following fields: mail, status, account created, last access, and last login; filters: mail (using standard LIKE op), status, account created, last access, last login; sorts: uid, mail, status, created, access, login.
This patch also moves views_handler_field_email
from views_profile.in to views_user.inc. This seemed more logical to me.
Also, there are two new generic field handlers: views_handler_field_value
and views_handler_field_map
The first, views_handler_field_value
, runs check_plain() on the $value. I know this is standard behavior if one does not specify a handler, but for email address, I wanted to specify two handlers, so I had to have something to call to create a plain text version. This handler could be used for the node title field too - instead of using the option field.
The second, views_handler_field_map
allows field definitions to pass in an array of key-value pairs. For the key that matches the $value, the value from the array is returned.
Both of these handlers probably should go into views.module proper. If there are already handlers that do this, let me know and I'll reroll the patch.
On a final note: I think all the 'User: XXXX' labels should be changed to "Author: XXXX". E.g. "User: Author's Email" could be the less verbose, clearer "Author: Email". I think this makes a lot more sense about what data is being displayed, filtered, or sorted. I have not done that in this patch, but I would happily update this patch if there is support for that idea.
Comment | File | Size | Author |
---|---|---|---|
views_20070511_user_table.patch | 7.75 KB | mfredrickson | |
Comments
Comment #1
fagothanks - I've should have done that myself along time ago.. ;)
+1 for using Author: .. It's clear and it helps avoiding confusing people about the difference of Usernode: .. <-> User: ..
@views_handler_field_value: I've used '' => ... in the past, which works too, because views uses the default behavior then. But that's not very clean..
@views_handler_field_map: Also a nice idea. Imho a check_plain isn't needed, as usually this shouldn't be used with "unsafe" data and so one could use HTML. But probably it should be mentioned in the docs..
However I agree that the last two should go into the views.module - and views_handler_field_value() should be used as default if there is no defined handler. Another use case I could think of for views_handler_field_map() are the node option flags (published, frontpage, ..), which currently have not any views fields.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedPlease get someone to test this and confirm. It looks pretty good so I doubt there will be issues; I'll commit this after Views 1.6 if it all checks out. Thanks. =)
Comment #3
dtabach CreditAttribution: dtabach commentedThis is a great and much useful addition. I tested the attached patch against Views 5.x-1.6, and it worked fine in my local site.
It allowed me to remove Usernode module, which I used only for filtering views by last access.
Update: the patched Views went live for 3 weeks now, and everything is OK!
Comment #4
webmasterkai CreditAttribution: webmasterkai commentedThis is extremely useful. I patched against Views 5.x-1.6 and it works fine on a live site. I am using it to list User: Author Email.
Thanks!
Comment #5
mroswell CreditAttribution: mroswell commentedCan this be placed into a new release for views 1 (or has this been done already, somewhere?)
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedRight now no one is really working on the Drupal 5 version of views.
Comment #7
sun@mfredrickson/fago: Will there be any conflict with usernode if this gets committed for 1.7?
Comment #8
esmerel CreditAttribution: esmerel commentedAt this time, only security fixes will be made to the 5.x version of Views.