1

we have mageworx files download which can be accessed by only adminstrator role and when we create new roles and assign the resource to the role it does not work, the problem is that the _isAllowed does not exist in the controller:

here is the controller and I added the isAllowed inside, I do not want to return true because if I do so, still someone that don't have access can access the module:

class MageWorx_Adminhtml_Adminhtml_Mageworx_FilesController extends Mage_Adminhtml_Controller_Action
{
       protected function _isAllowed() {
        return Mage::getSingleton('admin/session')->isAllowed('cms/downloads/files/mageworx_files'); 
    }
}

here is the part of config.xml that is related to the module:

<adminhtml>
    <menu>
        <cms>
            <children>
                <downloads translate="title" module="downloads">
                    <title>File Downloads</title>
                    <depends>
                        <config>mageworx_cms/downloads/enabled</config>
                    </depends>
                    <children>
                        <files translate="title" module="downloads">
                            <title>Manage Files</title>
                            <sort_order>0</sort_order>
                            <action>adminhtml/mageworx_files/</action>
                        </files>
                        <categories translate="title" module="downloads">
                            <title>Manage Categories</title>
                            <sort_order>1</sort_order>
                            <action>adminhtml/mageworx_categories/</action>
                        </categories>
                        <configuration translate="title" module="downloads">
                            <title>Configuration</title>
                            <sort_order>2</sort_order>
                            <action>adminhtml/system_config/edit/section/mageworx_cms/</action>
                        </configuration>
                    </children>
                </downloads>
            </children>
        </cms>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <mageworx_cms translate="title" module="downloads">
                                        <title>MageWorx &gt; CMS</title>
                                        <sort_order>1</sort_order>
                                        <children>
                                            <downloads translate="title" module="downloads">
                                                <title><![CDATA[File Downloads & Product Attachments]]></title>
                                            </downloads>
                                        </children>
                                    </mageworx_cms>
                                </children>
                            </config>
                        </children>
                    </system>
                    <cms>
                        <children>
                            <downloads translate="title" module="downloads">
                                <title>File Downloads</title>
                                <sort_order>100</sort_order>
                                <children>
                                    <files translate="title">
                                        <title>Manage Files</title>
                                        <sort_order>0</sort_order>
                                    </files>
                                    <categories translate="title">
                                        <title>Manage Categories</title>
                                        <sort_order>1</sort_order>
                                    </categories>
                                    <configuration translate="title">
                                        <title>Configuration</title>
                                        <sort_order>2</sort_order>
                                    </configuration>
                                </children>
                            </downloads>
                        </children>
                    </cms>
                </children>
            </admin>
        </resources>
    </acl>
    <layout>
        <updates>
            <downloads>
                <file>downloads.xml</file>
            </downloads>
        </updates>
    </layout>
    <events>
        <catalog_product_save_after>
            <observers>
                <downloads>
                    <type>singleton</type>
                    <class>MageWorx_Downloads_Model_Observer</class>
                    <method>saveProductFiles</method>
                </downloads>
            </observers>
        </catalog_product_save_after>
    </events>
</adminhtml>

I don't know why my isAllowed function is wrong, how can I correct it? and here is the part of url that we can see the module:

index.php/admin/mageworx_files/index/key/xxxxx

2 Answers 2

0

I fixed it and I am not sure why? but it should be this:

protected function _isAllowed() {
  return Mage::getSingleton('admin/session')->isAllowed('cms/downloads/files'); 
    }

let me know if anybody can help me to understand why this one works and cms/downloads/files/mageworx_files does not work!

0

mageworx_files is your action your acl is up yo files so change your isAllowed method like belo

class MageWorx_Adminhtml_Adminhtml_Mageworx_FilesController extends Mage_Adminhtml_Controller_Action
{
   protected function _isAllowed() {
    return Mage::getSingleton('admin/session')->isAllowed('cms/downloads/files');  //this should be till your last acl children node 
   }
}
4
  • thank you I still don't get why cms/downloads/files what are these three and what is the format to have for this to work?
    – Nickool
    Commented Sep 23, 2016 at 15:42
  • for outer menu you give name is cms under that you give name node to downloads and for your controller you give name to node files . in your adminhtml acl Commented Sep 23, 2016 at 16:30
  • I know that we do it from config.xml and we write children I want to know why.
    – Nickool
    Commented Sep 23, 2016 at 16:45
  • I explained it here: magento.stackexchange.com/questions/45141/… hope it helps Commented Sep 23, 2016 at 20:25

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.