hello

i am trying the new release and configuring the site.
i just realize that if a user has not permissions to edit categories and variation types, the product setting option and these two items appear in the management menu. if you go to them, of course, you get the 403 error for access denied.

thanks for your work :)

Comments

candelas’s picture

the same (they dont have permissions) happens with:

  • Content/Settings/Content types
  • Store settings/Product settings
  • Store settings/Promotions
  • Site settings/Visual & Layaout
  • Site settings/Advanced settings/Structure

have nice holidays!

candelas’s picture

more on the management menu.
i have applied diferent style to it. when i am as admin, i get the changes.
when i am as another role, the Products menu doesnt get the style. but only this one, the others get the changes.

in firebug i can see that the commerce kickstart menus it is applied after my theme in those items, but not in the rest.
the style

#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-1 div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-1 div.toolbar-menu-wrapper ul.menu li:hover a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-1 li:hover div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-2 div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-2 div.toolbar-menu-wrapper ul.menu li:hover a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-2 li:hover div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-3 div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-3 div.toolbar-menu-wrapper ul.menu li:hover a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-3 li:hover div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-4 div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-4 div.toolbar-menu-wrapper ul.menu li:hover a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-4 li:hover div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-5 div.toolbar-menu-wrapper ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-5 div.toolbar-menu-wrapper ul.menu li:hover a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.group-5 li:hover div.toolbar-menu-wrapper ul.menu li a {
  color: #3EC927;
  font-size: 15px;
  font-weight: 500;
}
candelas’s picture

i resolved this adding this two rules to my custom style css. but still i dont understand why this is not needed in the admin role/user.

/* Wider Mega Menu */
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-products div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-products div.toolbar-menu-wrapper ul.menu li:hover a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-products li:hover div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-orders div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-orders div.toolbar-menu-wrapper ul.menu li:hover a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-orders li:hover div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-content div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-content div.toolbar-menu-wrapper ul.menu li:hover a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-content li:hover div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-store-settings div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-store-settings div.toolbar-menu-wrapper ul.menu li:hover a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-store-settings li:hover div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-site-settings div.toolbar-menu-wrapper ul.menu li a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-site-settings div.toolbar-menu-wrapper ul.menu li:hover a,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-site-settings li:hover div.toolbar-menu-wrapper ul.menu li a {

  color: #3ec927;
  font-size: 15px;
  font-weight: 100;
}

#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-products div.toolbar-menu-wrapper ul.menu ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-orders div.toolbar-menu-wrapper ul.menu ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-content div.toolbar-menu-wrapper ul.menu ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-store-settings div.toolbar-menu-wrapper ul.menu ul.menu li a, #toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-site-settings div.toolbar-menu-wrapper ul.menu ul.menu li a { 
  color: #FFFFFF;
  font-weight: 100;
  font-size: 15px;
}
candelas’s picture

Title: management menu: product settings aren't disabled when user has no permissions » commerce_kickstart_menus.module: management menu: several menu items have wrong "access callback"
Priority: Normal » Major

i keep studying why some menu items show if the user has not permission to them.
i hope this helps the maintainers to fix it.
sorry for my bad english :)

i centered in :

  • admin/commerce/manage-products/settings
  • admin/commerce/manage-products/settings/categories
  • admin/commerce/manage-products/settings/product-variation-types

in commerce_kickstart_menus.module line 52 they are defined

 // Products > Settings
  $items['admin/commerce/manage-products/settings'] = array(
    'title' => 'Settings',
    'description' => 'Products settings.',
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array('access administration pages'),
    'file path' => drupal_get_path('module', 'system'),
    'file' => 'system.admin.inc',
    'weight' => 1,
    'options' => array(
      'toolbar_expanded' => TRUE,
      'toolbar_break' => TRUE,
    ),
  );
  // Products > Settings > Categories
  $items['admin/commerce/manage-products/settings/categories'] = array(
    'title' => 'Categories',
    'description' => 'Manage tagging, categorization, and classification of your products.',
    'page callback' => 'drupal_goto',
    'page arguments' => array('admin/commerce/config/products-categories'),
    'access callback' => TRUE,
  );
  // Products > Settings > Variation types
  $items['admin/commerce/manage-products/settings/product-variation-types'] = array(
    'title' => 'Variation types',
    'description' => 'Manage products variation types for your store.',
    'page callback' => 'drupal_goto',
    'page arguments' => array('admin/commerce/config/product-variation-types'),
    'access callback' => TRUE,
  );

admin/commerce/manage-products/settings has not a 'access callback', so it inherits from products (it has a view with: Access: Permission | Administer products) or gets the default on the cell if it is not given (i dont find documentation on this). i see in the database, table menu_router, cell acces_callback that settings has as acces_callback : user_access

my need is that one role can administer products, but not settings (variations and categories). so settings need a different callback, a new perm or access arguments.

