Differential D16284 Diff 39171 src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
case self::TYPE_DECLINE: | case self::TYPE_DECLINE: | ||||
return pht( | return pht( | ||||
'%s declined this event.', | '%s declined this event.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
case self::TYPE_INVITE: | case self::TYPE_INVITE: | ||||
$text = null; | $text = null; | ||||
// Fill in any new invitees as "uninvited" in the old data, to make | list($old, $new) = $this->getSimpleInvites($old, $new); | ||||
// some of the rendering logic a little easier. | |||||
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED; | |||||
$old = $old + array_fill_keys(array_keys($new), $status_uninvited); | |||||
if (count($old) === 1 | if (count($old) === 1 | ||||
&& count($new) === 1 | && count($new) === 1 | ||||
&& isset($old[$author_phid])) { | && isset($old[$author_phid])) { | ||||
// user joined/declined/accepted event themself | // user joined/declined/accepted event themself | ||||
$old_status = $old[$author_phid]; | $old_status = $old[$author_phid]; | ||||
$new_status = $new[$author_phid]; | $new_status = $new[$author_phid]; | ||||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
case self::TYPE_DECLINE: | case self::TYPE_DECLINE: | ||||
return pht( | return pht( | ||||
'%s declined %s.', | '%s declined %s.', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
case self::TYPE_INVITE: | case self::TYPE_INVITE: | ||||
$text = null; | $text = null; | ||||
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED; | list($old, $new) = $this->getSimpleInvites($old, $new); | ||||
$old = $old + array_fill_keys(array_keys($new), $status_uninvited); | |||||
if (count($old) === 1 | if (count($old) === 1 | ||||
&& count($new) === 1 | && count($new) === 1 | ||||
&& isset($old[$author_phid])) { | && isset($old[$author_phid])) { | ||||
// user joined/declined/accepted event themself | // user joined/declined/accepted event themself | ||||
$old_status = $old[$author_phid]; | $old_status = $old[$author_phid]; | ||||
$new_status = $new[$author_phid]; | $new_status = $new[$author_phid]; | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | switch ($this->getTransactionType()) { | ||||
case self::TYPE_END_DATE: | case self::TYPE_END_DATE: | ||||
case self::TYPE_CANCEL: | case self::TYPE_CANCEL: | ||||
$tags[] = self::MAILTAG_RESCHEDULE; | $tags[] = self::MAILTAG_RESCHEDULE; | ||||
break; | break; | ||||
} | } | ||||
return $tags; | return $tags; | ||||
} | } | ||||
private function getSimpleInvites(array $old, array $new) { | |||||
// Fill in any new invitees as "uninvited" in the old data, to make | |||||
// some of the rendering logic a little easier. | |||||
$status_uninvited = PhabricatorCalendarEventInvitee::STATUS_UNINVITED; | |||||
$old = $old + array_fill_keys(array_keys($new), $status_uninvited); | |||||
$all = $old + $new; | |||||
foreach (array_keys($all) as $key) { | |||||
// If the invitee exists in both the old and new lists with the same | |||||
// value, remove it from both. | |||||
if (isset($old[$key]) && isset($new[$key])) { | |||||
if ($old[$key] == $new[$key]) { | |||||
unset($old[$key]); | |||||
unset($new[$key]); | |||||
} | |||||
} | |||||
} | |||||
return array($old, $new); | |||||
} | |||||
} | } |