本文整理汇总了PHP中app\models\Users类的典型用法代码示例。如果您正苦于以下问题:PHP Users类的具体用法?PHP Users怎么用?PHP Users使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Users类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Staff model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (Yii::$app->user->can('admin')) {
$model = new Staff();
if (Yii::$app->request->isAjax && $model->load($_POST)) {
Yii::$app->response->format = 'json';
return \yii\widgets\ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post())) {
$user = new Users();
$user->usertype = 'Staff';
$user->password = strtolower($model->apellido1 . substr($model->rut, 5, -2));
$user->email = $model->correo;
$model->save();
$user->id_orig = $model->id;
$user->username = $model->nombre . " " . $model->apellido1;
$user->save();
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
} else {
throw new ForbiddenHttpException();
}
}
开发者ID:godzukison,项目名称:mngrApp,代码行数:30,代码来源:StaffController.php
示例2: actionReg
public function actionReg()
{
$model = new RegForm();
$error = null;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$user = new Users();
$user->login = Html::encode($model->login);
$user->password = md5($model->password);
$user->name = Html::encode($model->name);
$user->email = Html::encode($model->email);
$user->phone = Html::encode($model->phone);
if (UploadedFile::getInstance($model, 'photo')) {
$model->photo = UploadedFile::getInstance($model, 'photo');
$model->photo->saveAs('img/photo/' . $model->photo->baseName . '.' . $model->photo->extension);
$photo = 'img/photo/' . $model->photo->baseName . '.' . $model->photo->extension;
$user->photo = $photo;
}
$uc = new UserClass();
if ($uc->isUniqueLogin($user->login)) {
$user->save();
return $this->render('regsuccess');
} else {
$error = 'Такой логин уже существует';
}
}
return $this->render('reg', ['model' => $model, 'error' => $error]);
}
开发者ID:siegigor,项目名称:shopheadphones,代码行数:27,代码来源:UserController.php
示例3: indexAction
/**
* Action to register a new user
*/
public function indexAction()
{
$form = new RegisterForm();
if ($this->request->isPost()) {
$name = $this->request->getPost('name', array('string', 'striptags'));
$username = $this->request->getPost('username', 'alphanum');
$email = $this->request->getPost('email', 'email');
$password = $this->request->getPost('password');
$repeatPassword = $this->request->getPost('repeatPassword');
if ($password != $repeatPassword) {
$this->flash->error('Passwords are different');
return false;
}
$user = new Users();
$user->username = $username;
$user->password = sha1($password);
$user->name = $name;
$user->email = $email;
$user->created_at = new \Phalcon\Db\RawValue('now()');
$user->active = 'Y';
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
$this->flash->error((string) $message);
}
} else {
$this->tag->setDefault('email', '');
$this->tag->setDefault('password', '');
$this->flash->success('Thanks for sign-up, please log-in to start generating invoices');
return $this->forward('session/index');
}
}
$this->view->form = $form;
}
开发者ID:kenikori,项目名称:phalcon2_invo,代码行数:36,代码来源:RegisterController.php
示例4: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
if ($request->userID) {
$user = Users::where("uID", $request->userID)->first();
if ($request->password) {
$user->uPassword = md5($request->password);
}
} else {
$user = new Users();
$user->uPassword = md5($request->password);
$user->uRegisteredDate = date('Y-m-d');
$user->uIsActive = 1;
$user->uRole = 1;
$user->uUsername = $request->username;
$user->uEmail = $request->email;
}
$user->uBirthday = date('Y-m-d', strtotime($request->birthday));
$user->uAddress = $request->address;
$user->uPhone = $request->phone;
$file = Input::file('image');
// $file->getRealPath()
if (!is_null($file)) {
$destinationPath = public_path() . '/assets/images/avatar/';
$fileName = explode(".", $file->getClientOriginalName())[0];
$fileName = $fileName . rand(1, 9999) . "." . $file->getClientOriginalExtension();
Input::file('image')->move($destinationPath, $fileName);
Image::make($destinationPath . $fileName)->resize(400, 400)->save($destinationPath . '400x400/' . $fileName);
$user->uAvatar = $fileName;
}
$user->save();
return Redirect::action('admin\\user@index');
}
开发者ID:NguyenHoangThien,项目名称:learningBlog,代码行数:38,代码来源:user.php
示例5: loginAction
public function loginAction()
{
if (!is_null($this->session->getCurrentUser())) {
$this->redirect('/');
}
if (is_null($this->request->getPost('user')) || is_null($this->request->getPost('password'))) {
throw new LoginException('Неверные данные формы авторизации.');
}
$user = addslashes(trim(strip_tags($this->request->getPost('user'))));
$password = addslashes(trim(strip_tags($this->request->getPost('password'))));
$usersModel = new Users();
try {
$currentUser = $usersModel->getUsersDataByLogPass($user, $password);
} catch (\Exception $e) {
throw new LoginException($e->getMessage());
}
if ($currentUser['roles_id'] == self::BANNED) {
throw new LoginException('Доступ временно запрещен. Обратитесь к администратору.');
}
unset($currentUser['password']);
$userObj = new User();
$userObj->fillData($currentUser);
$this->session->setCurrentUser($userObj);
echo json_encode(array('location' => '/'));
exit;
}
开发者ID:BoesesGenie,项目名称:team-rex,代码行数:26,代码来源:LoginController.php
示例6: userInfo
public function userInfo($userInfo)
{
print_r($userInfo);
$user = new Users();
$user->email = $userInfo['email'];
$user->name = $userInfo['name'];
$user->save();
}
开发者ID:nixwins,项目名称:microframework,代码行数:8,代码来源:old_Controller.php
示例7: saveAction
public function saveAction()
{
if (!$this->isXmlHttpRequest()) {
throw new \Exception('Неверный тип запроса!');
}
$usersModel = new Users();
$data = $this->request->getPost();
if (!isset($data['id']) || !isset($data['roles_id']) || !isset($data['user']) || !isset($data['password'])) {
throw new \Exception('Неверный тип запроса!');
}
if ($data['action'] == 'add' && (!isset($data['lastname']) || !isset($data['firstname']) || !isset($data['secondname']) || !isset($data['org_name']))) {
throw new \Exception('Неверный тип запроса!');
}
$data['id'] = (int) $data['id'];
if (!$data['id'] && $data['action'] != 'add') {
throw new \Exception('Неверный идентификатор пользователя!');
}
$data['roles_id'] = (int) $data['roles_id'];
if ($data['roles_id'] == 0) {
throw new \Exception('Не выбраны права пользователя!');
}
$data['user'] = trim($data['user']);
if ($data['user'] == '') {
throw new \Exception('Не заполнено обязательное поле Email!');
}
$data['password'] = trim($data['password']);
if ($data['password'] == '' && $data['action'] != 'add') {
unset($data['password']);
}
if (isset($data['password']) && mb_strlen($data['password']) < 6) {
throw new \Exception('Пароль должен быть больше 6 символов!');
}
if ($data['action'] == 'add') {
$data['lastname'] = trim($data['lastname']);
if ($data['lastname'] == '') {
throw new \Exception('Не заполнено обязательное поле Фамилия!');
}
$data['firstname'] = trim($data['firstname']);
if ($data['firstname'] == '') {
throw new \Exception('Не заполнено обязательное поле Имя!');
}
$data['secondname'] = trim($data['secondname']);
if ($data['secondname'] == '') {
throw new \Exception('Не заполнено обязательное поле Отчество!');
}
$data['org_name'] = trim($data['org_name']);
if ($data['org_name'] == '') {
throw new \Exception('Не заполнено обязательное поле Организация!');
}
}
unset($data['action']);
$data['id'] = $usersModel->save($data);
$usersModel->setWhere(array('id' => $data['id']));
$uData = $usersModel->select();
$this->view->data = $uData[0];
$rolesModel = new Roles();
$this->view->roles = $rolesModel->select();
}
开发者ID:BoesesGenie,项目名称:team-rex,代码行数:58,代码来源:UsersController.php
示例8: setUp
protected function setUp()
{
$_SERVER['REQUEST_URI'] = 'index.php';
parent::setUp();
$this->controllerSite = \Yii::$app->createControllerByID('site');
$user = new Users();
$user->username = $user->password = 'root';
$user->save();
}
开发者ID:yurii-github,项目名称:yii2-mylib,代码行数:9,代码来源:AuthenticationTest.php
示例9: reg
public function reg()
{
$user = new Users();
$user->username = $this->username;
$user->setPassword($this->password);
$user->generateAuthKey();
$user->save();
return $user;
}
开发者ID:eropkinvitaliy,项目名称:tech-admin,代码行数:9,代码来源:RegForm.php
示例10: actionRegister
public function actionRegister()
{
$model = new Users();
$model->load(Yii::$app->request->post());
if ($model->validate()) {
$model->save();
return $this->render('confirm', ['model' => $model]);
}
return $this->render('register', ['model' => $model]);
}
开发者ID:smackmybitchup,项目名称:yii2project,代码行数:10,代码来源:JopaController.php
示例11: actionIndex
public function actionIndex()
{
$model = new app\models\Users();
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
// form inputs are valid, do something here
return;
}
}
return $this->render('form1', ['model' => $model]);
}
开发者ID:fran242,项目名称:Yii2-2,代码行数:11,代码来源:Form1Controller.php
示例12: actionRegister
public function actionRegister()
{
$model = new Users();
$result = ['model' => $model];
if (\Yii::$app->request->isPost) {
$post = \Yii::$app->request->post();
if ($model->load($post) && $model->validate()) {
echo '注册成功';
}
}
return $this->render('register', $result);
}
开发者ID:xiaohongyang,项目名称:yii_shop,代码行数:12,代码来源:PublicController.php
示例13: test_validates
public function test_validates()
{
$user = new Users();
$user->username = 'yurii';
$user->password = 'pass';
$user->access_token = 'token';
$user->save();
/* @var $user_db Users */
$user_db = Users::getUserByUsername('yurii');
$this->assertTrue($user_db->validatePassword('pass'));
$this->assertTrue($user_db->validateAuthKey($user->auth_key));
}
开发者ID:yurii-github,项目名称:yii2-mylib,代码行数:12,代码来源:UsersTest.php
示例14: beforeSave
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
$adminUserModel = new Users();
$adminUserModel->setPassword($this->password_hash);
//print_r($adminUserModel->password_hash);exit();
$this->password_hash = $adminUserModel->password_hash;
return true;
} else {
return false;
}
}
开发者ID:ewwgit,项目名称:eptri,代码行数:12,代码来源:AdminMaster.php
示例15: register
public function register()
{
if (!$this->validate()) {
return false;
}
$user = new Users();
$user->login = $this->login;
$user->password_hash = Yii::$app->security->generatePasswordHash($this->password);
$user->save();
Yii::$app->user->login(User::findByUsername($this->login), 3600 * 24 * 30);
return true;
}
开发者ID:andreyshade,项目名称:manage-users,代码行数:12,代码来源:RegistrationForm.php
示例16: store
/**
* Store a newly created resource in storage.
* POST
* @return Response
*/
public function store()
{
$Users = new Users();
$Users->first_name = 'Michael';
$Users->last_name = 'Pierre';
$Users->age = '31';
$Users->city = 'Orlando';
$Users->state = 'Florida';
$Users->country = 'USA';
$Users->about = 'Cool Dude';
$Users->save();
return Users::where('uid', $Users->id)->get();
}
开发者ID:mikepierre,项目名称:social-profile-api,代码行数:18,代码来源:UsersController.php
示例17: reg
public function reg()
{
$user = new Users();
$user->family = $this->family;
$user->name = $this->name;
$user->father = $this->father;
$user->login = $this->login;
$user->setPassword($this->password);
$user->email = $this->email;
$user->phone = $this->phone;
//$user->generateAuthKey();
return $user->save() ? $user : null;
}
开发者ID:pozdny,项目名称:hunter.dev,代码行数:13,代码来源:RegForm.php
示例18: actionAuthenticate
public function actionAuthenticate()
{
$request = Yii::$app->request;
$username = $request->post('username');
$user = Users::findByUsername($username);
// Just create the user if not found
if (!$user) {
$user = new Users();
$user->username = $username;
$user->save();
}
echo json_encode(['auth' => $user->getId() ? true : false, 'id' => $user->id, 'username' => $user->username]);
}
开发者ID:atymchuk,项目名称:test-skyeng,代码行数:13,代码来源:AuthController.php
示例19: signup
public function signup()
{
if ($this->validate()) {
$users = new Users();
$users->name = $this->name;
$users->email = $this->email;
$users->status = $this->status;
$users->setPassword($this->password);
$users->generateAuthKey();
return $users->save() ? $users : null;
}
return null;
}
开发者ID:shapik2004,项目名称:artem,代码行数:13,代码来源:UserForm.php
示例20: actionTest
public function actionTest()
{
$users = [];
$musers = [];
for ($i = 0; $i < 5; $i++) {
$no = str_pad($i + 1, 5, 0, STR_PAD_LEFT);
$u = ['user_name' => 'user' . $no, 'mobile' => 'mobile' . $no, 'idcard' => 'idcard' . $no, 'create_time' => time()];
$user = new Users();
$user->attributes = $u;
$user->save();
$users[] = $user;
}
//$user = Users::loadMultiple($musers,$users);
var_dump($users);
}
开发者ID:864051749,项目名称:campus,代码行数:15,代码来源:SiteController.php
注:本文中的app\models\Users类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论