diff --git a/resources/sql/autopatches/20161104.calendar.01.availability.sql b/resources/sql/autopatches/20161104.calendar.01.availability.sql new file mode 100644 index 0000000000..cb64339df2 --- /dev/null +++ b/resources/sql/autopatches/20161104.calendar.01.availability.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_calendar.calendar_eventinvitee + ADD availability VARCHAR(64) NOT NULL; diff --git a/resources/sql/autopatches/20161104.calendar.02.availdefault.sql b/resources/sql/autopatches/20161104.calendar.02.availdefault.sql new file mode 100644 index 0000000000..12a42f711a --- /dev/null +++ b/resources/sql/autopatches/20161104.calendar.02.availdefault.sql @@ -0,0 +1,3 @@ +UPDATE {$NAMESPACE}_calendar.calendar_eventinvitee + SET availability = 'default' + WHERE availability = ''; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 46069785a6..4c6fb41333 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2035,6 +2035,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarEvent' => 'applications/calendar/storage/PhabricatorCalendarEvent.php', 'PhabricatorCalendarEventAcceptTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventAcceptTransaction.php', 'PhabricatorCalendarEventAllDayTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventAllDayTransaction.php', + 'PhabricatorCalendarEventAvailabilityController' => 'applications/calendar/controller/PhabricatorCalendarEventAvailabilityController.php', 'PhabricatorCalendarEventCancelController' => 'applications/calendar/controller/PhabricatorCalendarEventCancelController.php', 'PhabricatorCalendarEventCancelTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventCancelTransaction.php', 'PhabricatorCalendarEventDateTransaction' => 'applications/calendar/xaction/PhabricatorCalendarEventDateTransaction.php', @@ -6881,6 +6882,7 @@ phutil_register_library_map(array( ), 'PhabricatorCalendarEventAcceptTransaction' => 'PhabricatorCalendarEventReplyTransaction', 'PhabricatorCalendarEventAllDayTransaction' => 'PhabricatorCalendarEventTransactionType', + 'PhabricatorCalendarEventAvailabilityController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventCancelTransaction' => 'PhabricatorCalendarEventTransactionType', 'PhabricatorCalendarEventDateTransaction' => 'PhabricatorCalendarEventTransactionType', diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php index 8caf8c27ec..fa534280a0 100644 --- a/src/applications/calendar/application/PhabricatorCalendarApplication.php +++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php @@ -61,6 +61,8 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication { => 'PhabricatorCalendarEventJoinController', 'export/(?P[1-9]\d*)/(?P[^/]*)' => 'PhabricatorCalendarEventExportController', + 'availability/(?P[1-9]\d*)/(?P[^/]+)/' + => 'PhabricatorCalendarEventAvailabilityController', ), 'export/' => array( $this->getQueryRoutePattern() diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventAvailabilityController.php b/src/applications/calendar/controller/PhabricatorCalendarEventAvailabilityController.php new file mode 100644 index 0000000000..04a2454a0f --- /dev/null +++ b/src/applications/calendar/controller/PhabricatorCalendarEventAvailabilityController.php @@ -0,0 +1,56 @@ +getViewer(); + $id = $request->getURIData('id'); + + $event = id(new PhabricatorCalendarEventQuery()) + ->setViewer($viewer) + ->withIDs(array($id)) + ->executeOne(); + if (!$event) { + return new Aphront404Response(); + } + + $response = $this->newImportedEventResponse($event); + if ($response) { + return $response; + } + + $cancel_uri = $event->getURI(); + + if (!$event->getIsUserAttending($viewer->getPHID())) { + return $this->newDialog() + ->setTitle(pht('Not Attending Event')) + ->appendParagraph( + pht( + 'You can not change your display availability for events you '. + 'are not attending.')) + ->addCancelButton($cancel_uri); + } + + // TODO: This endpoint currently only works via AJAX. It would be vaguely + // nice to provide a plain HTML version of the workflow where we return + // a dialog with a vanilla