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


PHP Users::findFirst方法代码示例

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


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

示例1: accessTokenAction

 /**
  * @return \Phalcon\Http\ResponseInterface
  */
 public function accessTokenAction()
 {
     $oauth = new OAuth($this->config->github);
     $response = $oauth->accessToken();
     if (is_array($response)) {
         if (isset($response['error'])) {
             $this->flashSession->error('Github: ' . $response['error']);
             return $this->indexRedirect();
         }
         $githubUser = new GithubUsers($response['access_token']);
         if (!$githubUser->isValid()) {
             $this->flashSession->error('Invalid Github response. Please try again');
             return $this->indexRedirect();
         }
         $userName = $githubUser->getLogin();
         if (empty($userName)) {
             $this->flashSession->error('Invalid Github response. Please try again');
             return $this->indexRedirect();
         }
         /**
          * Edit/Create the user
          */
         $user = ForumUsers::findFirst(['conditions' => 'login = :login:', 'bind' => ['login' => $userName]]);
         if ($user == false) {
             $user = new ForumUsers();
             $user->token_type = $response['token_type'];
             $user->access_token = $response['access_token'];
         }
         if ($user->banned == 'Y') {
             $this->flashSession->error('You have been banned from the forum.');
             return $this->indexRedirect();
         }
         //$user = ForumUsers::findFirst();
         // Update session id
         session_regenerate_id(true);
         /**
          * Update the user information
          */
         $user->name = $githubUser->getName();
         $user->login = $githubUser->getLogin();
         $email = $githubUser->getEmail();
         if (is_string($email)) {
             $user->email = $email;
         } else {
             if (is_array($email)) {
                 if (isset($email['email'])) {
                     $user->email = $email['email'];
                 }
             }
         }
         $user->gravatar_id = $githubUser->getGravatarId();
         if (!$user->gravatar_id) {
             if ($user->email && strpos($user->email, '@') !== false) {
                 $user->gravatar_id = md5(strtolower($user->email));
             }
         }
         $user->increaseKarma(Karma::LOGIN);
         if (!$user->save()) {
             foreach ($user->getMessages() as $message) {
                 $this->flashSession->error((string) $message);
                 return $this->indexRedirect();
             }
         }
         /**
          * Store the user data in session
          */
         $this->session->set('identity', $user->id);
         $this->session->set('identity-name', $user->name);
         $this->session->set('identity-gravatar', $user->gravatar_id);
         $this->session->set('identity-timezone', $user->timezone);
         $this->session->set('identity-theme', $user->theme);
         $this->session->set('identity-moderator', $user->moderator);
         if ($user->getOperationMade() == Model::OP_CREATE) {
             $this->flashSession->success('Welcome ' . $user->name);
         } else {
             $this->flashSession->success('Welcome back ' . $user->name);
         }
         if ($user->email && strpos($user->email, '@') !== false) {
             if (strpos($user->email, '@users.noreply.github.com') !== false) {
                 $messageNotAlllow = 'Your current e-mail: ' . $this->escaper->escapeHtml($user->email) . ' does not allow us to send you e-mail notifications';
                 $this->flashSession->notice($messageNotAlllow);
             }
         } else {
             $messageCantSend = 'We weren\'t able to obtain your e-mail address' . ' from Github, we can\'t send you e-mail notifications';
             $this->flashSession->notice($messageCantSend);
         }
         if ($user->getOperationMade() != Model::OP_CREATE) {
             /**
              * Show a notification to users that have e-mail bounces
              */
             $parametersBounces = array('email = ?0 AND reported = "N"', 'bind' => array($user->email));
             $bounces = NotificationsBounces::find($parametersBounces);
             if (count($bounces)) {
                 foreach ($bounces as $bounce) {
                     $bounce->reported = 'Y';
                     $bounce->save();
                 }
//.........这里部分代码省略.........
开发者ID:zphalcon,项目名称:phalcon-tip,代码行数:101,代码来源:SessionController.php


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