diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-02-20 13:46:43 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-02-20 13:46:43 +0000 |
commit | 584f3e886a7c9850d53fedaab2c8f3d0249bda10 (patch) | |
tree | 8a089ab394e25f3703e9e47912ca242e0550be5d /modules/node/node.module | |
parent | 8e0d6b4690866b3dd39bd4128e9845d9fb79b6fc (diff) | |
download | brdo-584f3e886a7c9850d53fedaab2c8f3d0249bda10.tar.gz brdo-584f3e886a7c9850d53fedaab2c8f3d0249bda10.tar.bz2 |
- Patch #30984 by webchick, keith.smith, kkaefer, Crell et al: provide descriptions for permissions on the permission administration page.
Diffstat (limited to 'modules/node/node.module')
-rw-r--r-- | modules/node/node.module | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index b517608d9..9213311fb 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1120,16 +1120,18 @@ function theme_node_log_message($log) { * Implementation of hook_perm(). */ function node_perm() { - $perms = array('administer content types', 'administer nodes', 'access content', 'view revisions', 'revert revisions', 'delete revisions'); + $perms = array( + 'administer content types' => t('Manage content types and content type administration settings.'), + 'administer nodes' => t('Manage all website content, and bypass any content-related access control. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))), + 'access content' => t('View published content.'), + 'view revisions' => t('View content revisions.'), + 'revert revisions' => t('Replace content with an older revision.'), + 'delete revisions' => t('Delete content revisions.'), + ); foreach (node_get_types() as $type) { if ($type->module == 'node') { - $name = check_plain($type->type); - $perms[] = 'create '. $name .' content'; - $perms[] = 'delete own '. $name .' content'; - $perms[] = 'delete any '. $name .' content'; - $perms[] = 'edit own '. $name .' content'; - $perms[] = 'edit any '. $name .' content'; + $perms += node_list_permissions($type); } } @@ -2731,3 +2733,25 @@ function node_unpublish_by_keyword_action($node, $context) { } } } + +/** + * Helper function to generate standard node permission list for a given type. + * + * @param $type + * The machine-readable name of the node type. + * @return array + * An array of permission names and descriptions. + */ +function node_list_permissions($type) { + $info = node_get_types('type', $type); + $type = check_plain($info->type); + + // Build standard list of node permissions for this type. + $perms["create $type content"] = t('Create new %type_name content.', array('%type_name' => $info->name)); + $perms["delete any $type content"] = t('Delete any %type_name content, regardless of its author.', array('%type_name' => $info->name)); + $perms["delete own $type content"] = t('Delete %type_name content created by the user.', array('%type_name' => $info->name)); + $perms["edit own $type content"] = t('Edit %type_name content created by the user.', array('%type_name' => $info->name)); + $perms["edit any $type content"] = t('Edit any %type_name content, regardless of its author.', array('%type_name' => $info->name)); + + return $perms; +} |