Active
Project:
To do list
Version:
6.x-1.4
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Dec 2010 at 16:17 UTC
Updated:
30 Dec 2010 at 21:31 UTC
I realize that the permissions system was just overhauled -- which is great and much appreciated -- but I'd like to make some suggestions for additional permissions:
1. can set priority
2. can set assignment (if they can't set the assignment, it's always assigned to self.)
3. can set dates
4. can set priority
I added the following code in hook_form_later to achieve this the first two above. Note that it's a role named 'youth' with a key of 4 that I want to remove those fields for. You will also see that if a 'builder' is also a 'youth', we don't want this code executed.
case 'to_do_node_form':
global $user;
$role_ids = array_keys($user->roles);
// User is 'youth' and not 'builder'
if (in_array(4, $role_ids) && !in_array(3, $role_ids)) {
dsm('user is a youth');
if (isset($form['assignment']['new_user0']['#type'])) {
$form['assignment']['new_user0']['#type'] = 'hidden';
}
if (isset($form['assignment']['new_user1']['#type'])) {
$form['assignment']['new_user1']['#type'] = 'hidden';
}
if (isset($form['assignment']['new_user2']['#type'])) {
$form['assignment']['new_user2']['#type'] = 'hidden';
}
if (isset($form['assignment']['mark_permissions']['#type'])) {
$form['assignment']['mark_permissions']['#type'] = 'hidden';
}
if (isset($form['assignment']['self']['#default_value'])) {
$form['assignment']['self']['#default_value'] = '1';
$form['assignment']['self']['#type'] = 'hidden';
}
if (isset($form['assignment']['#type'])) {
$form['assignment']['#type'] = 'hidden';
}
}
break;
Comments
Comment #1
AlexisWilke commentedHi Capellic,
Do you need "can set priority" twice or did you mean something else?
My worry on this one would be the complexity of the thing. I'm not too sure why people would want such granularity. Plus, you could say "can set Urgent priority"... and other similar super detailed permissions. And again, that would make it complex not just to maintain, but also for users to know what the heck is going on (especially since permissions are not set by default.)
This being said, I would imagine that having a separate module (to_do_permissions) would be a solution. That extra module could hack the default to_do form and remove items that a user is not allowed to tweak (the hack would be to transform the fields in #value so they are not editable but still available to the validate and submit features.)
Another concern, although I don't think it would happen too often, the validation may require the change of a hidden parameter rendering certain changes non save-able.
Thank you.
Alexis Wilke