本文整理汇总了PHP中app\models\Users::getUserByUserName方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::getUserByUserName方法的具体用法?PHP Users::getUserByUserName怎么用?PHP Users::getUserByUserName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::getUserByUserName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionLogin
public function actionLogin()
{
$model = new EntryForm();
$session = Yii::$app->session;
if (isset($session['user'])) {
$user = $session['user'];
if ($user['permission'] == 0) {
return $this->redirect('?r=admin/index');
} else {
if ($user['permission'] == 1) {
$count = Email::find()->count();
$pagination = new Pagination(['defaultPageSize' => 8, 'totalCount' => Email::find()->count()]);
$email = Email::find()->orderBy(['sendtime' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
return $this->render('/Users\\distributer\\index', ['user' => $user, 'email' => $email, 'pagination' => $pagination, 'count' => $count]);
} else {
if ($user['permission'] == 2) {
$count = Check::find()->where(['check_user_id' => $session['user_id'], 'check_status' => 0])->count();
$countall = Check::find()->where(['check_user_id' => $session['user_id']])->count();
$pagination = new Pagination(['defaultPageSize' => 8, 'totalCount' => $countall]);
$session['count'] = $count;
$check = Check::find()->where(['check_user_id' => $session['user_id']])->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
$checkemails = array();
foreach ($check as $key) {
$checkemail = SentEmail::find()->where(['id' => $key['email_id']])->asArray()->one();
$emailuser = Users::find()->where(['id' => $checkemail['user_id']])->asArray()->one();
$checkemail['dealername'] = $emailuser['username'];
$checkemail['check_status'] = $key['check_status'];
$checkemail['foreignid'] = $key['id'];
$checkemails[] = $checkemail;
}
$check['count'] = $count;
return $this->render('/verifier\\index', ['user' => $user, 'check' => $check, 'checkemails' => $checkemails, 'pagination' => $pagination]);
} else {
if ($user['permission'] == 3) {
$count = Email_user_rs::find()->where(['user_id' => $user['id']])->count();
$pagination = new Pagination(['defaultPageSize' => 8, 'totalCount' => $count]);
$session['count'] = $count;
$dealEmail = Email_user_rs::find()->where(['user_id' => $user['id']])->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
/*$sql='SELECT e.id,e.subject,e.sender,e.receiver,e.text,e.label,e.check_status,e.sendtime,e.attachment,es.* FROM email as e,email_user_rs as es WHERE e.id=es.email_id and es.user_id='.$user['id'];
$connection=Yii::$app->db;
$command=$connection->createCommand($sql);
$result=$command->queryAll();
return $this->render('/Users\dealer\index', ['user' => $user,'pagination'=>$pagination]);*/
$emails = array();
foreach ($dealEmail as $key) {
$useremail = Email::find()->orderBy(['sendtime' => SORT_DESC])->where(['id' => $key['email_id']])->asArray()->one();
$emails[] = $useremail;
}
return $this->render('/Users\\dealer\\index', ['user' => $user, 'emails' => $emails, 'dealEmail' => $dealEmail, 'pagination' => $pagination]);
}
}
}
}
} else {
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$user = Users::getUserByUserName($model->name);
$session['user'] = $user;
$session['user_id'] = $user['id'];
$session['model'] = $model;
if (empty($user)) {
$message = "用户名不存在!";
return $this->render('login', ['message' => $message, 'model' => $model]);
} else {
if ($user['password'] != $model->password) {
$message = "密码输入错误!";
return $this->render('login', ['message' => $message, 'model' => $model]);
} else {
if ($user['permission'] == 0) {
return $this->redirect('?r=admin/index');
} else {
if ($user['permission'] == 1) {
$count = Email::find()->where(['handle_status' => 0])->count();
$session['undistributer_count'] = $count;
$pagination = new Pagination(['defaultPageSize' => 8, 'totalCount' => Email::find()->count()]);
$email = Email::find()->orderBy(['sendtime' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
return $this->render('/Users\\distributer\\index', ['user' => $user, 'email' => $email, 'pagination' => $pagination, 'count' => $count]);
} else {
if ($user['permission'] == 2) {
$count = Check::find()->where(['check_user_id' => $session['user_id'], 'check_status' => 0])->count();
$countall = Check::find()->where(['check_user_id' => $session['user_id']])->count();
$pagination = new Pagination(['defaultPageSize' => 8, 'totalCount' => $countall]);
$session['count'] = $count;
$check = Check::find()->where(['check_user_id' => $session['user_id']])->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
$checkemails = array();
foreach ($check as $key) {
$checkemail = SentEmail::find()->where(['id' => $key['email_id']])->asArray()->one();
$emailuser = Users::find()->where(['id' => $checkemail['user_id']])->asArray()->one();
$checkemail['dealername'] = $emailuser['username'];
$checkemail['check_status'] = $key['check_status'];
$checkemail['foreignid'] = $key['id'];
$checkemails[] = $checkemail;
}
$check['count'] = $count;
return $this->render('/verifier\\index', ['user' => $user, 'check' => $check, 'checkemails' => $checkemails, 'pagination' => $pagination]);
} else {
if ($user['permission'] == 3) {
$count = Email_user_rs::find()->where(['user_id' => $user['id']])->count();
$pagination = new Pagination(['defaultPageSize' => 8, 'totalCount' => $count]);
$session['count'] = $count;
$dealEmail = Email_user_rs::find()->where(['user_id' => $user['id']])->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
//.........这里部分代码省略.........