Exemplo n.º 1
0
 function permissions($id)
 {
     // primero actualiza los permisos
     $this->update_acos();
     // importando las clases
     App::import('Model', 'UserGroup');
     App::import('Model', 'Aro');
     App::import('Model', 'ArosAco');
     // consulta todos los acos
     $aco = new Aco();
     $this->set('acos', $aco->find('threaded', array('recursive' => 0)));
     // consulta el id del aro
     $aro = new Aro();
     $aro_row = $aro->find('first', array('conditions' => array('model' => 'UserGroup', 'foreign_key' => $id)));
     $this->UserGroup = new UserGroup();
     $this->set('userGroup', $this->UserGroup->read(null, $id));
     $this->set('aro_foreignkey', $id);
     if (!empty($this->data)) {
         // guarda los permisos
         $group =& $this->UserGroup;
         $group->id = $id;
         $aro_aco_del = new ArosAco();
         foreach ($this->data['Acos'] as $aco_id => $mode) {
             switch ($mode['option']) {
                 case 1:
                     // allow
                     $this->Acl->allow($group, $mode['url']);
                     break;
                 case 2:
                     // deny
                     $this->Acl->deny($group, $mode['url']);
                     break;
                 default:
                     // lo borra
                     $aro_aco_del->deleteAll(array('aro_id' => $aro_row['Aro']['id'], 'aco_id' => $aco_id));
                     break;
             }
         }
         $this->Session->setFlash(__('UserGroup permissions changed successfully', true));
         $this->redirect(array('action' => 'index'));
     }
     // consulta la relacion de aros_acos
     $aros_aco = new ArosAco();
     $this->set('aros_acos', $aros_aco->find('all', array('conditions' => array('aro_id' => $aro_row['Aro']['id']))));
 }