Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
Show All 16 Lines | protected function shouldApplyInitialEffects( | ||||
return true; | return true; | ||||
} | } | ||||
protected function applyInitialEffects( | protected function applyInitialEffects( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
$actor = $this->requireActor(); | $actor = $this->requireActor(); | ||||
$object->removeViewerTimezone($actor); | |||||
if ($object->getIsStub()) { | if ($object->getIsStub()) { | ||||
$this->materializeStub($object); | $this->materializeStub($object); | ||||
} | } | ||||
} | } | ||||
private function materializeStub(PhabricatorCalendarEvent $event) { | private function materializeStub(PhabricatorCalendarEvent $event) { | ||||
if (!$event->getIsStub()) { | if (!$event->getIsStub()) { | ||||
throw new Exception( | throw new Exception( | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
return PhabricatorCalendarEventInvitee::STATUS_ATTENDING; | return PhabricatorCalendarEventInvitee::STATUS_ATTENDING; | ||||
case PhabricatorCalendarEventTransaction::TYPE_DECLINE: | case PhabricatorCalendarEventTransaction::TYPE_DECLINE: | ||||
return PhabricatorCalendarEventInvitee::STATUS_DECLINED; | return PhabricatorCalendarEventInvitee::STATUS_DECLINED; | ||||
case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: | case PhabricatorCalendarEventTransaction::TYPE_ALL_DAY: | ||||
return (int)$xaction->getNewValue(); | return (int)$xaction->getNewValue(); | ||||
case PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE: | case PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE: | ||||
case PhabricatorCalendarEventTransaction::TYPE_START_DATE: | case PhabricatorCalendarEventTransaction::TYPE_START_DATE: | ||||
case PhabricatorCalendarEventTransaction::TYPE_END_DATE: | case PhabricatorCalendarEventTransaction::TYPE_END_DATE: | ||||
return $xaction->getNewValue()->getEpoch(); | return $xaction->getNewValue(); | ||||
} | } | ||||
return parent::getCustomTransactionNewValue($object, $xaction); | return parent::getCustomTransactionNewValue($object, $xaction); | ||||
} | } | ||||
protected function applyCustomInternalTransaction( | protected function applyCustomInternalTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | protected function applyFinalEffects( | ||||
$phids = mpull($object->getInvitees(), 'getInviteePHID'); | $phids = mpull($object->getInvitees(), 'getInviteePHID'); | ||||
$phids = array_fuse($phids); | $phids = array_fuse($phids); | ||||
if (!$invalidate_all) { | if (!$invalidate_all) { | ||||
$phids = array_select_keys($phids, $invalidate_phids); | $phids = array_select_keys($phids, $invalidate_phids); | ||||
} | } | ||||
if ($phids) { | if ($phids) { | ||||
$object->applyViewerTimezone($this->getActor()); | |||||
$user = new PhabricatorUser(); | $user = new PhabricatorUser(); | ||||
$conn_w = $user->establishConnection('w'); | $conn_w = $user->establishConnection('w'); | ||||
queryfx( | queryfx( | ||||
$conn_w, | $conn_w, | ||||
'UPDATE %T SET availabilityCacheTTL = NULL | 'UPDATE %T SET availabilityCacheTTL = NULL | ||||
WHERE phid IN (%Ls) AND availabilityCacheTTL >= %d', | WHERE phid IN (%Ls) AND availabilityCacheTTL >= %d', | ||||
$user->getTableName(), | $user->getTableName(), | ||||
$phids, | $phids, | ||||
Show All 20 Lines | protected function validateAllTransactions( | ||||
$end_date = $object->getDateTo(); | $end_date = $object->getDateTo(); | ||||
$recurrence_end = $object->getRecurrenceEndDate(); | $recurrence_end = $object->getRecurrenceEndDate(); | ||||
$is_recurring = $object->getIsRecurring(); | $is_recurring = $object->getIsRecurring(); | ||||
$errors = array(); | $errors = array(); | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
if ($xaction->getTransactionType() == $start_date_xaction) { | if ($xaction->getTransactionType() == $start_date_xaction) { | ||||
$start_date = $xaction->getNewValue()->getEpoch(); | $start_date = $xaction->getNewValue(); | ||||
} else if ($xaction->getTransactionType() == $end_date_xaction) { | } else if ($xaction->getTransactionType() == $end_date_xaction) { | ||||
$end_date = $xaction->getNewValue()->getEpoch(); | $end_date = $xaction->getNewValue(); | ||||
} else if ($xaction->getTransactionType() == $recurrence_end_xaction) { | } else if ($xaction->getTransactionType() == $recurrence_end_xaction) { | ||||
$recurrence_end = $xaction->getNewValue(); | $recurrence_end = $xaction->getNewValue(); | ||||
} else if ($xaction->getTransactionType() == $is_recurrence_xaction) { | } else if ($xaction->getTransactionType() == $is_recurrence_xaction) { | ||||
$is_recurring = $xaction->getNewValue(); | $is_recurring = $xaction->getNewValue(); | ||||
} | } | ||||
} | } | ||||
if ($start_date > $end_date) { | if ($start_date > $end_date) { | ||||
$type = PhabricatorCalendarEventTransaction::TYPE_END_DATE; | $type = PhabricatorCalendarEventTransaction::TYPE_END_DATE; | ||||
$errors[] = new PhabricatorApplicationTransactionValidationError( | $errors[] = new PhabricatorApplicationTransactionValidationError( | ||||
$type, | $type, | ||||
pht('Invalid'), | pht('Invalid'), | ||||
pht('End date must be after start date.'), | pht('End date must be after start date.'), | ||||
null); | null); | ||||
} | } | ||||
Show All 30 Lines | switch ($type) { | ||||
pht('Required'), | pht('Required'), | ||||
pht('Event name is required.'), | pht('Event name is required.'), | ||||
nonempty(last($xactions), null)); | nonempty(last($xactions), null)); | ||||
$error->setIsMissingFieldError(true); | $error->setIsMissingFieldError(true); | ||||
$errors[] = $error; | $errors[] = $error; | ||||
} | } | ||||
break; | break; | ||||
case PhabricatorCalendarEventTransaction::TYPE_RECURRENCE_END_DATE: | |||||
case PhabricatorCalendarEventTransaction::TYPE_START_DATE: | |||||
case PhabricatorCalendarEventTransaction::TYPE_END_DATE: | |||||
foreach ($xactions as $xaction) { | |||||
$date_value = $xaction->getNewValue(); | |||||
if (!$date_value->isValid()) { | |||||
$errors[] = new PhabricatorApplicationTransactionValidationError( | |||||
$type, | |||||
pht('Invalid'), | |||||
pht('Invalid date.'), | |||||
$xaction); | |||||
} | |||||
} | |||||
break; | |||||
} | } | ||||
return $errors; | return $errors; | ||||
} | } | ||||
protected function shouldPublishFeedStory( | protected function shouldPublishFeedStory( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |