mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Fix displaying of user status
Summary: This fixes two separate issues: # `getTextStatus()` is used for machine readable data in handles and user.info method. Broken since D3810. # Status may contain date. Broken since beginning but masked by the fact that CSS ignores unknown class names. Test Plan: Displayed revision with reviewer away. Called `user.addstatus`. Edited status in calendar. Reviewers: btrahan, epriestley Reviewed By: epriestley CC: nh, aran, Korvin Differential Revision: https://secure.phabricator.com/D4275
This commit is contained in:
parent
1264e38541
commit
f2639e528c
5 changed files with 23 additions and 9 deletions
|
@ -36,7 +36,7 @@ final class PhabricatorCalendarBrowseController
|
|||
$event->setEpochRange($status->getDateFrom(), $status->getDateTo());
|
||||
|
||||
$name_text = $handles[$status->getUserPHID()]->getName();
|
||||
$status_text = $status->getTextStatus();
|
||||
$status_text = $status->getHumanStatus();
|
||||
$event->setUserPHID($status->getUserPHID());
|
||||
$event->setName("{$name_text} ({$status_text})");
|
||||
$details = '';
|
||||
|
|
|
@ -38,7 +38,7 @@ final class ConduitAPI_user_addstatus_Method extends ConduitAPI_user_Method {
|
|||
$user_phid = $request->getUser()->getPHID();
|
||||
$from = $request->getValue('fromEpoch');
|
||||
$to = $request->getValue('toEpoch');
|
||||
$status = ucfirst($request->getValue('status'));
|
||||
$status = $request->getValue('status');
|
||||
$description = $request->getValue('description', '');
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,6 +11,15 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
|
|||
const STATUS_AWAY = 1;
|
||||
const STATUS_SPORADIC = 2;
|
||||
|
||||
private static $statusTexts = array(
|
||||
self::STATUS_AWAY => 'away',
|
||||
self::STATUS_SPORADIC => 'sporadic',
|
||||
);
|
||||
|
||||
public function getTextStatus() {
|
||||
return self::$statusTexts[$this->status];
|
||||
}
|
||||
|
||||
public function getStatusOptions() {
|
||||
return array(
|
||||
self::STATUS_AWAY => pht('Away'),
|
||||
|
@ -18,7 +27,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
|
|||
);
|
||||
}
|
||||
|
||||
public function getTextStatus() {
|
||||
public function getHumanStatus() {
|
||||
$options = $this->getStatusOptions();
|
||||
return $options[$this->status];
|
||||
}
|
||||
|
@ -33,7 +42,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
|
|||
}
|
||||
|
||||
public function setTextStatus($status) {
|
||||
$statuses = array_flip($this->getStatusOptions());
|
||||
$statuses = array_flip(self::$statusTexts);
|
||||
return $this->setStatus($statuses[$status]);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ final class PhabricatorObjectHandle {
|
|||
private $timestamp;
|
||||
private $alternateID;
|
||||
private $status = PhabricatorObjectHandleStatus::STATUS_OPEN;
|
||||
private $title;
|
||||
private $complete;
|
||||
private $disabled;
|
||||
|
||||
|
@ -51,6 +52,11 @@ final class PhabricatorObjectHandle {
|
|||
return $this->status;
|
||||
}
|
||||
|
||||
public function setTitle($title) {
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFullName($full_name) {
|
||||
$this->fullName = $full_name;
|
||||
return $this;
|
||||
|
@ -176,7 +182,7 @@ final class PhabricatorObjectHandle {
|
|||
|
||||
if ($this->status != PhabricatorObjectHandleStatus::STATUS_OPEN) {
|
||||
$class .= ' handle-status-'.$this->status;
|
||||
$title = $this->status;
|
||||
$title = (isset($this->title) ? $this->title : $this->status);
|
||||
}
|
||||
|
||||
if ($this->disabled) {
|
||||
|
|
|
@ -223,12 +223,11 @@ final class PhabricatorObjectHandleData {
|
|||
$handle->setAlternateID($user->getID());
|
||||
$handle->setComplete(true);
|
||||
if (isset($statuses[$phid])) {
|
||||
$status = $statuses[$phid]->getTextStatus();
|
||||
$handle->setStatus($statuses[$phid]->getTextStatus());
|
||||
if ($this->viewer) {
|
||||
$date = $statuses[$phid]->getDateTo();
|
||||
$status .= ' until '.phabricator_date($date, $this->viewer);
|
||||
$handle->setTitle(
|
||||
$statuses[$phid]->getTerseSummary($this->viewer));
|
||||
}
|
||||
$handle->setStatus($status);
|
||||
}
|
||||
$handle->setDisabled($user->getIsDisabled());
|
||||
|
||||
|
|
Loading…
Reference in a new issue