Magento - не удается сохранить ресурс роли для пользовательского модуля

Я создал собственный модуль, и мой config.xml выглядит следующим образом…

<?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>

Модуль работает должным образом, если вход в систему выполнен с учетной записью администратора. Я вижу модуль в панели администратора и на вкладке ресурсов ролей (Система->Разрешения->Роли), но когда я попытался проверить модуль и сохранить пользователя роль, он скажет, что он был сохранен. Но когда я перепроверил роль пользователя, она все еще не отмечена.

И когда я попытался войти в систему, используя учетную запись с указанной ролью пользователя, пользовательский модуль был скрыт. В чем проблема? Любая помощь очень ценится..

Спасибо.


person Leon Lai    schedule 02.05.2013    source источник


Ответы (2)


Ваш раздел конфигурации acl немного неверен. Теги должны быть похожи на раздел меню. Итак, в вашем случае это должно выглядеть так:

<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>
person Alexei Yerofeyev    schedule 02.05.2013

Вот мой раздел acl в 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>

Также добавьте приведенную ниже функцию в свой контроллер, чтобы избежать сообщения «Отказано в доступе».

protected function _isAllowed(){
        return true;
}

Код взят с: http://chandreshrana.blogspot.in/2015/06/custom-module-role-not-save-in.html

person Chandresh    schedule 24.06.2016