How to use Zend Acl in zend framework 1.12.

Discussion in 'PHP' started by UniqueGeek, Nov 14, 2013.

  1. #1
    How do I use the Zend ACL to allow access to certain users to some of the actions within a controller? Right now, I only know how to allow a user to access the whole controller, but I want to limit the actions within the controller!

    How to allow/deny the permission of user in indexcontroller. Please help ?
     
    UniqueGeek, Nov 14, 2013 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    You would just add the actions as resources and deny/allow them to the roles.

    If you can post your current logic, we can probably show you how.
     
    ThePHPMaster, Nov 14, 2013 IP
  3. UniqueGeek

    UniqueGeek Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    I created a custom plugin and placed it in
    myzend/library/My/Controller/Plugin/Acl.php where myzend is directory of my project.I am trying to initialize this custom plugin from application.ini using

    autoloaderNamespaces[] = "My_" resources.frontController.plugins.acl = "My_Controller_Plugin_Acl"

    and place this code in bootstrap
    protectedfunction _initAcl(){
    $frontController =Zend_Controller_Front::getInstance();
    $frontController->registerPlugin(newMy_Controller_Plugin_Acl());}



    I am getting error message

    Fatal error: Class 'My_Controller_Plugin_Acl' not found in E:\wamp\www\myZend\library\Zend\Application\Resource\Frontcontroller.php on line 117. Help me
     
    UniqueGeek, Nov 14, 2013 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #4
    Try changing autoloaderNamespaces to autoloadernamespaces and insure that your Acl.php class name is My_Controller_Plugin_Acl.

    If that doesn't work, try adding the namespace dynamically in your _initAcl:

    Zend_Loader_Autoloader::getInstance()->registerNamespace('My_');
     
    ThePHPMaster, Nov 15, 2013 IP