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 23:22:52 -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 23:22:53 -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,25 +667,6 @@ function taxonomy_node_get_terms($node, } /** - * Make sure incoming vids are free tagging enabled. - */ -function taxonomy_node_validate(&$node) { - if (!empty($node->taxonomy)) { - $terms = $node->taxonomy; - if (!empty($terms['tags'])) { - foreach ($terms['tags'] as $vid => $vid_value) { - $vocabulary = taxonomy_vocabulary_load($vid); - if (empty($vocabulary->tags)) { - // 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))); - } - } - } - } -} - -/** * Save term associations for a given node. */ function taxonomy_node_save($node, $terms) { @@ -684,10 +695,15 @@ function taxonomy_node_save($node, $term } if (!$typed_term_tid) { - $edit = array('vid' => $vid, 'name' => $typed_term); - $term = (object)$edit; - $status = taxonomy_term_save($term); - $typed_term_tid = $term->tid; + if (user_access("create terms in $vid")) { + $edit = array('vid' => $vid, 'name' => $typed_term); + $term = (object)$edit; + $status = taxonomy_term_save($term); + $typed_term_tid = $term->tid; + } + else { + drupal_set_message(t('%name was not created as a new term because you do not have permission to create terms in this vocabulary.', array('%name' => check_plain($typed_term)))); + } } // Defend against duplicate, differently cased tags @@ -1246,13 +1262,6 @@ function taxonomy_nodeapi_delete_revisio } /** - * Implementation of hook_nodeapi_validate(). - */ -function taxonomy_nodeapi_validate($node, $arg = 0) { - taxonomy_node_validate($node); -} - -/** * Implementation of hook_nodeapi_rss_item(). */ function taxonomy_nodeapi_rss_item($node, $arg = 0) {