コード例 #1
0
ファイル: user.php プロジェクト: redcapeman/kinspire
 function afterSave($created)
 {
     if ($created) {
         // its a creation
         $id = $this->getLastInsertID();
         $aro = new Aro();
         $aro->updateAll(array('alias' => '\'User:'******'\''), array('Aro.model' => 'User', 'Aro.foreign_key' => $id));
     } else {
         // its an edit, we have to update the tree
         $data = $this->read();
         $parent_id = $data['User']['group_id'];
         $aro = new Aro();
         $aro_record = $aro->findByAlias($this->name . ':' . $this->id);
         $parent_record = $aro->findByAlias('Group:' . $parent_id);
         if (!empty($aro_record)) {
             $parent_id = '0';
             if (!empty($parent_record)) {
                 $parent_id = $parent_record['Aro']['id'];
             }
             // just changing parents
             $this->Aro->save(array('parent_id' => $parent_id, 'id' => $aro_record['Aro']['id']));
         }
     }
     return true;
 }
コード例 #2
0
 function edit($id = null)
 {
     $this->set("modul", "page");
     $back['title'] = 'Back to Group List';
     $back['url'] = '/groups/index';
     $this->set("back", $back);
     if (!$id && empty($this->data)) {
         $this->Session->setFlash(__('Invalid Group', true));
         $this->redirect(array('action' => 'index'));
     }
     if (!empty($this->data)) {
         if ($this->Group->save($this->data)) {
             $aro = new Aro();
             $group = $aro->find(array("model" => "Group", "foreign_key" => $this->data['Group']['id']));
             $group['Aro']['alias'] = $this->data['Group']['name'];
             $aro->save($group);
             $this->Session->setFlash(__('The Group has been saved', true));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The Group could not be saved. Please, try again.', true));
         }
     }
     if (empty($this->data)) {
         $this->data = $this->Group->read(null, $id);
     }
 }
コード例 #3
0
ファイル: user.php プロジェクト: ni-c/simpleve
 function beforeDelete()
 {
     $aro = new Aro();
     $aro_data = $aro->findByForeignKeyAndModel($this->id, 'User');
     $aro->delete($aro_data['Aro']['id']);
     return true;
 }
コード例 #4
0
 function enable($id = null)
 {
     if (empty($this->data)) {
         $this->data = $this->User->read(null, $id);
     } else {
         if ($this->User->save($this->data)) {
             $user = $this->User->read(null, $this->data['User']['id']);
             $aro_user = $user['User']['USERNAME'];
             $aro_group = null;
             $parent_id = 0;
             if ($user['User']['TYPE'] === 'MAHASISWA') {
                 $aro_group = 'Mahasiswa';
                 $parent_id = 1;
             } else {
                 if ($user['User']['TYPE'] === 'DOSEN') {
                     $aro_group = 'Dosen';
                     $parent_id = 2;
                 } else {
                     $aro_group = 'Pegawai';
                     $parent_id = 3;
                 }
             }
             $aro = new Aro();
             $aro->create();
             if (!$aro->node("{$aro_group}/{$aro_user}")) {
                 $aro->save(array('alias' => $aro_user, 'parent_id' => $parent_id, 'model' => 'User', 'foreign_key' => $user['User']['id']));
             }
             $this->Session->setFlash(__('The User has been Actived', true));
             $this->redirect(array('action' => 'index'));
         }
     }
 }
コード例 #5
0
 function activateAccount()
 {
     $this->autoLayout = false;
     $this->autoRender = false;
     if (empty($this->params['url']['key'])) {
         $this->redirect(array('controller' => 'home', 'action' => 'index'), null, true);
     }
     $key = $this->params['url']['key'];
     $data = $this->Pending->findByKey($key);
     if ($data) {
         $uid = $data['Pending']['user_id'];
         $user = $this->User->findById($uid);
         if ($user) {
             $user['User']['pending'] = 'no';
             $user['User']['secret'] = $this->User->mksecret();
             $user['User']['passkey'] = sha1($user['User']['username'] . mktime() . $user['User']['username']);
             $user['User']['group_id'] = 3;
             $this->User->save($user);
             $this->Pending->remove($data['Pending']['id']);
             $aro = new Aro();
             $arodata = $aro->findByForeign_key($uid);
             $newgroup = $aro->find('model LIKE "Group" AND foreign_key = 3');
             $arodata['Aro']['parent_id'] = $newgroup['Aro']['id'];
             $aro->save($arodata);
             $this->ZTAuth->fields = array('username' => 'username', 'password' => 'sha_hash');
             if ($this->ZTAuth->login($user['User'])) {
                 $this->redirect(array('controller' => 'home', 'action' => 'index'), null, true);
             }
         }
     }
 }
