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


PHP User::load方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         // print_r($_POST);
         // die();
         $pass = Yii::$app->security->generatePasswordHash($_POST['User']['password']);
         $model->password_hash = $pass;
         $content = '
                 <center><img src="http://i.imgur.com/rkxzCKf.png"/></center><br/>
                 <h4 align="center">Sekolah Tinggi Terpadu Nurul Fikri ' . date('Y') . '</h4>
                 <hr/>
                 <p>Yth ' . $model->username . ',<br/>  
                 Dengan ini kami sampaikan password telah direset  sebagai berikut:<br/> 
                 Username : ' . $model->username . ' <br/>
                 Password :<b>' . $_POST['User']['password'] . '</b><br/>
                 Mohon lakukan penggantian password Anda setelah melakukan login. <hr/>
                 <h5 align="center">Developer By Hendra Aditya Wijaya Mentor Ilham Malik Ibrahim' . date('Y') . '</h5><br/>';
         Yii::$app->mailer->compose("@common/mail/layouts/html", ["content" => $content])->setTo($_POST['User']['email'])->setFrom([$_POST['User']['email'] => 'Aplikasi Simpel Bapeten'])->setSubject('Ubah Kata Sandi')->setTextBody($_POST['User']['password'])->send();
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
开发者ID:jigunk,项目名称:yudisium,代码行数:30,代码来源:UserController.php

示例2: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:komsin,项目名称:yii,代码行数:14,代码来源:UserController.php

示例3: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User(['scenario' => 'admin-create']);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->authManager->assign(Yii::$app->authManager->getRole($model->role), $model->id);
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:clh021,项目名称:yii2cms,代码行数:15,代码来源:UserController.php

示例4: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     //if(!Yii::$app->user->can('createUser')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth'));
     $model = new User(['scenario' => 'admin-create']);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //Yii::$app->authManager->assign(Yii::$app->authManager->getRole($model->role), $model->id);
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:CTaiDeng,项目名称:funshop,代码行数:16,代码来源:UserController.php

示例5: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         // Yii::$app->Controllers->activity_user("[CREATE COS]");
         Yii::$app->Controllers->historyUserWithData($model);
         echo 1;
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
 }
开发者ID:budipratama,项目名称:admin_lte,代码行数:16,代码来源:UserController.php

示例6: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     if ($model->load(Yii::$app->request->post())) {
         $model->auth_key = Yii::$app->security->generateRandomString();
         $model->password_hash = Yii::$app->security->generatePasswordHash($model->newpass);
         $model->password_reset_token = NULL;
         $model->save();
         $this->actionApprole($model->id, 'user');
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'admin' => true]);
     }
 }
开发者ID:Griff19,项目名称:it_base,代码行数:19,代码来源:UserController.php

示例7: actionCreate

 /**
  * 创建用户
  *
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     if ($model->load(Yii::$app->request->post())) {
         $model->setPassword('123456');
         $model->generateAuthKey();
         //$model->signup();
         $ret = $model->save();
         if ($ret) {
             return $this->redirect(['index']);
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:xishuophp,项目名称:vipoa,代码行数:19,代码来源:UserController.php

示例8: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         if ($model->save()) {
             $userdata = new WooUserData();
             $userdata->user_id = $model->id;
             $userdata->user_name = "Unset";
             $userdata->user_lastname = "Unset";
             $model->link("woouserdata", $userdata);
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:bolom009,项目名称:Yii2-API_RESful-CRUD-Relations,代码行数:22,代码来源:UserController.php

示例9: create

 /**
  * function ::create ($data)
  */
 public static function create($data)
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = new User();
     if ($model->load($data)) {
         if ($log = new UserLog()) {
             $log->username = $username;
             $log->action = "Create";
             $log->object_class = "User";
             $log->created_at = $now;
             $log->is_success = 0;
             $log->save();
         }
         $model->created_at = $now;
         $model->dob = strtotime($model->dob);
         do {
             $path = FileUtils::generatePath($now);
         } while (file_exists(Yii::$app->params['images_folder'] . $path));
         $model->image_path = $path;
         $targetFolder = Yii::$app->params['images_folder'] . $model->image_path;
         $targetUrl = Yii::$app->params['images_url'] . $model->image_path;
         if (!empty($data['user-image'])) {
             $copyResult = FileUtils::copyImage(['imageName' => $model->image, 'fromFolder' => Yii::$app->params['uploads_folder'], 'toFolder' => $targetFolder, 'resize' => [[120, 120], [200, 200]], 'resizeType' => 2, 'removeInputImage' => true]);
             if ($copyResult['success']) {
                 $model->image = $copyResult['imageName'];
             }
         }
         // User class
         $model->generateAuthKey();
         $model->setPassword($model->password);
         if ($model->save()) {
             if ($log) {
                 $log->object_pk = $model->id;
                 $log->is_success = 1;
                 $log->save();
             }
             return $model;
         }
         $model->getErrors();
         return $model;
     }
     return false;
 }
开发者ID:quyettvq,项目名称:luspel,代码行数:47,代码来源:User.php

