I've been banging my head against this all day, but I've barely gotten anywhere.
I'd like to do two things.
1) Filter results based on the current user's ID, but I don't want to filter against the node's UID - I want to filter against a CCK user reference field within the node. Basically, it's an 'assigned to' value that may be different than the node's owner.
2) Filter out results based on one of my CCK integer fields EXCEPT when a user has a particular role (or permission, perhaps). I have a CCK checkbox that is intended as a 'restrict seeing this node to the editor group'.
Can anyone assist? I've spent about four hours slogging through Google search results, the Views code, etc., but I'm having a rough time of it.
Comments
Comment #1
knieveltech commentedYou may be able to get what you're after with argument handling code and/or an added computed field or two, but it sounds like it'd be simpler to bail out of views on this one in favor of writing something quick and dirty that queries the db directly for the nodes you're after.
I haven't done much work with CCK's user reference field but if it's sufficiently similar to node reference getting it to work with views may require you to add a computed field that stores a copy of the value(s) you're trying to sort/filter on. You might also consider inserting an argument or two, that way you have somewhere to insert your user role checking.
If you're truly desperate you might try cutting a quick and dirty module that implements hook_views_arguments() with your context checking and sql extensions appended to $query via a handler function. This will allow you to roll your own argument for views. You might also implement _views_views_tables() and write your own custom filters.
Comment #2
merlinofchaos commentedAdd a relationship on the user reference to the user; then filter user:uid (using that relationship) is currently user.
Comment #3
merlinofchaos commentedComment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.