Beispiel #1
0
 /**
  * Approves a specific post and optionally notifies it's author
  *
  * @param string $type         request/reservation
  * @param int    $id           post id
  * @param string $notifyUserID id of user to notify
  *
  * @return array
  */
 static function approve($type, $id, $notifyUserID = null)
 {
     global $Database;
     if (!$Database->where('id', $id)->update("{$type}s", array('lock' => true))) {
         Response::dbError();
     }
     $postdata = array('type' => $type, 'id' => $id);
     Logs::action('post_lock', $postdata);
     if (!empty($notifyUserID)) {
         Notifications::send($notifyUserID, 'post-approved', $postdata);
     }
     return $postdata;
 }
Beispiel #2
0
             if (!$Database->where('id', $Post->id)->update("{$type}s", $update)) {
                 Response::dbError();
             }
             $postdata = array('type' => $type, 'id' => $Post->id);
             $message = '';
             if (isset($update['lock'])) {
                 $message .= "<p>The image appears to be in the group gallery already, so we marked it as approved.</p>";
                 Logs::action('post_lock', $postdata);
                 if ($Post->reserved_by !== $currentUser->id) {
                     Notifications::send($Post->reserved_by, 'post-approved', $postdata);
                 }
             }
             if ($type === 'request') {
                 $u = Users::get($Post->requested_by, 'id', 'name,id');
                 if (!empty($u) && $Post->requested_by !== $currentUser->id) {
                     $notifSent = Notifications::send($u->id, 'post-finished', $postdata);
                     $message .= "<p><strong>{$u->name}</strong> " . ($notifSent === 0 ? 'has been notified' : 'will receive a notification shortly') . '.' . (is_string($notifSent) ? "</p><div class='notice fail'><strong>Error:</strong> {$notifSent}" : '') . "</div>";
                 }
             }
             if (!empty($message)) {
                 Response::success($message);
             }
             Response::done();
             break;
     }
 } else {
     if ($action === 'unreserve') {
         Response::done(array('li' => Posts::getLi($Post)));
     } else {
         if ($action === 'finish') {
             Response::fail("This {$type} has not been reserved by anypony yet");
Beispiel #3
0
            switch ($Notif['type']) {
                case "post-passon":
                    $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s");
                    if (empty($Post)) {
                        Posts::clearTransferAttempts($Post, $data['type'], 'del');
                        Response::fail("The {$data['type']} doesn't exist or has been deleted");
                    }
                    if ($read_action === 'true') {
                        if ($Post['reserved_by'] !== $currentUser->id) {
                            Posts::clearTransferAttempts($Post, $data['type'], 'perm', null, $currentUser->id);
                            Response::fail('You are not allowed to transfer this reservation');
                        }
                        Notifications::safeMarkRead($Notif['id'], $read_action);
                        Notifications::send($data['user'], "post-passallow", array('id' => $data['id'], 'type' => $data['type'], 'by' => $currentUser->id));
                        $Database->where('id', $data['id'])->update("{$data['type']}s", array('reserved_by' => $data['user'], 'reserved_at' => date('c')));
                        Posts::clearTransferAttempts($Post, $data['type'], 'deny');
                        Logs::action('res_transfer', array('id' => $data['id'], 'type' => $data['type'], 'to' => $data['user']));
                    } else {
                        Notifications::safeMarkRead($Notif['id'], $read_action);
                        Notifications::send($data['user'], "post-passdeny", array('id' => $data['id'], 'type' => $data['type'], 'by' => $currentUser->id));
                    }
                    Response::done();
                    break;
                default:
                    Notifications::safeMarkRead($Notif['id'], $read_action);
            }
        } else {
            Notifications::safeMarkRead($Notif['id']);
        }
        Response::done();
}