I am currently in the process of upgrading from Drupal 4.7 to 5.7, and while I'm at it, I'm switching from Simple Access to Nodeaccess. Simple Access was never really satisfactory for me, mostly due to its annoying habit of forgetting grants whenever someone edited a node - it was never possible to grant any rights to a node to any more than a single group. Nodeaccess seems to be an improvement, but it is not entirely satisfactory either - I found myself missing some features from Simple Access and the danger of losing grants was still there.
Fortunately I am sufficiently fluent in PHP to figure out how this module worked, and to solve the issues I had. I'm including a patch which includes new features I needed, hoping someone else might find them useful also. There are also some minor cases of cleanup, such as correcting typos in comments and code indentation.
Feature 1: limiting the editable grants
My most pressing need was to limit the grants I would allow users to edit. I wanted to use Nodeaccess for granting edit rights to users, and nothing else. In my patch, there is a new option in the settings which lets you check which grants you want to use. If for instance you check only Edit, then users can only see and change Edit rights. By default all are checked.
Feature 2: preserving the hidden grants while saving
This feature was absolutely necessary after the first. Before, if for instance you did not allow users to edit the grants for anonymous visitors, and they edited the grants they were allowed to see, any grants that were hidden would be revoked, leaving the page invisible to anonymous visitors. With my first feature this got more serious: if only Edit rights were enabled for users to change, then all view and delete rights would be gone the moment they clicked save.
This called for a method of preserving the grants that were hidden. There is now an option in the settings which, if on, preserves all the hidden grants unchanged. It is by default on, but can be turned off if anyone actually needs the previous behaviour. It affects all the hidden grants, whether they are hidden roles or hidden rights.
Feature 3: aliases and weights for roles
I am using LDAP Integration in conjunction with Nodeaccess. The annoying thing about this is that LDAP groups have their own way of naming: I'm told that some legacy systems will only understand group names no more than 8 characters long. Keeping the group names that short may be overkill on part of our LDAP admin, but either way, I'm stuck with LDAP groups and roles with names as illuminating as 'websmlb' - which means hardly anything to even members of the Statistical Machine Learning and Bioinformatics research group which it is an acronym of. Consider the fact that I have 25 such roles, and you'll agree that I can't blame anyone for failing to understand which group they should grant Edit rights to.
What I needed was to give human-readbale aliases to these machine-readable role names. This I did, and while I was at it, I gave them weights too, which can be used to arrange the roles in a desired order for the user to see. These can be edited in the settings, in the same fieldset where you enable specific roles. Of course, you don't need to make any aliases: leave the field empty, and it will default to the name of the role. The weights default to 0.
Installation
I made a new table named 'nodeaccess_role_alias' for storing the aliases and weights of roles. Since it is necessary for everything else to work right, you need to run update.php after installing this patch. The update will create and populate the table, and it will also set View, Edit and Delete to be editable by default, as they are now. The only immediate difference is that hidden grants will no longer disappear when clicking save, but this and all other new options can be changed at will.
This is all I have for today. Hope this helps someone out there.
I'm including both the patch file and the .tar.gz containing all the files of the module. I only edited nodeaccess.module and nodeaccess.install.
Teemu Mäntylä
Webmaster of HIIT - Helsinki Institute for Information Technology - www.hiit.fi
| Comment | File | Size | Author |
|---|---|---|---|
| nodeaccess_new.tar_.gz | 17.47 KB | mantyla | |
| nodeaccess.patch | 21.95 KB | mantyla |
Comments
Comment #1
mantyla commentedGo here for the latest version of my patch, and a D6 version: http://drupal.org/node/244613.