Response::fail('This reservation was added directly and cannot be marked unfinished. To remove it, check the unbind from user checkbox.'); } } $update['deviation_id'] = null; $update['finished_at'] = null; if (!$Database->where('id', $Post->id)->update("{$type}s", $update)) { Response::dbError(); } Response::done(); break; case 'finish': if (!$isUserReserver && Permission::insufficient('staff')) { Response::fail(); } $update = Posts::checkRequestFinishingImage($Post->reserved_by); $finished_at = Posts::validateFinishedAt(); $update['finished_at'] = isset($finished_at) ? date('c', $finished_at) : date('c'); 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');