diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php index 489b4e6d25..69492a416a 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php @@ -203,15 +203,17 @@ final class PhabricatorCalendarEventEditController PhabricatorCalendarEventTransaction::TYPE_NAME) ->setNewValue($name); - $xactions[] = id(new PhabricatorCalendarEventTransaction()) - ->setTransactionType( - PhabricatorCalendarEventTransaction::TYPE_RECURRING) - ->setNewValue($is_recurring); + if ($this->isCreate()) { + $xactions[] = id(new PhabricatorCalendarEventTransaction()) + ->setTransactionType( + PhabricatorCalendarEventTransaction::TYPE_RECURRING) + ->setNewValue($is_recurring); - $xactions[] = id(new PhabricatorCalendarEventTransaction()) - ->setTransactionType( - PhabricatorCalendarEventTransaction::TYPE_FREQUENCY) - ->setNewValue(array('rule' => $frequency)); + $xactions[] = id(new PhabricatorCalendarEventTransaction()) + ->setTransactionType( + PhabricatorCalendarEventTransaction::TYPE_FREQUENCY) + ->setNewValue(array('rule' => $frequency)); + } $xactions[] = id(new PhabricatorCalendarEventTransaction()) ->setTransactionType( @@ -294,37 +296,42 @@ final class PhabricatorCalendarEventEditController } } + $is_recurring_checkbox = null; + $recurrence_frequency_select = null; + $name = id(new AphrontFormTextControl()) ->setLabel(pht('Name')) ->setName('name') ->setValue($name) ->setError($error_name); - Javelin::initBehavior('recurring-edit', array( - 'isRecurring' => $is_recurring_id, - 'frequency' => $frequency_id, - )); + if ($this->isCreate()) { + Javelin::initBehavior('recurring-edit', array( + 'isRecurring' => $is_recurring_id, + 'frequency' => $frequency_id, + )); - $is_recurring_checkbox = id(new AphrontFormCheckboxControl()) - ->addCheckbox( - 'isRecurring', - 1, - pht('Recurring Event'), - $is_recurring, - $is_recurring_id); + $is_recurring_checkbox = id(new AphrontFormCheckboxControl()) + ->addCheckbox( + 'isRecurring', + 1, + pht('Recurring Event'), + $is_recurring, + $is_recurring_id); - $recurrence_frequency_select = id(new AphrontFormSelectControl()) - ->setName('frequency') - ->setOptions(array( - 'daily' => pht('Daily'), - 'weekly' => pht('Weekly'), - 'monthly' => pht('Monthly'), - 'yearly' => pht('Yearly'), - )) - ->setValue($frequency) - ->setLabel(pht('Recurring Event Frequency')) - ->setID($frequency_id) - ->setDisabled(!$is_recurring); + $recurrence_frequency_select = id(new AphrontFormSelectControl()) + ->setName('frequency') + ->setOptions(array( + 'daily' => pht('Daily'), + 'weekly' => pht('Weekly'), + 'monthly' => pht('Monthly'), + 'yearly' => pht('Yearly'), + )) + ->setValue($frequency) + ->setLabel(pht('Recurring Event Frequency')) + ->setID($frequency_id) + ->setDisabled(!$is_recurring); + } Javelin::initBehavior('event-all-day', array( 'allDayID' => $all_day_id, @@ -409,9 +416,16 @@ final class PhabricatorCalendarEventEditController ->addHiddenInput('next', $next_workflow) ->addHiddenInput('query', $uri_query) ->setUser($viewer) - ->appendChild($name) - ->appendChild($is_recurring_checkbox) - ->appendChild($recurrence_frequency_select) + ->appendChild($name); + + if ($is_recurring_checkbox) { + $form->appendChild($is_recurring_checkbox); + } + if ($recurrence_frequency_select) { + $form->appendControl($recurrence_frequency_select); + } + + $form ->appendChild($all_day_checkbox) ->appendChild($start_control) ->appendChild($end_control) diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php index 3ef692b9a8..37411c9786 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php @@ -135,7 +135,7 @@ final class PhabricatorCalendarEventViewController $event, PhabricatorPolicyCapability::CAN_EDIT); - if (($event->getIsRecurring() && $event->getIsGhostEvent())) { + if ($event->getIsRecurring() && $event->getIsGhostEvent()) { $index = $event->getSequenceIndex(); $actions->addAction( diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php index 979fec1444..c3d8e36534 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php @@ -279,6 +279,9 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO $frequency = $this->getFrequencyUnit(); $modify_key = '+'.$sequence_index.' '.$frequency; + $instance_of = ($this->getPHID()) ? + $this->getPHID() : $this->instanceOfEventPHID; + $date = $this->dateFrom; $date_time = PhabricatorTime::getDateTimeFromEpoch($date, $actor); $date_time->modify($modify_key); @@ -294,7 +297,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO ->setDateTo($date + $duration) ->setIsRecurring(true) ->setRecurrenceFrequency($this->recurrenceFrequency) - ->setInstanceOfEventPHID($this->getPHID()) + ->setInstanceOfEventPHID($instance_of) ->setSequenceIndex($sequence_index) ->setEditPolicy($edit_policy);