Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
| Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | final class PhabricatorCalendarEventEditor | ||||
| protected function applyFinalEffects( | protected function applyFinalEffects( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| // Clear the availability caches for users whose availability is affected | // Clear the availability caches for users whose availability is affected | ||||
| // by this edit. | // by this edit. | ||||
| $phids = mpull($object->getInvitees(), 'getInviteePHID'); | |||||
| $phids = array_fuse($phids); | |||||
| $invalidate_all = false; | $invalidate_all = false; | ||||
| $invalidate_phids = array(); | $invalidate_phids = array(); | ||||
| foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| case PhabricatorCalendarEventUntilDateTransaction::TRANSACTIONTYPE: | case PhabricatorCalendarEventUntilDateTransaction::TRANSACTIONTYPE: | ||||
| case PhabricatorCalendarEventStartDateTransaction::TRANSACTIONTYPE: | case PhabricatorCalendarEventStartDateTransaction::TRANSACTIONTYPE: | ||||
| case PhabricatorCalendarEventEndDateTransaction::TRANSACTIONTYPE: | case PhabricatorCalendarEventEndDateTransaction::TRANSACTIONTYPE: | ||||
| case PhabricatorCalendarEventCancelTransaction::TRANSACTIONTYPE: | case PhabricatorCalendarEventCancelTransaction::TRANSACTIONTYPE: | ||||
| case PhabricatorCalendarEventAllDayTransaction::TRANSACTIONTYPE: | case PhabricatorCalendarEventAllDayTransaction::TRANSACTIONTYPE: | ||||
| // For these kinds of changes, we need to invalidate the availabilty | // For these kinds of changes, we need to invalidate the availabilty | ||||
| // caches for all attendees. | // caches for all attendees. | ||||
| $invalidate_all = true; | $invalidate_all = true; | ||||
| break; | break; | ||||
| case PhabricatorCalendarEventAcceptTransaction::TRANSACTIONTYPE: | case PhabricatorCalendarEventAcceptTransaction::TRANSACTIONTYPE: | ||||
| case PhabricatorCalendarEventDeclineTransaction::TRANSACTIONTYPE: | case PhabricatorCalendarEventDeclineTransaction::TRANSACTIONTYPE: | ||||
| $acting_phid = $this->getActingAsPHID(); | $acting_phid = $this->getActingAsPHID(); | ||||
| $invalidate_phids[$acting_phid] = $acting_phid; | $invalidate_phids[$acting_phid] = $acting_phid; | ||||
| break; | break; | ||||
| case PhabricatorCalendarEventInviteTransaction::TRANSACTIONTYPE: | case PhabricatorCalendarEventInviteTransaction::TRANSACTIONTYPE: | ||||
| foreach ($xaction->getNewValue() as $phid => $ignored) { | foreach ($xaction->getOldValue() as $phid) { | ||||
| // Add the possibly un-invited user to the list of potentially | |||||
| // affected users if they are't already present. | |||||
| $phids[$phid] = $phid; | |||||
| $invalidate_phids[$phid] = $phid; | |||||
| } | |||||
| foreach ($xaction->getNewValue() as $phid) { | |||||
| $invalidate_phids[$phid] = $phid; | $invalidate_phids[$phid] = $phid; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| $phids = mpull($object->getInvitees(), 'getInviteePHID'); | |||||
| $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()); | $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)', | ||||
| $user->getTableName(), | $user->getTableName(), | ||||
| $phids, | $phids); | ||||
| $object->getStartDateTimeEpochForCache()); | |||||
| } | } | ||||
| return $xactions; | return $xactions; | ||||
| } | } | ||||
| protected function validateAllTransactions( | protected function validateAllTransactions( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| ▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines | |||||