if (!isset($_POST['state']) || $_POST['state'] == '') { throw new fValidationException('Status field is required.'); } $newStatus = filter_var($_POST['state'], FILTER_SANITIZE_STRING); $reason = filter_var($_POST['reason'], FILTER_SANITIZE_STRING); if ($newStatus != $project->getState() && $project->canTransitionStates($project->getState(), $newStatus)) { $project->setState($newStatus); $project->store(); if ($reason != '') { $reason = ' with the reason \'' . $reason . "'"; } // log the update $project->submitLog('Status changed to ' . $project->getState() . $reason, $user->getId()); if ($project->getState() != 'Archived') { // send to mailing list $project->submitMailingList('Status changed to ' . $project->getState() . $reason . " by " . htmlspecialchars($user->getFullName())); // inform the owner $project->submitEmailToOwner("Dear {$projectUser->getFullName()},<br/><br/>" . "This is an automatic email to let you know your project {$project->getName()} has been updated with status {$project->getState()}{$reason}.<br/><br/>" . "If you have any questions or concerns regarding this change you can discuss this with members on the <a href=\"{$project->getMailingListURL()}\">Mailing List</a>.<br/><br/>" . "Best,<br/>Monkeys in the machine"); } } fURL::redirect("/storage/list.php"); } catch (fValidationException $e) { echo $e->printMessage(); } catch (fSQLException $e) { echo '<div class="alert alert-danger">An unexpected error occurred, please try again later</div>'; } } ?> <?php if ($user->getId() == $project->getUserId() && ($project->getState() == 'Pending Approval' || $project->getState() == 'Unapproved')) {
} else { $auto = false; $logDetails = "Request updated"; $initial = false; } $project->setUpdatedDate(date('Y-m-d')); $project->setUserId($user->getId()); $project->store(); $project->submitLog($logDetails, $user->getId()); // post to Google Groups $projectUser = new User($project->getUserId()); $message = '<strong>' . $project->getName() . "</strong><br>\n" . "https://london.hackspace.org.uk/storage/" . $project->getId() . "<br>\n" . "by <a href=\"https://london.hackspace.org.uk/members/member.php?id=" . $project->getUserId() . "\">" . htmlspecialchars($projectUser->getFullName()) . "</a><br>\n" . $project->outputDates() . "<br>\n" . $project->outputDuration() . ' ' . $project->outputLocation() . "<br>\n<br>\n" . nl2br(stripslashes($project->getDescription())) . "<br>\n<br>\n"; if ($auto && !$project->isShortTerm()) { $message .= "<strong>***If no one replies to this topic the request will be automatically approved within " . $project->automaticApprovalDuration() . " days.***</strong>"; } $project->submitMailingList($message, $initial); // is this a short term request? If so automatically approve it if ($project->isShortTerm()) { $project->setState('Approved'); $project->store(); // log the update $logmsg = 'Short term storage detected, status automatically changed to ' . $project->getState(); $project->submitLog($logmsg, false); $project->submitMailingList($logmsg); } fURL::redirect("/storage/{$project->getId()}"); } catch (fValidationException $e) { echo $e->printMessage(); } catch (fSQLException $e) { echo '<div class="alert alert-danger">An unexpected error occurred, please try again later</div>'; }