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


PHP Users::getOperationMade方法代码示例

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


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

示例1: accessTokenAction

 /**
  * @return \Phalcon\Http\ResponseInterface
  */
 public function accessTokenAction()
 {
     $oauth = new OAuth($this->config->get('github', new Config()));
     $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();
         }
         /**
          * Edit/Create the user
          */
         $user = ForumUsers::findFirstByAccessToken($response['access_token']);
         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();
         }
         // 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;
         } elseif (is_array($email) && isset($email['email'])) {
             $user->email = $email['email'];
         }
         // In any case user has Gravatar ID even if he has no email
         $user->gravatar_id = $this->gravatar->getEmailHash($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-email', $user->email);
         $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) {
             if (false !== strpos($user->email, '@users.noreply.github.com')) {
                 $messageNotAllow = sprintf('Your current e-mail %s does not allow us to send you e-mail notifications', $this->escaper->escapeHtml($user->email));
                 $this->flashSession->notice($messageNotAllow);
             }
         } 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 = ['email = ?0 AND reported = "N"', 'bind' => [$user->email]];
             $bounces = NotificationsBounces::find($parametersBounces);
             if (count($bounces)) {
                 foreach ($bounces as $bounce) {
                     $bounce->reported = 'Y';
                     $bounce->save();
                 }
                 $messageFailed = 'We have failed to deliver you some email notifications,' . ' this might be caused by an invalid email associated to your Github account or ' . 'its mail server is rejecting our emails. Your current e-mail is: ' . $this->escaper->escapeHtml($user->email);
                 $this->flashSession->notice($messageFailed);
                 $parametersBouncesMax = ['email = ?0 AND created_at >= ?1', 'bind' => [$user->email, time() - 86400 * 7]];
                 $bounces = NotificationsBounces::find($parametersBouncesMax);
                 if (count($bounces) >= NotificationsBounces::MAX_BOUNCES) {
                     $messageRepeat = 'Due to a repeated number of email bounces we have disabled email ' . 'notifications for your email. You can re-enable them in your settings';
                     $this->flashSession->notice($messageRepeat);
                     $user->notifications = 'N';
                     $user->save();
                 }
             }
             /**
              * Show a notification to users that haven't spend their votes
//.........这里部分代码省略.........
开发者ID:huoybb,项目名称:forum,代码行数:101,代码来源:SessionController.php


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