当前位置: 首页>>代码示例>>PHP>>正文


PHP UserModel::model方法代码示例

本文整理汇总了PHP中UserModel::model方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::model方法的具体用法?PHP UserModel::model怎么用?PHP UserModel::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModel的用法示例。


在下文中一共展示了UserModel::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function login()
 {
     if ($this->_identity === null) {
         $this->_identity = new UserIdentity($this->username, $this->password);
         $this->_identity->authenticate();
     }
     if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
         $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
         // 30 days
         Yii::app()->user->login($this->_identity, $duration);
         $userInfo = UserModel::model()->find('username=:username', array(':username' => $this->username));
         Yii::app()->session['userInfo'] = array('uid' => $userInfo->uid, 'username' => $userInfo->username, 'nickname' => $userInfo->nickname, 'group_id' => $userInfo->group_id);
         //log
         $log = new ActiveRecordLog();
         $log->description = Yii::t('admin/activeLog', 'User {username} login', array('username' => Yii::app()->user->Name));
         $log->action = 'LOGIN';
         $log->model = __CLASS__;
         $log->idModel = $userInfo->uid;
         $log->field = '';
         $log->created_at = new CDbExpression('NOW()');
         $log->username = Yii::app()->user->id;
         $log->save();
         return true;
     } else {
         return false;
     }
 }
开发者ID:00606,项目名称:wechat,代码行数:31,代码来源:LoginForm.php