示例10: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     $model->scenario = 'create';
     if ($model->load(Yii::$app->request->post())) {
         $image = $model->uploadImage();
         if ($model->save()) {
             // upload only if valid uploaded file instance found
             if ($image !== false) {
                 $path = $model->getImageFile();
                 $image->saveAs($path);
             }
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:iwansusanto,项目名称:jurnalrumah,代码行数:24,代码来源:UserController.php

示例11: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can('createUser')) {
         $model = new User();
         if ($model->load(Yii::$app->request->post())) {
             $lastInsertID = $model->getPrimaryKey();
             $model->id = $lastInsertID;
             $model->password_hash = Yii::$app->security->generatePasswordHash($_POST['User']['password_hash']);
             $model->created_at = time();
             $model->updated_at = time();
             $model->save(false);
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }
开发者ID:ASzczesna,项目名称:LemiRestaurant,代码行数:24,代码来源:UserController.php

示例12: actionCreate

 public function actionCreate()
 {
     $error = '';
     $model = new User();
     $data['_csrf'] = Yii::$app->request->post('_csrf', '');
     $data['User'] = Yii::$app->request->post();
     if (isset($data['User']['submit'])) {
         $error .= empty($data['User']['username']) ? '<p> - Username không được bỏ trống </p>' : '';
         $error .= empty($data['User']['full_name']) ? '<p> - Full_name không được bỏ trống </p>' : '';
         $error .= empty($data['User']['password']) ? '<p> - Password không được bỏ trống </p>' : '';
         $error .= empty($data['User']['re-password']) ? '<p> - Re-password không được bỏ trống </p>' : '';
         $error .= empty($data['User']['email']) ? '<p> - Email không được bỏ trống </p>' : '';
         if (!empty($data['User']['password']) && !empty($data['User']['re-password'])) {
             $error .= $data['User']['password'] != $data['User']['re-password'] ? '<p> - Password nhập lại không chính xác' : '';
         }
         $checkUsername = $model->findByUsername($data['User']['username']);
         $checkEmail = $model->findByEmail($data['User']['email']);
         $error .= !empty($checkUsername) ? '<p> - Username đã tồn tại </p>' : '';
         $error .= !empty($checkEmail) ? '<p> - Email đã được sử dụng </p>' : '';
         $data['User']['create_date'] = time();
         $data['User']['user_create'] = \Yii::$app->user->id;
         $data['User']['password'] = md5(md5($data['User']['password']) . 'cinefun2015');
     }
     if (empty($error) && $model->load($data) && $model->save()) {
         $user = $model->findByUsername($data['User']['username']);
         $id = $user->id;
         $auth = new AuthAssignment();
         $dataAuth['_csrf'] = $data['_csrf'];
         $dataAuth['AuthAssignment']['item_name'] = $data['User']['group'];
         $dataAuth['AuthAssignment']['user_id'] = $id;
         $dataAuth['AuthAssignment']['created_at'] = time();
         $auth->load($dataAuth);
         $auth->save();
         return $this->redirect(['index']);
     } else {
         $group = $model->getGroup();
         return $this->render('create', ['group' => $group, 'error' => $error]);
     }
 }
开发者ID:Thinlt,项目名称:hadasai,代码行数:39,代码来源:UserController.php

示例13: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     $pi = new PersonalInformation();
     if ($pi->load(Yii::$app->request->post())) {
         /*print_r($this->pi_name);
           die();*/
         /*$pi = new PersonalInformation();
           $pi->load(Yii::$app->request->post());*/
         $pi->pi_name = $pi->pi_name;
         $pi->save();
         if ($pi->save() == 1) {
             // this is inserted user id
             //$model = new User();
             $model->load(Yii::$app->request->post());
             /*print_r($model);
               //print_r($pi);
               die();*/
             $userID = $pi->pi_id;
             $model->pi_id = $userID;
             $model->username = $model->username;
             $model->status = $model->status;
             $model->online_status = "0";
             $model->created_at = time();
             $model->updated_at = time();
             $model->auth_key = "vBZS7KGrvXesyOkgQhGYCY5KCZi6st5g";
             $model->password_hash = "\$2y\$13\$4cRqqw0nmEj5.NJRcJYaE.YUSh9DJaQsSpLM3OCicXckrCPoAgWYC";
             $model->save();
             /*print_r($model->getErrors());
               die();*/
         }
         return $this->redirect(['index', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:NeroJz,项目名称:admbackend,代码行数:41,代码来源:UserController.php

示例14: actionReset

 /**
  * Action to reset password from admin.
  * @param int $id
  * @return mixed
  */
 public function actionReset($id)
 {
     $model1 = $this->findModel($id);
     $model = new User();
     if ($model->load(Yii::$app->request->post())) {
         $password = $_POST['password'];
         $hash = Yii::$app->getSecurity()->generatePasswordHash($password);
         $model->password_hash = $hash;
         $sql = "update user set password_hash='{$hash}' where id='{$id}'";
         $res = Yii::$app->db->createCommand($sql)->execute();
         Yii::$app->session->setFlash('success', 'Password Sucessfully Reset');
     }
     return $this->render('reset', ['model' => $this->findModel($id), 'model1' => $model]);
 }
开发者ID:Rakeshdrupal,项目名称:yiifirstliveproject,代码行数:19,代码来源:UserController.php


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