Beispiel #1
0
 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);
         $Post->reserved_by = null;
         break;
     }
     Response::fail("This {$type} has already been reserved by " . Users::get($Post->reserved_by)->getProfileLink(), array('li' => Posts::getLi($Post)));
     break;
 case 'lock':
     if (empty($Post->deviation_id)) {
         Response::fail("Only finished {$type}s can be locked");
     }
     CoreUtils::checkDeviationInClub($Post->deviation_id);
     if (!$Database->where('id', $Post->id)->update("{$type}s", array('lock' => true))) {
         Response::dbError();
     }
     $postdata = Posts::approve($type, $Post->id, !$isUserReserver ? $Post->reserved_by : null);
     $Post->lock = true;
     $response = array('message' => "The image appears to be in the group gallery and as such it is now marked as approved.", 'li' => Posts::getLi($Post));
     if ($isUserReserver) {
         $response['message'] .= " Thank you for your contribution!<div class='align-center'><span class='sideways-smiley-face'>;)</span></div>";
     }
     Response::done($response);
     break;
 case 'unlock':
     if (Permission::insufficient('staff')) {
         Response::fail();
     }
Beispiel #2
0
 $data['label'] = $label;
 $notes = (new Input('notes', 'text', array(Input::IS_OPTIONAL => true, Input::IN_RANGE => $creating || $Appearance['id'] !== 0 ? [null, 1000] : null, Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_RANGE => 'Appearance notes cannot be longer than @max characters'))))->out();
 if (isset($notes)) {
     CoreUtils::checkStringValidity($notes, "Appearance notes", INVERSE_PRINTABLE_ASCII_PATTERN);
     $notes = CoreUtils::sanitizeHtml($notes);
     if ($creating || $notes !== $Appearance['notes']) {
         $data['notes'] = $notes;
     }
 } else {
     $data['notes'] = null;
 }
 $cm_favme = (new Input('cm_favme', 'string', array(Input::IS_OPTIONAL => true)))->out();
 if (isset($cm_favme)) {
     try {
         $Image = new ImageProvider($cm_favme, array('fav.me', 'dA'));
         CoreUtils::checkDeviationInClub($Image->id, true);
         $data['cm_favme'] = $Image->id;
     } catch (MismatchedProviderException $e) {
         Response::fail('The vector must be on DeviantArt, ' . $e->getActualProvider() . ' links are not allowed');
     } catch (Exception $e) {
         Response::fail("Cutie Mark link issue: " . $e->getMessage());
     }
     $cm_dir = (new Input('cm_dir', function ($value) {
         if ($value !== 'th' && $value !== 'ht') {
             return Input::ERROR_INVALID;
         }
     }, array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'Cutie mark orientation must be set if a link is provided', Input::ERROR_INVALID => 'Cutie mark orientation (@value) is invalid'))))->out();
     $cm_dir = $cm_dir === 'ht' ? CM_DIR_HEAD_TO_TAIL : CM_DIR_TAIL_TO_HEAD;
     if ($creating || $Appearance['cm_dir'] !== $cm_dir) {
         $data['cm_dir'] = $cm_dir;
     }