Index: modules/taxonomy/taxonomy.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v retrieving revision 1.37 diff -u -p -r1.37 taxonomy.admin.inc --- modules/taxonomy/taxonomy.admin.inc 13 Nov 2008 08:13:56 -0000 1.37 +++ modules/taxonomy/taxonomy.admin.inc 30 Nov 2008 22:44:06 -0000 @@ -701,12 +701,16 @@ function taxonomy_form_term(&$form_state '#value' => t('Save')); if ($edit['tid']) { - $form['delete'] = array( - '#type' => 'submit', - '#value' => t('Delete')); + if (user_access("delete terms in $vocabulary->vid") || user_access('administer taxonomy')) { + $form['delete'] = array( + '#type' => 'submit', + '#value' => t('Delete'), + ); + } $form['tid'] = array( '#type' => 'value', - '#value' => $edit['tid']); + '#value' => $edit['tid'], + ); } else { $form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']); Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.442 diff -u -p -r1.442 taxonomy.module --- modules/taxonomy/taxonomy.module 13 Nov 2008 08:13:56 -0000 1.442 +++ modules/taxonomy/taxonomy.module 30 Nov 2008 22:44:09 -0000 @@ -10,12 +10,34 @@ * Implementation of hook_perm(). */ function taxonomy_perm() { - return array( + $permissions = array( 'administer taxonomy' => array( 'title' => t('Administer taxonomy'), 'description' => t('Manage taxonomy vocabularies and terms.'), ), ); + foreach (taxonomy_get_vocabularies() as $vocabulary) { + $name = check_plain($vocabulary->name); + $permissions += array( + "create terms in $vocabulary->vid" => array( + 'title' => t("Create terms in $name"), + 'description' => t("Create terms in the $name vocabulary."), + ), + ); + $permissions += array( + "edit terms in $vocabulary->vid" => array( + 'title' => t("Edit terms in $name"), + 'description' => t("Edit terms in the $name vocabulary."), + ), + ); + $permissions += array( + "delete terms in $vocabulary->vid" => array( + 'title' => t("Edit terms in $name"), + 'description' => t("Delete terms in the $name vocabulary."), + ), + ); + } + return $permissions; } /** @@ -153,7 +175,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, ); @@ -209,6 +232,13 @@ function taxonomy_admin_vocabulary_title } /** + * 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'); +} + +/** * Save a vocabulary given a vocabulary object. */ function taxonomy_vocabulary_save($vocabulary) { @@ -637,7 +667,8 @@ function taxonomy_node_get_terms($node, } /** - * Make sure incoming vids are free tagging enabled. + * Confirm that the user has permission to create new freetagging terms when + * saving a node. */ function taxonomy_node_validate(&$node) { if (!empty($node->taxonomy)) { @@ -645,10 +676,10 @@ function taxonomy_node_validate(&$node) if (!empty($terms['tags'])) { foreach ($terms['tags'] as $vid => $vid_value) { $vocabulary = taxonomy_vocabulary_load($vid); - if (empty($vocabulary->tags)) { + if (!user_access("create terms in $vocabulary->vid")) { // see form_get_error $key = implode('][', $element['#parents']); // on why this is the key - form_set_error("taxonomy][tags][$vid", t('The %name vocabulary can not be modified in this way.', array('%name' => $vocabulary->name))); + form_set_error("taxonomy][tags][$vid", t('You do not have permission to create terms in %name vocabulary.', array('%name' => $vocabulary->name))); } } }