コード例 #6
0
ファイル: users.php プロジェクト: phpcurious/cakecms
 function afterSave($created = null)
 {
     if ($created) {
         $users_id = $this->getLastInsertId();
         $aro = new Aro();
         $aro->updateAll(array('alias' => "'" . $this->data['Users']['username'] . "'"), array('Aro.model' => 'Users', 'Aro.foreign_key' => $users_id));
     }
 }
コード例 #7
0
 function add()
 {
     if (!empty($this->data)) {
         $this->User->create();
         if ($this->User->save($this->data)) {
             # add an ACL entry.
             $aro = new Aro();
             $arodata = array('alias' => $this->data['User']['name'], 'parent_id' => 2, 'model' => 'User', 'foreign_key' => $this->User->getLastInsertId());
             $aro->save($arodata);
             $this->Session->setFlash(__('The user has been saved', true));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The user could not be saved. Please, try again.', true));
         }
     }
 }
コード例 #8
0
ファイル: aros_controller.php プロジェクト: jcalado/planetuga
 function create_users()
 {
     $aro = new Aro();
     //Here are our user records, ready to be linked up to new ARO records
     //This data could come from a model and modified, but we're using static
     //arrays here for demonstration purposes.
     $users = array(0 => array('parent_id' => 1, 'model' => 'User', 'foreign_key' => 1), 1 => array('parent_id' => 1, 'model' => 'User', 'foreign_key' => 2), 2 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 3), 3 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 4), 4 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 5), 5 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 6), 6 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 7), 7 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 8), 8 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 9), 9 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 10), 10 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 11), 11 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 12), 12 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 13), 13 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 14), 14 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 15), 15 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 16), 16 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 17), 17 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 18), 18 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 19), 19 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 20), 20 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 21), 21 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 22), 22 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 23), 23 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 24), 24 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 25), 25 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 26), 26 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 27), 27 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 28), 28 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 29), 29 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 30), 30 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 31), 31 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 32), 32 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 33), 33 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 34), 34 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 35), 35 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 36), 36 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 37), 37 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 38), 38 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 39), 39 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 40), 40 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 41), 41 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 42), 42 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 43), 43 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 44), 44 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 45), 45 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 46), 46 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 47), 47 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 48), 48 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 49), 49 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 50), 50 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 51), 51 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 52), 52 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 53), 53 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 54), 54 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 55), 55 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 56), 56 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 57), 57 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 58), 58 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 59), 59 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 60), 60 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 61), 61 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 62), 62 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 63), 63 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 64), 64 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 65), 65 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 66), 66 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 67), 67 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 68), 68 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 69), 69 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 70), 70 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 71), 71 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 72), 72 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 73), 73 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 74), 74 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 75), 75 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 76), 76 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 77), 77 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 78), 78 => array('parent_id' => 2, 'model' => 'User', 'foreign_key' => 79), 79 => array('parent_id' => 3, 'model' => 'User', 'foreign_key' => 80));
     //Iterate and create AROs (as children)
     foreach ($users as $data) {
         //Remember to call create() when saving in loops...
         $aro->create();
         //Save data
         $aro->save($data);
     }
     //Other action logic goes here...
 }
コード例 #9
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']))));
 }
コード例 #10
0
ファイル: users_controller.php プロジェクト: napo/taolintools
 function admin_activate($uid, $active = 1)
 {
     Configure::write('debug', '0');
     //turn debugging off; debugging breaks ajax
     $aro = new Aro();
     //find the id of this user's aco
     $aro->create();
     $user_aro = $aro->find('first', array('conditions' => array('model' => 'User', 'foreign_key' => $uid), 'fields' => array('id')));
     $new_aro = array('model' => 'User', 'foreign_key' => $uid);
     if ($user_aro) {
         $new_aro['id'] = $user_aro['Aro']['id'];
     }
     if ($active) {
         // add this user to the users Aro group
         // find the id of the users group
         $aro->create();
         $users_aro = $aro->findByAlias('users');
         $users_aro_id = $users_aro['Aro']['id'];
         $new_aro['parent_id'] = $users_aro_id;
     } else {
         $new_aro['parent_id'] = NULL;
     }
     $aro->save($new_aro);
     $user['id'] = $uid;
     $user['active'] = $active;
     $this->User->save($user);
 }
