Download & Extend

Integrate with Block Edit or Native Basic/Zen admin hover links

Project:Menu Admin per Menu
Version:6.x-1.4
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

The module "Block Edit" and the themes Basic & Zen both feature admin hover links like "edit menu" and "configure" for users with the "administer menu" permission. It would be nice if these links would show up when Menu Admin per Menu has determined that the user has permission for a particular menu.

Unfortunately, since these functions rely on the "administer menu" permission, so it's an all or none situation-- making it incompatible with Menu Admin per Menu.

Is there a way to do this?

Comments

#1

Thanks for the info Madmatter23, I will have a look at this!

#2

Thanks, that would go a long way toward improving the usability of Drupal for users with limited permissions and experience.

There are about 1300+ using your module and 2300+ using block edit, not to mention the countless themes implementing this at the template.php level.

Speaking of which, here's the code that generates the link for the Basic theme (which has a great template.php file)

<?php
if (theme_get_setting('hook_block_editing') && user_access('administer blocks')) {
       
// Display 'edit block' for custom blocks.
       
if ($block->module == 'block') {
         
$edit_links[] = l('<span>' . t('edit block') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
            array(
             
'attributes' => array(
               
'title' => t('edit the content of this block'),
               
'class' => 'block-edit',
              ),
             
'query' => drupal_get_destination(),
             
'html' => TRUE,
            )
          );
        }
       
// Display 'configure' for other blocks.
       
else {
         
$edit_links[] = l('<span>' . t('configure') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
            array(
             
'attributes' => array(
               
'title' => t('configure this block'),
               
'class' => 'block-config',
              ),
             
'query' => drupal_get_destination(),
             
'html' => TRUE,
            )
          );
        }
       
// Display 'edit menu' for Menu blocks.
       
if (($block->module == 'menu' || ($block->module == 'user' && $block->delta == 1)) && user_access('administer menu')) {
         
$menu_name = ($block->module == 'user') ? 'navigation' : $block->delta;
         
$edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
            array(
             
'attributes' => array(
               
'title' => t('edit the menu that defines this block'),
               
'class' => 'block-edit-menu',
              ),
             
'query' => drupal_get_destination(),
             
'html' => TRUE,
            )
          );
        }
       
// Display 'edit menu' for Menu block blocks.
       
elseif ($block->module == 'menu_block' && user_access('administer menu')) {
          list(
$menu_name, ) = split(':', variable_get("menu_block_{$block->delta}_parent", 'navigation:0'));
         
$edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
            array(
             
'attributes' => array(
               
'title' => t('edit the menu that defines this block'),
               
'class' => 'block-edit-menu',
              ),
             
'query' => drupal_get_destination(),
             
'html' => TRUE,
            )
          );
        }
       
$vars['edit_links_array'] = $edit_links;
       
$vars['edit_links'] = '<div class="edit">' . implode(' ', $edit_links) . '</div>';
      }
?>

Looks like it just checks for

<?php
user_access
('administer menu')
?>
. Is there a simple way to swap this out with a function from your module?

Thanks!

#3

Sorry I'm on holiday at the moment and don't have too much time :-)
The function you're looking for is:

<?php
_menu_admin_per_menu_menu_access
($menu)
?>

#4

Thanks for the pointer.

For anyone that's interested, I've put together a
custom template.php file with block preprocessing based on your suggestion. Details:

  1. Integrated with Menu Admin per Menu module, so that the "Edit Menu" and "Configure" links for each block can be controlled per menu & by role.
  2. Integrated with Nice Menus and Menu Block modules.
  3. Integrated with Block Access module, so that the "Edit" and "Configure" links for each block can be controlled per block & by role.
  4. Added first and last classes to blocks per region.

#5

Status:active» needs review

Thanks for this.
Couldn't this be turned into a releasable sub-module or something?