#313213 by maartenvg, Gábor Hojtsy: Add a 'title' attribute for permissions to allow for localization of permission names

merge-requests/26/head
Angie Byron 2008-10-09 15:15:55 +00:00
parent c9c35d2d58
commit d59ba41f65
23 changed files with 235 additions and 67 deletions

View File

@ -19,7 +19,7 @@ Drupal 7.0, xxxx-xx-xx (development version)
* Implemented drag-and-drop positioning for input format listings.
* Implemented drag-and-drop positioning for language listing.
* Implemented drag-and-drop positioning for poll options.
* Provided descriptions for user permissions.
* Provided descriptions and human-readable names for user permissions.
* Removed comment controls for users.
* Removed display order settings for comment module. Comment display
order can now be customised using the Views module.

View File

@ -270,8 +270,14 @@ function _aggregator_has_categories() {
*/
function aggregator_perm() {
return array(
'administer news feeds' => t('Add, edit or delete news feeds that are aggregated to your site.'),
'access news feeds' => t('View aggregated news feed items.'),
'administer news feeds' => array(
'title' => t('Administer news feeds'),
'description' => t('Add, edit or delete news feeds that are aggregated to your site.'),
),
'access news feeds' => array(
'title' => t('Access news feeds'),
'description' => t('View aggregated news feed items.'),
),
);
}

View File

@ -105,8 +105,14 @@ function block_theme() {
*/
function block_perm() {
return array(
'administer blocks' => t('Select which blocks are displayed, and arrange them on the page.'),
'use PHP for block visibility' => t('Enter PHP code in the field for block visibility settings. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
'administer blocks' => array(
'title' => t('Administer blocks'),
'description' => t('Select which blocks are displayed, and arrange them on the page.'),
),
'use PHP for block visibility' => array(
'title' => t('Use PHP for block visibility'),
'description' => t('Enter PHP code in the field for block visibility settings. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
),
);
}

View File

@ -25,7 +25,10 @@ function blogapi_help($path, $arg) {
*/
function blogapi_perm() {
return array(
'administer content with blog api' => t('Manage website content from external tools.'),
'administer content with blog api' => array(
'title' => t('Administer content with blog API'),
'description' => t('Manage website content from external tools.'),
),
);
}

View File

@ -41,10 +41,22 @@ function book_theme() {
*/
function book_perm() {
return array(
'administer book outlines' => t('Manage books through the administration panel.'),
'create new books' => t('Add new top-level books.'),
'add content to books' => t('Add new content and child pages to books.'),
'access printer-friendly version' => t('View a book page and all of its sub-pages as a single document for ease of printing. Can be performance heavy.'),
'administer book outlines' => array(
'title' => t('Administer book outlines'),
'description' => t('Manage books through the administration panel.'),
),
'create new books' => array(
'title' => t('Create new books'),
'description' => t('Add new top-level books.'),
),
'add content to books' => array(
'title' => t('Add content to books'),
'description' => t('Add new content and child pages to books.'),
),
'access printer-friendly version' => array(
'title' => t('Access printer-friendly version'),
'description' => t('View a book page and all of its sub-pages as a single document for ease of printing. Can be performance heavy.'),
),
);
}

View File

@ -241,10 +241,22 @@ function comment_node_type($op, $info) {
*/
function comment_perm() {
return array(
'administer comments' => t('Manage and approve comments, and configure comment administration settings.'),
'access comments' => t('View comments attached to content.'),
'post comments' => t('Add comments to content (approval required).'),
'post comments without approval' => t('Add comments to content (no approval required).'),
'administer comments' => array(
'title' => t('Administer comments'),
'description' => t('Manage and approve comments, and configure comment administration settings.'),
),
'access comments' => array(
'title' => t('Access comments'),
'description' => t('View comments attached to content.'),
),
'post comments' => array(
'title' => t('Post comments'),
'description' => t('Add comments to content (approval required).'),
),
'post comments without approval' => array(
'title' => t('Post comments without approval'),
'description' => t('Add comments to content (no approval required).'),
),
);
}

View File

@ -37,8 +37,14 @@ function contact_help($path, $arg) {
*/
function contact_perm() {
return array(
'administer site-wide contact form' => t('Configure site-wide contact form administration settings.'),
'access site-wide contact form' => t('Send feedback to administrators via e-mail using the site-wide contact form.'),
'administer site-wide contact form' => array(
'title' => t('Administer site-wide contact form'),
'description' => t('Configure site-wide contact form administration settings.'),
),
'access site-wide contact form' => array(
'title' => t('Access site-wide contact form'),
'description' => t('Send feedback to administrators via e-mail using the site-wide contact form.'),
),
);
}

View File

@ -146,7 +146,10 @@ function filter_admin_format_title($format) {
*/
function filter_perm() {
return array(
'administer filters' => t('Manage input formats and filters, and select which roles may use them. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
'administer filters' => array(
'title' => t('Administer filters'),
'description' => t('Manage input formats and filters, and select which roles may use them. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
),
);
}

View File

@ -382,7 +382,10 @@ function forum_access($op, $node, $account) {
*/
function forum_perm() {
$perms = array(
'administer forums' => t('Manage forums and configure forum administration settings.'),
'administer forums' => array(
'title' => t('Administer forums'),
'description' => t('Manage forums and configure forum administration settings.'),
),
);
$perms += node_list_permissions('forum');
return $perms;

View File

@ -190,8 +190,14 @@ function locale_inc_callback() {
*/
function locale_perm() {
return array(
'administer languages' => t('Manage the languages in which the website content and interface text may be displayed.'),
'translate interface' => t('Translate the text of the website interface.'),
'administer languages' => array(
'title' => t('Administer languages'),
'description' => t('Manage the languages in which the website content and interface text may be displayed.'),
),
'translate interface' => array(
'title' => t('Translate the interface'),
'description' => t('Translate the text of the website interface.'),
),
);
}

View File

@ -38,7 +38,10 @@ function menu_help($path, $arg) {
*/
function menu_perm() {
return array(
'administer menu' => t('Manage menus and menu items.'),
'administer menu' => array(
'title' => t('Administer menu'),
'description' => t('Manage menus and menu items.'),
),
);
}

View File

@ -1170,12 +1170,30 @@ function theme_node_log_message($log) {
*/
function node_perm() {
$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.'),
'administer content types' => array(
'title' => t('Administer content types'),
'description' => t('Manage content types and content type administration settings.'),
),
'administer nodes' => array(
'title' => t('Administer nodes'),
'description' => 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' => array(
'title' => t('Access content'),
'description' => t('View published content.'),
),
'view revisions' => array(
'title' => t('View revisions'),
'description' => t('View content revisions.'),
),
'revert revisions' => array(
'title' => t('Revert revisions'),
'description' => t('Replace content with an older revision.'),
),
'delete revisions' => array(
'title' => t('Delete revisions'),
'description' => t('Delete content revisions.'),
),
);
foreach (node_get_types() as $type) {
@ -2874,11 +2892,28 @@ function node_list_permissions($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["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));
$perms["delete own $type content"] = t('Delete %type_name content created by the user.', 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 = array(
"create $type content" => array(
'title' => t('Create %type_name content', array('%type_name' => $info->name)),
'description' => t('Create new %type_name content.', array('%type_name' => $info->name)),
),
"edit own $type content" => array(
'title' => t('Edit own %type_name content', array('%type_name' => $info->name)),
'description' => t('Edit %type_name content created by the user.', array('%type_name' => $info->name)),
),
"edit any $type content" => array(
'title' => t('Edit any %type_name content', array('%type_name' => $info->name)),
'description' => t('Edit any %type_name content, regardless of its author.', array('%type_name' => $info->name)),
),
"delete own $type content" => array(
'title' => t('Delete own %type_name content', array('%type_name' => $info->name)),
'description' => t('Delete %type_name content created by the user.', array('%type_name' => $info->name)),
),
"delete any $type content" => array(
'title' => t('Delete any %type_name content', array('%type_name' => $info->name)),
'description' => t('Delete any %type_name content, regardless of its author.', array('%type_name' => $info->name)),
),
);
return $perms;
}

View File

@ -217,8 +217,14 @@ function path_form_alter(&$form, $form_state, $form_id) {
*/
function path_perm() {
return array(
'administer url aliases' => t('Manage URL aliases across the entire website.'),
'create url aliases' => t('Manage URL aliases on content.'),
'administer url aliases' => array(
'title' => t('Administer URL aliases'),
'description' => t('Manage URL aliases across the entire website.'),
),
'create url aliases' => array(
'title' => t('Create URL aliases'),
'description' => t('Manage URL aliases on content.'),
),
);
}

View File

@ -56,9 +56,18 @@ function poll_theme() {
function poll_perm() {
$perms = node_list_permissions('poll');
$perms += array(
'vote on polls' => t('Cast votes on polls.'),
'cancel own vote' => t('Retract and optionally change own votes.'),
'inspect all votes' => t('View voting results.'),
'vote on polls' => array(
'title' => t('Vote on polls'),
'description' => t('Cast votes on polls.'),
),
'cancel own vote' => array(
'title' => t('Cancel own vote'),
'description' => t('Retract and optionally change own votes.'),
),
'inspect all votes' => array(
'title' => t('Inspect all votes'),
'description' => t('View voting results.'),
),
);
return $perms;

View File

@ -142,9 +142,18 @@ function search_theme() {
*/
function search_perm() {
return array(
'administer search' => t('Configure search administration settings.'),
'search content' => t('Search website content.'),
'use advanced search' => t('Limit search results with additional criteria, such as specific content types. Could have performance implications.'),
'administer search' => array(
'title' => t('Administer search'),
'description' => t('Configure search administration settings.'),
),
'search content' => array(
'title' => t('Search content'),
'description' => t('Search website content.'),
),
'use advanced search' => array(
'title' => t('Use advanced search'),
'description' => t('Limit search results with additional criteria, such as specific content types. Could have performance implications.'),
),
);
}

View File

@ -35,7 +35,10 @@ function simpletest_menu() {
*/
function simpletest_perm() {
return array(
'administer unit tests' => t('Manage and run automated testing. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
'administer unit tests' => array(
'title' => t('Administer unit tests'),
'description' => t('Manage and run automated testing. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
),
);
}

View File

@ -84,8 +84,14 @@ function statistics_exit() {
*/
function statistics_perm() {
return array(
'access statistics' => t('View content access statistics.'),
'view post access counter' => t('View the total number of times a piece of content has been accessed.'),
'access statistics' => array(
'title' => t('Access statistics'),
'description' => t('View content access statistics.'),
),
'view post access counter' => array(
'title' => t('View post access counter'),
'description' => t('View the total number of times a piece of content has been accessed.'),
),
);
}

View File

@ -165,13 +165,34 @@ function system_theme() {
*/
function system_perm() {
return array(
'administer site configuration' => t('Configure site-wide settings such as module or theme administration settings.'),
'administer actions' => t('Manage the actions defined for your site.'),
'administer files' => t('Manage user-uploaded files.'),
'access administration pages' => t('View the administration panel and browse the help system.'),
'access site reports' => t('View reports from system logs and other status information.'),
'select different theme' => t('Select a theme other than the default theme set by the site administrator.'),
'block IP addresses' => t('Block IP addresses from accessing your site.'),
'administer site configuration' => array(
'title' => t('Administer site configuration'),
'description' => t('Configure site-wide settings such as module or theme administration settings.'),
),
'administer actions' => array(
'title' => t('Administer actions'),
'description' => t('Manage the actions defined for your site.'),
),
'administer files' => array(
'title' => t('Administer files'),
'description' => t('Manage user-uploaded files.'),
),
'access administration pages' => array(
'title' => t('Access administration pages'),
'description' => t('View the administration panel and browse the help system.'),
),
'access site reports' => array(
'title' => t('Access site reports'),
'description' => t('View reports from system logs and other status information.'),
),
'select different theme' => array(
'title' => t('Select different theme'),
'description' => t('Select a theme other than the default theme set by the site administrator.'),
),
'block IP addresses' => array(
'title' => t('Block IP addresses'),
'description' => t('Block IP addresses from accessing your site.'),
),
);
}

View File

@ -11,7 +11,10 @@
*/
function taxonomy_perm() {
return array(
'administer taxonomy' => t('Manage taxonomy vocabularies and terms.'),
'administer taxonomy' => array(
'title' => t('Administer taxonomy'),
'description' => t('Manage taxonomy vocabularies and terms.'),
),
);
}

View File

@ -86,7 +86,10 @@ function _translation_tab_access($node) {
*/
function translation_perm() {
return array(
'translate content' => t('Translate website content.'),
'translate content' => array(
'title' => t('Tranlate content'),
'description' => t('Translate website content.'),
),
);
}

View File

@ -44,8 +44,14 @@ function upload_theme() {
*/
function upload_perm() {
return array(
'upload files' => t('Attach images and other files to content.'),
'view uploaded files' => t('View and download files attached to content.'),
'upload files' => array(
'title' => t('Upload files'),
'description' => t('Attach images and other files to content.'),
),
'view uploaded files' => array(
'title' => t('View uploaded files'),
'description' => t('View and download files attached to content.'),
),
);
}

View File

@ -514,18 +514,13 @@ function user_admin_perm($form_state, $rid = NULL) {
if ($permissions = module_invoke($module, 'perm')) {
$form['permission'][] = array(
'#markup' => $module,
);
foreach ($permissions as $perm => $description) {
// Account for permissions lacking a description.
if (is_int($perm)) {
$perm = $description;
$description = NULL;
}
);
foreach ($permissions as $perm => $perm_item) {
$options[$perm] = '';
$form['permission'][$perm] = array(
'#type' => 'item',
'#markup' => t($perm),
'#description' => $hide_descriptions ? $description : NULL,
'#markup' => $perm_item['title'],
'#description' => $hide_descriptions ? $perm_item['description'] : NULL,
);
foreach ($role_names as $rid => $name) {
// Builds arrays for checked boxes for each role

View File

@ -571,10 +571,22 @@ function user_is_blocked($name) {
*/
function user_perm() {
return array(
'administer permissions' => t('Manage the permissions assigned to user roles. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
'administer users' => t('Manage or block users, and manage their role assignments.'),
'access user profiles' => t('View profiles of users on the site, which may contain personal information.'),
'change own username' => t('Select a different username.'),
'administer permissions' => array(
'title' => t('Administer permissions'),
'description' => t('Manage the permissions assigned to user roles. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
),
'administer users' => array(
'title' => t('Administer users'),
'description' => t('Manage or block users, and manage their role assignments.'),
),
'access user profiles' => array(
'title' => t('Access user profiles'),
'description' => t('View profiles of users on the site, which may contain personal information.'),
),
'change own username' => array(
'title' => t('Change own username'),
'description' => t('Select a different username.'),
),
);
}