Ejemplo n.º 1
0
 public function actionGetUsers()
 {
     $keyword = addslashes(trim($_GET['keyword']));
     $condition = "1=1 ";
     if ($keyword) {
         $condition = $condition . " and name like '%{$keyword}%'";
     }
     if (isset($_GET['page_num']) && is_numeric($_GET['page_num'])) {
         $page_num = intval($_GET['page_num']);
     } else {
         $page_num = 1;
     }
     if (isset($_GET['page_size']) && is_numeric($_GET['page_size'])) {
         $page_size = intval($_GET['page_size']);
     } else {
         $page_size = 10;
     }
     $result = UserManager::findAll($page_num, $page_size, $condition);
     //pagination
     $criteria = new CDbCriteria();
     $criteria->condition = $condition;
     $records = user::model()->findAll($criteria);
     $number = count($records);
     $sum_page = ceil($number / $page_size);
     $result = array('sum_page' => $sum_page, 'data' => $result, 'sum_count' => $number);
     echo CJSON::encode($result);
 }
Ejemplo n.º 2
0
 public function actionIndex()
 {
     $access = parent::getAccess();
     if (0 < $access) {
         $this->ajaxReturn(array("login" => true, "formhash" => FORMHASH, "uid" => Yii::app()->user->uid, "user" => user::model()->fetchByUid(Yii::app()->user->uid)), "JSONP");
     } else {
         $this->ajaxReturn(array("login" => false, "msg" => "登录已超时,请重新登录"), "JSONP");
         exit;
     }
 }
Ejemplo n.º 3
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $userInfo = user::model()->find('username = :name', array(':name' => $this->username));
     if ($userInfo == NULL) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
         return false;
     }
     if ($userInfo['password'] != md5($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         return false;
     }
     $this->errorCode = self::ERROR_NONE;
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = user::model()->find('username=:username', array(':username' => $this->username));
     if ($user == null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (!$user->validatePassword($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $user->id;
         $this->setState('userid', $user->id);
         $this->setState('username', $this->username);
         $this->errorCode = self::ERROR_NONE;
     }
     return $this->errorCode == self::ERROR_NONE;
 }
Ejemplo n.º 5
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $username = $this->username;
     $password = $this->password;
     $user = user::model()->find(array('condition' => "username='******'"));
     if (!empty($user)) {
         if ($password == $user->password) {
             $this->errorCode = self::ERROR_NONE;
             $this->setState('user', $user->username);
             $this->setState('id', $user->id);
         } else {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         }
     } else {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     return !$this->errorCode;
 }
Ejemplo n.º 6
0
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = user::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Ejemplo n.º 7
0
?>
	 </div>
    </div>
 </div>

 <div class="row">
	<div class="form-group">
     <div class="span2">
		<?php 
echo $form->labelEx($model, 'created_by');
?>
        </div>
        <div class="col-sm-8 clearLeftPadding">
		<?php 
//echo $form->textField($model,'created_by');
echo $form->dropDownList($model, 'created_by', CHtml::listData(user::model()->findAll(array('select' => 'id, username', 'order' => 'username')), 'id', 'username'), array('empty' => '- Select -'));
?>
		<?php 
echo $form->error($model, 'created_by');
?>
	 </div>
    </div>
 </div>

 <div class="row">
	<div class="form-group">
     <div class="span2">
		<?php 
echo $form->labelEx($model, 'is_current');
?>
        </div>
Ejemplo n.º 8
0
 public static function activeEmployer($id)
 {
     $user = user::model()->findByPk($id);
     $user->activated = 1;
     $user->save(false);
 }
Ejemplo n.º 9
0
 public function actionPassword()
 {
     $password = '******';
     $user = user::model()->createPassword($password);
     var_dump($user);
 }
Ejemplo n.º 10
0
 public function actionUpdatepw()
 {
     if (!API_UPDATEPW) {
         echo API_RETURN_FORBIDDEN;
     }
     $username = $_GET['username'];
     $password = $_GET['password'];
     $user = user::model()->findByAttributes(array('username' => $username));
     if ($user !== null) {
         $user->password = md5($password);
         if ($user->save()) {
             echo API_RETURN_SUCCEED;
         } else {
             echo API_RETURN_FAILED;
         }
     } else {
         echo API_RETURN_FAILED;
     }
 }
Ejemplo n.º 11
0
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return user the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }