Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. cakephp ACL permissions inside loops
  2. foreach($users as $user)
  3. {
  4.     // check if user has permission to execute action
  5.     $is_allowed = $this->Acl->check(
  6.             array('model'=>'User', 'foreign_key'=>$the_user_id),
  7.                 'controllers/MyController/action_to_be_executed');
  8.  
  9.     if(!$is_allowed)
  10.     {
  11.         // give permission to user
  12.         $this->Acl->allow(
  13.             array('model'=>'User', 'foreign_key'=>$the_user_id),
  14.                 'controllers/MyController/action_to_be_executed');
  15.     }
  16. }
  17.        
  18. $this->Auth->allow('action_to_be_executed');