Page 1 of 1

Restrict component submenu items using ACL ?

Posted: Fri Apr 22, 2022 10:56 am
by david0058
Hi,

I have a backend component with five submenu options defined in <menu> entries in the <submenu> node of the component.xml. I would like all of these to be visible to superusers (core.admin) but only the first three to be shown to administrators (core.manage).

Is this possible ? I can clearly block access to the underlying functions in the code by checking the access permissions but I'd prefer to just not display menu items if the users don't have access to them.

Thanks,

David

J3.10.3

Re: Restrict component submenu items using ACL ?

Posted: Fri Apr 22, 2022 12:24 pm
by david0058
It seems to be something to do with putting the logic in helpers/xxx.php in the addSubmenu($vName) function:

Code: Select all

 {   
        $canDo = JHelperContent::getActions('com_xxx');

        if ($canDo->get('core.edit.own')){
            JSubMenuHelper::addEntry( JText::_('COM_XXX_SUBMENU_OPTION1'), 'index.php?option=com_xxx&view=option1', $vName == 'option1');
            JHtmlSidebar::addEntry( JText::_('COM_XXX_SUBMENU_OPTION1'), 'index.php?option=com_xxx&view=option1, $vName == 'option1');
        }
     }
However while this is fine once the component code is actually run, I don't see how to tell Joomla what to display in the main menu when a user logs in but before they run anything ...

Re: Restrict component submenu items using ACL ?

Posted: Fri Apr 22, 2022 10:28 pm
by AMurray
I thought the Administrator menu system worked in a similar way as the front-end (as far as the ACL is concerned).

Wouldn't you simply place those users wanting access to those three admin items in the "Administrator" user group?

Re: Restrict component submenu items using ACL ?

Posted: Sat Apr 23, 2022 7:44 pm
by Webdongle
1. Create a new user group add the relevant permissions and select it in the 'Special' view access level
2. In each Super Users account select the new user group
3. Create a view access level and the new group in it
4. Set the view level of the (relevant) menu items to the new access level