From ab636f36bf7469fcd79adc18d83fff3ec1b57e5a Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 6 Feb 2014 10:07:29 -0800 Subject: [PATCH] Rename PhabricatorUserStatus to PhabricatorCalendarEvent Summary: Ref T4375. We never join this table, so this is a pretty straight find/replace. Test Plan: Browsed around Calendar, verified that nothing seemed broken. Saw my red dot in other apps. Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Maniphest Tasks: T4375 Differential Revision: https://secure.phabricator.com/D8145 --- resources/sql/autopatches/20140205.cal.1.rename.sql | 2 ++ src/__phutil_library_map__.php | 12 ++++++------ .../PhabricatorCalendarBrowseController.php | 2 +- .../controller/PhabricatorCalendarController.php | 2 +- .../PhabricatorCalendarDeleteStatusController.php | 2 +- .../PhabricatorCalendarEditStatusController.php | 8 ++++---- .../PhabricatorCalendarViewStatusController.php | 6 +++--- ...PhabricatorCalendarEventInvalidEpochException.php | 4 ++++ .../PhabricatorCalendarEventOverlapException.php | 4 ++++ .../storage/PhabricatorCalendarEvent.php} | 8 ++++---- .../conpherence/query/ConpherenceThreadQuery.php | 2 +- .../people/conduit/ConduitAPI_user_Method.php | 2 +- .../conduit/ConduitAPI_user_addstatus_Method.php | 6 +++--- .../people/conduit/ConduitAPI_user_query_Method.php | 2 +- .../conduit/ConduitAPI_user_removestatus_Method.php | 4 ++-- .../customfield/PhabricatorUserStatusField.php | 2 +- .../PhabricatorPeopleHovercardEventListener.php | 2 +- .../PhabricatorUserStatusInvalidEpochException.php | 4 ---- .../PhabricatorUserStatusOverlapException.php | 4 ---- .../people/query/PhabricatorPeopleQuery.php | 2 +- .../remarkup/PhabricatorRemarkupRuleMention.php | 6 +++--- src/applications/people/storage/PhabricatorUser.php | 5 ++--- src/infrastructure/storage/lisk/LiskDAO.php | 2 +- 23 files changed, 47 insertions(+), 46 deletions(-) create mode 100644 resources/sql/autopatches/20140205.cal.1.rename.sql create mode 100644 src/applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php create mode 100644 src/applications/calendar/exception/PhabricatorCalendarEventOverlapException.php rename src/applications/{people/storage/PhabricatorUserStatus.php => calendar/storage/PhabricatorCalendarEvent.php} (88%) delete mode 100644 src/applications/people/exception/PhabricatorUserStatusInvalidEpochException.php delete mode 100644 src/applications/people/exception/PhabricatorUserStatusOverlapException.php diff --git a/resources/sql/autopatches/20140205.cal.1.rename.sql b/resources/sql/autopatches/20140205.cal.1.rename.sql new file mode 100644 index 0000000000..83622ae3ad --- /dev/null +++ b/resources/sql/autopatches/20140205.cal.1.rename.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_user.user_status + RENAME {$NAMESPACE}_calendar.calendar_event; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4332232fa5..3b5bbde35f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1262,6 +1262,9 @@ phutil_register_library_map(array( 'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php', 'PhabricatorCalendarDeleteStatusController' => 'applications/calendar/controller/PhabricatorCalendarDeleteStatusController.php', 'PhabricatorCalendarEditStatusController' => 'applications/calendar/controller/PhabricatorCalendarEditStatusController.php', + 'PhabricatorCalendarEvent' => 'applications/calendar/storage/PhabricatorCalendarEvent.php', + 'PhabricatorCalendarEventInvalidEpochException' => 'applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php', + 'PhabricatorCalendarEventOverlapException' => 'applications/calendar/exception/PhabricatorCalendarEventOverlapException.php', 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php', 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', 'PhabricatorCalendarViewStatusController' => 'applications/calendar/controller/PhabricatorCalendarViewStatusController.php', @@ -2136,10 +2139,7 @@ phutil_register_library_map(array( 'PhabricatorUserSSHKey' => 'applications/settings/storage/PhabricatorUserSSHKey.php', 'PhabricatorUserSearchIndexer' => 'applications/people/search/PhabricatorUserSearchIndexer.php', 'PhabricatorUserSinceField' => 'applications/people/customfield/PhabricatorUserSinceField.php', - 'PhabricatorUserStatus' => 'applications/people/storage/PhabricatorUserStatus.php', 'PhabricatorUserStatusField' => 'applications/people/customfield/PhabricatorUserStatusField.php', - 'PhabricatorUserStatusInvalidEpochException' => 'applications/people/exception/PhabricatorUserStatusInvalidEpochException.php', - 'PhabricatorUserStatusOverlapException' => 'applications/people/exception/PhabricatorUserStatusOverlapException.php', 'PhabricatorUserTestCase' => 'applications/people/storage/__tests__/PhabricatorUserTestCase.php', 'PhabricatorUserTitleField' => 'applications/people/customfield/PhabricatorUserTitleField.php', 'PhabricatorUserTransaction' => 'applications/people/storage/PhabricatorUserTransaction.php', @@ -3900,6 +3900,9 @@ phutil_register_library_map(array( 'PhabricatorCalendarDAO' => 'PhabricatorLiskDAO', 'PhabricatorCalendarDeleteStatusController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEditStatusController' => 'PhabricatorCalendarController', + 'PhabricatorCalendarEvent' => 'PhabricatorCalendarDAO', + 'PhabricatorCalendarEventInvalidEpochException' => 'Exception', + 'PhabricatorCalendarEventOverlapException' => 'Exception', 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', 'PhabricatorCalendarViewStatusController' => 'PhabricatorCalendarController', @@ -4893,10 +4896,7 @@ phutil_register_library_map(array( 'PhabricatorUserSSHKey' => 'PhabricatorUserDAO', 'PhabricatorUserSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorUserSinceField' => 'PhabricatorUserCustomField', - 'PhabricatorUserStatus' => 'PhabricatorUserDAO', 'PhabricatorUserStatusField' => 'PhabricatorUserCustomField', - 'PhabricatorUserStatusInvalidEpochException' => 'Exception', - 'PhabricatorUserStatusOverlapException' => 'Exception', 'PhabricatorUserTestCase' => 'PhabricatorTestCase', 'PhabricatorUserTitleField' => 'PhabricatorUserCustomField', 'PhabricatorUserTransaction' => 'PhabricatorApplicationTransaction', diff --git a/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php b/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php index 88e2dfeb05..6a5e7e1ddd 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php @@ -19,7 +19,7 @@ final class PhabricatorCalendarBrowseController "{$year}-{$month}-01", "{$year}-{$month}-31"); - $statuses = id(new PhabricatorUserStatus()) + $statuses = id(new PhabricatorCalendarEvent()) ->loadAllWhere( 'dateTo >= %d AND dateFrom <= %d', strtotime("{$year}-{$month}-01"), diff --git a/src/applications/calendar/controller/PhabricatorCalendarController.php b/src/applications/calendar/controller/PhabricatorCalendarController.php index 8ad6de4a1c..34cc7b3d2d 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarController.php @@ -3,7 +3,7 @@ abstract class PhabricatorCalendarController extends PhabricatorController { - protected function buildSideNavView(PhabricatorUserStatus $status = null) { + protected function buildSideNavView(PhabricatorCalendarEvent $status = null) { $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); diff --git a/src/applications/calendar/controller/PhabricatorCalendarDeleteStatusController.php b/src/applications/calendar/controller/PhabricatorCalendarDeleteStatusController.php index e5f317b051..d4e312beee 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarDeleteStatusController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarDeleteStatusController.php @@ -12,7 +12,7 @@ final class PhabricatorCalendarDeleteStatusController public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); - $status = id(new PhabricatorUserStatus()) + $status = id(new PhabricatorCalendarEvent()) ->loadOneWhere('id = %d', $this->id); if (!$status) { diff --git a/src/applications/calendar/controller/PhabricatorCalendarEditStatusController.php b/src/applications/calendar/controller/PhabricatorCalendarEditStatusController.php index 47be7d376e..64aff975d9 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEditStatusController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEditStatusController.php @@ -30,7 +30,7 @@ final class PhabricatorCalendarEditStatusController ->setInitialTime(AphrontFormDateControl::TIME_END_OF_DAY); if ($this->isCreate()) { - $status = new PhabricatorUserStatus(); + $status = new PhabricatorCalendarEvent(); $end_value = $end_time->readValueFromRequest($request); $start_value = $start_time->readValueFromRequest($request); $submit_label = pht('Create'); @@ -38,7 +38,7 @@ final class PhabricatorCalendarEditStatusController $page_title = pht('Create Status'); $redirect = 'created'; } else { - $status = id(new PhabricatorUserStatus()) + $status = id(new PhabricatorCalendarEvent()) ->loadOneWhere('id = %d', $this->id); $end_time->setValue($status->getDateTo()); $start_time->setValue($status->getDateFrom()); @@ -67,9 +67,9 @@ final class PhabricatorCalendarEditStatusController ->setDateTo($end_value) ->setDescription($description) ->save(); - } catch (PhabricatorUserStatusInvalidEpochException $e) { + } catch (PhabricatorCalendarEventInvalidEpochException $e) { $errors[] = pht('Start must be before end.'); - } catch (PhabricatorUserStatusOverlapException $e) { + } catch (PhabricatorCalendarEventOverlapException $e) { $errors[] = pht('There is already a status within the specified '. 'timeframe. Edit or delete this existing status.'); } diff --git a/src/applications/calendar/controller/PhabricatorCalendarViewStatusController.php b/src/applications/calendar/controller/PhabricatorCalendarViewStatusController.php index b8f1a8ccd5..c58efb9f9e 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarViewStatusController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarViewStatusController.php @@ -16,7 +16,7 @@ final class PhabricatorCalendarViewStatusController $request = $this->getRequest(); $user = $request->getUser(); $handle = $this->getHandle($this->phid); - $statuses = id(new PhabricatorUserStatus()) + $statuses = id(new PhabricatorCalendarEvent()) ->loadAllWhere('userPHID = %s AND dateTo > UNIX_TIMESTAMP()', $this->phid); @@ -43,7 +43,7 @@ final class PhabricatorCalendarViewStatusController } private function buildStatusList(array $statuses) { - assert_instances_of($statuses, 'PhabricatorUserStatus'); + assert_instances_of($statuses, 'PhabricatorCalendarEvent'); $user = $this->getRequest()->getUser(); @@ -66,7 +66,7 @@ final class PhabricatorCalendarViewStatusController $from = phabricator_datetime($status->getDateFrom(), $user); $to = phabricator_datetime($status->getDateTo(), $user); - $color = ($status->getStatus() == PhabricatorUserStatus::STATUS_AWAY) + $color = ($status->getStatus() == PhabricatorCalendarEvent::STATUS_AWAY) ? 'red' : 'yellow'; diff --git a/src/applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php b/src/applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php new file mode 100644 index 0000000000..88b9aa5b4a --- /dev/null +++ b/src/applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php @@ -0,0 +1,4 @@ +dateTo, $viewer); - if ($this->status == PhabricatorUserStatus::STATUS_SPORADIC) { + if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) { return 'Sporadic until '.$until; } else { return 'Away until '.$until; @@ -65,7 +65,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO { public function save() { if ($this->getDateTo() <= $this->getDateFrom()) { - throw new PhabricatorUserStatusInvalidEpochException(); + throw new PhabricatorCalendarEventInvalidEpochException(); } $this->openTransaction(); @@ -82,7 +82,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO { if ($overlap) { $this->endWriteLocking(); $this->killTransaction(); - throw new PhabricatorUserStatusOverlapException(); + throw new PhabricatorCalendarEventOverlapException(); } } diff --git a/src/applications/conpherence/query/ConpherenceThreadQuery.php b/src/applications/conpherence/query/ConpherenceThreadQuery.php index f36d9d8fd8..474f6718d5 100644 --- a/src/applications/conpherence/query/ConpherenceThreadQuery.php +++ b/src/applications/conpherence/query/ConpherenceThreadQuery.php @@ -221,7 +221,7 @@ final class ConpherenceThreadQuery $this->getViewer()); $start_epoch = $epochs['start_epoch']; $end_epoch = $epochs['end_epoch']; - $statuses = id(new PhabricatorUserStatus()) + $statuses = id(new PhabricatorCalendarEvent()) ->loadAllWhere( 'userPHID in (%Ls) AND dateTo >= %d AND dateFrom <= %d', $participant_phids, diff --git a/src/applications/people/conduit/ConduitAPI_user_Method.php b/src/applications/people/conduit/ConduitAPI_user_Method.php index 8f9e2f899b..e9c12673bb 100644 --- a/src/applications/people/conduit/ConduitAPI_user_Method.php +++ b/src/applications/people/conduit/ConduitAPI_user_Method.php @@ -12,7 +12,7 @@ abstract class ConduitAPI_user_Method extends ConduitAPIMethod { protected function buildUserInformationDictionary( PhabricatorUser $user, - PhabricatorUserStatus $current_status = null) { + PhabricatorCalendarEvent $current_status = null) { $roles = array(); if ($user->getIsDisabled()) { diff --git a/src/applications/people/conduit/ConduitAPI_user_addstatus_Method.php b/src/applications/people/conduit/ConduitAPI_user_addstatus_Method.php index 0e8b206fe3..17266d14e0 100644 --- a/src/applications/people/conduit/ConduitAPI_user_addstatus_Method.php +++ b/src/applications/people/conduit/ConduitAPI_user_addstatus_Method.php @@ -42,16 +42,16 @@ final class ConduitAPI_user_addstatus_Method extends ConduitAPI_user_Method { $description = $request->getValue('description', ''); try { - id(new PhabricatorUserStatus()) + id(new PhabricatorCalendarEvent()) ->setUserPHID($user_phid) ->setDateFrom($from) ->setDateTo($to) ->setTextStatus($status) ->setDescription($description) ->save(); - } catch (PhabricatorUserStatusInvalidEpochException $e) { + } catch (PhabricatorCalendarEventInvalidEpochException $e) { throw new ConduitException('ERR-BAD-EPOCH'); - } catch (PhabricatorUserStatusOverlapException $e) { + } catch (PhabricatorCalendarEventOverlapException $e) { throw new ConduitException('ERR-OVERLAP'); } } diff --git a/src/applications/people/conduit/ConduitAPI_user_query_Method.php b/src/applications/people/conduit/ConduitAPI_user_query_Method.php index 33a9b00a3c..8906106946 100644 --- a/src/applications/people/conduit/ConduitAPI_user_query_Method.php +++ b/src/applications/people/conduit/ConduitAPI_user_query_Method.php @@ -69,7 +69,7 @@ final class ConduitAPI_user_query_Method } $users = $query->execute(); - $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( + $statuses = id(new PhabricatorCalendarEvent())->loadCurrentStatuses( mpull($users, 'getPHID')); $results = array(); diff --git a/src/applications/people/conduit/ConduitAPI_user_removestatus_Method.php b/src/applications/people/conduit/ConduitAPI_user_removestatus_Method.php index 93bac9c656..860c3ae971 100644 --- a/src/applications/people/conduit/ConduitAPI_user_removestatus_Method.php +++ b/src/applications/people/conduit/ConduitAPI_user_removestatus_Method.php @@ -39,7 +39,7 @@ final class ConduitAPI_user_removestatus_Method extends ConduitAPI_user_Method { throw new ConduitException('ERR-BAD-EPOCH'); } - $table = new PhabricatorUserStatus(); + $table = new PhabricatorCalendarEvent(); $table->openTransaction(); $table->beginReadLocking(); @@ -52,7 +52,7 @@ final class ConduitAPI_user_removestatus_Method extends ConduitAPI_user_Method { if ($status->getDateFrom() < $from) { if ($status->getDateTo() > $to) { // Split the interval. - id(new PhabricatorUserStatus()) + id(new PhabricatorCalendarEvent()) ->setUserPHID($user_phid) ->setDateFrom($to) ->setDateTo($status->getDateTo()) diff --git a/src/applications/people/customfield/PhabricatorUserStatusField.php b/src/applications/people/customfield/PhabricatorUserStatusField.php index 433076d4e6..1a52c267a9 100644 --- a/src/applications/people/customfield/PhabricatorUserStatusField.php +++ b/src/applications/people/customfield/PhabricatorUserStatusField.php @@ -25,7 +25,7 @@ final class PhabricatorUserStatusField $user = $this->getObject(); $viewer = $this->requireViewer(); - $statuses = id(new PhabricatorUserStatus()) + $statuses = id(new PhabricatorCalendarEvent()) ->loadCurrentStatuses(array($user->getPHID())); if (!$statuses) { return pht('Available'); diff --git a/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php b/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php index 380e446b64..a037ed61af 100644 --- a/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php +++ b/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php @@ -38,7 +38,7 @@ final class PhabricatorPeopleHovercardEventListener } else if (!$user->isUserActivated()) { $hovercard->addField(pht('Account'), pht('Not Activated')); } else { - $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( + $statuses = id(new PhabricatorCalendarEvent())->loadCurrentStatuses( array($user->getPHID())); if ($statuses) { $current_status = reset($statuses); diff --git a/src/applications/people/exception/PhabricatorUserStatusInvalidEpochException.php b/src/applications/people/exception/PhabricatorUserStatusInvalidEpochException.php deleted file mode 100644 index be495f4e83..0000000000 --- a/src/applications/people/exception/PhabricatorUserStatusInvalidEpochException.php +++ /dev/null @@ -1,4 +0,0 @@ -needStatus) { $user_list = mpull($users, null, 'getPHID'); - $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( + $statuses = id(new PhabricatorCalendarEvent())->loadCurrentStatuses( array_keys($user_list)); foreach ($user_list as $phid => $user) { $status = idx($statuses, $phid); diff --git a/src/applications/people/remarkup/PhabricatorRemarkupRuleMention.php b/src/applications/people/remarkup/PhabricatorRemarkupRuleMention.php index ada30a05fd..be35114892 100644 --- a/src/applications/people/remarkup/PhabricatorRemarkupRuleMention.php +++ b/src/applications/people/remarkup/PhabricatorRemarkupRuleMention.php @@ -76,7 +76,7 @@ final class PhabricatorRemarkupRuleMention ->execute(); if ($users) { - $user_statuses = id(new PhabricatorUserStatus()) + $user_statuses = id(new PhabricatorCalendarEvent()) ->loadCurrentStatuses(mpull($users, 'getPHID')); $user_statuses = mpull($user_statuses, null, 'getUserPHID'); } else { @@ -113,9 +113,9 @@ final class PhabricatorRemarkupRuleMention $status = idx($user_statuses, $user->getPHID()); if ($status) { $status = $status->getStatus(); - if ($status == PhabricatorUserStatus::STATUS_AWAY) { + if ($status == PhabricatorCalendarEvent::STATUS_AWAY) { $tag->setDotColor(PHUITagView::COLOR_RED); - } else if ($status == PhabricatorUserStatus::STATUS_AWAY) { + } else if ($status == PhabricatorCalendarEvent::STATUS_AWAY) { $tag->setDotColor(PHUITagView::COLOR_ORANGE); } } diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index 2a76f6481f..d7df6f7065 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -609,14 +609,13 @@ EOBODY; return celerity_get_resource_uri('/rsrc/image/avatar.png'); } - public function attachStatus(PhabricatorUserStatus $status) { + public function attachStatus(PhabricatorCalendarEvent $status) { $this->status = $status; return $this; } public function getStatus() { - $this->assertAttached($this->status); - return $this->status; + return $this->assertAttached($this->status); } public function hasStatus() { diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php index 36aac50de2..d755fba930 100644 --- a/src/infrastructure/storage/lisk/LiskDAO.php +++ b/src/infrastructure/storage/lisk/LiskDAO.php @@ -775,7 +775,7 @@ abstract class LiskDAO { * row in retrieving other rows. Example of a correct usage: * * $status = $author->loadOneRelative( - * new PhabricatorUserStatus(), + * new PhabricatorCalendarEvent(), * 'userPHID', * 'getPHID', * '(UNIX_TIMESTAMP() BETWEEN dateFrom AND dateTo)');