Skip to content


Subversion checkout URL

You can clone with
Download ZIP
CakePHP plugin. Allows to display only the links that can be accessed with Acl
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

AclUtilities Plugin for CakePHP

AclUtilities permits to translarently display or hide links in view according to Acl rules.


  • in the views, replace $this->Html->link() by $this->Acl->link()


<?php echo $this->Html->link(__('List Posts', true), array('action' => 'index')); ?>

<?php echo $this->Html->link(__('Edit User', true), array('controller'=>'User','action' => 'edit')); ?>

replaced by:

<?php echo $this->Acl->link(__('List Posts', true), array('action' => 'index')); ?>

<?php echo $this->Acl->link(__('Edit User', true), array('controller'=>'User','action' => 'edit')); ?>

Be sure to use an array format for the URL.

  • in the AppController, add the helper AclUtilities.Acl

    var $helpers = array(/*...,*/ 'AclUtilities.Acl');
  • If you are using Auth->allowedActions or Auth->allow()
    Then you have to move them all into AppController::beforeFilter() like the following:

    function beforeFilter() { //[...] // $allowedActions = array([Controller]=>array([action1],[action2]); Configure::write('AclUtilities.allowedActions', $allowedActions = array( 'News' => array('*'), // access to all the actions 'Groups' => array(), // no access to groups 'Pages' => array('display'), 'Posts' => array('index', 'view'), 'Users' => array('login','register'), ));

      // now, we need to allow the action for the current module
      if (isset($allowedActions[$this->name]))


And this is it; your links are now only displayed when they can be accessed!

More Examples

  • use of the option wrapper:

    • <?php echo $this->Html->link(__('List Posts', true), array('action' => 'index')); ?>
        • <?php echo $this->Acl->link(__('List Posts', true) ,array('action' => 'index') ,array('wrapper'=>'li'); ?>

          • another use of the wrapper

            Html->link(__('List Posts', true), array('action' => 'index')); ?>

            <?php echo $this->Acl->link(__('List Posts', true) ,array('action' => 'index') ,array('wrapper'=>'

            '); ?>

          • use of $this->Acl->check()

            Acl->check(array('action' => 'index'))): ?>
            Html->link(__('List Posts', true), array('action' => 'index')); ?>
              <?php endif; ?>

          • use of blocks (only display a block if a link is successful):

            Acl->startBlock() ?>
            Acl->link(__('List Posts', true), array('action' => 'index')); ?>
            Acl->endBlock() ?>

          Use a different Model

          In AppController::beforeFilter() add this:

Something went wrong with that request. Please try again.