I added a menu item in the installation script like this:
$menuItem = [
'menu_name' => 'main-menu',
'link_path' => 'admin/structure/nodequeue/home-queue',
'router_path' => 'admin/structure/nodequeue/%',
'link_title' => 'Home queue',
'module' => 'myModule',
'customized' => 1,
'weight' => -10
];
menu_link_save($menuItem);
The path takes me correctly to the nodequeue, as I use pathauto.
Now when a user with role X logs in, the menu item is not seen with only the 'Manipulate queues' permission, even with role X selected in the home-queue options.
If I also select the 'Manipulate all queues'permission, the menu item shows up, but I don't want role X to manipulate all queues.
The following is used to create the nodequeue, as maybe I do this wrong?:
variable_set('nodequeue_view_per_queue', 0);
$queue = (object) [
'name' => 'home_queue',
'title' => 'Home queue',
'subqueue_title' => '',
'size' => '0',
'reverse' => 0,
'link' => '',
'link_remove' => '',
'roles' => [DRUPAL_AUTHENTICATED_RID],
'types' => [0 => 'page_hero', 1 => 'product_feature', 2 => 'page_foot'],
'i18n' => 1,
'op' => 'Submit',
'submit' => 'Submit',
'owner' => 'nodequeue',
'show_in_links' => false,
'show_in_tab' => true,
'show_in_ui' => true,
'reference' => 0,
'subqueues' => [],
'new' => true,
'add_subqueue' => [0 => 'Home queue'] // Match title above.
];
$homeQueueId = nodequeue_save($queue);
// !!! Always make sure you create an alias so that we can add menu's for this.
$alias = [
'source' => 'admin/structure/nodequeue/'.$homeQueueId,
'alias' => 'admin/structure/nodequeue/home-queue'
];
path_save($alias);
I hope it's something I doing wrong?
Comments
Comment #1
jenlamptonHi @DieterAtWork,
I'm changing this issue from a bug-report to a support request since you are asking for support with custom code. It looks like you could use a review of Drupal coding standards as I've never seen the funny array syntax you are using with square brackets, and I wonder if that might be presenting some issues for you.
To answer your question, you could manually set an `access callback` for your menu item to check whether a user has `Manipulate queues' permission. Good luck!