From 28e0af5a62c81eaf14a26ca9f4317f567bedd10c Mon Sep 17 00:00:00 2001 From: lkassianik Date: Tue, 30 Jun 2015 11:47:53 -0700 Subject: [PATCH] Commenting on instances of a recurring event should create a new event with its own comments Summary: Closes T8696, Commenting on instances of a recurring event should create a new event with its own comments Test Plan: Open recurring event instance (not exception), should see no timeline, leave a comment, an exception to event should be created. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8696 Differential Revision: https://secure.phabricator.com/D13481 --- .../PhabricatorCalendarApplication.php | 2 +- ...bricatorCalendarEventCommentController.php | 25 ++++++++++++++++--- ...PhabricatorCalendarEventViewController.php | 21 +++++++++++----- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php index 20e89425df..b5bdfaa1eb 100644 --- a/src/applications/calendar/application/PhabricatorCalendarApplication.php +++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php @@ -61,7 +61,7 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication { => 'PhabricatorCalendarEventCancelController', '(?Pjoin|decline|accept)/(?P[1-9]\d*)/' => 'PhabricatorCalendarEventJoinController', - 'comment/(?P[1-9]\d*)/' + 'comment/(?P[1-9]\d*)/(?:(?P\d+)/)?' => 'PhabricatorCalendarEventCommentController', ), ), diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventCommentController.php b/src/applications/calendar/controller/PhabricatorCalendarEventCommentController.php index 4d31b020c4..a735ee5caa 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventCommentController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventCommentController.php @@ -11,12 +11,14 @@ final class PhabricatorCalendarEventCommentController } public function handleRequest(AphrontRequest $request) { - $user = $request->getUser(); - if (!$request->isFormPost()) { return new Aphront400Response(); } + $user = $request->getUser(); + $is_preview = $request->isPreviewRequest(); + $draft = PhabricatorDraft::buildFromRequest($request); + $event = id(new PhabricatorCalendarEventQuery()) ->setViewer($user) ->withIDs(array($this->id)) @@ -25,8 +27,23 @@ final class PhabricatorCalendarEventCommentController return new Aphront404Response(); } - $is_preview = $request->isPreviewRequest(); - $draft = PhabricatorDraft::buildFromRequest($request); + $index = $request->getURIData('sequence'); + if ($index && !$is_preview) { + $result = $this->getEventAtIndexForGhostPHID( + $user, + $event->getPHID(), + $index); + + if ($result) { + $event = $result; + } else { + $event = $this->createEventFromGhost( + $user, + $event, + $index); + $event->applyViewerTimezone($user); + } + } $view_uri = '/'.$event->getMonogram(); diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php index 0aea0c5607..dcc717d474 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php @@ -16,9 +16,10 @@ final class PhabricatorCalendarEventViewController public function processRequest() { $request = $this->getRequest(); $viewer = $request->getUser(); - $sequence = $request->getURIData('sequence'); + $timeline = null; + $event = id(new PhabricatorCalendarEventQuery()) ->setViewer($viewer) ->withIDs(array($this->id)) @@ -60,9 +61,11 @@ final class PhabricatorCalendarEventViewController $crumbs->addTextCrumb($title, '/E'.$event->getID()); } - $timeline = $this->buildTransactionTimeline( - $event, - new PhabricatorCalendarEventTransactionQuery()); + if (!$event->getIsGhostEvent()) { + $timeline = $this->buildTransactionTimeline( + $event, + new PhabricatorCalendarEventTransactionQuery()); + } $header = $this->buildHeaderView($event); $actions = $this->buildActionView($event); @@ -78,13 +81,19 @@ final class PhabricatorCalendarEventViewController ? pht('Add Comment') : pht('Add To Plate'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $event->getPHID()); + if ($sequence) { + $comment_uri = $this->getApplicationURI( + '/event/comment/'.$event->getID().'/'.$sequence.'/'); + } else { + $comment_uri = $this->getApplicationURI( + '/event/comment/'.$event->getID().'/'); + } $add_comment_form = id(new PhabricatorApplicationTransactionCommentView()) ->setUser($viewer) ->setObjectPHID($event->getPHID()) ->setDraft($draft) ->setHeaderText($add_comment_header) - ->setAction( - $this->getApplicationURI('/event/comment/'.$event->getID().'/')) + ->setAction($comment_uri) ->setSubmitButtonName(pht('Add Comment')); return $this->buildApplicationPage(