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


PHP User::findByPk方法代码示例

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


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

示例1: actionDelete

 public function actionDelete()
 {
     $models = User::findAllByPk($_POST['User']);
     $number = 0;
     $names = [];
     foreach ($models as $model) {
         $names[] = $model->name;
         $number += (int) $model->delete();
     }
     User::findByPk(WebApp::get()->user()->id)->logAction(UserHistory::ACTION_ADMINDELETE, "Users: \n", implode("\n   ", $names));
     if (1 !== $number) {
         Messages::get()->success("User deleted!");
     } else {
         Messages::get()->success("{$number} users deleted!");
     }
     $this->getRequest()->goBack();
 }
开发者ID:mpf-soft,项目名称:app-basic,代码行数:17,代码来源:Users.php

示例2: actionIndex

 public function actionIndex()
 {
     $user = User::findByPk($this->container->user->getID(), $this->container);
     if (!$user) {
         $this->redirect('/logout');
     }
     /** @var array $setup */
     if ($setup = $this->container->request->post('Setup')) {
         if (!empty($setup['pass'])) {
             $user->pass = md5($setup['pass']);
         }
         if (!empty($setup['fio'])) {
             $user->fio = $setup['fio'];
         }
         $user->save();
     }
     $v = new View($this->container);
     $v->addParameter('user', $user);
     return $v;
 }
开发者ID:dp-ifacesoft,项目名称:micro,代码行数:20,代码来源:ProfileController.php

示例3: actionDeleteUser

 public function actionDeleteUser($id)
 {
     User::findByPk($id)->delete();
     $this->redirect('/admin/users');
 }
开发者ID:gembux2012,项目名称:ksp.dem,代码行数:5,代码来源:Admin.php

示例4: checkGoogle

 public function checkGoogle($force = false)
 {
     if (is_null($client = $this->getGoogleClient($force))) {
         return null;
     }
     if (!isset($_GET['code']) || isset($_GET['state'])) {
         return null;
     }
     $this->debug($_GET['code']);
     $client->authenticate($_GET['code']);
     $user = $this->googleOauth->userinfo->get();
     $details = ['id' => $user['id'], 'name' => filter_var($user['name'], FILTER_SANITIZE_SPECIAL_CHARS), 'email' => filter_var($user['email'], FILTER_SANITIZE_EMAIL), 'profile_url' => filter_var($user['link'], FILTER_VALIDATE_URL), 'image_url' => filter_var($user['picture'], FILTER_VALIDATE_URL)];
     if ($force) {
         $user = User::findByPk($this->id);
         $user->google_id = $details['id'];
         UserConfig::set('GOOGLE_NAME', $details['name']);
         UserConfig::set('GOOGLE_EMAIL', $details['email']);
         UserConfig::set('GOOGLE_PROFILE', $details['profile_url']);
         UserConfig::set('GOOGLE_IMAGE', $details['image_url']);
         return $user->save(false);
     }
     if (!is_null($user = User::findByAttributes(['google_id' => $details['id']]))) {
         return $user;
     }
     return User::googleRegister($details);
 }
开发者ID:mpf-soft,项目名称:app-basic,代码行数:26,代码来源:ActiveUser.php

示例5: getRules

 public static function getRules()
 {
     return array(array('name, email, comment', 'required, safe', 'on' => 'admin-insert'), array('name, email, newPassword, repeatedPassword', 'required, safe', 'on' => 'register'), array('email, newEmail', 'unique, email', 'column' => 'email', 'on' => 'register, change-email'), array('name', 'safe', 'on' => 'user-edit'), array('name, newPassword, repeatedPassword', 'safe, required', 'on' => 'register-auto'), array('name, email, groupIDs, status, title_id', 'safe', 'on' => 'admin-edit'), array('name, password', 'required, safe', 'on' => 'login'), array('name', 'unique', 'on' => 'register'), array('newEmail, oldPassword', 'required', 'on' => 'change-email'), array('email', 'required', 'on' => 'forgot-password'), array('oldPassword, newPassword, repeatedPassword', 'required', 'on' => 'change-password'), array('repeatedPassword', 'compare', 'column' => 'newPassword'), array('oldPassword', function (Validator $validator, $field, $options, $label, $message) {
         // check if old password is correct
         if (User::hashPassword($validator->getValue($field)) == User::findByPk(WebApp::get()->user()->id)->password) {
             return true;
         }
         throw new \Exception($message ? $message : $validator->translate($label . ' is wrong!'));
     }, 'on' => 'change-password, change-email'));
 }
开发者ID:mpf-soft,项目名称:app-basic,代码行数:10,代码来源:User.php

示例6: actionValidateEmail

 /**
  * Sends a request to User to validate new email
  * @param $code
  */
 public function actionValidateEmail($code)
 {
     list($id, $code) = explode(".", $code, 2);
     $user = \app\models\User::findByPk($id);
     if (!$user) {
         $this->assign('error', true);
         return;
     }
     if ($user->validateEmail($code, true)) {
         $this->assign('success', true);
         $this->assign('error', false);
         return;
     }
     $this->assign('error', true);
 }
开发者ID:mpf-soft,项目名称:app-basic,代码行数:19,代码来源:User.php


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