3

I need to be able to control my custom module's role permission and I can see I have to add acl in my XML.

I have tried to add it in config.xml and also made an adminhtml.xml in the same location.

Can you take a look and see where I have to add it?

UPDATE: I've tried the steps mentioned below, but no luck. I can't get it to work. Can someone help to solve the problem?

config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <Puk_EmailOrder>
      <version>0.1.1</version>
    </Puk_EmailOrder>
  </modules>
    <frontend>
        <routers>
            <routeurfrontend>
                <use>standard</use>
                <args>
                    <module>Puk_EmailOrder</module>
                    <frontName>emailorder</frontName>
                </args>
            </routeurfrontend> 
        </routers>
        <layout>
            <updates>
                <emailorder>
                    <file>emailorder.xml</file>
                </emailorder>
            </updates>
        </layout>
    </frontend>
  <global>
    <helpers>
      <emailorder>
        <class>Puk_EmailOrder_Helper</class>
      </emailorder>
    </helpers>
    <blocks>
      <emailorder>
        <class>Puk_EmailOrder_Block</class>
      </emailorder>
    </blocks>
    <models>
        <emailorder>
            <class>Puk_EmailOrder_Model</class>
            <resourceModel>emailorder_mysql4</resourceModel>
        </emailorder>
        <emailorder_mysql4>
            <class>Puk_EmailOrder_Model_Mysql4</class>
            <entities>
                <emailorder>
                    <table>emailorder</table>
                </emailorder>
            </entities>
        </emailorder_mysql4>
      </models> 
    <resources>
      <emailorder_setup>
        <setup>
          <module>Puk_EmailOrder</module>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </emailorder_setup>
      <emailorder_write>
        <connection>
          <use>core_write</use>
        </connection>
      </emailorder_write>
      <emailorder_read>
        <connection>
          <use>core_read</use>
        </connection>
      </emailorder_read>
    </resources>
  </global>
  <admin>
    <routers>
      <adminhtml>
        <args>
            <modules>
              <emailorder before="Mage_Adminhtml">Puk_EmailOrder_Adminhtml</emailorder>
            </modules>
        </args>
      </adminhtml>
    </routers>
  </admin>
  <adminhtml>
    <menu>
        <sales>
          <children>
              <order_items translate="title" >
                 <title>Email Order</title>
                 <sort_order>20</sort_order>
                 <action>adminhtml/order_items/index</action>
              </order_items>
          </children>         
        </sales>
      </menu>
  </adminhtml>
</config> 

adminhtml.xml:

<?xml version="1.0" encoding="UTF-8" ?>
    <config>
        <acl>
          <resources>
            <all>
              <title>Allow Everything</title>
            </all>
            <admin>
             <children>
                <customer translate="title" module="emailOrder">
                  <children>
                    <set_time translate="title">
                    <title>Email order</title>
                    </set_time>
                  </children>
                </customer>
              </children>
            </admin>
          </resources>
        </acl>
    <config>
3

Your "acl" tree does not match the "menu" tree.

You have to copy everything below menu to acl/resources/admin/children and remove the <action> nodes.

Example:

http://i.stack.imgur.com/9CiIQ.png

In your case, that means, adminhtml.xml should look like this:

<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <acl>
      <resources>
        <admin>
         <children>

           <sales>
             <children>
               <order_items translate="title" >
                 <title>Email Order</title>
                 <sort_order>20</sort_order>
               </order_items>
             </children>         
           </sales>

          </children>
        </admin>
      </resources>
    </acl>
</config>
  • Okay that makes sense! :) But i can still not add permissions. Where should this adminhtml.xml be? Mine is the same folder as config.xml – Patrick Knudsen Sep 14 '16 at 9:41
  • That's the right place. Don't forget to clean the cache, log out of the admin panel and log back in (the ACL is loaded on login only, see also: magento.stackexchange.com/questions/13924/…) – Fabian Schmengler Sep 14 '16 at 9:41
  • Still not apearing... What can the problem be? – Patrick Knudsen Sep 14 '16 at 9:45
  • No idea, this really should work. Are you sure, the module is loaded? Do you see the menu? – Fabian Schmengler Sep 14 '16 at 9:49
  • I can se the menu when i choose another userrole – Patrick Knudsen Sep 14 '16 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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