Try the Demo

Magento Forum

   
Can’t Save Role Resource for Custom Module
 
severinolorilla
Jr. Member
 
Total Posts:  4
Joined:  2012-11-19
 

I’ve created a custom module and my adminhtml.xml is as follows…

<config>
    <
menu>
        <
web translate="title" module="adminhtml">
            <
title>Custom</title>
            <
sort_order>110</sort_order>
            <
children>
                <
web>
                    <
title>User Info</title>
                    <
action>web/adminhtml_web</action>
                </
web>
            </
children>
        </
web>
    </
menu>
    <
acl>
        <
resources>
            <
admin>
                <
children>
                    <
Company_Web>
                        <
title>Custom</title>
                        <
sort_order>60</sort_order>
                        <
children>
                            <
info translate="title">
                                <
title>User Info</title>
                            </
info>
                        </
children>
                   </
Company_Web>
               </
children>
           </
admin>
       </
resources>
    </
acl>
</
config>

The module works as expected if an admin account is logged in. I can see the module in the admin panel and in the Role Resource Tab (System->Permissions->Roles), but when I tried to check the module and save the user role, it will say that it has been saved. But when I rechecked the user role, it is still unchecked.

And when I tried to login using the account with the said user role, the custom module is hidden. What seems to be the problem? Any kind of help is much appreciated..

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GoMageTeam
Sr. Member
 
Avatar
Total Posts:  152
Joined:  2013-01-13
Warsaw, Poland
 

Hello,

You can set the structure in ACL for the possibility of the changing the access permissions in the administrative panel (System -> Permissions -> Choose the role -> Role Resources -> Custom). Then you can check whether the user has the access permissions for certain actions using this construction:

Mage::getSingleton('admin/session')->isAllowed('cms/page/save');

You can do the same in the controller using the method _isAllowed (the example is taken from Mage_Adminhtml_Cms_PageController class):

/**
 * Check the permission to run it
 *
 * @return boolean
 */
protected function _isAllowed()
{
    
switch ($this->getRequest()->getActionName()) {
        
case 'new':
        case 
'save':
            return 
Mage::getSingleton('admin/session')->isAllowed('cms/page/save');
            break;
        case 
'delete':
            return 
Mage::getSingleton('admin/session')->isAllowed('cms/page/delete');
            break;
        default:
            return 
Mage::getSingleton('admin/session')->isAllowed('cms/page');
            break;
    
}
}

Please, be attentive because the access permissions (acl) and can be set in the file adminhtml.xml and also new menu elements can be added.

<acl>
        ...
        <
privilegeSets>
            <default>
                <
view>
                    <
descr>View entity</descr>
                </
view>
                <
edit>
                    <
descr>Edit entity</descr>
                </
edit>
                <
delete>
                    <
descr/>
                </
delete>
                <
create>
                    <
descr/>
                </
create>
            </default>
        </
privilegeSets>
    </
acl>

 Signature 

Bronze Partner of Magento
• A high-leveled development company – Providing easy, comfortable and useful Magento extensions
• The supporters of qualified and fast service. Find out more here: http://www.gomage.com

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top