コード例 #11
0
ファイル: group.php プロジェクト: redcapeman/kinspire
 function afterSave($created)
 {
     if ($created) {
         // its a creation
         $id = $this->getLastInsertID();
         $aro = new Aro();
         $aro->updateAll(array('alias' => '\'Group:' . $id . '\''), array('Aro.model' => 'Group', 'Aro.foreign_key' => $id));
     } else {
         // its an edit, we have to update the tree
         $data = $this->read();
         $parent_id = $data['Group']['parent_id'];
         $aro = new Aro();
         $aro_record = $aro->findByForeignKey($this->id);
         $parent_record = $aro->findByForeignKey($parent_id);
         if (empty($aro_record)) {
             // orphaned child
             $this->Aro->save(array('model' => $this->name, 'foreign_key' => $this->id, 'alias' => $this->name . ':' . $this->id, 'parent_id' => $parent_record['Aro']['id']));
         } else {
             // just moving nodes
             $this->Aro->save(array('model' => $this->name, 'foreign_key' => $this->id, 'alias' => $this->name . ':' . $this->id, 'parent_id' => $parent_record['Aro']['id'], 'id' => $aro_record['Aro']['id']));
         }
     }
     return true;
 }
コード例 #12
0
ファイル: GroupsController.php プロジェクト: dfventura/Kakau
 /**
  * Members_delete method
  * Freitas - 2014-11-16
  */
 public function members_delete($id = null)
 {
     if ($this->request->is('post')) {
         //Exclusão do aro.
         $aro = new Aro();
         $aro->create();
         $aro_options = array('id' => $this->request->data['Group']['aro_id']);
         if ($aro->delete($aro_options)) {
             $this->Session->setFlash(__('Membro excluido com sucesso!'), 'alert_success');
             return $this->redirect(array('action' => 'view', $id));
         } else {
             $this->Session->setFlash(__('Membro não pode ser excluido, tente novamete!'), 'alert_error');
         }
     }
 }
コード例 #13
0
ファイル: db_acl.php プロジェクト: carriercomm/pastebin-5
 /**
  * Get an array of access-control links between the given Aro and Aco
  *
  * @param mixed $aro
  * @param mixed $aco
  * @return array
  * @access public
  */
 function getAclLink($aro, $aco)
 {
     $Aro = new Aro();
     $Aco = new Aco();
     $Link = new ArosAco();
     $obj = array();
     $obj['Aro'] = $Aro->find($Aro->_resolveID($aro));
     $obj['Aco'] = $Aco->find($Aco->_resolveID($aco));
     $obj['Aro'] = $obj['Aro']['Aro'];
     $obj['Aco'] = $obj['Aco']['Aco'];
     if ($obj['Aro'] == null || count($obj['Aro']) == 0 || $obj['Aco'] == null || count($obj['Aco']) == 0) {
         return false;
     }
     return array('aro' => $obj['Aro']['id'], 'aco' => $obj['Aco']['id'], 'link' => $Link->findAll(array('ArosAco.aro_id' => $obj['Aro']['id'], 'ArosAco.aco_id' => $obj['Aco']['id'])));
 }
コード例 #14
0
 function register()
 {
     if ($this->data) {
         if ($this->data['User']['password'] == $this->Auth->password($this->data['User']['confirm_password'])) {
             $this->User->create();
             $this->User->save($this->data);
             // Insert user into the AROS
             $aro = new Aro();
             //Here are our user records, ready to be linked up to new ARO records
             //This data could come from a model and modified, but we're using static
             //arrays here for demonstration purposes.
             $users = array(0 => array('parent_id' => 3, 'model' => 'User', 'foreign_key' => $this->User->id));
             //Iterate and create AROs (as children)
             foreach ($users as $data) {
                 //Remember to call create() when saving in loops...
                 $aro->create();
                 //Save data
                 $aro->save($data);
             }
             //Other action logic goes here...
         }
     }
 }
