2
votes

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

<?xml version="1.0"?>
  <config>
   <admin>
    <routers>
        <blacklist>
            <use>admin</use>
            <args>
                <module>Leon_Blacklist</module>
                <frontName>blacklist</frontName>
            </args>
        </blacklist>
    </routers>
</admin>
<adminhtml>
    <menu>
        <blacklist translate="title" module="blacklist">
            <title>Blacklist</title>
            <sort_order>71</sort_order>               
            <children>
                <items translate="title" module="blacklist">
                    <title>Manage Items</title>
                    <sort_order>0</sort_order>
                    <action>blacklist/adminhtml_blacklist</action>
                </items>
            </children>
        </blacklist>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <Leon_Blacklist translate="title" module="blacklist">
                        <title>Blacklist Module</title>
                        <sort_order>10</sort_order>

                        <children>
                            <items translate="title" module="blacklist">
                                <title>Manage Items</title>
                            </items>                        
                        </children>
                    </Leon_Blacklist>
                </children>
            </admin>
        </resources>
    </acl>
    <layout>
        <updates>
            <blacklist>
                <file>blacklist.xml</file>
            </blacklist>
        </updates>
    </layout>
</adminhtml> 
<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.

2

2 Answers

5
votes

Your acl section of config is a little wrong. Tags should be similar to menu section. So in your case it should look like this:

<acl>
    <resources>
        <admin>
            <children>
                <blacklist translate="title" module="blacklist">
                    <title>Blacklist Module</title>
                    <sort_order>10</sort_order>

                    <children>
                        <items translate="title" module="blacklist">
                            <title>Manage Items</title>
                        </items>                        
                    </children>
                </blacklist>
            </children>
        </admin>
    </resources>
</acl>
0
votes

Here is my acl section of config.xml

<acl>
    <resources>
        <all>
            <title>Allow Everything</title>
        </all>
        <admin>
            <children>
                <banner translate="title" module="banner">
                    <title>Banner Module</title>
                    <sort_order>10</sort_order>
                    <children>
                        <banner translate="title" module="banner">
                            <title>Manage Banners</title>
                        </banner>                      
                    </children>
                </banner>
            </children>
        </admin>
    </resources>
</acl>

Also add the below function in your controller to avoid the "Access denied" message

protected function _isAllowed(){
        return true;
}

Code taken from: http://chandreshrana.blogspot.in/2015/06/custom-module-role-not-save-in.html