From 7015520b9344a951250af099da3db6b3b22f7e44 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Mon, 8 Jun 2015 21:40:32 -0700 Subject: [PATCH] Add helper method on event object to determine if event is the parent of a recurrence. Summary: Ref T8472, Add helper method on event object to determine if event is the parent of a recurrence. Test Plan: No user facing change. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T8472 Differential Revision: https://secure.phabricator.com/D13221 --- .../PhabricatorCalendarEventCancelController.php | 7 +++---- .../PhabricatorCalendarEventViewController.php | 8 ++++---- .../calendar/storage/PhabricatorCalendarEvent.php | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventCancelController.php b/src/applications/calendar/controller/PhabricatorCalendarEventCancelController.php index 8e3cfdb8fa..c29541bcfd 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventCancelController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventCancelController.php @@ -42,8 +42,7 @@ final class PhabricatorCalendarEventCancelController $is_cancelled = $event->getIsCancelled(); $is_parent_cancelled = $event->getIsParentCancelled(); - $is_recurring = $event->getIsRecurring(); - $instance_of = $event->getInstanceOfEventPHID(); + $is_parent = $event->getIsRecurrenceParent(); $validation_exception = null; @@ -86,7 +85,7 @@ final class PhabricatorCalendarEventCancelController cancelled recurring event.'); $cancel = pht('Cancel'); $submit = null; - } else if ($is_recurring && !$instance_of) { + } else if ($is_parent) { $title = pht('Reinstate Recurrence'); $paragraph = pht('Reinstate the entire series of recurring events?'); @@ -105,7 +104,7 @@ final class PhabricatorCalendarEventCancelController of a recurring event.'); $cancel = pht('Don\'t Cancel Instance'); $submit = pht('Cancel Instance'); - } else if ($is_recurring && !$instance_of) { + } else if ($is_parent) { $title = pht('Cancel Recurrence'); $paragraph = pht('Cancel the entire series of recurring events?'); diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php index 004c2e0669..e9e4941359 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php @@ -164,10 +164,10 @@ final class PhabricatorCalendarEventViewController $index = $event->getSequenceIndex(); $edit_label = pht('Edit This Instance'); $edit_uri = "event/edit/{$id}/{$index}/"; - } else if ($event->getInstanceOfEventPHID() && !$event->getIsGhostEvent()) { + } else if ($event->getIsRecurrenceException()) { $edit_label = pht('Edit This Instance'); $edit_uri = "event/edit/{$id}/"; - } else if (!$event->getIsRecurring()) { + } else if (!$event->getIsRecurrenceParent()) { $edit_label = pht('Edit'); $edit_uri = "event/edit/{$id}/"; } @@ -208,12 +208,12 @@ final class PhabricatorCalendarEventViewController $reinstate_label = pht('Reinstate This Instance'); $cancel_disabled = (!$can_edit || $can_reinstate); $cancel_uri = $this->getApplicationURI("event/cancel/{$id}/{$index}/"); - } else if ($event->getInstanceOfEventPHID()) { + } else if ($event->getIsRecurrenceException()) { $can_reinstate = $event->getIsParentCancelled(); $cancel_label = pht('Cancel This Instance'); $reinstate_label = pht('Reinstate This Instance'); $cancel_disabled = (!$can_edit || $can_reinstate); - } else if ($event->getIsRecurring()) { + } else if ($event->getIsRecurrenceParent()) { $cancel_label = pht('Cancel Recurrence'); $reinstate_label = pht('Reinstate Recurrence'); $cancel_disabled = !$can_edit; diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php index 73dee4e399..ea6c6a48ef 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php @@ -347,6 +347,20 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO return $this->isCancelled; } + public function getIsRecurrenceParent() { + if ($this->isRecurring && !$this->instanceOfEventPHID) { + return true; + } + return false; + } + + public function getIsRecurrenceException() { + if ($this->instanceOfEventPHID && !$this->isGhostEvent) { + return true; + } + return false; + } + public function getIsParentCancelled() { if ($this->instanceOfEventPHID == null) { return false;