Page MenuHomePhabricator

D12625.id30311.diff
No OneTemporary

D12625.id30311.diff

diff --git a/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php b/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php
@@ -36,9 +36,14 @@
case self::TYPE_STATUS:
case self::TYPE_DESCRIPTION:
case self::TYPE_CANCEL:
- case self::TYPE_INVITE:
$phids[] = $this->getObjectPHID();
break;
+ case self::TYPE_INVITE:
+ $new = $this->getNewValue();
+ foreach ($new as $phid => $status) {
+ $phids[] = $phid;
+ }
+ break;
}
return $phids;
@@ -138,11 +143,89 @@
break;
}
case self::TYPE_INVITE:
- return pht(
- "%s updated the event's invitee list.",
- $this->renderHandleLink($author_phid));
+ if (count($old) === 1
+ && count($new) === 1
+ && isset($old[$author_phid])) {
+ // user joined/declined/accepted event themself
+ $old_status = $old[$author_phid];
+ $new_status = $new[$author_phid];
+
+ if ($old_status !== $new_status) {
+ switch ($new_status) {
+ case PhabricatorCalendarEventInvitee::STATUS_INVITED:
+ $text = pht(
+ '%s has joined this event.',
+ $this->renderHandleLink($author_phid));
+ break;
+ case PhabricatorCalendarEventInvitee::STATUS_ATTENDING:
+ $text = pht(
+ '%s is attending this event.',
+ $this->renderHandleLink($author_phid));
+ break;
+ case PhabricatorCalendarEventInvitee::STATUS_DECLINED:
+ case PhabricatorCalendarEventInvitee::STATUS_UNINVITED:
+ $text = pht(
+ '%s has declined this event.',
+ $this->renderHandleLink($author_phid));
+ break;
+ default:
+ $text = pht(
+ '%s has changed their status for this event.',
+ $this->renderHandleLink($author_phid));
+ break;
+ break;
+ }
+ }
+ } else {
+ // user changed status for many users
+ $self_joined = null;
+ $self_declined = null;
+ $added = array();
+ $uninvited = array();
+ $text = null;
+
+ foreach ($new as $phid => $status) {
+ if ($status == PhabricatorCalendarEventInvitee::STATUS_INVITED
+ || $status == PhabricatorCalendarEventInvitee::STATUS_ATTENDING) {
+ // added users
+ $added[] = $phid;
+ } else if (
+ $status == PhabricatorCalendarEventInvitee::STATUS_DECLINED
+ || $status == PhabricatorCalendarEventInvitee::STATUS_UNINVITED) {
+ $uninvited[] = $phid;
+ }
+ }
+
+ $count_added = count($added);
+ $count_uninvited = count($uninvited);
+ $added_text = null;
+ $uninvited_text = null;
+
+ if ($count_added > 0 && $count_uninvited == 0) {
+ $added_text = $this->renderHandleList($added);
+ $text = pht('%s invited: %s.',
+ $this->renderHandleLink($author_phid),
+ $added_text);
+ } else if ($count_added > 0 && $count_uninvited > 0) {
+ $added_text = $this->renderHandleList($added);
+ $uninvited_text = $this->renderHandleList($uninvited);
+ $text = pht('%s invited: %s and uninvited: %s',
+ $this->renderHandleLink($author_phid),
+ $added_text,
+ $uninvited_text);
+ } else if ($count_added == 0 && $count_uninvited > 0) {
+ $uninvited_text = $this->renderHandleList($uninvited);
+ $text = pht('%s uninvited: %s.',
+ $this->renderHandleLink($author_phid),
+ $uninvited_text);
+ } else {
+ $text = pht('%s updated the invitee list.',
+ $this->renderHandleLink($author_phid));
+ }
+ }
+ return $text;
break;
- }
+ }
return parent::getTitle();
}
@@ -154,6 +237,7 @@
$old = $this->getOldValue();
$new = $this->getNewValue();
+
$viewer = $this->getViewer();
$type = $this->getTransactionType();

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 19, 4:43 PM (3 d, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7711664
Default Alt Text
D12625.id30311.diff (4 KB)

Event Timeline