コード例 #15
0
 /**
  * Test Node()
  *
  * @return void
  */
 public function testNode()
 {
     $Person = new AclPerson();
     $aroData = array('Aro' => array('model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => NULL));
     $this->Aro->save($aroData);
     $Person->id = 2;
     $result = $Person->node(NULL, 'Aro');
     $this->assertTrue(is_array($result));
     $this->assertEquals(1, count($result));
 }
コード例 #16
0
 /**
  * modify 
  * 
  * @access public
  * @return void
  */
 function modify()
 {
     Configure::write('debug', '0');
     $this->layout = 'ajax';
     if ($this->Acl->check($this->ZTAuth->user('username'), "Users::edit", '*')) {
         if ($this->User->save($this->data['User'])) {
             $aro = new Aro();
             $arodata = $aro->findByForeign_Key($this->data['User']['id']);
             // try to find group ARO
             $newgroup = $aro->find('model LIKE "Group" AND foreign_key =' . $this->data['User']['group_id']);
             if (empty($newgroup)) {
                 $this->set('result', '{success:false, msg:"Group ARO not found"}');
                 return;
             }
             // update ARO fields
             $arodata['Aro']['model'] = 'User';
             $arodata['Aro']['alias'] = $this->data['User']['username'];
             $arodata['Aro']['foreign_key'] = $this->data['User']['id'];
             $arodata['Aro']['parent_id'] = $newgroup['Aro']['id'];
             // create new ARO for user if it's not already exists
             if (empty($arodata['Aro']['id'])) {
                 $aro->create();
             }
             $aro->save($arodata);
             $this->set('result', '{success:true}');
         } else {
             $this->set('result', '{success:false}');
         }
     } else {
         $this->set('result', '{success:false, msg:"You can not do that"}');
     }
 }
コード例 #17
0
ファイル: users_controller.php プロジェクト: vad/taolin
 function admin_create_basic_acl()
 {
     Configure::write('debug', '2');
     //turn debugging off; debugging breaks ajax
     die('not now!');
     $aco = new Aco();
     $aro = new Aro();
     /*
     $aro->create();
     $aro->save(array('alias' => 'users'));
     $aro->create();
     $aro->save(array('alias' => 'admins', 'parent_id' => 1));
     
     $aco->create();
     $aco->save(array('alias' => 'admin'));
     $aco->create();
     $aco->save(array('alias' => 'site', 'parent_id' => 1));
     */
     //$this->Acl->grant(array('alias' => 'users'), array('alias' => 'site'));
     $rr = $aro->findByAlias('users');
     $rc = $aco->findByAlias('site');
     print_r($rr);
     $this->Acl->grant(array('Aro' => array('alias' => 'users')), array('Aco' => array('alias' => 'site')), '*');
     //$this->Acl->grant(2, 1);
     //$this->Acl->grant(array('alias' => 'admins'), array('alias' => 'admin'));
     $this->set('json', 'a');
 }
コード例 #18
0
 function assignPermissions1Dot7Dot1()
 {
     App::import('Component', 'Acl');
     $this->Acl = new AclComponent();
     // Usuarios
     $this->Acl->allow('usuarios', 'Planes/ajax_similars');
     // crear rol Ministros
     $aro = new Aro();
     $aro->create();
     $aro->save(array('alias' => 'ministros', 'parent_id' => '1'));
     $this->Acl->allow('ministros', 'Fondos/index_x_instit');
     $this->Acl->allow('ministros', 'Fondos/index_x_jurisdiccion');
     echo 'done 1.7.1';
 }
コード例 #19
0
 function beforeFilter()
 {
     $this->Auth->loginRedirect = '/';
     // for the authorizations
     $this->Auth->authorize = 'actions';
     $this->Auth->actionPath = 'controllers/';
     // if the user is not logged and it requests the root '/' url
     // redirects to '/login'
     if (!$this->Session->read('Auth.User.id')) {
         if ($this->params['url']['url'] == '/') {
             $this->redirect('/login');
         }
     }
     App::import('Model', 'User');
     if ($this->Session->read('Auth.User.id')) {
         if ($this->params['url']['url'] == '/') {
             $user = new User();
             $user = $user->read(null, $this->Session->read('Auth.User.id'));
             $this->redirect($user['UserGroup']['home_url']);
         }
     }
     if ($this->layout == 'default' && $this->Session->read('Auth.User.id')) {
         // creating an array with all the permissions for this user
         // and in the view we check if it has permissions to show the link
         // getting all the acos with permissions
         App::import('Model', 'Aco');
         App::import('Model', 'Aro');
         App::import('Model', 'ArosAco');
         $aco = new Aco();
         $aro = new Aro();
         $aros_aco = new ArosAco();
         $acos = $aco->find('threaded', array('recursive' => 0));
         // consulta el id del aro
         $aro_row = $aro->find('first', array('conditions' => array('model' => 'UserGroup', 'foreign_key' => $this->Session->read('Auth.User.user_group_id'))));
         // consulta la relacion de aros_acos
         $aros_acos = $aros_aco->find('all', array('conditions' => array('aro_id' => $aro_row['Aro']['id'])));
         $this->set('acl_lists', $this->AclGetList->get($this->Session->read('Auth.User.user_group_id'), $acos, $aros_acos));
     }
     // rendering the menu for "default" layout
     // checking if there is a logged user
     if ($this->layout == 'default' && $this->Session->read('Auth.User.id')) {
         // renders the menu according the user group
         App::import('Model', 'Menu');
         $menu = new Menu();
         $this->set('layout_menus', $menu->find_for_show($this->Session->read('Auth.User.user_group_id')));
         // selecting the current menu
         $this->set('layout_current', $this->params['url']['url']);
         //$route = Router::parse('/'.$this->params['url']['url']);
         //$aco_alias = 'controllers/'.$route['controller'].'/'.$route['action'];
         //$this->set('layout_acos', $this->Acl->Aco->node('controllers/'.$route['controller'].'/'.$route['action']));
         // asks the controller for selecting the correct link in the menu
         $cont = split('_', $this->params['controller']);
         $newcont = '';
         foreach ($cont as $c) {
             $newcont .= ucfirst($c);
         }
         $current_aco = $this->Acl->Aco->node('controllers/' . $newcont . '/' . $this->params['action']);
         $this->set('layout_aco_id', $current_aco[0]['Aco']['id']);
         //$route = Router::parse('/profile');
         //$this->set('menu_url', '/'.$this->params['controller'].'/'.$this->params['action']);
         if ($this->Session->read('Auth.User.type') == 'web') {
             $user = new User();
             $user->id = $this->Session->read('Auth.User.id');
             $user->updatecredit_expiration();
             $this->set('user_balance', $user->getBalance());
             $this->set('user_expirationdate', $user->getExpirationDate());
         }
     }
 }
コード例 #20
0
 function admin_addgroup($parentid = 0)
 {
     $aro = new Aro();
     if (empty($this->data)) {
         // allow addition of new group
     } else {
         $aro->create();
         if ($aro->save($this->data)) {
             $this->Session->setFlash(__('The new group has been saved.', true));
             $this->redirect(array('controller' => 'users', 'action' => 'groups'));
         } else {
             $this->Session->setFlash(__('There was an error creating the new group.', true));
         }
     }
     $this->set(compact('parentid'));
 }
コード例 #21
0
ファイル: members_controller.php プロジェクト: uwitec/eduoa
 function install()
 {
     $aro = new Aro();
     //创建组
     $aro->create(0, null, 'Admins');
     $aro->create(0, null, 'Finances');
     $aro->create(0, null, 'Members');
     $aro->create(0, null, 'Workstations');
     $aro->create(0, null, 'Merchants');
     //创建ARO(admin)
     $aro->create(1, null, 'admin');
     //把admin授权到Admins组
     $aro->setParent('Admins', 'admin');
     $this->Session->setFlash('系统授权成功!');
 }
コード例 #22
0
 /**
  * Groups_delete method
  * Freitas - 2014-11-20
  */
 public function groups_delete($userId = null, $aroId = null)
 {
     if ($this->request->is('post')) {
         //Exclusão do aro.
         $aro = new Aro();
         $aro->create();
         $aro_options = array('id' => $aroId);
         if ($aro->delete($aro_options)) {
             $this->Session->setFlash(__('Grupo excluido com sucesso!'), 'alert_success');
             return $this->redirect(array('action' => 'edit', $userId));
         } else {
             $this->Session->setFlash(__('Grupo não pode ser excluido, tente novamete!'), 'alert_error');
         }
     }
 }
コード例 #23
0
 /**
  * Test Node()
  *
  * @return void
  * @access public
  */
 function testNode()
 {
     $Person =& new AclPerson();
     $aroData = array('Aro' => array('model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => null));
     $this->Aro->save($aroData);
     $Person->id = 2;
     $result = $Person->node();
     $this->assertTrue(is_array($result));
     $this->assertEqual(count($result), 1);
 }
コード例 #24
0
 function initAcl()
 {
     $aro = new Aro();
     $groupsAll = array(0 => array('alias' => 'all'));
     //Iterate and create ARO groups
     foreach ($groupsAll as $data) {
         //Remember to call create() when saving in loops...
         $aro->create();
         //Save data
         $aro->save($data);
     }
     $aro = new Aro();
     //            $groups=$this->Group->find('all', array('conditions' => array('Group.id' != 1)));
     //            debug($groups);
     $aroList = array(0 => array('alias' => 'admin', 'parent_id' => 1), 1 => array('alias' => 'user', 'parent_id' => 1), 2 => array('alias' => 'anonymous', 'parent_id' => 1));
     //            $i=0;
     //            foreach($groups as $group){
     //                $aroList[$i++]=
     //                array(
     //                'alias' => $group['Group']['name'],
     //                'parent_id' => 1,
     //                );
     //            }
     //iterate through groups adding to aro table
     //            $groups = array(
     //            0 => array(
     //            'alias' => 'users'
     //            ),
     //            1 => array(
     //            'alias' => 'administrators'
     //            ),
     //            );
     //Iterate and create ARO groups
     foreach ($aroList as $data) {
         //Remember to call create() when saving in loops...
         $aro->create();
         //Save data
         $aro->save($data);
     }
     /*
      * next we add our existing add users to users group
      * ! adds all users to user group, you may add some logic to 
      * ! detemrine admins based on role, or edit manually later
      * 
      * the   **whos**
      */
     $aro = new Aro();
     //pull users form existing user table
     $users = $this->User->find('all');
     debug($users);
     $i = 0;
     foreach ($users as $user) {
         $id = $user['User']['id'];
         $groupId = $user['User']['group_id'];
         $aroList2[$i++] = array('alias' => $id, 'parent_id' => $groupId, 'model' => 'User', 'foreign_key' => $id);
     }
     //print to screen to verify layout
     debug($aroList2);
     //now save!
     foreach ($aroList2 as $data) {
         //Remember to call create() when saving in loops...
         $aro->create();
         //Save data
         $aro->save($data);
     }
     /*
      * now on to  *whats* can they access
      * 
      * for my layout I have the entire site as a parent, two sub groups that contain all models.
      * 
      */
     $aco = new Aco();
     //admin can access whole site
     $controllers = array(0 => array('alias' => 'vsetko'));
     //Iterate and create ARO groups
     foreach ($controllers as $data) {
         //Remember to call create() when saving in loops...
         $aco->create();
         //Save data
         $aco->save($data);
     }
     $aco = new Aco();
     //Here's all of our sub-ACO info in an array we can iterate through
     $controllers = array(0 => array('alias' => 'uploads', 'parent_id' => 1), 1 => array('alias' => 'posts', 'parent_id' => 1), 2 => array('alias' => 'galleries', 'parent_id' => 1), 3 => array('alias' => 'aclpreps', 'parent_id' => 1), 4 => array('alias' => 'p28n', 'parent_id' => 1), 5 => array('alias' => 'welcome', 'parent_id' => 1), 6 => array('alias' => 'about', 'parent_id' => 1), 7 => array('alias' => 'contact', 'parent_id' => 1), 8 => array('alias' => 'products', 'parent_id' => 1), 9 => array('alias' => 'products_form', 'parent_id' => 1));
     //Iterate and create ACO nodes
     foreach ($controllers as $data) {
         //Remember to call create() when saving in loops...
         $aco->create();
         //Save data
         $aco->save($data);
     }
     die;
     exit;
     $this->redirect(array('controller' => 'aclpreps', 'action' => 'index'));
 }