if (!Permission::sufficient('staff')) { Response::fail(); } $ids = (new Input('ids', 'int[]', array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'List of deviation IDs is missing', Input::ERROR_INVALID => 'List of deviation IDs (@value) is invalid'))))->out(); $list = ""; foreach ($ids as $id) { $list .= "'d" . base_convert($id, 10, 36) . "',"; } $list = rtrim($list, ','); $Posts = $Database->rawQuery("SELECT 'request' as type, id, deviation_id FROM requests WHERE deviation_id IN ({$list}) && lock = false\n\t\tUNION ALL\n\t\tSELECT 'reservation' as type, id, deviation_id FROM reservations WHERE deviation_id IN ({$list}) && lock = false"); if (empty($Posts)) { Response::success('There were no posts in need of marking as approved'); } $approved = 0; foreach ($Posts as $p) { if (CoreUtils::isDeviationInClub($p['deviation_id']) !== true) { continue; } Posts::approve($p['type'], $p['id']); $approved++; } if ($approved === 0) { Response::success('There were no posts in need of marking as approved'); } Response::success('Marked ' . CoreUtils::makePlural('post', $approved, PREPEND_NUMBER) . ' as approved. To see which ones, check the <a href="/admin/logs/1?type=post_lock&by=you">list of posts you\'ve approved</a>.', array('reload' => true)); } else { if ($data === 'add-reservation') { if (!Permission::sufficient('staff')) { Response::fail(); } $_POST['allow_overwrite_reserver'] = true;
/** * Checks the image which allows a request to be finished * * @param string|null $ReserverID * * @return array */ static function checkRequestFinishingImage($ReserverID = null) { global $Database; $deviation = (new Input('deviation', 'string', array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'Please specify a deviation URL'))))->out(); try { $Image = new ImageProvider($deviation, array('fav.me', 'dA')); foreach (Posts::$TYPES as $what) { if ($Database->where('deviation_id', $Image->id)->has("{$what}s")) { Response::fail("This exact deviation has already been marked as the finished version of a different {$what}"); } } $return = array('deviation_id' => $Image->id); $Deviation = DeviantArt::getCachedSubmission($Image->id); if (!empty($Deviation['author'])) { $Author = Users::get($Deviation['author'], 'name'); if (!empty($Author)) { if (!isset($_POST['allow_overwrite_reserver']) && !empty($ReserverID) && $Author->id !== $ReserverID) { global $currentUser; $sameUser = $currentUser->id === $ReserverID; $person = $sameUser ? 'you' : 'the user who reserved this post'; Response::fail("You've linked to an image which was not submitted by {$person}. If this was intentional, press Continue to proceed with marking the post finished <b>but</b> note that it will make {$Author->name} the new reserver." . ($sameUser ? "<br><br>This means that you'll no longer be able to interact with this post until {$Author->name} or an administrator cancels the reservation on it." : ''), array('retry' => true)); } $return['reserved_by'] = $Author->id; } } if (CoreUtils::isDeviationInClub($return['deviation_id']) === true) { $return['lock'] = true; } return $return; } catch (MismatchedProviderException $e) { Response::fail('The finished vector must be uploaded to DeviantArt, ' . $e->getActualProvider() . ' links are not allowed'); } catch (\Exception $e) { Response::fail($e->getMessage()); } }