diff -urP taxonomy_manager_old/css/taxonomy_manager.css taxonomy_manager/css/taxonomy_manager.css --- taxonomy_manager_old/css/taxonomy_manager.css 2008-09-16 19:06:29.000000000 +0700 +++ taxonomy_manager/css/taxonomy_manager.css 2008-10-19 16:20:49.000000000 +0700 @@ -99,9 +99,14 @@ } #taxonomy-manager-toolbar-throbber { - float: right; margin: 0px; + margin-left: 30px; padding: 0px; + line-height: 40px; +} + +#taxonomy-manager-toolbar-throbber img { + vertical-align: middle; } #taxonomy-manager-toolbar-buttons { diff -urP taxonomy_manager_old/js/termData.js taxonomy_manager/js/termData.js --- taxonomy_manager_old/js/termData.js 2008-09-16 19:06:29.000000000 +0700 +++ taxonomy_manager/js/termData.js 2008-10-19 17:09:59.000000000 +0700 @@ -193,5 +193,5 @@ $('fieldset#taxonomy-term-data-fieldset legend').html(name); $('ul.treeview li input:hidden[@class=term-id][@value='+ this.tid +']') .siblings('div.term-item') - .find('div.form-item label.option a').html(name); + .find('div.form-item label.option a.term-data-name').html(name); } diff -urP taxonomy_manager_old/taxonomy_manager.admin.inc taxonomy_manager/taxonomy_manager.admin.inc --- taxonomy_manager_old/taxonomy_manager.admin.inc 2008-09-16 20:23:30.000000000 +0700 +++ taxonomy_manager/taxonomy_manager.admin.inc 2008-10-19 17:04:11.000000000 +0700 @@ -9,7 +9,7 @@ $voc_list = array(); foreach ($vocabularies as $vocabulary) { - $voc_list[] = l($vocabulary->name, 'admin/content/taxonomy_manager/voc/'. $vocabulary->vid); + $voc_list[] = l($vocabulary->name, 'taxonomy_manager/voc/'. $vocabulary->vid); } if (!count($voc_list)) { $voc_list[] = t('No Vocabularies available'); @@ -36,22 +36,22 @@ drupal_add_js($module_path .'js/hideForm.js'); drupal_add_js($module_path .'js/updateWeight.js'); drupal_add_js($module_path .'js/termData.js'); - drupal_add_js('misc/textarea.js'); //because of term data form wich gets dynamically loaded + drupal_add_js('misc/textarea.js'); //because of term data form which gets dynamically loaded - drupal_add_js(array('termData' => array('url' => url("admin/content/taxonomy_manager/termdata/edit/". $vid), 'tid' => $tid, 'term_url' => url('admin/content/taxonomy_manager/termdata/'. $vid))), 'setting'); + drupal_add_js(array('termData' => array('url' => url("taxonomy_manager/termdata/edit/". $vid), 'tid' => $tid, 'term_url' => url('taxonomy_manager/termdata/'. $vid))), 'setting'); - drupal_add_js(array('updateWeight' => array('up' => 'edit-weight-up', 'down' => 'edit-weight-down', 'url' => url('admin/content/taxonomy_manager/weight/'. $vid), 'disable_mouseover' => variable_get('taxonomy_manager_disable_mouseover', 0))), 'setting'); + drupal_add_js(array('updateWeight' => array('up' => 'edit-weight-up', 'down' => 'edit-weight-down', 'url' => url('taxonomy_manager/weight/'. $vid), 'disable_mouseover' => variable_get('taxonomy_manager_disable_mouseover', 0))), 'setting'); drupal_add_js(array('TMAjaxThrobber' => array('add' => TRUE)), 'setting'); $form = array(); $voc = taxonomy_vocabulary_load($vid); - drupal_set_title(t("Taxonomy Manager - %voc_name", array("%voc_name" => $voc->name))); + drupal_set_title("View Topics"); if (!is_numeric($voc->vid)) { $text = t('No vocabulary with this ID available!. '); - $text .= t('Check this !link_list for available vocabularies or !link_create a new one', array('!link_list' => l('list', 'admin/content/taxonomy_manager'), '!link_create' => l('create', 'admin/content/taxonomy/add/vocabulary'))); + $text .= t('Check this !link_list for available vocabularies or !link_create a new one', array('!link_list' => l('list', 'taxonomy_manager'), '!link_create' => l('create', 'taxonomy/add/vocabulary'))); $form['text'] = array( '#value' => $text, ); @@ -65,12 +65,24 @@ $form['text'] = array( '#value' => $text, ); - $form += taxonomy_manager_add_form($voc, false); + // check to make sure the user can add terms + if (user_access('add taxonomy terms')) { + $form += taxonomy_manager_add_form($voc, false); + } return $form; } $form['#cache'] = TRUE; + // check user permissions + $add = user_access('add taxonomy terms'); + $move = user_access('move taxonomy terms'); + $delete = user_access('delete taxonomy terms'); + $merge = user_access('merge taxonomy terms'); + $export = user_access('export taxonomy terms'); + + $toolbar = $add || $move || $delete || $merge || $export; + $form['taxonomy']['#tree'] = TRUE; $form['taxonomy']['manager'] = array( @@ -85,120 +97,143 @@ '#vid' => $vid, '#pager' => TRUE, '#search_string' => ($tid) ? NULL : $filter, + '#toolbar' => $toolbar, + '#can_edit' => user_access('edit taxonomy terms'), ); + + // check to make sure the user can search terms + if (user_access('search taxonomy terms')) { - $search_description = t("You can search directly for exisiting terms. + $search_description = t("You can search directly for existing terms. If your input doesn't match an existing term, it will be used for filtering root level terms (useful for non-hierarchical vocabularies)."); - $form['search'] = array( - '#type' => 'fieldset', - '#attributes' => array('id' => 'taxonomy-manager-search'), - '#title' => t('Search'), - '#description' => $search_description, - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#tree' => TRUE, - ); - - $form['search']['field'] = array( - '#type' => 'textfield', - '#title' => t('Search String'), - '#autocomplete_path' => 'taxonomy/autocomplete/'. $voc->vid, - '#prefix' => '
', - '#suffix' => '
', - ); + $form['search'] = array( + '#type' => 'fieldset', + '#attributes' => array('id' => 'taxonomy-manager-search'), + '#title' => t('Search'), + '#description' => $search_description, + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#tree' => TRUE, + ); - $form['search']['button'] = array( - '#type' => 'submit', - '#attributes' => array('class' => 'taxonomy-manager-buttons search'), - '#value' => t('Search'), - '#suffix' => '
', - ); - - $form['toolbar'] = array( - '#type' => 'fieldset', - '#title' => t('Toolbar'), - '#attributes' => array('id' => 'taxonomy-manager-toolbar'), - ); + $form['search']['field'] = array( + '#type' => 'textfield', + '#title' => t('Search String'), + '#autocomplete_path' => 'taxonomy/autocomplete/'. $voc->vid, + '#prefix' => '
', + '#suffix' => '
', + ); - $form['toolbar']['weight_up'] = array( - '#type' => 'button', - '#attributes' => array('class' => 'taxonomy-manager-buttons'), - '#value' => t('Up'), - '#theme' => 'no_submit_button', - '#prefix' => '
', - ); + $form['search']['button'] = array( + '#type' => 'submit', + '#attributes' => array('class' => 'taxonomy-manager-buttons search'), + '#value' => t('Search'), + '#suffix' => '
', + ); + } - $form['toolbar']['weight-down'] = array( - '#type' => 'button', - '#attributes' => array('class' => 'taxonomy-manager-buttons'), - '#value' => t('Down'), - '#theme' => 'no_submit_button', - ); + // check to make sure the user has access to at least one of the toolbar actions + if ($toolbar) { + + $form['toolbar'] = array( + '#type' => 'fieldset', + '#title' => t('Toolbar'), + '#attributes' => array('id' => 'taxonomy-manager-toolbar'), + ); + + if ($move) { + $form['toolbar']['weight_up'] = array( + '#type' => 'button', + '#attributes' => array('class' => 'taxonomy-manager-buttons'), + '#value' => t('Up'), + '#theme' => 'no_submit_button', + '#prefix' => '
', + ); + + $form['toolbar']['weight-down'] = array( + '#type' => 'button', + '#attributes' => array('class' => 'taxonomy-manager-buttons'), + '#value' => t('Down'), + '#theme' => 'no_submit_button', + ); + + $form['toolbar']['move_show'] = array( + '#type' => 'button', + '#value' => t('Move'), + '#attributes' => array('class' => 'taxonomy-manager-buttons move'), + '#theme' => 'no_submit_button', + ); + } - $form['toolbar']['delete_confirm'] = array( - '#type' => 'button', - '#attributes' => array('class' => 'taxonomy-manager-buttons delete'), - '#value' => t('Delete'), - '#theme' => 'no_submit_button', - /*'#ahah' => array( - 'path' => 'admin/content/taxonomy_manager/toolbar/form', - 'method' => 'replace', - 'event' => 'click', - 'wrapper' => 'taxonomy-manager-toolbar-forms', - 'progress' => array(), - ),*/ - ); - - $form['toolbar']['add_show'] = array( - '#type' => 'button', - '#attributes' => array('class' => 'taxonomy-manager-buttons add'), - '#value' => t('Add'), - '#theme' => 'no_submit_button', - ); - - $form['toolbar']['move_show'] = array( - '#type' => 'button', - '#value' => t('Move'), - '#attributes' => array('class' => 'taxonomy-manager-buttons move'), - '#theme' => 'no_submit_button', - ); - - $form['toolbar']['merge_show'] = array( - '#type' => 'button', - '#attributes' => array('class' => 'taxonomy-manager-buttons merge'), - '#value' => t('Merge'), - '#theme' => 'no_submit_button', - ); - - $form['toolbar']['export_show'] = array( - '#type' => 'button', - '#attributes' => array('class' => 'taxonomy-manager-buttons export'), - '#value' => t('CSV Export'), - '#theme' => 'no_submit_button', - '#suffix' => '
' - ); - - $form['toolbar']['wrapper'] = array( - '#type' => 'markup', - '#value' => '
', - '#weight' => 20, - ); - $form['toolbar_forms_wrapper'] = array( - '#type' => 'markup', - '#value' => '
', - ); - - - $form += taxonomy_manager_add_form($voc); - - $form += taxonomy_manager_merge_form($voc); - - $form += taxonomy_manager_move_form($voc); + if ($add) { + $form['toolbar']['add_show'] = array( + '#type' => 'button', + '#attributes' => array('class' => 'taxonomy-manager-buttons add'), + '#value' => t('Add'), + '#theme' => 'no_submit_button', + ); + } + + if ($delete) { + $form['toolbar']['delete_confirm'] = array( + '#type' => 'button', + '#attributes' => array('class' => 'taxonomy-manager-buttons delete'), + '#value' => t('Delete'), + '#theme' => 'no_submit_button', + ); + } + + if ($merge) { + $form['toolbar']['merge_show'] = array( + '#type' => 'button', + '#attributes' => array('class' => 'taxonomy-manager-buttons merge'), + '#value' => t('Merge'), + '#theme' => 'no_submit_button', + ); + } - $form += taxonomy_manager_confirm_delete($voc); + if ($export) { + $form['toolbar']['export_show'] = array( + '#type' => 'button', + '#attributes' => array('class' => 'taxonomy-manager-buttons export'), + '#value' => t('CSV Export'), + '#theme' => 'no_submit_button', + '#suffix' => '
' + ); + } + + $form['toolbar']['wrapper'] = array( + '#type' => 'markup', + '#value' => '
', + '#weight' => 20, + ); + + $form['toolbar_forms_wrapper'] = array( + '#type' => 'markup', + '#value' => '
', + ); - $form += taxonomy_manager_export_form($voc); + if ($add) { + $form += taxonomy_manager_add_form($voc); + } + + if ($merge) { + $form += taxonomy_manager_merge_form($voc); + } + + if ($move) { + $form += taxonomy_manager_move_form($voc); + } + + if ($delete) { + $form += taxonomy_manager_confirm_delete($voc); + } + + if ($export) { + $form += taxonomy_manager_export_form($voc); + } + } if ($tid) { $form += taxonomy_manager_form_term_data($tid); @@ -207,23 +242,25 @@ $form['term_data'] = array('#tree' => TRUE); } - // add save button for term_data already to the form array, - // but do not render (see theme_taxonomy_manager_form) if not needed - // otherwise an #ahah callback on dynamically added forms makes problems - $form['term_data']['save'] = array( - '#type' => 'submit', - '#value' => t('Save changes'), - '#submit' => array(''), - '#attributes' => array('class' => 'taxonomy-manager-buttons save'), - '#ahah' => array( - 'path' => 'admin/content/taxonomy_manager/termdata/edit', - 'method' => 'replace', - 'event' => 'click', - 'wrapper' => 'taxonomy-term-data', - ), - '#weight' => 20, - ); + if ($toolbar) { + // add save button for term_data already to the form array, + // but do not render (see theme_taxonomy_manager_form) if not needed + // otherwise an #ahah callback on dynamically added forms makes problems + $form['term_data']['save'] = array( + '#type' => 'submit', + '#value' => t('Save changes'), + '#submit' => array(''), + '#attributes' => array('class' => 'taxonomy-manager-buttons save'), + '#ahah' => array( + 'path' => 'taxonomy_manager/termdata/edit', + 'method' => 'replace', + 'event' => 'click', + 'wrapper' => 'taxonomy-term-datataxonomy-term-data', + ), + '#weight' => 20, + ); + } return $form; } @@ -327,19 +364,22 @@ '#type' => 'textfield', ); } - $form['add']['mass'] = array( - '#type' => 'fieldset', - '#tree' => TRUE, - '#title' => t('Mass term import (with textarea)'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['add']['mass']['mass_add'] = array( - '#type' => 'textarea', - '#title' => t('Terms'), - '#description' => t('One term per line'), - '#rows' => 10, - ); + if (user_access('import taxonomy terms')) { + $form['add']['mass'] = array( + '#type' => 'fieldset', + '#tree' => TRUE, + '#title' => t('Mass term import (with textarea)'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['add']['mass']['mass_add'] = array( + '#type' => 'textarea', + '#title' => t('Terms'), + '#description' => t('One term per line'), + '#rows' => 10, + ); + } + $form['add']['add'] = array( '#type' => 'submit', '#attributes' => array('class' => 'taxonomy-manager-buttons add'), @@ -493,7 +533,7 @@ $module_path = drupal_get_path('module', 'taxonomy_manager') .'/'; drupal_add_js($module_path .'js/csv_export.js'); - drupal_add_js(array('exportCSV' => array('url' => url("admin/content/taxonomy_manager/export"))), 'setting'); + drupal_add_js(array('exportCSV' => array('url' => url("taxonomy_manager/export"))), 'setting'); $form = array(); @@ -563,13 +603,13 @@ */ function taxonomy_manager_update_term_data_form($vid, $tid, $ahah = FALSE, $print = TRUE) { if (!$ahah) { - drupal_goto('admin/content/taxonomy_manager/voc/'. $vid .'/'. $tid); + drupal_goto('taxonomy_manager/voc/'. $vid .'/'. $tid); } $GLOBALS['devel_shutdown'] = FALSE; //prevent devel queries footprint $params = $_GET; - //actually we don not need do use the caching because the saving only happens through a AJAX callback + //actually we do not need do use the caching because the saving only happens through a AJAX callback //and it's a bit faster, cache loading, form building and cache saving needs some time else. /*$form_state = array('submitted' => FALSE); $form = form_get_cache($params['form_build_id'], $form_state); @@ -583,7 +623,7 @@ '#submit' => array(''), '#attributes' => array('class' => 'taxonomy-manager-buttons save'), '#ahah' => array( - 'path' => 'admin/content/taxonomy_manager/termdata/edit', + 'path' => 'taxonomy_manager/termdata/edit', 'method' => 'replace', 'event' => 'click', 'wrapper' => 'taxonomy-term-data', @@ -620,7 +660,9 @@ if (strlen($title) >= 33) { $title = substr($title, 0, 33) . "..."; } - $title .= " (". $term->tid .")"; + if (user_access('administer taxonomy')) { + $title .= " (". $term->tid .")"; + } $form['term_data'] = array( '#type' => 'fieldset', @@ -649,28 +691,32 @@ '#rows' => 4, ); - $form['term_data']['synonyms'] = _taxonomy_manager_form_term_data_lists($term, taxonomy_get_synonyms($term->tid), t('Synonyms'), 'synonym', FALSE); - $form['term_data']['synonyms']['#tree'] = TRUE; - $form['term_data']['synonyms']['#weight'] = '50'; - - $form['term_data']['relations'] = _taxonomy_manager_form_term_data_lists($term, taxonomy_get_related($term->tid), t('Relations'), 'related'); - $form['term_data']['relations']['#tree'] = TRUE; - $form['term_data']['relations']['#weight'] = '51'; - - $parents = taxonomy_get_parents($term->tid); - $p_add = TRUE; - $form['term_data']['parents'] = _taxonomy_manager_form_term_data_lists($term, $parents, t('Parents'), 'parent', TRUE); - $form['term_data']['parents']['#tree'] = TRUE; - $form['term_data']['parents']['#weight'] = '52'; - - $form['term_data']['weight'] = array( - '#type' => 'weight', - '#default_value' => $term->weight, - '#delta' => 40, - '#prefix' => '
', - '#suffix' => '
', - '#title' => t('Weight'), - ); + if (user_access('administer taxonomy')) { + $form['term_data']['synonyms'] = _taxonomy_manager_form_term_data_lists($term, taxonomy_get_synonyms($term->tid), t('Synonyms'), 'synonym', FALSE); + $form['term_data']['synonyms']['#tree'] = TRUE; + $form['term_data']['synonyms']['#weight'] = '50'; + + $form['term_data']['relations'] = _taxonomy_manager_form_term_data_lists($term, taxonomy_get_related($term->tid), t('Relations'), 'related'); + $form['term_data']['relations']['#tree'] = TRUE; + $form['term_data']['relations']['#weight'] = '51'; + + $parents = taxonomy_get_parents($term->tid); + $p_add = TRUE; + $form['term_data']['parents'] = _taxonomy_manager_form_term_data_lists($term, $parents, t('Parents'), 'parent', TRUE); + $form['term_data']['parents']['#tree'] = TRUE; + $form['term_data']['parents']['#weight'] = '52'; + } + + if (user_access('move taxonomy terms')) { + $form['term_data']['weight'] = array( + '#type' => 'weight', + '#default_value' => $term->weight, + '#delta' => 40, + '#prefix' => '
', + '#suffix' => '
', + '#title' => t('Weight'), + ); + } $link_img = theme("image", $module_path ."images/link-small.png", "link to term page"); $form['term_data']['link'] = array('#value' => '
'. l($link_img .' '. t('Go to the term page site'), taxonomy_term_path($term), array('attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description), 'target' => '_blank'), 'html' => TRUE)), '#weight' => '53'); $form['term_data']['vid'] = array('#type' => 'value', '#value' => $term->vid); @@ -763,10 +809,10 @@ $term = array_shift($terms); $tid = $term['tid']; if ($tid) { - drupal_goto('admin/content/taxonomy_manager/voc/'. $form_state['values']['vid'] .'/'. $tid); + drupal_goto('taxonomy_manager/voc/'. $form_state['values']['vid'] .'/'. $tid); } else { - drupal_goto('admin/content/taxonomy_manager/voc/'. $form_state['values']['vid'] .'/0/'. $search_string); + drupal_goto('taxonomy_manager/voc/'. $form_state['values']['vid'] .'/0/'. $search_string); } } @@ -850,7 +896,7 @@ $msg .= t('This action cannot be undone.'); return confirm_form($form, t('Are you sure you want to delete the following terms: '), - 'admin/content/taxonomy_manager/voc/'. $vid, + 'taxonomy_manager/voc/'. $vid, $msg, t('Delete'), t('Cancel')); @@ -862,7 +908,7 @@ */ function taxonomy_manager_term_confirm_delete_submit($form, &$form_state) { taxonomy_manager_delete_terms($form_state['values']['selected_terms'], $form_state['values']['options']); - $form_state['redirect'] = 'admin/content/taxonomy_manager/voc/'. $form_state['values']['vid']; + $form_state['redirect'] = 'taxonomy_manager/voc/'. $form_state['values']['vid']; drupal_set_message("Selected terms deleted"); return; } @@ -1422,12 +1468,12 @@ $top = drupal_render($form); $output = $top . $pager; $output .= '
'; - $output .= '
'; - $output .= $tree; - $output .= '
'; $output .= '
'; $output .= is_array($form['term_data']['tid']) ? $term_data : ''; $output .= '
'; + $output .= '
'; + $output .= $tree; + $output .= '
'; $output .= '
'; return $output; diff -urP taxonomy_manager_old/taxonomy_manager.module taxonomy_manager/taxonomy_manager.module --- taxonomy_manager_old/taxonomy_manager.module 2008-09-16 19:06:29.000000000 +0700 +++ taxonomy_manager/taxonomy_manager.module 2008-10-19 23:05:47.000000000 +0700 @@ -11,66 +11,83 @@ * */ +/** + * Implementation of hook_perm + */ +function taxonomy_manager_perm() { + return array( + 'search taxonomy terms', + 'add taxonomy terms', + 'move taxonomy terms', + 'delete taxonomy terms', + 'merge taxonomy terms', + 'export taxonomy terms', + 'import taxonomy terms', + 'edit taxonomy terms', + 'view taxonomy tree', + ); +} + /** * Implementation of hook_menu */ function taxonomy_manager_menu() { - $items['admin/content/taxonomy_manager'] = array( - 'title' => 'Taxonomy Manager', + $items['taxonomy_manager'] = array( + 'title' => 'View Topics', 'description' => 'Administer vocabularies with the Taxonomy Manager', 'page callback' => 'taxonomy_manager_voc_list', - 'access arguments' => array('administer taxonomy'), + 'access arguments' => array('view taxonomy tree'), 'type' => MENU_NORMAL_ITEM, 'file' => 'taxonomy_manager.admin.inc', ); - $items['admin/content/taxonomy_manager/childform'] = array( + $items['taxonomy_manager/childform'] = array( 'page callback' => 'taxonomy_manager_tree_build_child_form', - 'access arguments' => array('administer taxonomy'), + 'access arguments' => array('view taxonomy tree'), 'type' => MENU_CALLBACK, ); - $items['admin/content/taxonomy_manager/weight'] = array( + $items['taxonomy_manager/weight'] = array( 'page callback' => 'taxonomy_manager_update_weights', - 'access arguments' => array('administer taxonomy'), + 'access arguments' => array('move taxonomy terms'), 'type' => MENU_CALLBACK, 'file' => 'taxonomy_manager.admin.inc', ); - $items['admin/content/taxonomy_manager/termdata'] = array( + $items['taxonomy_manager/termdata'] = array( 'page callback' => 'taxonomy_manager_update_term_data_form', - 'access arguments' => array('administer taxonomy'), + 'access arguments' => array('edit taxonomy terms'), 'type' => MENU_CALLBACK, 'file' => 'taxonomy_manager.admin.inc', ); - $items['admin/content/taxonomy_manager/siblingsform'] = array( + $items['taxonomy_manager/siblingsform'] = array( 'page callback' => 'taxonomy_manager_tree_build_siblings_form', 'access arguments' => array('administer taxonomy'), 'type' => MENU_CALLBACK, ); - $items['admin/content/taxonomy_manager/termdata/edit'] = array( + $items['taxonomy_manager/termdata/edit'] = array( 'page callback' => 'taxonomy_manager_term_data_edit', - 'access arguments' => array('administer taxonomy'), + 'access arguments' => array('edit taxonomy terms'), 'type' => MENU_CALLBACK, 'file' => 'taxonomy_manager.admin.inc', ); - $items['admin/content/taxonomy_manager/export'] = array( + $items['taxonomy_manager/export'] = array( 'page callback' => 'taxonomy_manager_export', - 'access arguments' => array('administer taxonomy'), + 'access arguments' => array('export taxonomy terms'), 'type' => MENU_CALLBACK, 'file' => 'taxonomy_manager.admin.inc', ); - $items['admin/content/taxonomy_manager/voc'] = array( - 'title' => 'Taxonomy Manager', + $items['taxonomy_manager/voc'] = array( + 'title' => 'View Topics', 'page callback' => 'drupal_get_form', 'page arguments' => array('taxonomy_manager_form'), - 'access arguments' => array('administer taxonomy'), + 'access arguments' => array('view taxonomy tree'), 'type' => MENU_CALLBACK, 'file' => 'taxonomy_manager.admin.inc', ); @@ -84,7 +101,7 @@ 'file' => 'taxonomy_manager.admin.inc', ); - $items['admin/content/taxonomy_manager/toolbar/form'] = array( + $items['taxonomy_manager/toolbar/form'] = array( 'page callback' => 'taxonomy_manager_toolbar_forms', 'access arguments' => array('administer taxonomy'), 'type' => MENU_CALLBACK, @@ -170,7 +187,7 @@ * @param $vid vocabulary id */ function taxonomy_manager_tree_link($term) { - return "admin/content/taxonomy_manager/termdata/". $term->vid ."/". $term->tid; + return "taxonomy_manager/termdata/". $term->vid ."/". $term->tid; } /** @@ -307,8 +324,8 @@ drupal_add_css($module_path .'css/taxonomy_manager.css'); drupal_add_js($module_path .'js/tree.js'); - drupal_add_js(array('siblingsForm' => array('url' => url('admin/content/taxonomy_manager/siblingsform'), 'modulePath' => $module_path)), 'setting'); - drupal_add_js(array('childForm' => array('url' => url('admin/content/taxonomy_manager/childform'), 'modulePath' => $module_path)), 'setting'); + drupal_add_js(array('siblingsForm' => array('url' => url('taxonomy_manager/siblingsform'), 'modulePath' => $module_path)), 'setting'); + drupal_add_js(array('childForm' => array('url' => url('taxonomy_manager/childform'), 'modulePath' => $module_path)), 'setting'); drupal_add_js(array('taxonomy_manager' => array('modulePath' => (url($module_path) == $module_path) ? $module_path : (base_path() . $module_path))), 'setting'); drupal_add_js(array('taxonomytree' => array('id' => $id, 'vid' => $vid)), 'setting'); } @@ -346,8 +363,8 @@ $terms_to_expand = taxonomy_manager_tree_get_terms_to_expand($tree, $element['#default_value'], $element['#multiple']); } - taxonomy_manager_tree_build_form($index = 0, $tree, $element['#elements'], $element, $element['#parents'], !$element['#pager'], $element['#siblings_page'], $element['#default_value'], $element['#multiple'], $terms_to_expand); - + taxonomy_manager_tree_build_form($index = 0, $tree, $element['#elements'], $element, $element['#parents'], !$element['#pager'], $element['#siblings_page'], $element['#default_value'], $element['#multiple'], $terms_to_expand, $element['#toolbar'], $element['#can_edit']); + return $element; } @@ -420,7 +437,7 @@ * @param $tree of terms (generated by taxonomy_get_tree) * @return a form array */ -function taxonomy_manager_tree_build_form(&$index, $tree, &$form, $root_form, $parents = array(), $build_subtrees = TRUE, $page = 0, $default_value = array(), $multiple = TRUE, $terms_to_expand = array()) { +function taxonomy_manager_tree_build_form(&$index, $tree, &$form, $root_form, $parents = array(), $build_subtrees = TRUE, $page = 0, $default_value = array(), $multiple = TRUE, $terms_to_expand = array(), $toolbar = TRUE, $can_edit = TRUE) { $current_depth = $tree[$index]->depth; while ($index < count($tree) && $tree[$index]->depth >= $current_depth) { @@ -442,13 +459,17 @@ $value = in_array($tree[$newindex]->tid, $terms_to_expand) ? 1 : 0; } } + $form[$term->tid]['checkbox'] = array( - '#type' => ($multiple) ? 'checkbox' : 'radio', + '#type' => $multiple ? 'checkbox' : 'radio', '#title' => $term->name, '#value' => $value, '#return_value' => $term->tid, '#theme' => ($multiple) ? 'taxonomy_manager_tree_checkbox' : 'taxonomy_manager_tree_radio', + '#toolbar' => $toolbar, + '#can_edit' => $can_edit, ); + if (!empty($root_form['#link_callback'])) { $link_callback = $root_form['#link_callback']; if (function_exists($link_callback)) { @@ -493,7 +514,7 @@ if ($build_subtrees) { if ($tree[$index]->depth > $current_depth) { $form[$term->tid]['#attributes']['class'] .= _taxonomy_manager_tree_term_get_class($index-1, $tree, ($root_form['#expand_all'] || in_array($term->tid, $terms_to_expand))); - taxonomy_manager_tree_build_form($index, $tree, $form[$term->tid]['children'], $root_form, array_merge($this_parents, array('children')), $build_subtrees, $page, $default_value, $multiple, $terms_to_expand); + taxonomy_manager_tree_build_form($index, $tree, $form[$term->tid]['children'], $root_form, array_merge($this_parents, array('children')), $build_subtrees, $page, $default_value, $multiple, $terms_to_expand, $toolbar, $can_edit); } else { if ((count($tree)-1 == $index-1) || ($tree[$index]->depth < $current_depth)) { @@ -610,11 +631,22 @@ $form_state = array('submitted' => FALSE); + // check user permissions + $add = user_access('add taxonomy terms'); + $move = user_access('move taxonomy terms'); + $delete = user_access('delete taxonomy terms'); + $merge = user_access('merge taxonomy terms'); + $export = user_access('export taxonomy terms'); + + $toolbar = $add || $move || $delete || $merge || $export; + $child_form = array( '#type' => 'taxonomy_manager_tree', '#vid' => $vid, '#parent' => $parent, '#pager' => TRUE, + '#toolbar' => $toolbar, + '#can_edit' => user_access('edit taxonomy terms'), ); if (!$root_level) { //TODO ? $child_form['#siblings_page'] = 1; @@ -798,6 +830,7 @@ * @return html lists */ function theme_taxonomy_manager_tree_elements($element) { + $output .= "