コード例 #1
0
ファイル: CommonPage.php プロジェクト: LWFeng/hush
 public function personalAction()
 {
     $aclUserDao = $this->dao->load('Core_User');
     $userId = $this->admin['id'] ? $this->admin['id'] : 0;
     $user = $aclUserDao->read($this->admin['id']);
     // do post
     if ($_POST) {
         // validation
         if (!$userId) {
             $this->addError('common.notempty', 'User Id');
         }
         if (!Zend_Validate::is($this->param('name'), 'NotEmpty')) {
             $this->addError('common.notempty', 'User name');
         }
         if ($this->noError()) {
             $data['name'] = $this->param('name');
             if ($this->param('pass')) {
                 $data['pass'] = Hush_Util::md5($this->param('pass'));
             }
             // do update
             if ($userId) {
                 $aclUserDao->update($data, 'id=' . $userId);
                 $this->addErrorMsg('Personal Infomation updated successfully');
             }
         }
     }
     $this->view->user = $user;
 }
コード例 #2
0
ファイル: User.php プロジェクト: liningwang/camera-beijing
 /**
  * Login function
  * @uses Used by user login process
  * @param string $user
  * @param string $pass
  * @return bool or array
  */
 public function authenticate($user, $pass)
 {
     $sql = $this->select()->from($this->t1, "*")->where("name = ?", $user);
     $user = $this->dbr()->fetchRow($sql);
     if (!$user['id'] || !$user['pass']) {
         return false;
     }
     if (strcmp($user['pass'], Hush_Util::md5($pass))) {
         return $user['id'];
     }
     $sql = $this->select()->from($this->t2, "*")->join($this->rsh, "{$this->t2}.id = {$this->rsh}.role_id", null)->where("{$this->rsh}.user_id = ?", $user['id']);
     $roles = $this->dbr()->fetchAll($sql);
     if (!sizeof($roles)) {
         return false;
     }
     foreach ($roles as $role) {
         $user['role'][] = $role['id'];
         $user['priv'][] = $role['alias'];
     }
     return $user;
 }
コード例 #3
0
ファイル: AclPage.php プロジェクト: liningwang/camera-beijing
 public function userEditAction()
 {
     $aclUserDao = $this->dao->load('Core_User');
     $user = $aclUserDao->read($this->param('id'));
     // do post
     if ($_POST) {
         // merged roles
         $roles = $this->mergeRoles($this->param('roles_'), $this->param('roles'));
         // validation
         if (!Zend_Validate::is($this->param('name'), 'NotEmpty')) {
             $this->addError('common.notempty', 'User name');
         }
         if (!$roles) {
             $this->addError('common.notempty', 'Role list');
         }
         if ($this->noError()) {
             // prepare data
             $data['name'] = $this->param('name');
             if ($this->param('pass')) {
                 $data['pass'] = Hush_Util::md5($this->param('pass'));
             }
             // do update
             if ($this->param('id')) {
                 $aclUserDao->update($data, 'id=' . $this->param('id'));
                 $aclUserDao->updateRoles($this->param('id'), $roles);
                 $this->forward('userList');
             }
         }
     }
     // default data
     $this->view->user = $user;
     // fill role select box
     $aclRoleDao = $this->dao->load('Core_Role');
     $this->view->allroles = $aclRoleDao->getAllPrivs($this->admin['role']);
     $this->view->selroles = $aclRoleDao->getRoleByUserId($this->param('id'), $this->getRoleIds($this->view->allroles));
     $this->view->oldroles = $this->buildRoles($this->filterOldRoles($this->view->selroles));
     $this->render('acl/user/edit.tpl');
 }