Skip to content

Commit a46a436

Browse files
author
epriestley
committed
Smooth over a few more transaction compatibility/structure issues with Calendar events
Summary: Ref T9275. This gets things roughly into shape for a cutover to EditEngine, mostly by fixing some problems with "recurrence end date" not being nullable while editing events. Test Plan: Edited events with EditPro controller, nothing was obviously broken. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9275 Differential Revision: https://secure.phabricator.com/D16282
1 parent bac6acb commit a46a436

File tree

7 files changed

+49
-18
lines changed

7 files changed

+49
-18
lines changed

src/__phutil_library_map__.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6633,7 +6633,7 @@
66336633
'PhabricatorCalendarEventCancelController' => 'PhabricatorCalendarController',
66346634
'PhabricatorCalendarEventDragController' => 'PhabricatorCalendarController',
66356635
'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController',
6636-
'PhabricatorCalendarEventEditProController' => 'ManiphestController',
6636+
'PhabricatorCalendarEventEditProController' => 'PhabricatorCalendarController',
66376637
'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor',
66386638
'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand',
66396639
'PhabricatorCalendarEventFulltextEngine' => 'PhabricatorFulltextEngine',

src/aphront/httpparametertype/AphrontEpochHTTPParameterType.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,30 @@
33
final class AphrontEpochHTTPParameterType
44
extends AphrontHTTPParameterType {
55

6+
private $allowNull;
7+
8+
public function setAllowNull($allow_null) {
9+
$this->allowNull = $allow_null;
10+
return $this;
11+
}
12+
13+
public function getAllowNull() {
14+
return $this->allowNull;
15+
}
16+
617
protected function getParameterExists(AphrontRequest $request, $key) {
718
return $request->getExists($key) ||
819
$request->getExists($key.'_d');
920
}
1021

1122
protected function getParameterValue(AphrontRequest $request, $key) {
12-
return AphrontFormDateControlValue::newFromRequest($request, $key);
23+
$value = AphrontFormDateControlValue::newFromRequest($request, $key);
24+
25+
if ($this->getAllowNull()) {
26+
$value->setOptional(true);
27+
}
28+
29+
return $value;
1330
}
1431

1532
protected function getParameterTypeName() {

src/applications/calendar/controller/PhabricatorCalendarEventEditController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function handleRequest(AphrontRequest $request) {
185185
$xactions[] = id(new PhabricatorCalendarEventTransaction())
186186
->setTransactionType(
187187
PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE)
188-
->setNewValue($recurrence_end_date_value->getEpoch());
188+
->setNewValue($recurrence_end_date_value);
189189
}
190190
}
191191

@@ -203,12 +203,12 @@ public function handleRequest(AphrontRequest $request) {
203203
$xactions[] = id(new PhabricatorCalendarEventTransaction())
204204
->setTransactionType(
205205
PhabricatorCalendarEventTransaction::TYPE_START_DATE)
206-
->setNewValue($start_value->getEpoch());
206+
->setNewValue($start_value);
207207

208208
$xactions[] = id(new PhabricatorCalendarEventTransaction())
209209
->setTransactionType(
210210
PhabricatorCalendarEventTransaction::TYPE_END_DATE)
211-
->setNewValue($end_value->getEpoch());
211+
->setNewValue($end_value);
212212
}
213213

214214

src/applications/calendar/controller/PhabricatorCalendarEventEditProController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
final class PhabricatorCalendarEventEditProController
4-
extends ManiphestController {
4+
extends PhabricatorCalendarController {
55

66
public function handleRequest(AphrontRequest $request) {
77
return id(new PhabricatorCalendarEditEngine())

src/applications/calendar/editor/PhabricatorCalendarEventEditor.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ protected function getCustomTransactionOldValue(
8585
PhabricatorApplicationTransaction $xaction) {
8686
switch ($xaction->getTransactionType()) {
8787
case PhabricatorCalendarEventTransaction::TYPE_RECURRING:
88-
return $object->getIsRecurring();
88+
return (int)$object->getIsRecurring();
8989
case PhabricatorCalendarEventTransaction::TYPE_FREQUENCY:
90-
return $object->getRecurrenceFrequency();
90+
return $object->getFrequencyUnit();
9191
case PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE:
9292
return $object->getRecurrenceEndDate();
9393
case PhabricatorCalendarEventTransaction::TYPE_NAME:
@@ -120,7 +120,6 @@ protected function getCustomTransactionNewValue(
120120
PhabricatorLiskDAO $object,
121121
PhabricatorApplicationTransaction $xaction) {
122122
switch ($xaction->getTransactionType()) {
123-
case PhabricatorCalendarEventTransaction::TYPE_RECURRING:
124123
case PhabricatorCalendarEventTransaction::TYPE_FREQUENCY:
125124
case PhabricatorCalendarEventTransaction::TYPE_NAME:
126125
case PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION:
@@ -132,11 +131,12 @@ protected function getCustomTransactionNewValue(
132131
case PhabricatorCalendarEventTransaction::TYPE_DECLINE:
133132
return PhabricatorCalendarEventInvitee::STATUS_DECLINED;
134133
case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY:
134+
case PhabricatorCalendarEventTransaction::TYPE_RECURRING:
135135
return (int)$xaction->getNewValue();
136136
case PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE:
137137
case PhabricatorCalendarEventTransaction::TYPE_START_DATE:
138138
case PhabricatorCalendarEventTransaction::TYPE_END_DATE:
139-
return $xaction->getNewValue();
139+
return $xaction->getNewValue()->getEpoch();
140140
case PhabricatorCalendarEventTransaction::TYPE_INVITE:
141141
$status_invited = PhabricatorCalendarEventInvitee::STATUS_INVITED;
142142
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
@@ -187,9 +187,12 @@ protected function applyCustomInternalTransaction(
187187

188188
switch ($xaction->getTransactionType()) {
189189
case PhabricatorCalendarEventTransaction::TYPE_RECURRING:
190-
return $object->setIsRecurring($xaction->getNewValue());
190+
return $object->setIsRecurring((int)$xaction->getNewValue());
191191
case PhabricatorCalendarEventTransaction::TYPE_FREQUENCY:
192-
return $object->setRecurrenceFrequency($xaction->getNewValue());
192+
return $object->setRecurrenceFrequency(
193+
array(
194+
'rule' => $xaction->getNewValue(),
195+
));
193196
case PhabricatorCalendarEventTransaction::TYPE_NAME:
194197
$object->setName($xaction->getNewValue());
195198
return;
@@ -370,11 +373,11 @@ protected function validateAllTransactions(
370373

371374
foreach ($xactions as $xaction) {
372375
if ($xaction->getTransactionType() == $start_date_xaction) {
373-
$start_date = $xaction->getNewValue();
376+
$start_date = $xaction->getNewValue()->getEpoch();
374377
} else if ($xaction->getTransactionType() == $end_date_xaction) {
375-
$end_date = $xaction->getNewValue();
378+
$end_date = $xaction->getNewValue()->getEpoch();
376379
} else if ($xaction->getTransactionType() == $recurrence_end_xaction) {
377-
$recurrence_end = $xaction->getNewValue();
380+
$recurrence_end = $xaction->getNewValue()->getEpoch();
378381
} else if ($xaction->getTransactionType() == $is_recurrence_xaction) {
379382
$is_recurring = $xaction->getNewValue();
380383
}

src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,13 @@ public function getTitle() {
265265
$this->renderHandleLink($author_phid));
266266
return $text;
267267
case self::TYPE_FREQUENCY:
268+
$rule = $new;
269+
if (is_array($rule)) {
270+
$rule = idx($rule, 'rule');
271+
}
272+
268273
$text = '';
269-
switch ($new['rule']) {
274+
switch ($rule) {
270275
case PhabricatorCalendarEvent::FREQUENCY_DAILY:
271276
$text = pht('%s set this event to repeat daily.',
272277
$this->renderHandleLink($author_phid));
@@ -487,8 +492,13 @@ public function getTitleForFeed() {
487492
$this->renderHandleLink($object_phid));
488493
return $text;
489494
case self::TYPE_FREQUENCY:
495+
$rule = $new;
496+
if (is_array($rule)) {
497+
$rule = idx($rule, 'rule');
498+
}
499+
490500
$text = '';
491-
switch ($new['rule']) {
501+
switch ($rule) {
492502
case PhabricatorCalendarEvent::FREQUENCY_DAILY:
493503
$text = pht('%s set %s to repeat daily.',
494504
$this->renderHandleLink($author_phid),

src/applications/transactions/editfield/PhabricatorEpochEditField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ protected function newControl() {
2121
}
2222

2323
protected function newHTTPParameterType() {
24-
return new AphrontEpochHTTPParameterType();
24+
return id(new AphrontEpochHTTPParameterType())
25+
->setAllowNull($this->getAllowNull());
2526
}
2627

2728
protected function newConduitParameterType() {

0 commit comments

Comments
 (0)