Permalink
Browse files

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
  • Loading branch information...
1 parent 1264e38 commit f2639e528c37b8030f9af03447ee2708d435f9fb vrana committed Dec 22, 2012
@@ -36,7 +36,7 @@ public function processRequest() {
$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 @@ protected function execute(ConduitAPIRequest $request) {
$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,14 +11,23 @@
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'),
self::STATUS_SPORADIC => pht('Sporadic'),
);
}
- public function getTextStatus() {
+ public function getHumanStatus() {
$options = $this->getStatusOptions();
return $options[$this->status];
}
@@ -33,7 +42,7 @@ public function getTerseSummary(PhabricatorUser $viewer) {
}
public function setTextStatus($status) {
- $statuses = array_flip($this->getStatusOptions());
+ $statuses = array_flip(self::$statusTexts);
return $this->setStatus($statuses[$status]);
}
@@ -12,6 +12,7 @@
private $timestamp;
private $alternateID;
private $status = PhabricatorObjectHandleStatus::STATUS_OPEN;
+ private $title;
private $complete;
private $disabled;
@@ -51,6 +52,11 @@ public function getStatus() {
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 @@ public function renderLink() {
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 @@ public function loadHandles() {
$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());

0 comments on commit f2639e5

Please sign in to comment.