示例2: userAuthenticateWifi

 public function userAuthenticateWifi($msisdn)
 {
     if ($msisdn) {
         // get user info from phone
         $user = UserModel::model()->findByAttributes(array("phone" => $msisdn));
         if ($user) {
             if (!empty($user->suggested_list)) {
                 $this->setState('_user', array('id' => $user->id, 'suggested_list' => $user->suggested_list));
             } else {
                 $this->setState('_user', array('phone' => $msisdn, 'suggested_list' => ""));
             }
         } else {
             $this->setState('_user', array('phone' => $msisdn, 'suggested_list' => ""));
         }
         $this->_msisdn = $msisdn;
         $this->setState('msisdn', $msisdn);
         $package = WapUserSubscribeModel::model()->getUserSubscribe($this->_msisdn);
         // get user_subscribe record by phone
         if ($package) {
             $packageObj = WapPackageModel::model()->findByPk($package->package_id);
             $this->setState('package', $packageObj->code);
         }
         self::_logDetectMSISDN($msisdn, 'wifi');
         $this->errorCode = self::ERROR_NONE;
     } else {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     return !$this->errorCode;
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:29,代码来源:UserIdentity.php

示例3: ajaxAction

 public function ajaxAction($command = '', $params = array())
 {
     switch ($command) {
         case 'view_accountlist':
             $userlist = UserModel::model()->getRows();
             $this->setVar("userlist", $userlist);
             $this->loadView("admin/accounts_list");
             break;
         case 'json_user':
             $user = UserModel::model()->getRowFromPk($_GET['user_id']);
             echo $user->toJSON();
             break;
         case 'post_delete':
             $user_id = $_POST['user_id'];
             $user = UserModel::model()->getRowFromPk($user_id);
             $user->delete();
             break;
         case 'post_add':
             $user = UserModel::model();
             $user->user_name = $_POST['user_name'];
             $user->email = $_POST['email'];
             $user->plain_pass = $_POST['pass'];
             $user->pass = $_POST['pass'];
             $user->pass_confirm = $_POST['pass_confirm'];
             $user->privilege = $_POST['privilege'];
             $user->useRuleSet("admin_new");
             if ($user->save()) {
                 echo '0';
             } else {
                 echo join('<br>', $user->getErrors());
             }
             break;
         case 'post_edit':
             $user = UserModel::model()->getRowFromPk($_POST['user_id']);
             if (!$user) {
                 echo "Bad ID";
                 BTApp::end();
             }
             $user->user_name = $_POST['user_name'];
             $user->email = $_POST['email'];
             if ($_POST['pass']) {
                 $user->plain_pass = $_POST['pass'];
                 $user->pass = $_POST['pass'];
                 $user->pass_confirm = $_POST['pass_confirm'];
             } else {
                 //to satisfy the validation
                 $user->pass = $user->pass;
                 $user->pass_confirm = $user->pass;
             }
             $user->privilege = $_POST['privilege'];
             $user->useRuleSet("admin_edit");
             if ($user->save()) {
                 echo '0';
             } else {
                 echo join('<br>', $user->getErrors());
             }
             break;
     }
 }
开发者ID:sakibanda,项目名称:ballistic-tracking,代码行数:59,代码来源:AdminAccountsController.php

示例4: actionIndex

 public function actionIndex()
 {
     $model = UserModel::model()->findByPk(Yii::app()->user->id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $this->render('index', array('model' => $model));
 }
开发者ID:dalinhuang,项目名称:styleshop,代码行数:8,代码来源:SettingController.php

示例5: createUserIfNotExist

 protected function createUserIfNotExist()
 {
     $user = UserModel::model()->getByAttr('email', $this->user_email);
     if ($user->isNewRecord()) {
         $user->setAttributes(array('email' => $this->user_email));
         $user->save();
     }
     $this->aAttributes['user_id'] = UserModel::model()->getByAttr('email', $this->user_email)->getAttributeValue('id');
 }
开发者ID:Abyss403,项目名称:test,代码行数:9,代码来源:PostModel.php

示例6: __construct

 public function __construct($id, $module = null)
 {
     parent::__construct($id, $module = null);
     if (Yii::app()->user->isGuest) {
         $this->redirect(array('site/login'));
     } else {
         $userInfo = UserModel::model()->find('username=:username', array(':username' => Yii::app()->user->name));
         Yii::app()->session['userInfo'] = array('uid' => $userInfo->uid, 'username' => $userInfo->username, 'nickname' => $userInfo->nickname, 'group_id' => $userInfo->group_id);
     }
 }
开发者ID:00606,项目名称:wechat,代码行数:10,代码来源:Controller.php

示例7: actionProfile

 public function actionProfile()
 {
     $model = UserModel::model()->find(array('condition' => 'username=:username', 'params' => array(':username' => Yii::app()->user->id)));
     if (isset($_POST['UserModel'])) {
         $model->attributes = $_POST['UserModel'];
         if ($model->validate()) {
             $model->save();
             $this->redirect(array('group/user'));
         }
     }
     $this->render('/user/profile', array('model' => $model));
 }
开发者ID:00606,项目名称:wechat,代码行数:12,代码来源:UserController.php

示例8: authenticate

 /**
  * 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()
 {
     $models = UserModel::model()->findAll();
     $users = CHtml::listData($models, 'user_email', 'user_password');
     if (!isset($users[$this->username])) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif ($users[$this->username] !== $this->password) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
开发者ID:smijo149,项目名称:registration,代码行数:21,代码来源:UserIdentity.php

示例9: actionAddCall

 public function actionAddCall()
 {
     if (isset($_POST['RequestCall']) && !empty($_POST['RequestCall'])) {
         $cost = 0;
         if ($_POST['RequestCall']['type'] == RequestCall::TYPE_SIMPLE) {
             $cost = 300;
         } elseif ($_POST['RequestCall']['type'] == RequestCall::TYPE_DIFFICULT) {
             $cost = 500;
         } elseif ($_POST['RequestCall']['type'] == RequestCall::TYPE_VERY_DIFFICULT) {
             $cost = 1000;
         }
         $user = UserModel::model()->client()->findByPk(Yii::app()->user->id);
         if ($user) {
             if ($user->balance - $cost < 0) {
                 Yii::app()->user->setFlash('error', 'Недостаточно средств! пополните баланс и закажите звонок');
                 $this->refresh();
             } else {
                 Yii::app()->user->setFlash('success', 'Звонок заказан! с вашего счета снято ' . $cost . 'руб');
                 $user->balance = $user->balance - $cost;
                 $user->save(false);
             }
         }
         $model = new RequestCall();
         $model->setAttributes($_POST['RequestCall']);
         $model->user_id = Yii::app()->user->id;
         $model->status = 1;
         $model->save();
         $image = CUploadedFile::getInstance($model, 'file');
         if ($image) {
             if (!is_dir('uploads/phoneDocument/images')) {
                 mkdir('uploads/phoneDocument/images', 0777, true);
             }
             $ext = explode('.', $image->name);
             $model->file = Yii::app()->user->id . '_' . md5(time()) . '.' . $ext[1];
             $image->saveAs('uploads/phoneDocument/images/' . $model->file);
             $model->save(false);
         }
     }
     $jurist = UserModel::model()->jurist()->findByPk(Yii::app()->user->id);
     if (Yii::app()->user->isGuest) {
         Yii::app()->user->setFlash('error', 'Заказать звонок может только зарегестрированный пользователь');
         $this->redirect($this->createUrl('site/index'));
     }
     if ($jurist !== null) {
         Yii::app()->user->setFlash('error', 'Заказать звонок может только пользователь');
         $this->redirect($this->createUrl('cabinet/index'));
     }
     $this->render('newRequest', ['model' => new RequestCall()]);
 }
开发者ID:Alamast,项目名称:pravoved,代码行数:49,代码来源:RequestCallController.php

示例10: actionPswd

 public function actionPswd()
 {
     $userInfo = Yii::app()->session['userInfo'];
     $model = UserModel::model()->find(array('condition' => 'uid=:uid', 'params' => array(':uid' => $userInfo['uid'])));
     $model->scenario = 'pswd';
     if (isset($_POST['UserModel'])) {
         $model->attributes = $_POST['UserModel'];
         if ($model->validate()) {
             $model->pswd = md5($_POST['UserModel']['newpswd']);
             $model->save();
             ShowMessage::success('修改成功!', Yii::app()->createUrl('user/pswd'));
         }
     }
     $this->render('pswd', array('model' => $model));
 }
开发者ID:00606,项目名称:wechat,代码行数:15,代码来源:UserController.php

示例11: authenticate

 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = UserModel::model()->find('LOWER(email)=?', [strtolower($this->username)]);
     if ($user === NULL) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
开发者ID:snipesn,项目名称:pravoved,代码行数:19,代码来源:UserIdentity.php

示例12: actionDelete

 public function actionDelete($id)
 {
     $model = UserModel::model()->findByPk($id);
     if ($model) {
         if ($model->info) {
             $model->info->delete();
         }
         if ($model->schooling) {
             $model->schooling->delete();
         }
         if ($model->contact) {
             $model->contact->delete();
         }
         $model->delete();
     }
 }
开发者ID:Alamast,项目名称:pravoved,代码行数:16,代码来源:AdminController.php

示例13: authenticate

 public function authenticate()
 {
     $record = UserModel::model()->findByAttributes(array('email' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->password !== $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->_id;
             //$this->setState('title', $record->title);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
开发者ID:dalinhuang,项目名称:styleshop,代码行数:16,代码来源:MeUserIdentity.php

示例14: actionForget

 public function actionForget()
 {
     $model = new UserForm('foget');
     $msg = '';
     if (!empty($_POST['UserForm'])) {
         $model->attributes = $_POST['UserForm'];
         if ($model->validate()) {
             $user = new UserModel();
             $user->password = UserModel::model()->cryptPass($pass = UserModel::model()->genPassword());
             $user->save();
             Yii::app()->email->send($model->email, 'Новый пароль', 'Ваш новый пароль:' . $pass);
             $msg = 'Новый пароль отправлен Вам на почту.';
         }
     }
     $this->render('forget', ['model' => $model, 'msg' => $msg]);
 }
开发者ID:Alamast,项目名称:pravoved,代码行数:16,代码来源:AccessController.php

示例15: actionLogin

 public function actionLogin()
 {
     $connection = Yii::app()->db;
     $email = $_REQUEST['email'];
     $password = $_REQUEST['pwd'];
     $user = UserModel::model()->find('email=:email and password=:pwd', array(':email' => $email, ':pwd' => $password));
     if (isset($user)) {
         //邮箱密码正确,找到名字对应的_id。
         $sql = "select _id from tbl_user where email = :email";
         $command = $connection->createCommand($sql);
         $tmp = $command->query(array(':email' => $email))->readAll();
         echo json_encode(array('result' => 1, 'res' => $tmp[0]["_id"]));
     } else {
         echo json_encode(array('result' => 0, 'comment' => 'login fail'));
     }
 }
开发者ID:dalinhuang,项目名称:styleshop,代码行数:16,代码来源:ApiController.php


注:本文中的UserModel::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。