diff --git a/menu_attributes.module b/menu_attributes.module index 32c7567..2c7ef70 100644 --- a/menu_attributes.module +++ b/menu_attributes.module @@ -7,6 +7,14 @@ */ /** + * Implements hook_perm() + */ + +function menu_attributes_perm() { + return array('administer menu attributes'); +} + +/** * Implements hook_menu(). */ function menu_attributes_menu() { @@ -16,7 +24,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,16 +130,18 @@ 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); + if (user_access('administer menu attributes')) { + $item = $form['menu']['#item']; + _menu_attributes_form_alter($form['menu'], $item); - // Because this form uses a special $form['description'] field which is - // really the 'title' attribute, we need to add special pre-submit handling - // to ensure our field gets saved as the title attribute. - array_unshift($form['#submit'], 'menu_attributes_form_menu_edit_item_submit'); + // Because this form uses a special $form['description'] field which is + // really the 'title' attribute, we need to add special pre-submit handling + // to ensure our field gets saved as the title attribute. + array_unshift($form['#submit'], 'menu_attributes_form_menu_edit_item_submit'); - // Hide the 'description' field since we will be using our own 'title' field. - $form['menu']['description']['#access'] = FALSE; + // Hide the 'description' field since we will be using our own 'title' field. + $form['menu']['description']['#access'] = FALSE; + } } /** @@ -152,7 +162,7 @@ function menu_attributes_form_menu_edit_item_submit($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); array_unshift($form['#submit'], 'menu_attributes_form_node_form_submit'); @@ -249,3 +259,4 @@ function menu_attributes_form_menu_configure_alter(&$form, $form_state) { $form['attributes']['#pre_render'][] = 'vertical_tabs_form_pre_render'; } } +