1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-29 08:50:58 +01:00

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
This commit is contained in:
epriestley 2014-02-06 10:07:29 -08:00
parent 980f06f3da
commit ab636f36bf
23 changed files with 47 additions and 46 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_user.user_status
RENAME {$NAMESPACE}_calendar.calendar_event;

View file

@ -1262,6 +1262,9 @@ phutil_register_library_map(array(
'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php', 'PhabricatorCalendarDAO' => 'applications/calendar/storage/PhabricatorCalendarDAO.php',
'PhabricatorCalendarDeleteStatusController' => 'applications/calendar/controller/PhabricatorCalendarDeleteStatusController.php', 'PhabricatorCalendarDeleteStatusController' => 'applications/calendar/controller/PhabricatorCalendarDeleteStatusController.php',
'PhabricatorCalendarEditStatusController' => 'applications/calendar/controller/PhabricatorCalendarEditStatusController.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', 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
'PhabricatorCalendarViewStatusController' => 'applications/calendar/controller/PhabricatorCalendarViewStatusController.php', 'PhabricatorCalendarViewStatusController' => 'applications/calendar/controller/PhabricatorCalendarViewStatusController.php',
@ -2136,10 +2139,7 @@ phutil_register_library_map(array(
'PhabricatorUserSSHKey' => 'applications/settings/storage/PhabricatorUserSSHKey.php', 'PhabricatorUserSSHKey' => 'applications/settings/storage/PhabricatorUserSSHKey.php',
'PhabricatorUserSearchIndexer' => 'applications/people/search/PhabricatorUserSearchIndexer.php', 'PhabricatorUserSearchIndexer' => 'applications/people/search/PhabricatorUserSearchIndexer.php',
'PhabricatorUserSinceField' => 'applications/people/customfield/PhabricatorUserSinceField.php', 'PhabricatorUserSinceField' => 'applications/people/customfield/PhabricatorUserSinceField.php',
'PhabricatorUserStatus' => 'applications/people/storage/PhabricatorUserStatus.php',
'PhabricatorUserStatusField' => 'applications/people/customfield/PhabricatorUserStatusField.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', 'PhabricatorUserTestCase' => 'applications/people/storage/__tests__/PhabricatorUserTestCase.php',
'PhabricatorUserTitleField' => 'applications/people/customfield/PhabricatorUserTitleField.php', 'PhabricatorUserTitleField' => 'applications/people/customfield/PhabricatorUserTitleField.php',
'PhabricatorUserTransaction' => 'applications/people/storage/PhabricatorUserTransaction.php', 'PhabricatorUserTransaction' => 'applications/people/storage/PhabricatorUserTransaction.php',
@ -3900,6 +3900,9 @@ phutil_register_library_map(array(
'PhabricatorCalendarDAO' => 'PhabricatorLiskDAO', 'PhabricatorCalendarDAO' => 'PhabricatorLiskDAO',
'PhabricatorCalendarDeleteStatusController' => 'PhabricatorCalendarController', 'PhabricatorCalendarDeleteStatusController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEditStatusController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEditStatusController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEvent' => 'PhabricatorCalendarDAO',
'PhabricatorCalendarEventInvalidEpochException' => 'Exception',
'PhabricatorCalendarEventOverlapException' => 'Exception',
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
'PhabricatorCalendarViewStatusController' => 'PhabricatorCalendarController', 'PhabricatorCalendarViewStatusController' => 'PhabricatorCalendarController',
@ -4893,10 +4896,7 @@ phutil_register_library_map(array(
'PhabricatorUserSSHKey' => 'PhabricatorUserDAO', 'PhabricatorUserSSHKey' => 'PhabricatorUserDAO',
'PhabricatorUserSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorUserSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'PhabricatorUserSinceField' => 'PhabricatorUserCustomField', 'PhabricatorUserSinceField' => 'PhabricatorUserCustomField',
'PhabricatorUserStatus' => 'PhabricatorUserDAO',
'PhabricatorUserStatusField' => 'PhabricatorUserCustomField', 'PhabricatorUserStatusField' => 'PhabricatorUserCustomField',
'PhabricatorUserStatusInvalidEpochException' => 'Exception',
'PhabricatorUserStatusOverlapException' => 'Exception',
'PhabricatorUserTestCase' => 'PhabricatorTestCase', 'PhabricatorUserTestCase' => 'PhabricatorTestCase',
'PhabricatorUserTitleField' => 'PhabricatorUserCustomField', 'PhabricatorUserTitleField' => 'PhabricatorUserCustomField',
'PhabricatorUserTransaction' => 'PhabricatorApplicationTransaction', 'PhabricatorUserTransaction' => 'PhabricatorApplicationTransaction',

View file

@ -19,7 +19,7 @@ final class PhabricatorCalendarBrowseController
"{$year}-{$month}-01", "{$year}-{$month}-01",
"{$year}-{$month}-31"); "{$year}-{$month}-31");
$statuses = id(new PhabricatorUserStatus()) $statuses = id(new PhabricatorCalendarEvent())
->loadAllWhere( ->loadAllWhere(
'dateTo >= %d AND dateFrom <= %d', 'dateTo >= %d AND dateFrom <= %d',
strtotime("{$year}-{$month}-01"), strtotime("{$year}-{$month}-01"),

View file

@ -3,7 +3,7 @@
abstract class PhabricatorCalendarController extends PhabricatorController { abstract class PhabricatorCalendarController extends PhabricatorController {
protected function buildSideNavView(PhabricatorUserStatus $status = null) { protected function buildSideNavView(PhabricatorCalendarEvent $status = null) {
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));

View file

@ -12,7 +12,7 @@ final class PhabricatorCalendarDeleteStatusController
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$status = id(new PhabricatorUserStatus()) $status = id(new PhabricatorCalendarEvent())
->loadOneWhere('id = %d', $this->id); ->loadOneWhere('id = %d', $this->id);
if (!$status) { if (!$status) {

View file

@ -30,7 +30,7 @@ final class PhabricatorCalendarEditStatusController
->setInitialTime(AphrontFormDateControl::TIME_END_OF_DAY); ->setInitialTime(AphrontFormDateControl::TIME_END_OF_DAY);
if ($this->isCreate()) { if ($this->isCreate()) {
$status = new PhabricatorUserStatus(); $status = new PhabricatorCalendarEvent();
$end_value = $end_time->readValueFromRequest($request); $end_value = $end_time->readValueFromRequest($request);
$start_value = $start_time->readValueFromRequest($request); $start_value = $start_time->readValueFromRequest($request);
$submit_label = pht('Create'); $submit_label = pht('Create');
@ -38,7 +38,7 @@ final class PhabricatorCalendarEditStatusController
$page_title = pht('Create Status'); $page_title = pht('Create Status');
$redirect = 'created'; $redirect = 'created';
} else { } else {
$status = id(new PhabricatorUserStatus()) $status = id(new PhabricatorCalendarEvent())
->loadOneWhere('id = %d', $this->id); ->loadOneWhere('id = %d', $this->id);
$end_time->setValue($status->getDateTo()); $end_time->setValue($status->getDateTo());
$start_time->setValue($status->getDateFrom()); $start_time->setValue($status->getDateFrom());
@ -67,9 +67,9 @@ final class PhabricatorCalendarEditStatusController
->setDateTo($end_value) ->setDateTo($end_value)
->setDescription($description) ->setDescription($description)
->save(); ->save();
} catch (PhabricatorUserStatusInvalidEpochException $e) { } catch (PhabricatorCalendarEventInvalidEpochException $e) {
$errors[] = pht('Start must be before end.'); $errors[] = pht('Start must be before end.');
} catch (PhabricatorUserStatusOverlapException $e) { } catch (PhabricatorCalendarEventOverlapException $e) {
$errors[] = pht('There is already a status within the specified '. $errors[] = pht('There is already a status within the specified '.
'timeframe. Edit or delete this existing status.'); 'timeframe. Edit or delete this existing status.');
} }

View file

@ -16,7 +16,7 @@ final class PhabricatorCalendarViewStatusController
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$handle = $this->getHandle($this->phid); $handle = $this->getHandle($this->phid);
$statuses = id(new PhabricatorUserStatus()) $statuses = id(new PhabricatorCalendarEvent())
->loadAllWhere('userPHID = %s AND dateTo > UNIX_TIMESTAMP()', ->loadAllWhere('userPHID = %s AND dateTo > UNIX_TIMESTAMP()',
$this->phid); $this->phid);
@ -43,7 +43,7 @@ final class PhabricatorCalendarViewStatusController
} }
private function buildStatusList(array $statuses) { private function buildStatusList(array $statuses) {
assert_instances_of($statuses, 'PhabricatorUserStatus'); assert_instances_of($statuses, 'PhabricatorCalendarEvent');
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
@ -66,7 +66,7 @@ final class PhabricatorCalendarViewStatusController
$from = phabricator_datetime($status->getDateFrom(), $user); $from = phabricator_datetime($status->getDateFrom(), $user);
$to = phabricator_datetime($status->getDateTo(), $user); $to = phabricator_datetime($status->getDateTo(), $user);
$color = ($status->getStatus() == PhabricatorUserStatus::STATUS_AWAY) $color = ($status->getStatus() == PhabricatorCalendarEvent::STATUS_AWAY)
? 'red' ? 'red'
: 'yellow'; : 'yellow';

View file

@ -0,0 +1,4 @@
<?php
final class PhabricatorCalendarEventInvalidEpochException extends Exception {
}

View file

@ -0,0 +1,4 @@
<?php
final class PhabricatorCalendarEventOverlapException extends Exception {
}

View file

@ -1,6 +1,6 @@
<?php <?php
final class PhabricatorUserStatus extends PhabricatorUserDAO { final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO {
protected $userPHID; protected $userPHID;
protected $dateFrom; protected $dateFrom;
@ -34,7 +34,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
public function getTerseSummary(PhabricatorUser $viewer) { public function getTerseSummary(PhabricatorUser $viewer) {
$until = phabricator_date($this->dateTo, $viewer); $until = phabricator_date($this->dateTo, $viewer);
if ($this->status == PhabricatorUserStatus::STATUS_SPORADIC) { if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) {
return 'Sporadic until '.$until; return 'Sporadic until '.$until;
} else { } else {
return 'Away until '.$until; return 'Away until '.$until;
@ -65,7 +65,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
public function save() { public function save() {
if ($this->getDateTo() <= $this->getDateFrom()) { if ($this->getDateTo() <= $this->getDateFrom()) {
throw new PhabricatorUserStatusInvalidEpochException(); throw new PhabricatorCalendarEventInvalidEpochException();
} }
$this->openTransaction(); $this->openTransaction();
@ -82,7 +82,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
if ($overlap) { if ($overlap) {
$this->endWriteLocking(); $this->endWriteLocking();
$this->killTransaction(); $this->killTransaction();
throw new PhabricatorUserStatusOverlapException(); throw new PhabricatorCalendarEventOverlapException();
} }
} }

View file

@ -221,7 +221,7 @@ final class ConpherenceThreadQuery
$this->getViewer()); $this->getViewer());
$start_epoch = $epochs['start_epoch']; $start_epoch = $epochs['start_epoch'];
$end_epoch = $epochs['end_epoch']; $end_epoch = $epochs['end_epoch'];
$statuses = id(new PhabricatorUserStatus()) $statuses = id(new PhabricatorCalendarEvent())
->loadAllWhere( ->loadAllWhere(
'userPHID in (%Ls) AND dateTo >= %d AND dateFrom <= %d', 'userPHID in (%Ls) AND dateTo >= %d AND dateFrom <= %d',
$participant_phids, $participant_phids,

View file

@ -12,7 +12,7 @@ abstract class ConduitAPI_user_Method extends ConduitAPIMethod {
protected function buildUserInformationDictionary( protected function buildUserInformationDictionary(
PhabricatorUser $user, PhabricatorUser $user,
PhabricatorUserStatus $current_status = null) { PhabricatorCalendarEvent $current_status = null) {
$roles = array(); $roles = array();
if ($user->getIsDisabled()) { if ($user->getIsDisabled()) {

View file

@ -42,16 +42,16 @@ final class ConduitAPI_user_addstatus_Method extends ConduitAPI_user_Method {
$description = $request->getValue('description', ''); $description = $request->getValue('description', '');
try { try {
id(new PhabricatorUserStatus()) id(new PhabricatorCalendarEvent())
->setUserPHID($user_phid) ->setUserPHID($user_phid)
->setDateFrom($from) ->setDateFrom($from)
->setDateTo($to) ->setDateTo($to)
->setTextStatus($status) ->setTextStatus($status)
->setDescription($description) ->setDescription($description)
->save(); ->save();
} catch (PhabricatorUserStatusInvalidEpochException $e) { } catch (PhabricatorCalendarEventInvalidEpochException $e) {
throw new ConduitException('ERR-BAD-EPOCH'); throw new ConduitException('ERR-BAD-EPOCH');
} catch (PhabricatorUserStatusOverlapException $e) { } catch (PhabricatorCalendarEventOverlapException $e) {
throw new ConduitException('ERR-OVERLAP'); throw new ConduitException('ERR-OVERLAP');
} }
} }

View file

@ -69,7 +69,7 @@ final class ConduitAPI_user_query_Method
} }
$users = $query->execute(); $users = $query->execute();
$statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( $statuses = id(new PhabricatorCalendarEvent())->loadCurrentStatuses(
mpull($users, 'getPHID')); mpull($users, 'getPHID'));
$results = array(); $results = array();

View file

@ -39,7 +39,7 @@ final class ConduitAPI_user_removestatus_Method extends ConduitAPI_user_Method {
throw new ConduitException('ERR-BAD-EPOCH'); throw new ConduitException('ERR-BAD-EPOCH');
} }
$table = new PhabricatorUserStatus(); $table = new PhabricatorCalendarEvent();
$table->openTransaction(); $table->openTransaction();
$table->beginReadLocking(); $table->beginReadLocking();
@ -52,7 +52,7 @@ final class ConduitAPI_user_removestatus_Method extends ConduitAPI_user_Method {
if ($status->getDateFrom() < $from) { if ($status->getDateFrom() < $from) {
if ($status->getDateTo() > $to) { if ($status->getDateTo() > $to) {
// Split the interval. // Split the interval.
id(new PhabricatorUserStatus()) id(new PhabricatorCalendarEvent())
->setUserPHID($user_phid) ->setUserPHID($user_phid)
->setDateFrom($to) ->setDateFrom($to)
->setDateTo($status->getDateTo()) ->setDateTo($status->getDateTo())

View file

@ -25,7 +25,7 @@ final class PhabricatorUserStatusField
$user = $this->getObject(); $user = $this->getObject();
$viewer = $this->requireViewer(); $viewer = $this->requireViewer();
$statuses = id(new PhabricatorUserStatus()) $statuses = id(new PhabricatorCalendarEvent())
->loadCurrentStatuses(array($user->getPHID())); ->loadCurrentStatuses(array($user->getPHID()));
if (!$statuses) { if (!$statuses) {
return pht('Available'); return pht('Available');

View file

@ -38,7 +38,7 @@ final class PhabricatorPeopleHovercardEventListener
} else if (!$user->isUserActivated()) { } else if (!$user->isUserActivated()) {
$hovercard->addField(pht('Account'), pht('Not Activated')); $hovercard->addField(pht('Account'), pht('Not Activated'));
} else { } else {
$statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( $statuses = id(new PhabricatorCalendarEvent())->loadCurrentStatuses(
array($user->getPHID())); array($user->getPHID()));
if ($statuses) { if ($statuses) {
$current_status = reset($statuses); $current_status = reset($statuses);

View file

@ -1,4 +0,0 @@
<?php
final class PhabricatorUserStatusInvalidEpochException extends Exception {
}

View file

@ -1,4 +0,0 @@
<?php
final class PhabricatorUserStatusOverlapException extends Exception {
}

View file

@ -167,7 +167,7 @@ final class PhabricatorPeopleQuery
if ($this->needStatus) { if ($this->needStatus) {
$user_list = mpull($users, null, 'getPHID'); $user_list = mpull($users, null, 'getPHID');
$statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( $statuses = id(new PhabricatorCalendarEvent())->loadCurrentStatuses(
array_keys($user_list)); array_keys($user_list));
foreach ($user_list as $phid => $user) { foreach ($user_list as $phid => $user) {
$status = idx($statuses, $phid); $status = idx($statuses, $phid);

View file

@ -76,7 +76,7 @@ final class PhabricatorRemarkupRuleMention
->execute(); ->execute();
if ($users) { if ($users) {
$user_statuses = id(new PhabricatorUserStatus()) $user_statuses = id(new PhabricatorCalendarEvent())
->loadCurrentStatuses(mpull($users, 'getPHID')); ->loadCurrentStatuses(mpull($users, 'getPHID'));
$user_statuses = mpull($user_statuses, null, 'getUserPHID'); $user_statuses = mpull($user_statuses, null, 'getUserPHID');
} else { } else {
@ -113,9 +113,9 @@ final class PhabricatorRemarkupRuleMention
$status = idx($user_statuses, $user->getPHID()); $status = idx($user_statuses, $user->getPHID());
if ($status) { if ($status) {
$status = $status->getStatus(); $status = $status->getStatus();
if ($status == PhabricatorUserStatus::STATUS_AWAY) { if ($status == PhabricatorCalendarEvent::STATUS_AWAY) {
$tag->setDotColor(PHUITagView::COLOR_RED); $tag->setDotColor(PHUITagView::COLOR_RED);
} else if ($status == PhabricatorUserStatus::STATUS_AWAY) { } else if ($status == PhabricatorCalendarEvent::STATUS_AWAY) {
$tag->setDotColor(PHUITagView::COLOR_ORANGE); $tag->setDotColor(PHUITagView::COLOR_ORANGE);
} }
} }

View file

@ -609,14 +609,13 @@ EOBODY;
return celerity_get_resource_uri('/rsrc/image/avatar.png'); return celerity_get_resource_uri('/rsrc/image/avatar.png');
} }
public function attachStatus(PhabricatorUserStatus $status) { public function attachStatus(PhabricatorCalendarEvent $status) {
$this->status = $status; $this->status = $status;
return $this; return $this;
} }
public function getStatus() { public function getStatus() {
$this->assertAttached($this->status); return $this->assertAttached($this->status);
return $this->status;
} }
public function hasStatus() { public function hasStatus() {

View file

@ -775,7 +775,7 @@ abstract class LiskDAO {
* row in retrieving other rows. Example of a correct usage: * row in retrieving other rows. Example of a correct usage:
* *
* $status = $author->loadOneRelative( * $status = $author->loadOneRelative(
* new PhabricatorUserStatus(), * new PhabricatorCalendarEvent(),
* 'userPHID', * 'userPHID',
* 'getPHID', * 'getPHID',
* '(UNIX_TIMESTAMP() BETWEEN dateFrom AND dateTo)'); * '(UNIX_TIMESTAMP() BETWEEN dateFrom AND dateTo)');