コード例 #1
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);
     }
 }
コード例 #2
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);
             }
         }
     }
 }
コード例 #3
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);
 }
コード例 #4
0
ファイル: user.php プロジェクト: ni-c/simpleve
 function afterSave($created)
 {
     $aro = new Aro();
     if ($created) {
         // on insert
         $aro_data = array('alias' => $this->data['User']['username'], 'parent_id' => $this->data['User']['group_id'], 'model' => 'User', 'foreign_key' => $this->getLastInsertId());
         $aro->create();
         $aro->save($aro_data);
     } else {
         // on update
         $aro_data = $aro->findByForeignKeyAndModel($this->id, 'User');
         $aro_data['Aro']['parent_id'] = $this->data['User']['group_id'];
         $aro->id = $aro_data['Aro']['id'];
         $aro->save($aro_data);
     }
 }
コード例 #5
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'));
         }
     }
 }
コード例 #6
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));
         }
     }
 }
コード例 #7
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...
 }
コード例 #8
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);
 }
コード例 #9
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"}');
     }
 }
コード例 #10
0
ファイル: GroupsController.php プロジェクト: dfventura/Kakau
 /**
  * Members_Add method
  * Freitas - 2014-11-11
  */
 public function members_add($id = null)
 {
     if ($this->request->is('post')) {
         //Obtenção do aroId do grupo selecionado.
         $aro = $this->Acl->Aro->find('first', array('conditions' => array('Aro.model' => 'Group', 'Aro.foreign_key' => $id)));
         $aroId = $aro['Aro']['id'];
         //debug($aro);
         //Inserção do aro.
         $aro = new Aro();
         $aro->create();
         $aro_options = array('model' => 'User', 'foreign_key' => $this->data['Group']['user_id'], 'parent_id' => $aroId, 'alias' => 'via members');
         if ($aro->save($aro_options)) {
             $this->Session->setFlash(__('Membro adicionado com sucesso!'), 'alert_success');
             return $this->redirect(array('action' => 'view', $id));
         } else {
             $this->Session->setFlash(__('Membro não pode ser adicionado, tente novamete!'), 'alert_error');
         }
     }
 }
コード例 #11
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...
         }
     }
 }
コード例 #12
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';
 }
コード例 #13
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'));
 }
コード例 #14
0
ファイル: users_controller.php プロジェクト: vad/taolin
 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;
         $this->User->addtotimeline(null, null, 'users-admin_activate', $uid);
     } else {
         $new_aro['parent_id'] = NULL;
     }
     $aro->save($new_aro);
     $user['id'] = $uid;
     $user['active'] = $active;
     $this->User->save($user);
     $referer = $this->params['url']['r'];
     if ($referer) {
         $this->Session->setFlash('User activation status changed.', 'admin_flash_message_success');
         $this->redirect($referer);
     }
 }
コード例 #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
 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'));
 }