then, categories and variations types have an access callback => TRUE what makes them accessible to all users that can see the management menu (translators and editors), what is wrong in my case. i think it should be


  // Products > Settings > Categories
  $items['admin/commerce/manage-products/settings/categories'] = array(
    'title' => 'Categories',
    'description' => 'Manage tagging, categorization, and classification of your products.',
    'page callback' => 'drupal_goto',
    'page arguments' => array('admin/commerce/config/products-categories'),
    'access callback' => 'user_access',
    'access arguments' =>  array('administer taxonomy'),
  );
  // Products > Settings > Variation types
  $items['admin/commerce/manage-products/settings/product-variation-types'] = array(
    'title' => 'Variation types',
    'description' => 'Manage products variation types for your store.',
    'page callback' => 'drupal_goto',
    'page arguments' => array('admin/commerce/config/product-variation-types'),
    'access callback'  => 'user_access',
    'access arguments' =>array('administer product types'),
  );

i also see in table: menu_links, cell: hidden (A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)) that the 3 of them has 0. i imagine that it is because it is not defined.

since i am not an expert programmer, i dont now if i should submit a patch (learning on that) or make my own solution (worst, since other people will have the same need).

i wonder if i should use in a custom module a function to change the visibility depending on the user... while you decide what to do...

//hook_menu_link_alter():

function myMODULE_menu_link_alter(&$item) {
   if ($item['link_path'] == 'admin/commerce/manage-products/settings') {
      $item['hidden'] = 1;
   }
}

i have learned a lot about menus :)
thanks for the module and i hope you have time to give advice to me :)

candelas’s picture

StatusFileSize
new150 KB

i solved temporally this problem with hook_menu_alter, since hook_menu_link_alter will change it for all roles. i put it here just in case someone can use it :)

function yourMODULE_menu_alter(&$items) {
    
//product/settings

        $items['admin/commerce/manage-products/settings']['access callback'] = 'user_access';
        $items['admin/commerce/manage-products/settings']['access arguments'] = array('administer taxonomy');

//product/settings/categories

        $items['admin/commerce/manage-products/settings/categories']['access callback'] = 'user_access';
        $items['admin/commerce/manage-products/settings/categories']['access arguments'] = array('administer taxonomy');

//product/settings/product-variation-types

        $items['admin/commerce/manage-products/settings/product-variation-types']['access callback'] = 'user_access';
        $items['admin/commerce/manage-products/settings/product-variation-types']['access arguments'] = array('administer product types');

//content/settings

        $items['admin/commerce/manage-content/settings']['access callback'] = 'user_access';
        $items['admin/commerce/manage-content/settings']['access arguments'] = array('administer content types');

//content/settings/content-types

        $items['admin/commerce/manage-content/settings/content-types']['access callback'] = 'user_access';
        $items['admin/commerce/manage-content/settings/content-types']['access arguments'] = array('administer content types');

//store-settings/product-settings

        $items['admin/commerce/config/product-settings']['access callback'] = 'user_access';
        $items['admin/commerce/config/product-settings']['access arguments'] = array('administer taxonomy');

//store-settings/promotions

        $items['admin/commerce/config/promotions']['access callback'] = 'user_access';
        $items['admin/commerce/config/promotions']['access arguments'] = array('administer commerce discounts');

//site-settings/layaout

        $items['admin/site-config/layout']['access callback'] = 'user_access';
        $items['admin/site-config/layout']['access arguments'] = array('administer themes');

//site-settings/advanced-settings/structure

        $items['admin/structure']['access callback'] = 'user_access';
        $items['admin/structure']['access arguments'] = array('administer blocks');

                   
}

but now the menus that are empty doesnt look well

menu problem

now i have to go (31/dec), but, if i found a solution, i will put it here next days.

candelas’s picture

Status: Active » Needs review

solved by css. put in your custom theme:

/*from commerce_kickstart_menus.css */
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-store-settings div.toolbar-menu-wrapper,
#toolbar div.toolbar-menu div.toolbar-menu-wrapper ul.toolbar-menu-site-settings div.toolbar-menu-wrapper {
  width: auto;
}

so, my proposal is that the 'access callback' and 'access arguments' get changed, and the style too.
have a happy new year! :)

vasike’s picture

Title: commerce_kickstart_menus.module: management menu: several menu items have wrong "access callback" » Use redirect access for menu item with redirection in commerce_kickstart_menus.module: management menu
Version: 7.x-2.0 » 7.x-2.x-dev
Priority: Major » Normal
Status: Needs review » Active

i think the issue here it's the Menu items defined that use "drupal_goto()" function to redirect to other page, but haven't defined the access or the same "access".

jsacksick’s picture

Status: Active » Needs review
StatusFileSize
new4.96 KB
jsacksick’s picture

Status: Needs review » Fixed

I merged the fix.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.