本文整理匯總了PHP中UserInfo::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserInfo::model方法的具體用法?PHP UserInfo::model怎麽用?PHP UserInfo::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserInfo
的用法示例。
在下文中一共展示了UserInfo::model方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getUserInfo
public function getUserInfo()
{
if (!$this->_userInfo) {
$this->_userInfo = UserInfo::model()->findByAttributes(array('email' => $this->username));
}
return $this->_userInfo;
}
示例2: 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($Oauth = false)
{
$user = User::model()->findByAttributes(array('email' => $this->username));
if (!$user) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} elseif (!$user->comparePassword($this->password) && !$Oauth) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->errorCode = self::ERROR_NONE;
$userInfo = UserInfo::model()->findByAttributes(array('email' => $this->username));
$userInfo->upTime = time();
$userInfo->save();
if ($userInfo->status == 'frozened') {
throw new CHttpException(404, '錯誤!你的賬號已被凍結.');
Yii::app()->end();
}
//動態設為超級用戶
if ($userInfo->isAdmin) {
Yii::app()->user->setIsSuperuser(true);
}
// elseif($userInfo->inRoles(array('superAdmin','admin'))) Yii::app()->user->setIsSuperuser(true);
$this->_id = $userInfo->id;
//用setState添加的變量會加入Yii::app()->user的屬性中
$this->setState('displayName', $userInfo->name);
}
return !$this->errorCode;
}
示例3: fioById
static function fioById($id)
{
$model = UserInfo::model()->findByAttributes(['user_id' => $id]);
if ($model) {
return $model->surname . ' ' . $model->name . ' ' . $model->otchestvo;
}
}
示例4: getInfo
public static function getInfo($uid, $type)
{
if (!$uid || !$type) {
return false;
}
$info = UserInfo::model()->find('uid=:uid AND `name`=:name', array(':uid' => $uid, ':name' => $type));
return $info['value'];
}
示例5: check
/**
* @return bool
* 檢查數據庫中是否有相同的用戶名
*/
public function check()
{
$user = UserInfo::model()->findByAttributes(array('user_name' => $this->username));
if (empty($user)) {
return true;
} else {
return false;
}
}
示例6: userExtraInfo
public static function userExtraInfo($uid, $type = '')
{
$dataProvider = UserInfo::model()->findAllByAttributes(array('uid' => $uid));
$settings = CHtml::listData($dataProvider, 'name', 'value');
if (!empty($type)) {
return $settings[$type];
} else {
return $settings;
}
}
示例7: actionUpdate
/**
* 用戶更新資料方法
* @param int $userId 用戶的ID
*/
public function actionUpdate($userId)
{
// 實例化userInfo表的操作模型,調用updateByPK方法,很好用
$result = UserInfo::model()->updateByPk($userId, $_POST);
$arr = $_POST;
$arr['userId'] = $userId;
// 將更新的數據再次賦給session
$_SESSION['userMsg'] = $arr;
// 跳轉
$this->redirect("index.php?r=reaction/index/act/update/rst/{$result}");
}
示例8: checkUser
/**
* 檢查用戶是否存在
*/
public function checkUser()
{
parent::beforeSave();
$user = UserInfo::model()->find("name='{$_POST['People']['userName']}'");
if (!isset($user)) {
Yii::app()->user->setFlash('error', Yii::t('app', '用戶不存在'));
Yii::app()->controller->redirect(array('create', 'userName' => $_POST['People']['userName']));
} else {
$this->userId = $user->id;
return true;
}
}
示例9: login
public function login($identity, $duration = 0)
{
$result = parent::login($identity, $duration);
if (!$result) {
return $result;
}
$session = Yii::app()->getSession();
$info = UserInfo::model()->findByAttributes(['user_id' => $identity->getId()]);
$session['username'] = $info->name;
$session['surname'] = $info->surname;
$session['otchestvo'] = $info->otchestvo;
return $result;
}
示例10: actionHovercard
public function actionHovercard()
{
$user = UserInfo::model()->findByPk(Yii::app()->user->id);
if (count($user->noticesUnisChecked) > 0) {
$dataProvider = new CArrayDataProvider($user->noticesUnisChecked, array('keyField' => 'id'));
Notice::model()->updateAll(array('isChecked' => 1), 'userId=:userId and isChecked=0', array('userId' => Yii::app()->user->id));
} else {
$dataProvider = new CActiveDataProvider('Notice', array('criteria' => array('condition' => 'userId=' . Yii::app()->user->id, 'order' => 'addTime DESC'), 'pagination' => array('pageSize' => 5)));
}
Yii::app()->clientScript->scriptMap['*.js'] = false;
$this->renderPartial('hovercard', array('dataProvider' => $dataProvider), false, true);
// $this->renderPartial('hovercard',null,false,true );
}
示例11: actionIndex
public function actionIndex()
{
$this->pageTitle = "論壇首頁";
// 論壇公告
$notices = Notices::model()->find();
// 討論區類別
$bbsType = BbsType::model()->findAll();
// 話題計數
$bbsCount = BbsInfo::model()->count();
// 回帖計數
$revCount = Reviews::model()->count();
// 用戶計數
$userCount = UserInfo::model()->count();
// 綁定數據
$data = array('notices' => $notices, 'bbsType' => $bbsType, 'bbsCount' => $bbsCount, 'revCount' => $revCount, 'userCount' => $userCount);
$this->render('index', $data);
}
示例12: getNoticeParam
/**
*
*/
private function getNoticeParam($user)
{
$mailData['userName'] = $user['name'];
// 未讀的私信
$mailData['messageDataProvider'] = new CArrayDataProvider(UserInfo::model()->findByPk($user['id'])->messagesReceived, array('keyField' => 'id', 'pagination' => array('pageSize' => 1)));
// 未讀的提醒
$mailData['noticeDataProvider'] = new CArrayDataProvider(UserInfo::model()->findByPk($user['id'])->notices, array('keyField' => 'id', 'pagination' => array('pageSize' => 3)));
// 如果沒有私信和提醒
if (!count($mailData['messageDataProvider']->getData()) && !count($mailData['noticeDataProvider']->getData())) {
$param['nullMailData'] = 1;
return $param;
}
$param['to'] = 'zhanghooyo@qq.com';
$param['subject'] = 'test title';
$param['html'] = $this->renderPartial('_mail_template', $mailData, true);
return $param;
}
示例13: actionGotoPhpems
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionGotoPhpems()
{
//取得user
$user = UserInfo::model()->findByPk(Yii::app()->user->id);
//準備參數
$userid = $user->id;
//用戶ID
$username = $user->name;
//用戶名,GET方式過來
$email = $user->email;
//郵箱,GET方式過來
$ts = time();
$sign = md5($userid . $username . $email . $this->_sc . $ts);
//跳轉到phpems
$this->redirect($this->_phpemsurl . '&userid=' . $userid . '&username=' . $username . '&useremail=' . $email . '&ts=' . $ts . '&sign=' . $sign);
//$this->redirect($this->_phpemsurl,array('exam-api-login'=>'','userid'=>$userid,'username'=>$username,'useremail'=>$email,'ts'=>$ts,'sign'=>$sign));
}
示例14: actionLogin
/**
* 登錄類登錄方法
*/
public function actionLogin()
{
$userName = $_POST['userName'];
$password = md5($_POST['password']);
// 實例化userinfo表並調用find方法
$userInfo = UserInfo::model()->find("userName='{$userName}' AND password='{$password}'");
// 登錄失敗跳轉提醒
if ($userInfo == NULL) {
$result = 0;
$this->redirect("index.php?r=reaction/index/act/login/rst/{$result}");
} else {
// 將從數據庫中獲取到的userinfo賦給變量,將session轉化成一維數組
$array = array('userId' => $userInfo['userId'], 'userName' => $userInfo['userName'], 'password' => $userInfo['password'], 'mailBox' => $userInfo['mailBox'], 'sex' => $userInfo['sex'], 'address' => $userInfo['address'], 'qq' => $userInfo['qq'], 'tel' => $userInfo['tel'], 'headPic' => $userInfo['headPic'], 'signWord' => $userInfo['signWord']);
$_SESSION['userMsg'] = $array;
// 登錄成功跳轉
$this->redirect("index.php?r=reaction/index/act/login/rst/1");
}
}
示例15: actionAnswer
/**
* 為帖子投票
* Enter description here ...
* @param unknown_type $postid
* @param unknown_type $value
*/
public function actionAnswer($answerid, $value = 0)
{
//$vote = new PostVote;
$vote = AnswerVote::model()->findByAttributes(array('userId' => Yii::app()->user->id, 'answerid' => $answerid));
$answer = Answer::model()->with('question')->findByPk($answerid);
if ($vote && $vote->value == $value) {
//再點擊讚同(反對),即取消第一次投的讚同(反對)
$result = $vote->delete();
} else {
//讚同(反對)被第一次點擊
$vote or $vote = new AnswerVote();
$vote->answerid = $answerid;
$vote->value = $value;
$vote->userId = Yii::app()->user->id;
$vote->addTime = time();
$result = $vote->save();
//發送係統通知給回答主人
if ($answer->userId != $vote->userId) {
$notice = new Notice();
$notice->type = 'vote_answer';
$notice->setData(array('voteId' => $vote->getPrimaryKey()));
$notice->userId = $answer->userId;
$notice->save();
}
}
if ($result) {
// $question = Question::model()->findByPk($answer->question)
//修改答案投票次數統計
$answer->voteupNum = $answer->voteupCount;
$answer->count_votedown = $answer->votedownCount;
$answer->save();
//修改問題投票次數統計
$answer->question->updateVoteCount();
//修改用戶被讚數量
$user = UserInfo::model()->findByPk($answer->userId);
$user->answerVoteupNum = $user->getAnswerVoteupCount();
$user->save();
$score = $answer->voteupCount - $answer->votedownCount;
$this->renderPartial('result', array('score' => $score, 'voteupers' => $answer->voteupers));
}
}