Whenever I deal with sites requiring more granular access than per-role, I struggle with some modules not allowing more granular access. Check #309007: Add drupal_alter() after hook_node_access_records() to see that this is a real problem and Drupal 7 is adding drupal_alter to node access records.
What I would like to have in nodequeue - to be able to control who has access to queue or subqueue based on my module. It can simply be done by implementing drupal_alter at end of nodequeue_api_*queue_access functions.
I am attaching a patch to this, it's a small change.
Possible use case: We have a site based on organic groups. Every organic group is in fact a magazine with several readers, contributors and editors. Using OG subqueues, every magazine has own queue to use for frontpage. Only group admins have access to change that queue though. I need to allow magazine editors to edit it too.
Simple code:
/**
* Implementation of hook_nodequeue_api_subqueue_access_alter().
*
* Access to group subqueue: Magazine editor, Site admin, Group admin.
*/
function MYMODULE_nodequeue_api_subqueue_access_alter($access, $subqueue, $queue, $account) {
// Special roles we use. $subqueue->reference is organic group ID.
$roles = (array) $account->og_groups[$subqueue->reference]['csr_roles'];
// Magazine editor, Site admin or Group admin.
if ($roles[CSR_MAGAZINE_EDITOR_ROLE] || in_array('site admin', $account->roles) || $account->og_groups[$gid]['is_admin']) {
$access = TRUE;
} else {
$access = FALSE;
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| nodequeue_access.patch | 657 bytes | meba |
Comments
Comment #1
ezra-g commentedFor OG subqueues, are you using http://drupal.org/project/smartqueue_og ? It has a setting whereby group admins or all group members can manipulate a group queue which sounds like it might fit your use case. Aside from this issue, I'd love to hear more about the site and how your users are using Nodequeue.
Using drupal_alter seems like a great improvement upon the current smartqueue hook_implementation, which only allows one specifically named function to alter the access check for each queue or subqueue. Rather than add the drupal_alter at the end of this function, I think it should replace the current smartqueue_api checks. It would be great if you could re-roll the patch with that approach (and it would be even greater if you could make the related documentation changes) :D.
Thanks!