Hi,
First - thank you for the module!
I would like to re-direct all non-admin users from all node/* pages into other path/panel/...
How can I create this condition? (In the token i didn't find any [USER:Role])
Cheers,
Amitai
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | roles5.patch | 8.98 KB | liam mcdermott |
| #14 | roles4.patch | 8.98 KB | liam mcdermott |
| #8 | roles3.patch | 8.99 KB | liam mcdermott |
| #6 | roles2.patch | 9.28 KB | liam mcdermott |
| #4 | roles.patch | 8.15 KB | liam mcdermott |
Comments
Comment #1
fagoyep, I also have already noticed that token doesn't support user roles.
I'll either include token support or write a condition so that it's possible to restrict actions by user role.
Comment #2
amitaibuAfter we will have the filter by user role, how will it be possible to re-direct all non-admin users from all node/* pages into other path/panel/.. ?
Is there a way of comparing the URL and finding the word node?
Cheers,
Amitai
Comment #3
amitaibufyi
http://drupal.org/node/162502
Comment #4
liam mcdermott commentedHere's a patch that will fulfill this requirement. It also:
Comment #5
amitaibujeevesbond,
Checking your patch:
* Test if user has a role - rename to "Test certain role(s)" . (Since all users have a role, even if they are admin).
* Test if user has a role - can roles be multiple selection?
* Numeric comparison - Cool. maybe also add "Equal or greater"; "Equal or Less". It can be done with two conditions, but I think it is less user friendly.
* You rock! :)
Comment #6
liam mcdermott commentedPoint by point:
So: scratch that previous patch! Attached is newer, funkier one! ;)
Comment #7
fagogreat!
@numeric comparison
I wondered if we should cast the variables to floats (float)$var before doing the actual comparison - at least for == it wouldn't be a numeric comparison else. I don't know how php behaves with in case of strings, however a cast couldn't harm I think.
@equal or greater: Like you prefer, it can be done by combining some conditions nevertheless.
@language: "Test certain role(s)" - I don't think it's a good idea to include "test". Most conditions are tests so we would end with "Test content type", "Test .." - so I would prefer "User has role(s)".
@condition userhasrole:
Why the cast? And you could just call it $settings['roles'] - a bit cleaner I think.
Please use 'op' or better 'operation' as you have done with the numeric comparison. you could use values like
array('OR' => t('any'), 'AND' => t('all')) - to get clear UI and code.
In drupal this is usually called $rid, perhaps just use foreach ($roles as $rid => $role)..
obey drupal code style, use
That's it! Let's clear this small issues out and get it committed :)
Comment #8
liam mcdermott commentedSounds like a good idea. I've put a cast in front of each function call, it seems to be working: is this allowed in PHP though? I checked the online docs and they only show casting a variable. Just one of those things I've never had to do before!
Let's just commit as-is (if that's alright with you) and see what the demand to have >= etc. combined into the selection is.
Yep, good point. That's been changed.
The cast is there for when the user selects only one item, PHP returns a number instead of an array. Thought the code would be more readable with a cast instead of another if statement.
Good point, that code is about as readable as Ancient Egyptian at the moment. Have rewritten it as a switch case statement, it looks far better now.
Changed.
Changed and will bear in mind for future. :)
Hell Yeah(tm)! I've attached another patch, haven't had time to test it as thoroughly as the last one so give it a try before committing it! Think I got everything on your list, if something is missing, let me know. :)
Comment #9
amitaibuwow, I like the speed things are happening here...
jeevesbond/fago I found a bug:
1. import the Workflow.
2. Enter any node (node in URL) as an authorized user - message appears.
3. Ebter and node as anonymous - message does not appear.
Comment #10
amitaibuI see it also shows the message for Admin, but it should show only to Anonymous and authenticated .
Comment #11
liam mcdermott commentedThe anonymous problem: try using a different event, you're using: 'Invoked on event: Content view by a logged in user'. Which will not trigger the event for an anonymous user. Anonymous means not logged-in in Drupal. :)
I believe an Administrator is an authenticated user, that's why the message will display (in fact I believe anyone who's logged-in, ergo everyone but Anonymous, has the authenticated user role). You should probably pick a more specific role, or just live the odd message popping up. It's an advantage of Drupal that it has a role which covers every logged-in user in my opinion. :)
If you get any more problems do let us know though! It's better to be advised of a configuration issue than miss a bug. It's also cool to learn how people use stuff.
If I'm wrong about anything am certain fago will correct it, he's the final authority: I'm just his patch-tart. ;)
Comment #12
fagoyes, indeed great respond speed!
regarding the anonymous issue, read http://drupal.org/node/164170
@the patch:
It already looks a lot cleaner! However, some points you mentioned that you have changed are still in there? Perhaps you have uploaded a wrong version of your patch? ($role_key, Test user roles).
Then your role selection form isn't #multiple as you have written above?
Probably this is because you need to cast the roles to an array - because if #multiple is set the value should be always an array.
Comment #13
amitaibujeevesbond,
Maybe for the 'user friendliness', it is possible to show the relevant options, according to the chosen event.
Fago,
Maybe a nice feature would be to allow to change the Event. Currently, if user wants to change it - they need to create the WF.
Comment #14
liam mcdermott commentedI'll do that, if you pay me lots of money. :) Seriously though, that's easy to say but the framework doesn't (and probably never will) support it. It's too much work for what we call a 'fringe case' I'm afraid. You could raise another bug for it though, it would mean the condition would somehow have to be aware of the nature of the event, any thoughts fago?
I've had another go at a patch fago. Am really tired at the moment so am making lots of mistakes, thanks for being patient. I literally fell asleep in my chair after uploading that last one! :D
#multiple in forms, didn't know about that (apart from when creating a select element), have used that instead of a cast, tested and all seems well.
That would be desirable, are you going to create a new feature request? Personally I'd like to see multiple events for the same set of conditions/actions, I messed about with the code a little, but the system pretty-much assumes a single event per-item throughout; I gauged it not worth the effort (for the moment).
Comment #15
liam mcdermott commentedWhoah there Skippy! I've made another mistake! Didn't do a CVS update before creating that patch, here's a new one. :)
Comment #16
liam mcdermott commentedpatch attached....
Comment #17
fagothanks, good work! -> committed :)
Sry for confusing you with #mulitple, I was wrong in this point. I've overlooked that you have used checkboxes, and not a select. I meant just the #multiple property of a select. Nevertheless the (array) cast wasn't needed for checkboxes too.
So the form #multiple property doesn't exist - I removed this line.
Comment #18
fago@event changing:
I thought about this, but this isn't practicable - because changing the event would change the available arguments. As an affect the configured actions/conditions aren't valid any more. So no way to do so - sry.
Configuring multiple events would be possible - however then only the intersection of the available arguments would be available for configuration. So I'm not sure if this would be so neat.
Comment #19
(not verified) commented