From 7a9fc8a33d49badf34b6f41bed978a2aad004745 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 14 Oct 2009 14:14:44 +0000 Subject: - Patch #340652 by catch: added edit/delete terms permission per vocabulary. --- modules/taxonomy/taxonomy.module | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'modules/taxonomy/taxonomy.module') 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', @@ -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. */ -- cgit v1.2.3