public function init()
    {
        //Yii::app()->setTheme('adm');
        $cs = Yii::app()->getClientScript();
        $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/global.js');
        $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-ui.min.js');
        $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.alerts.js');
        //$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/jquery.confirm.js');
        //$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/jquery.blockui.js');
        $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-ui-1.8.2.custom.min.js');
        //$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/bsystemgroup.js');
        $cs->registerCssFile(Yii::app()->theme->baseUrl . '/css/jquery.alerts.css');
        Yii::app()->clientScript->registerScript('global', '                                                           
	          yii = {                                                                                                     
	              urls: {                                      
	                  base: ' . CJSON::encode(Yii::app()->theme->baseUrl) . '                                                        
	              }                                                                                                       
	          };                                                                                                          
	    ', CClientScript::POS_HEAD);
        if (Yii::app()->user->id) {
            $user = new ASystemUser();
            $userInfo = $user->getSystemUserById(Yii::app()->user->id);
            //var_dump($userInfo->cp_code);exit();
            $this->group_id = $userInfo->group_id;
            $this->username = $userInfo->username;
            Yii::app()->session['group_id'] = $this->group_id;
            Yii::app()->session['username'] = $this->username;
        }
        //$xmlPath = realpath($path = Yii::app()->basePath.'/../'.Yii::app()->params['config_folder'].'/');
        //        $xmlFile = Yii::app()->params['config_file_name'];
        //        $this->config = new LoadConfigXML($xmlPath,$xmlFile);
        Yii::$classMap = array_merge(Yii::$classMap, array('CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedAction.php', 'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedValidator.php'));
    }
 public function actionChangePassword()
 {
     $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : '';
     $new_pass = isset($_POST['password']) ? $_POST['password'] : '';
     $passmd5 = SystemUser::encrypt($new_pass, Yii::app()->params->hashkey);
     //$changePass = SystemUser::model()->updateByPk($id,array('password'=>$passmd5),new CDbCriteria(array('condition'=>'id = :id', 'params'=>array('id'=>$user_id))));
     //var_dump(ASystemUser::changePass($user_id,$passmd5));exit();
     if (ASystemUser::changePass($user_id, $passmd5)) {
         $arrReturn = array('status' => true, 'msg' => Yii::t('adm/app', 'LBL_SUCCESS'), 'stt_value' => $passmd5);
     } else {
         $arrReturn = array('status' => false, 'msg' => Yii::t('adm/app', 'LBL_UNSUCCESS'));
     }
     echo CJSON::encode($arrReturn);
     exit;
 }
Example #3
0
    public function init()
    {
        $cs = Yii::app()->getClientScript();
        $cs->registerCssFile(Yii::app()->baseUrl . '/css/mystyle.css');
        Yii::app()->clientScript->registerScript('global', '                                                           
	          yii = {                                                                                                     
	              urls: {                                      
	                  base: ' . CJSON::encode(Yii::app()->baseUrl) . '                                                        
	              }                                                                                                       
	          };                                                                                                          
	    ', CClientScript::POS_HEAD);
        if (Yii::app()->user->id) {
            $user = new ASystemUser();
            $userInfo = $user->getSystemUserById(Yii::app()->user->id);
            //var_dump($userInfo->cp_code);exit();
            $this->group_id = $userInfo->group_id;
            $this->username = $userInfo->username;
            Yii::app()->session['group_id'] = $this->group_id;
            Yii::app()->session['username'] = $this->username;
        }
        $xmlPath = realpath($path = Yii::app()->basePath . '/../' . Yii::app()->params['config_folder'] . '/');
        $xmlFile = Yii::app()->params['config_file_name'];
        $this->config = new LoadConfigXML($xmlPath, $xmlFile);
    }
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = ASystemUser::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     //var_dump($user); exit();
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password, Yii::app()->params->hashkey)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->_group_id = $user->group_id;
             $this->username = $user->username;
             $this->setState('role', $user->group_id);
             $this->errorCode = self::ERROR_NONE;
             //update login
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
 public static function getUserNameById($id)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'username';
     $criteria->condition = 'id=:id';
     $criteria->params = array(':id' => (int) $id);
     $rs = ASystemUser::model()->find($criteria);
     /*
     $connection = Yii::app()->db;
     $sql = "SELECT username
             FROM {{system_user}}
             WHERE id = '".$id."'";
     $command = $connection->createCommand($sql);
     */
     //$rs = $command->queryRow();
     if (isset($rs) && $rs['username'] != '') {
         return $rs['username'];
     } else {
         return false;
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = ASystemUser::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #7
0
 public function getSystemUserById($id)
 {
     return ASystemUser::model()->find('id=:id', array(':id' => $id));
 }