Skip to content
Snippets Groups Projects
Commit 7a9fc8a3 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #340652 by catch: added edit/delete terms permission per vocabulary.

parent 30fa81a7
No related branches found
No related tags found
No related merge requests found
......@@ -694,7 +694,9 @@ function taxonomy_form_term($form, &$form_state, $vocabulary, $edit = array()) {
if ($edit['tid']) {
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'));
'#value' => t('Delete'),
'#access' => user_access("delete terms in $vocabulary->vid") || user_access('administer taxonomy'),
);
$form['tid'] = array(
'#type' => 'value',
'#value' => $edit['tid']);
......
......@@ -10,12 +10,28 @@
* Implement hook_permission().
*/
function taxonomy_permission() {
return array(
$permissions = array(
'administer taxonomy' => array(
'title' => t('Administer taxonomy'),
'description' => t('Manage taxonomy vocabularies and terms.'),
),
);
foreach (taxonomy_get_vocabularies() as $vocabulary) {
$permissions += array(
'edit terms in ' . $vocabulary->vid => array(
'title' => t('Edit terms in %vocabulary', array('%vocabulary' => $vocabulary->name)),
'description' => t('Edit terms in the %vocabulary vocabulary.', array('%vocabulary' => $vocabulary->name)),
),
);
$permissions += array(
'delete terms in ' . $vocabulary->vid => array(
'title' => t('Delete terms in %vocabulary', array('%vocabulary' => $vocabulary->name)),
'description' => t('Delete terms in the %vocabulary vocabulary.', array('%vocabulary' => $vocabulary->name)),
),
);
}
return $permissions;
}
/**
......@@ -210,7 +226,8 @@ function taxonomy_menu() {
'title' => 'Edit term',
'page callback' => 'taxonomy_term_edit',
'page arguments' => array(2),
'access arguments' => array('administer taxonomy'),
'access callback' => 'taxonomy_term_edit_access',
'access arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'weight' => 10,
'file' => 'taxonomy.pages.inc',
......@@ -272,6 +289,13 @@ function taxonomy_menu() {
return $items;
}
/**
* Return edit access for a given term.
*/
function taxonomy_term_edit_access($term) {
return user_access("edit terms in $term->vid") || user_access('administer taxonomy');
}
/**
* Return the vocabulary name given the vocabulary object.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment