views:

7

answers:

0

Originally, I would run terminal commands to generate my ACL table data. However, this became tedious so I now use the below code to automatically generate my ACOS, AROS, and AROS_ACOS tables:

http://book.cakephp.org/view/647/An-Automated-tool-for-creating-ACOs

I also created these two functions to help populate those tables:

function buildaro() {
  $aro =& $this->Acl->Aro;
  $aro = new Aro();

  $groups = array(
      1 => array(
       'alias' => 'Admin',
             'model' => 'Group',
             'foreign_key' => 1),
      2 => array(
       'alias' => 'User',
             'model' => 'Group',
             'foreign_key' => 2),
      3 => array(
       'alias' => 'Vendor',
             'model' => 'Group',
             'foreign_key' => 3),
      4 => array(
       'alias' => 'Manufacturer',
             'model' => 'Group',
             'foreign_key' => 4)
  );
  foreach($groups as $group)
  {
      $aro->create();
      $aro->save($group);
  }

  $users = $this->User->find('all');
        foreach($users as $user) {
            $aro->create();
            $user = array(//'alias' => $user['User']['username'],
               'parent_id' => $user['User']['group_id'],
               'model' => 'User',
               'foreign_key' => $user['User']['id']);       
            $aro->save($user);
        }
 }

 function buildpermissions() {
  $this->Acl->allow('Admin', 'controllers');
  $this->Acl->allow('User', 'controllers');
  $this->Acl->allow('Vendor', 'controllers');
  $this->Acl->allow('Manufacturer', 'controllers');
 }

However, ever since I did this, the $this->Auth->allow() and $this->Auth->allowedactions() defined in my controllers no longer work. Every page on the site now requires login to access even if it's defined as an allowed action. I can't seem to figure out why. Any help would me be much appreciated, thanks!

related questions