Path: blob/master/src/applications/calendar/controller/PhabricatorCalendarEventAvailabilityController.php
12256 views
<?php12final class PhabricatorCalendarEventAvailabilityController3extends PhabricatorCalendarController {45public function handleRequest(AphrontRequest $request) {6$viewer = $this->getViewer();7$id = $request->getURIData('id');89$event = id(new PhabricatorCalendarEventQuery())10->setViewer($viewer)11->withIDs(array($id))12->executeOne();13if (!$event) {14return new Aphront404Response();15}1617$response = $this->newImportedEventResponse($event);18if ($response) {19return $response;20}2122$cancel_uri = $event->getURI();2324if (!$event->getIsUserAttending($viewer->getPHID())) {25return $this->newDialog()26->setTitle(pht('Not Attending Event'))27->appendParagraph(28pht(29'You can not change your display availability for events you '.30'are not attending.'))31->addCancelButton($cancel_uri);32}3334// TODO: This endpoint currently only works via AJAX. It would be vaguely35// nice to provide a plain HTML version of the workflow where we return36// a dialog with a vanilla <select /> in it for cases where all the JS37// breaks.38$request->validateCSRF();3940$invitee = $event->getInviteeForPHID($viewer->getPHID());4142$map = PhabricatorCalendarEventInvitee::getAvailabilityMap();43$new_availability = $request->getURIData('availability');44if (isset($map[$new_availability])) {45$invitee46->setAvailability($new_availability)47->save();4849// Invalidate the availability cache.50$viewer->writeAvailabilityCache(array(), null);51}5253return id(new AphrontRedirectResponse())->setURI($cancel_uri);54}55}565758