diff --git a/menu_attributes.module b/menu_attributes.module index 894d5f6..b0a56d4 100644 --- a/menu_attributes.module +++ b/menu_attributes.module @@ -7,6 +7,13 @@ */ /** + * Implements hook_perm(). + */ +function menu_attributes_perm() { + return array('administer menu attributes'); +} + +/** * Implements hook_menu(). */ function menu_attributes_menu() { @@ -16,7 +23,7 @@ function menu_attributes_menu() { 'description' => 'Configure the Menu Attributes module', 'page callback' => 'drupal_goto', 'page arguments' => array('admin/build/menu/settings'), - 'access arguments' => array('administer menu'), + 'access arguments' => array('administer menu attributes'), ); return $items; } @@ -122,8 +129,10 @@ function menu_attributes_get_menu_attribute_info() { * @see menu_attributes_form_menu_edit_item_submit() */ function menu_attributes_form_menu_edit_item_alter(&$form, $form_state) { - $item = $form['menu']['#item']; - _menu_attributes_form_alter($form['menu'], $item, $form); + if (user_access('administer menu attributes')) { + $item = $form['menu']['#item']; + _menu_attributes_form_alter($form['menu'], $item, $form); + } } /** @@ -134,7 +143,7 @@ function menu_attributes_form_menu_edit_item_alter(&$form, $form_state) { * @see _menu_attributes_form_alter() */ function menu_attributes_form_alter(&$form, $form_state, $form_id) { - if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id && isset($form['menu'])) { + if (user_access('administer menu attributes') && isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id && isset($form['menu'])) { $item = $form['#node']->menu; _menu_attributes_form_alter($form['menu'], $item, $form); array_unshift($form['#submit'], 'menu_attributes_form_node_form_submit'); @@ -247,35 +256,37 @@ function _menu_attributes_form_submit($form, &$form_state) { * @see menu_configure_form() */ function menu_attributes_form_menu_configure_alter(&$form, $form_state) { - $form['attributes'] = array( - '#type' => 'item', - '#title' => t('Menu item attribute options'), - ); - - $attributes = menu_attributes_get_menu_attribute_info(); - foreach ($attributes as $attribute => $info) { - $form['attributes'][$attribute] = array( - '#type' => 'fieldset', - '#title' => $info['label'], - '#group' => TRUE, - '#description' => $info['form']['#description'], - ); - $form['attributes'][$attribute]["menu_attributes_{$attribute}_enable"] = array( - '#type' => 'checkbox', - '#title' => t('Enable the @attribute attribute.', array('@attribute' => drupal_strtolower($info['label']))), - '#default_value' => $info['enabled'], + if (user_access('administer menu attributes')) { + $form['attributes'] = array( + '#type' => 'item', + '#title' => t('Menu item attribute options'), ); - $form['attributes'][$attribute]["menu_attributes_{$attribute}_default"] = array( - '#title' => t('Default'), - '#description' => '', - ) + $info['form']; - } - // Ensure the buttons sink to the bottom of the form. - $form['buttons'] += array('#weight' => 100); + $attributes = menu_attributes_get_menu_attribute_info(); + foreach ($attributes as $attribute => $info) { + $form['attributes'][$attribute] = array( + '#type' => 'fieldset', + '#title' => $info['label'], + '#group' => TRUE, + '#description' => $info['form']['#description'], + ); + $form['attributes'][$attribute]["menu_attributes_{$attribute}_enable"] = array( + '#type' => 'checkbox', + '#title' => t('Enable the @attribute attribute.', array('@attribute' => drupal_strtolower($info['label']))), + '#default_value' => $info['enabled'], + ); + $form['attributes'][$attribute]["menu_attributes_{$attribute}_default"] = array( + '#title' => t('Default'), + '#description' => '', + ) + $info['form']; + } - // Add vertical tabs to these fieldsets if it is available. - if (module_exists('vertical_tabs')) { - $form['attributes']['#pre_render'][] = 'vertical_tabs_form_pre_render'; + // Ensure the buttons sink to the bottom of the form. + $form['buttons'] += array('#weight' => 100); + + // Add vertical tabs to these fieldsets if it is available. + if (module_exists('vertical_tabs')) { + $form['attributes']['#pre_render'][] = 'vertical_tabs_form_pre_render'; + } } }