From e337029769ceb1568f0c1a71e1aec4d39a43ee67 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 4 Nov 2016 15:42:24 -0700 Subject: [PATCH] Allow users to mark themselves as "Available", "Busy" or "Away" while attending an event Summary: Ref T11816. - Now that we can do something meaningful with them, bring back the yellow dots for "busy". - Default to "busy" when attending events (we could make this "busy" for short events and "away" for long events or something). - Let users pick how to display their attending status on the event page. - Also show which event the user is attending since I had to mess with the cache code anyway. We can get rid of this again if it doesn't feel good. Test Plan: {F1904179} {F1904180} Reviewers: chad Reviewed By: chad Maniphest Tasks: T11816 Differential Revision: https://secure.phabricator.com/D16802 --- .../20161104.calendar.01.availability.sql | 2 + .../20161104.calendar.02.availdefault.sql | 3 + src/__phutil_library_map__.php | 2 + .../PhabricatorCalendarApplication.php | 2 + ...torCalendarEventAvailabilityController.php | 56 +++++++++++++++++++ ...PhabricatorCalendarEventViewController.php | 37 ++++++++++++ .../storage/PhabricatorCalendarEvent.php | 6 ++ .../PhabricatorCalendarEventInvitee.php | 51 +++++++++++++++++ .../view/PHUIUserAvailabilityView.php | 53 ++++++++++++++++-- .../phid/PhabricatorPeopleUserPHIDType.php | 7 ++- .../people/query/PhabricatorPeopleQuery.php | 32 ++++++++++- .../people/storage/PhabricatorUser.php | 26 +++++++++ 12 files changed, 269 insertions(+), 8 deletions(-) create mode 100644 resources/sql/autopatches/20161104.calendar.01.availability.sql create mode 100644 resources/sql/autopatches/20161104.calendar.02.availdefault.sql create mode 100644 src/applications/calendar/controller/PhabricatorCalendarEventAvailabilityController.php 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