listing of the default user roles anonymous and authenticated users is useless, as there are no entries in 'user_roles' for them.

this patch removes them from the user roles list.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Wouldn't it be better to actually utilize the roles, since we can check $user->uid for them?

fago’s picture

That's right.

There is an entry for anonymous users in the users_roles table, so only the role for authenticated users needs a special handling.
The attached patch adds a custom handler for this. To enable reusing of existing code I created a function views_handler_filter_default(), which does the default filter handling. I left this function in views_query.inc directly under the original code, hopefully that's ok so?

Further I stripped the function views_handler_filter_usercurrent_custom, which isn't used any more.

merlinofchaos’s picture

Hunk #2 of this patch failed to apply for me. How odd.

fago’s picture

oh sorry, there were some conflicts with the table alias prefix patch.

I've attached a new patch made with a clean views-head install. It includes some further tiny code improvements.

merlinofchaos’s picture

Ok, this is my fault, I let this sit too long, and naturally it won't apply anymore. :P I think I lost this one in the heaviness of my queue.

Can you do me a favor? Split this into two patches -- the cleanups really need to be a patch on their own. I think I like what you did but I don't want it tied to this, which is a much simpler issue.

fago’s picture

Assigned: Unassigned » fago
Status: Needs review » Needs work

hm, yeah it would made sense to split it, however this patch wouldn't be as simple if the other one isn't in, because then I would have to copy these default filter handling code to the custom handler too...

so to simplify it I would like to reroll it and either
* keep it together or
* make two patches, where the second one depends on the other one, which introduces views_handler_filter_default()

merlinofchaos’s picture

A dependency is ok.

fago’s picture

ok, here is the first part of the patch, which introduces views_handler_filter_default(), so that custom filter implementations could reuse it.

attached is the patch for 5.x

fago’s picture

Title: don't list default roles » don't list default roles & introduce views_handler_filter_default()
Status: Needs work » Needs review
FileSize
4.15 KB

and here is the one for 4.7

fago’s picture

here is a patch for 4.7, that fixes the role: author by role filter for 4.7 for all possible operations and roles.

it also moves the views_handler_filter_role() function to the user.inc, the only places where it is used and it removes the unused function views_handler_filter_usercurrent_custom().

I also wanted to make a patch for 5.x for this changes, however there is problem: drupal 5.x doesn't include the anonymous role 1 in the user roles table anymore. it got deleted with system_update_171. so this makes things rather difficult, but I'll have a look at it tomorrow.

fago’s picture

so, it's done. attached is a patch for 5.0 which also fixes the role: author by role filter for all possible operations and roles :)

as the patch for 4.7 it also moves the views_handler_filter_role() function to the user.inc, the only places where it is used and it removes the unused function views_handler_filter_usercurrent_custom().

fago’s picture

here it is

fago’s picture

and here is an updated patch for 4.7 - now it makes also use of the drupal constants DRUPAL_ANONYMOUS_RID and DRUPAL_AUTHENTICATED_RID for better readibility.

merlinofchaos’s picture

Status: Needs review » Fixed

Hey, guess what...once again the patch didn't apply!

Just kidding. It's in. =)

Anonymous’s picture

Status: Fixed » Closed (fixed)
RobRoy’s picture

Version: 6.x-2.x-dev » 5.x-1.x-dev
Priority: Minor » Normal
Status: Closed (fixed) » Active

I'm getting Fatal error: Call to undefined function views_handler_filter_default() in ....views\modules\views_user.inc on line 475 on a fresh update of DRUPAL-5. Is there another patch waiting to go in or did this not get backported correctly?

fago’s picture

backport? this is in views 5.x and it is working fine for me.
If you are manually applying these patches apply both! (Read the whole issue.)

RobRoy’s picture

The version was set to HEAD, so I thought it might have been committed to HEAD and not backported to DRUPAL-5. I did a clean update of DRUPAL-5 and got this error. I'll see if I can find a generic View to reproduce (as mine uses custom field types).

merlinofchaos’s picture

Crap, he's right. views_handler_filter_default() doesn't appear anywhere in current views -dev. And my memory is spotty on where that function originally appeared.

fago’s picture

Status: Active » Reviewed & tested by the community

ah, indeed. sry robroy..

Puh, what a zombie! Let's kill this issue merlin ;)
You forgot to commit the patches from the comments #8 and #9.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Hmm. Looks like I committed this on 4/12 and forgot to mark it fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)
deekayen’s picture

Just for the record, it wasn't 4/12 (since I looked for it there), it was CVS revisions 1.11.2.4 and 1.14.2.6 on Sat, Mar 3, 2007. I'm still having issues related to usernode, but will take that up at http://drupal.org/node/99726