02.27 php saved
aranworld
Tags add more
ACL, Component, action and auth  
Note
This modification to the Auth::action() function allows you to use the Acl component to control access to urls including the id value. Without this modification, the Auth component ignores the id parameter in the URL.
  1. /**
  2. * modified cake/libs/controller/components/auth.php
  3. *
  4. * enables Auth to check for id in URL, so that you can
  5. * assign permissions to aco elements that are identified by
  6. * an id value.
  7. */
  8.  
  9. function action($action = ':controller/:action') {
  10.     $actionModifier = null;
  11.     if( isset($this->params['named']['id'] ) ){
  12.     $actionModifier = '/'.$this->params['named']['id'];
  13.     } elseif ( isset( $this->params['pass'][0] ) && is_numeric($this->params['pass'][0]) ){
  14.         // assume that an argument which is numeric and in first position is an id
  15.     $actionModifier = '/'.$this->params['pass'][0];
  16.     }
  17.     return str_replace( array(':controller', :action'),
  18.         array(Inflector::camelize($this->params['controller']),
  19.         $this->params['action']),
  20.         $this->actionPath . $action . $actionModifier
  21.     );
  22. }
Parsed in 0.047 seconds, using GeSHi 1.0.7.14

Modify this Paste