2

I have create a custom admin action for a custom admin controller and have allow to this action for acl.

But till now, ACL is not working

Controller:

<?php
class Amit_HelloAdmin_Adminhtml_HelloadminController extends 
Mage_Adminhtml_Controller_Action
{

 protected function _isAllowed()
    {

        $action = strtolower($this->getRequest()->getActionName());
        if($action == 'search') {
                 return Mage::getSingleton('admin/session')
                    ->isAllowed('helloadmin/manage/search');
        }
        return parent::_isAllowed();;
    }


    //put your code here
    public function indexAction(){

        $_gotoSection =$this->getRequest()->getParam('gotosection');
        $this->loadLayout();
        $this->_setActiveMenu($_gotoSection);
        //$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Promotions'), Mage::helper('adminhtml')->__('Promo'));
        $this->renderLayout();

    }


   public function searchAction()
    {


    } 
    public function helloAction(){

        echo "how";

    }

}

adminhtml.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <menu>
        <helloadmin translate="title" module="helloadmin">
            <title>Admin Theme</title>
            <sort_order>41</sort_order>
            <!-- action>adminhtml/helloadmin/</action -->
            <children>
                <manage translate="title" module="helloadmin">
                    <title>Manage theme</title>
                    <action>adminhtml/helloadmin/</action>
                    <sort_order>0</sort_order>
                </manage>
            </children>
         </helloadmin>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <helloadmin translate="title" module="helloadmin">
                        <title>Admin Theme</title>
                        <sort_order>40</sort_order>
                        <children>
                            <manage translate="title">
                                <title>Manage theme</title>
                                <sort_order>0</sort_order>
                            </manage>
                        </children>
                    </helloadmin>
                </children>
            </admin>
        </resources>
    </acl>
</config>

My Question: why searchAction url is not working as i have already add return

Mage::getSingleton('admin/session')
                        ->isAllowed('helloadmin/manage/search');

Please help me to shot out this thing?

  • 1
    Well your ACL entry does not match the ACL declared in your XML file. Pretty sure it should be helloadmin/manage instead of mysolutionadmintheming/manage/global – Raphael at Digital Pianism Sep 12 '16 at 8:19
  • lot of type mistake . Have modify it.. Now let me know why searchAction not working – Amit Bera Sep 12 '16 at 8:30
  • Same problem you don't have an ACL matching helloadmin/manage/search you need to replace it with helloadmin/manage – Raphael at Digital Pianism Sep 12 '16 at 8:31
  • that at adminhtml.xml, i added <helloadmin translate="title" module="helloadmin"> <title>Admin Theme</title> <sort_order>40</sort_order> <children> <manage translate="title"> <title>Manage theme</title> <sort_order>0</sort_order> </manage> <children> <search translate="title"> <title>Manage ddsw</title> <sort_order>0</sort_order> </search> </children> </children> </helloadmin> but not working – Amit Bera Sep 12 '16 at 8:35
  • Have you try to assign role in System->permission->role ? – Murtuza Zabuawala Sep 13 '16 at 5:24
1

Hello I am not able to find mysolutionadmintheming and globalin your acl

I think you should try with

Mage::getSingleton('admin/session')
                    ->isAllowed('helloadmin/manage');

please try and let me know

  • please check update question.. – Amit Bera Sep 12 '16 at 8:30
  • I am also not able to find search in your acl , and also instead of Mage::getSingleton try it with Mage::getModel – Murtuza Zabuawala Sep 12 '16 at 8:32
  • Have you assign the role for that user in system > permission – Murtuza Zabuawala Sep 12 '16 at 8:40
3

If you want to be able to use helloadmin/manage/search as an ACL entry you need to update your adminhtml.xml file, replace the following:

<acl>
    <resources>
        <admin>
            <children>
                <helloadmin translate="title" module="helloadmin">
                    <title>Admin Theme</title>
                    <sort_order>40</sort_order>
                    <children>
                        <manage translate="title">
                            <title>Manage theme</title>
                            <sort_order>0</sort_order>
                        </manage>
                    </children>
                </helloadmin>
            </children>
        </admin>
    </resources>
</acl>

With

<acl>
    <resources>
        <admin>
            <children>
                <helloadmin translate="title" module="helloadmin">
                    <title>Admin Theme</title>
                    <sort_order>40</sort_order>
                    <children>
                        <manage translate="title">
                            <title>Manage theme</title>
                            <sort_order>0</sort_order>
                            <children>
                                <search translate="title">
                                    <title>Search</title>
                                    <sort_order>1</sort_order>
                                </search>
                            </children>
                        </manage>
                    </children>
                </helloadmin>
            </children>
        </admin>
    </resources>
</acl>
  • got.your point... Rapheal, will try shortly – Amit Bera Sep 12 '16 at 8:45
  • sorry, i did not the result.. so bad luck for me – Amit Bera Sep 12 '16 at 10:40

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.