2

I have coded a module with 3 features (and 3 menupoints). Then i copied the menu-section and edited it so it is useable as ACL resource.

It looks like this (adminhtml.xml):

<config>
    <menu>
        <MyModule translate="title" module="MyModule">
            <title>MyModule</title>
            <sort_order>99</sort_order>
            <children>
                <feature1 translate="title" module="MyModule">
                    <title>F1</title>
                    <sort_order>1</sort_order>
                    <action>MyModule/index/feature1</action>
                </feature1>
                <feature2>
                    <title>F2</title>
                    <sort_order>2</sort_order>
                    <action>MyModule/index/feature2</action>
                </feature2>
                <feature3>
                    <title>F3</title>
                    <sort_order>3</sort_order>
                    <action>MyModule/index/feature3</action>
                </feature3>
            </children>
        </MyModule>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <MyModule translate="title" module="MyModule">
                        <title>MyModule</title>
                        <sort_order>99</sort_order>
                        <children>
                            <feature1 translate="title" module="MyModule">
                                <title>F1</title>
                                <sort_order>1</sort_order>
                            </feature1>
                            <feature2>
                                <title>F2</title>
                                <sort_order>2</sort_order>
                            </feature2>
                            <feature3>
                                <title>F3</title>
                                <sort_order>4</sort_order>
                            </feature3>
                        </children>
                    </MyModule>
                </children>
            </admin>
        </resources>
    </acl>
</config>

now the strange thing is, it is working, but in magento if I edit the the roles it doesnt show up as checked its always unchecked in role resources. I even checked the database and it saved the correct value (allow/deny).

4 Answers 4

2

In my case problem was with this xml node

<MyModule translate="title" module="MyModule">

make it camel-case

<myModule translate="title" module="MyModule"> 

or make it lowercase (in my case lower is worked)

<mymodule translate="title" module="MyModule"> 
0

I suggest you add the following to your code:

<all>
    <title>Allow Everything</title>
</all>

So your acl part looks like this:

<acl>
    <resources>
        <all>
            <title>Allow Everything</title>
        </all>
        <admin>
            <children>
                <MyModule translate="title" module="MyModule">
                    <title>MyModule</title>
                    <sort_order>99</sort_order>
                    <children>
                        <feature1 translate="title" module="MyModule">
                            <title>F1</title>
                            <sort_order>1</sort_order>
                        </feature1>
                        <feature2>
                            <title>F2</title>
                            <sort_order>2</sort_order>
                        </feature2>
                        <feature3>
                            <title>F3</title>
                            <sort_order>4</sort_order>
                        </feature3>
                    </children>
                </MyModule>
            </children>
        </admin>
    </resources>
</acl>
3
  • Thanks for the suggestion, but sadly it didn't fix my problem :/ Commented Jan 21, 2016 at 16:53
  • Did you logout and log back in to the admin ? Commented Jan 21, 2016 at 16:54
  • I assigned the role to another user. When I login with that user the role is applied correctly, for example if I only allow MyModule, I only get the Menupoint from MyModule. Commented Jan 21, 2016 at 16:57
0

The resource identifiers should be all lowercase. You can see in Mage_Adminhtml_Block_Permissions_Tab_Rolesedit that strtolower() is used on the identifier when it's determined if the item is checked:

if (array_key_exists(strtolower($itemResourceId), $resources)) {
    if ($item->isAllowed()) {
        $resources[$itemResourceId]['checked'] = true;
        array_push($selrids, $itemResourceId);
    }
}

I don't know why this is, especially since it seems to work otherwise, but if you change the keys in adminhtml.xml from MyModule to mymodule it should work.

0

I tested this error on two Systems when i posted it here, but it seems to be there was an error in our setup of magento, i dont know where exactly, but when i tried it on a third magento setup it worked as it should.

So i assume there was nothing wrong with the module, but with the way i installed magento CE 1.9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.