Differential D18693 Diff 44881 src/applications/calendar/xaction/PhabricatorCalendarEventFrequencyTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/xaction/PhabricatorCalendarEventFrequencyTransaction.php
Show All 17 Lines | final class PhabricatorCalendarEventFrequencyTransaction | ||||
public function applyInternalEffects($object, $value) { | public function applyInternalEffects($object, $value) { | ||||
$rrule = id(new PhutilCalendarRecurrenceRule()) | $rrule = id(new PhutilCalendarRecurrenceRule()) | ||||
->setFrequency($value); | ->setFrequency($value); | ||||
// If the user creates a monthly event on the 29th, 30th or 31st of a | // If the user creates a monthly event on the 29th, 30th or 31st of a | ||||
// month, it means "the 30th of every month" as far as the RRULE is | // month, it means "the 30th of every month" as far as the RRULE is | ||||
// concerned. Such an event will not occur on months with fewer days. | // concerned. Such an event will not occur on months with fewer days. | ||||
// This is surprising, and proably not what the user wants. Instead, | // This is surprising, and probably not what the user wants. Instead, | ||||
// schedule these events relative to the end of the month: on the "-1st", | // schedule these events relative to the end of the month: on the "-1st", | ||||
// "-2nd" or "-3rd" day of the month. For example, a monthly event on | // "-2nd" or "-3rd" day of the month. For example, a monthly event on | ||||
// the 31st of a 31-day month translates to "every month, on the last | // the 31st of a 31-day month translates to "every month, on the last | ||||
// day of the month". | // day of the month". | ||||
if ($value == PhutilCalendarRecurrenceRule::FREQUENCY_MONTHLY) { | if ($value == PhutilCalendarRecurrenceRule::FREQUENCY_MONTHLY) { | ||||
$start_datetime = $object->newStartDateTime(); | $start_datetime = $object->newStartDateTime(); | ||||
$y = $start_datetime->getYear(); | $y = $start_datetime->getYear(); | ||||
Show All 26 Lines | public function validateTransactions($object, array $xactions) { | ||||
$valid = array_fuse($valid); | $valid = array_fuse($valid); | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
$value = $xaction->getNewValue(); | $value = $xaction->getNewValue(); | ||||
if (!isset($valid[$value])) { | if (!isset($valid[$value])) { | ||||
$errors[] = $this->newInvalidError( | $errors[] = $this->newInvalidError( | ||||
pht( | pht( | ||||
'Event frequency "%s" is not valid. Valid frequences are: %s.', | 'Event frequency "%s" is not valid. Valid frequencies are: %s.', | ||||
$value, | $value, | ||||
implode(', ', $valid)), | implode(', ', $valid)), | ||||
$xaction); | $xaction); | ||||
} | } | ||||
} | } | ||||
return $errors; | return $errors; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |