summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-14 14:14:44 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-14 14:14:44 +0000
commit7a9fc8a33d49badf34b6f41bed978a2aad004745 (patch)
treecbec869a16ddb27039f7a1df5c7b956fde233cb1 /modules/taxonomy/taxonomy.module
parent30fa81a763d5624437cb066d555ea1c1880de394 (diff)
downloadbrdo-7a9fc8a33d49badf34b6f41bed978a2aad004745.tar.gz
brdo-7a9fc8a33d49badf34b6f41bed978a2aad004745.tar.bz2
- Patch #340652 by catch: added edit/delete terms permission per vocabulary.
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r--modules/taxonomy/taxonomy.module28
1 files changed, 26 insertions, 2 deletions
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) {