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


PHP Posts::getTransferAttempts方法代码示例

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


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

示例1: array

         Response::fail($message, $data);
     }
     if ($reserved_by === $currentUser->id) {
         Response::fail("You've already reserved this {$type}");
     }
     if ($Post->isOverdue()) {
         $message = "This post was reserved " . Time::tag($Post->reserved_at) . " so anyone's free to reserve it now.";
         $checkIfUserCanReserve($message, $data, 'overdue');
         Response::fail($message, $data);
     }
     Users::reservationLimitExceeded();
     if (!$Post->isTransferable()) {
         Response::fail("This {$type} was reserved recently, please allow up to 5 days before asking for a transfer");
     }
     $ReserverLink = Users::get($reserved_by, 'id', 'name')->getProfileLink();
     $PreviousAttempts = Posts::getTransferAttempts($Post, $type, $currentUser->id, $reserved_by);
     if (!empty($PreviousAttempts[0]) && empty($PreviousAttempts[0]['read_at'])) {
         Response::fail("You already expressed your interest in this post to {$ReserverLink} " . Time::tag($PreviousAttempts[0]['sent_at']) . ', please wait for them to respond.');
     }
     $notifSent = Notifications::send($Post->reserved_by, 'post-passon', array('type' => $type, 'id' => $Post->id, 'user' => $currentUser->id));
     Response::success("A notification has been sent to {$ReserverLink}, please wait for them to react.<br>If they don't visit the site often, it'd be a good idea to send them a note asking him to consider your inquiry.");
 }
 $isUserReserver = $Post->reserved_by === $currentUser->id;
 if (!empty($Post->reserved_by)) {
     switch ($action) {
         case 'reserve':
             if ($isUserReserver) {
                 Response::fail("You've already reserved this {$type}", array('li' => Posts::getLi($Post)));
             }
             if ($Post->isOverdue()) {
                 $overdue = array('reserved_by' => $Post->reserved_by, 'reserved_at' => $Post->reserved_at);
开发者ID:ponydevs,项目名称:MLPVC-RR,代码行数:31,代码来源:post.php

示例2: clearTransferAttempts

 /**
  * @param Post        $Post
  * @param string      $type
  * @param string      $reason
  * @param string|null $sent_by
  * @param string|null $reserved_by
  */
 static function clearTransferAttempts(Post $Post, string $type, string $reason, string $sent_by = null, $reserved_by = null)
 {
     global $currentUser, $Database;
     if (empty(self::TRANSFER_ATTEMPT_CLEAR_REASONS[$reason])) {
         throw new \Exception("Invalid clear reason {$reason}");
     }
     $Database->where('read_at IS NULL');
     $TransferAttempts = Posts::getTransferAttempts($Post, $type, $sent_by, $reserved_by, 'id,data');
     if (!empty($TransferAttempts)) {
         $SentFor = array();
         foreach ($TransferAttempts as $n) {
             Notifications::safeMarkRead($n['id']);
             $data = JSON::decode($n['data']);
             if (!empty($SentFor[$data['user']][$reason]["{$data['type']}-{$data['id']}"])) {
                 continue;
             }
             Notifications::send($data['user'], "post-pass{$reason}", array('id' => $data['id'], 'type' => $data['type'], 'by' => $currentUser->id));
             $SentFor[$data['user']][$reason]["{$data['type']}-{$data['id']}"] = true;
         }
     }
 }
开发者ID:ponydevs,项目名称:MLPVC-RR,代码行数:28,代码来源:Posts.php


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