Hi, the features of this module look great, however I am not sure how to use it. Does it work only for the built-in menus? On the block management page, I only see menu_access versions of Drupal's built-in menus: Primary, Secondary and Navigation. Does that mean it works automatically for the extra menus I create?

I have a multilingual site where I created menus per language. So I have for instance menus called vertical-pt, vertical-es, etc.
Then I want translators to have access to the menu settings when they create or edit a page, but only for the menus in their target language, being able to create and edit menu item titles, weights etc.

So for a particular translator role on the permissions page I granted him the following rights: access menus, create menu content, edit menu content, access menu items, create menu item, delete menu item, edit menu item.

On the global menu and menu item settings I didn't grant any permissions.

For the particular menu he should have access to, I granted him all rights. As I understand the module, the menu items within that menu should then inherit the menu settings. I also suppose that if a user has various roles, it should only be necessary to grant permissions for one of his roles in order to make it work.

However, things didn't work out as expected. When editing a page, the menu options do not show.

I hope you will be able to help. Thanks a lot.

CommentFileSizeAuthor
#11 access_function.patch935 bytesAnonymous (not verified)
#10 menu_list.patch1.77 KBAnonymous (not verified)

Comments

LarsKramer’s picture

Hi again
I've done some further testing, and it seems that the access settings of this module only apply to the menu administer page, and only if a role has the "menu module -> administer menu" permission enabled on the user permissions page.

Even though a user role doesn't have global permission to view or edit menu items, when he edits or creates a node, in the menu options of that node, he will still be able to see all menus, add items to all menus and edit the menu item titles.

Is there any way I can make the settings of this module also apply to the menu options settings when creating or editing nodes?

emptyvoid’s picture

The current release only provide blocks for existing menus.. any additional menus would need to be added via programming a module or adding the menus to your chosen theme.

When editing node content the system should filter out menus that the current user does not have rights to access. This may be because you have administer menu enabled.. the security defined in the menu access module is overridden by the global Drupal administer menus permission. That administer menus permission means the user/role can access all menus.

LarsKramer’s picture

Hi, thanks for the reply.

greenbeans’s picture

Title: Does it work with custom menus? » Menu Access Blocks for Custom Menus
Category: support » feature
Status: Active » Needs review

Here's a rewrite of menu_access_block() that works with custom menus:


function menu_access_block($op = 'list', $delta = 0, $edit = array()) {
	global $user;
	$menus = menu_access_get_menus();

	if ($op == 'list') {
		$blocks = array();
		foreach ($menus as $name => $title) {
			$blocks[$name]['info'] = t('Menu Access - ') . check_plain($title);
			// Menu blocks can't be cached because each menu item can have
			// a custom access callback.
			$blocks[$name]['cache'] = BLOCK_NO_CACHE;
		}
		return $blocks;
	}
	else if ($op == 'view') {
		$block = array();
		if ($menu = menu_access_menu_tree($delta)) {
			if (menu_access_access('access menus', NULL, FALSE, $delta)) {
				$block['subject'] = $user->uid ? check_plain($user->name) : check_plain($menus[$delta]);
				$block['content'] = $menu;
				return $block;
			} else {
				return '';
			}
		}
		else {
			return '';
		}
	}
}
emptyvoid’s picture

thanks for the patch, as soon as I get my CVS account reactivated I will issue a new release to the dev branch for testing. I have several other patches and feature enhancement that I would like to roll into the next release.

emptyvoid’s picture

Assigned: Unassigned » emptyvoid
emptyvoid’s picture

Hello, I have added your code to the dev branch, please download the branch and let me know if you have any problems. I plan to add several fixes and a few features in the coming week/month and if all works out I'll issue a new release (much overdue).

emptyvoid’s picture

Status: Needs review » Patch (to be ported)
emptyvoid’s picture

Status: Patch (to be ported) » Closed (fixed)
Anonymous’s picture

StatusFileSize
new1.77 KB

When the block module runs the _block_rehash by cron and ask for the menu list, the module return an empty array to the anonymous user.
We have not to apply the access control in case we have to retrive the list of blocks.

Anonymous’s picture

StatusFileSize
new935 bytes

if ($search_result != -1 && $search_result != FALSE) {
mut to be
if ($search_result != -1 && $search_result !== FALSE) {
to avoid problem because the result might be 0