コード例 #1
0
ファイル: Cli.php プロジェクト: ericariyanto/angularjs-ci3
 public function add($type, $email, $password)
 {
     if (!$this->input->is_cli_request()) {
         return;
     }
     if ($type == 'user') {
         $this->Users->register($email, $password);
         if (!defined('PHPUNIT_TEST')) {
             echo "user added\r\n";
         }
     } else {
         if ($type == 'administrator') {
             $id = $this->Users->register($email, $password);
             $acl = new ACL();
             $acl->addUserRoles($id, 'administrator');
             if (!defined('PHPUNIT_TEST')) {
                 echo "administrator added\r\n";
             }
         }
     }
 }
コード例 #2
0
ファイル: Users.php プロジェクト: ericariyanto/angularjs-ci3
 public function update($user)
 {
     $this->db->select('*');
     $this->db->from('users');
     $this->db->where('id', $user->id);
     $this->db->limit(1);
     $query = $this->db->get();
     if ($query->num_rows() == 1) {
         $acl = new ACL();
         $roles = $acl->userRoles($user->id);
         if ($user->roles != $roles) {
             $acl->removeUserRoles($user->id, $roles);
             $acl->addUserRoles($user->id, $user->roles);
         }
         $this->db->where('id', $user->id);
         $this->db->update('users', $user);
         $user = $this->read($user->id);
     }
     return $user;
 }