summaryrefslogtreecommitdiff
path: root/modules/taxonomy
diff options
context:
space:
mode:
Diffstat (limited to 'modules/taxonomy')
-rw-r--r--modules/taxonomy/taxonomy.admin.inc4
-rw-r--r--modules/taxonomy/taxonomy.module28
2 files changed, 29 insertions, 3 deletions
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index a8e51837e..dd9f9fc56 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -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']);
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 4540efc74..4879f5a39 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -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',
@@ -273,6 +290,13 @@ function taxonomy_menu() {
}
/**
+ * 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.
*/
function taxonomy_admin_vocabulary_title_callback($vocabulary) {