[development] Even more flexibility in content management
Nedjo Rogers
nedjo at islandnet.com
Fri Dec 29 00:31:22 UTC 2006
> "view TYPE content" - roles that are allowed to view the content type's
> nodes
'view' is already one of the options fed into hook_access(), so in that
sense this set of permissions already exists--it's just not implemented
(yet) in the core node types. If you wish to implement it for a custom node
type, you can define perms 'view whatevers' and/or 'view own whatevers' in
hook_perm().
Then:
/**
* Implementation of hook_access().
*/
function whatever_access($op, $node) {
global $user;
if (user_access('administer whatevers')) {
return TRUE;
}
if ($op == 'view') {
return (user_access('view whatevers') || (user_access('view own
whatevers') && ($user->uid == $node->uid)));
}
,,,
}
> "administer TYPE content" - roles that are allowed to modify the
> publishing options on all nodes of that content type
This could be done in a contrib module for 5.0. Something like:
function adminnodetype_perm() {
$perms = array();
foreach (array_keys(node_get_types('names')) as $type) {
$perms[] = "administer $type content";
}
return $perms;
}
function adminnodetype_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' ==
$form_id && user_access( 'administer '. $form['type']['#value'] .'
content')) {
foreach (array('author', 'options') as $key) {
$form[$key]['#access'] = TRUE;
}
}
}
More information about the development
mailing list