Differential D12619 Diff 30301 src/applications/calendar/controller/PhabricatorCalendarEventJoinController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/controller/PhabricatorCalendarEventJoinController.php
| <?php | <?php | ||||
| final class PhabricatorCalendarEventJoinController | final class PhabricatorCalendarEventJoinController | ||||
| extends PhabricatorCalendarController { | extends PhabricatorCalendarController { | ||||
| private $id; | private $id; | ||||
| const ACTION_ACCEPT = 'accept'; | |||||
| const ACTION_DECLINE = 'decline'; | |||||
| const ACTION_JOIN = 'join'; | |||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $this->id = $request->getURIData('id'); | $this->id = $request->getURIData('id'); | ||||
| $action = $request->getURIData('action'); | |||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
| $declined_status = PhabricatorCalendarEventInvitee::STATUS_DECLINED; | $declined_status = PhabricatorCalendarEventInvitee::STATUS_DECLINED; | ||||
| $attending_status = PhabricatorCalendarEventInvitee::STATUS_ATTENDING; | $attending_status = PhabricatorCalendarEventInvitee::STATUS_ATTENDING; | ||||
| $event = id(new PhabricatorCalendarEventQuery()) | $event = id(new PhabricatorCalendarEventQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withIDs(array($this->id)) | ->withIDs(array($this->id)) | ||||
| Show All 31 Lines | if ($request->isFormPost()) { | ||||
| try { | try { | ||||
| $editor->applyTransactions($event, array($xaction)); | $editor->applyTransactions($event, array($xaction)); | ||||
| return id(new AphrontRedirectResponse())->setURI($cancel_uri); | return id(new AphrontRedirectResponse())->setURI($cancel_uri); | ||||
| } catch (PhabricatorApplicationTransactionValidationException $ex) { | } catch (PhabricatorApplicationTransactionValidationException $ex) { | ||||
| $validation_exception = $ex; | $validation_exception = $ex; | ||||
| } | } | ||||
| } | } | ||||
| if (!$is_attending) { | if (($action == self::ACTION_JOIN && !$is_attending) | ||||
| || $action == self::ACTION_ACCEPT) { | |||||
| $title = pht('Join Event'); | $title = pht('Join Event'); | ||||
| $paragraph = pht('Would you like to join this event?'); | $paragraph = pht('Would you like to join this event?'); | ||||
| $submit = pht('Join'); | $submit = pht('Join'); | ||||
| } else { | } else { | ||||
| $title = pht('Decline Event'); | $title = pht('Decline Event'); | ||||
| $paragraph = pht('Would you like to decline this event?'); | $paragraph = pht('Would you like to decline this event?'); | ||||
| $submit = pht('Decline'); | $submit = pht('Decline'); | ||||
| } | } | ||||
| Show All 9 Lines | |||||