Magento Custom Module Administrator Permissions

I created several custom modules for Magento, and when I try to assign permissions for the module (check the box), when I click the "Save" button, it unchecks the box.

Does anyone have any ideas? There seems to be something in my config.xml, so I will post it here just in case:

<config>
<modules>
    <Wpe_Vendorlist>
        <version>0.1.0</version>
    </Wpe_Vendorlist>
</modules>
<admin>
    <routers>
        <vendorlist>
            <use>admin</use>
            <args>
                <module>Wpe_Vendorlist</module>
                <frontName>vendorlist</frontName>
            </args>
        </vendorlist>
    </routers>
</admin>
<adminhtml>
    <menu>
        <customer>
            <children>
                <items module="vendorlist">
                    <title>SO Vendor List</title>
                    <sort_order>999</sort_order>
                    <action>vendorlist/adminhtml_vendorlist</action>
                </items>
            </children>
        </customer>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <Wpe_Vendorlist>
                        <title>Vendorlist Module</title>
                        <sort_order>10</sort_order>
                    </Wpe_Vendorlist>
                </children>
            </admin>
        </resources>
    </acl>
    <layout>
        <updates>
            <vendorlist>
                <file>vendorlist.xml</file>
            </vendorlist>
        </updates>
    </layout>
</adminhtml>
<global>
    <models>
        <vendorlist>
            <class>Wpe_Vendorlist_Model</class>
            <resourceModel>vendorlist_mysql4</resourceModel>
        </vendorlist>
        <vendorlist_mysql4>
            <class>Wpe_Vendorlist_Model_Mysql4</class>
            <entities>
                <vendorlist>
                    <table>vendorlist</table>
                </vendorlist>
            </entities>
        </vendorlist_mysql4>
    </models>
    <resources>
        <vendorlist_setup>
            <setup>
                <module>Wpe_Vendorlist</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </vendorlist_setup>
        <vendorlist_write>
            <connection>
                <use>core_write</use>
            </connection>
        </vendorlist_write>
        <vendorlist_read>
            <connection>
                <use>core_read</use>
            </connection>
        </vendorlist_read>
    </resources>
    <blocks>
        <vendorlist>
            <class>Wpe_Vendorlist_Block</class>
        </vendorlist>
    </blocks>
    <helpers>
        <vendorlist>
            <class>Wpe_Vendorlist_Helper</class>
        </vendorlist>
    </helpers>
</global>
</config>
+3
source share
5 answers

I highly recommend you take a look at Alan Storm ’s article on system configuration, and the rest of his series is the best information I’ve found. We've found out about purple programming.

For this specific question, here is how I did it in my module with your module name:

<acl><!-- permits -->
    <resources>
        <admin>
            <children>
                <customer translate="title" module="vendorlist"><!-- this tag matches the menu tag, and the same for his children -->
                    <title>what will appears in the checkboxes tree when you create a role</title>
                    <children>
                        <firstchild>
                            <title>what will appears in the checkboxes tree when you create a role</title>
                        </firstchild>
                    </children>
                </customer>
            </children>
        </admin>
    </resources>
</acl>

You will not need:

                <children>
                    <firstchild>
                        <title>what will appears in the checkboxes tree when you create a role</title>
                    </firstchild>
                </children>

, , .
,

+5

config.xml

<acl>
    <resources>
        <all>
            <title>Allow Everything</title>
        </all>
        <admin>
            <children>
                <Wpe_Vendorlist>
                    <title>Vendorlist Module</title>
                    <sort_order>10</sort_order>
                </Wpe_Vendorlist>
            </children>
        </admin>
    </resources>
</acl>

<acl>
    <resources>
        <all>
            <title>Allow Everything</title>
        </all>
        <admin>
            <children>
                <vendorlist>
                    <title>Vendorlist Module</title>
                    <sort_order>10</sort_order>
                </vendorlist>
            </children>
        </admin>
    </resources>
</acl>

Wpe_Vendorlist. , , .

+2

. . ///Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php

public function __construct()
{
    ...

    foreach ($rules_set->getItems() as $item) {
        $itemResourceId = $item->getResource_id();
        if (array_key_exists(strtolower($itemResourceId), $resources) && $item->getPermission() == 'allow') {
            $resources[$itemResourceId]['checked'] = true;
            array_push($selrids, $itemResourceId);
        }
    }

    ....

acl adminhtml.xml , config.xml.

, ​​ , acl-, acl , magento , , .

, , adminhtml.xml:

<adminhtml>
    <menu>
        <customer>
            <children>
                <wpe_vendorlist module="vendorlist">
                    <title>SO Vendor List</title>
                    <sort_order>999</sort_order>
                    <action>vendorlist/adminhtml_vendorlist</action>
                </wpe_vendorlist>
            </children>
        </customer>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <customer>
                        <children>
                            <wpe_vendorlist>
                                <title>Vendorlist Module</title>
                                <sort_order>10</sort_order>
                            </wpe_vendorlist>
                        </children>
                    </customer>
                </children>
            </admin>
        </resources>
    </acl>
</adminhtml>
+1

acl tag

0

Source: https://habr.com/ru/post/1753553/


All Articles