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:
@@ -36,7 +36,7 @@ final class PhabricatorCalendarBrowseController
|
|||||||
$event->setEpochRange($status->getDateFrom(), $status->getDateTo());
|
$event->setEpochRange($status->getDateFrom(), $status->getDateTo());
|
||||||
|
|
||||||
$name_text = $handles[$status->getUserPHID()]->getName();
|
$name_text = $handles[$status->getUserPHID()]->getName();
|
||||||
$status_text = $status->getTextStatus();
|
$status_text = $status->getHumanStatus();
|
||||||
$event->setUserPHID($status->getUserPHID());
|
$event->setUserPHID($status->getUserPHID());
|
||||||
$event->setName("{$name_text} ({$status_text})");
|
$event->setName("{$name_text} ({$status_text})");
|
||||||
$details = '';
|
$details = '';
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ final class ConduitAPI_user_addstatus_Method extends ConduitAPI_user_Method {
|
|||||||
$user_phid = $request->getUser()->getPHID();
|
$user_phid = $request->getUser()->getPHID();
|
||||||
$from = $request->getValue('fromEpoch');
|
$from = $request->getValue('fromEpoch');
|
||||||
$to = $request->getValue('toEpoch');
|
$to = $request->getValue('toEpoch');
|
||||||
$status = ucfirst($request->getValue('status'));
|
$status = $request->getValue('status');
|
||||||
$description = $request->getValue('description', '');
|
$description = $request->getValue('description', '');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
|
|||||||
const STATUS_AWAY = 1;
|
const STATUS_AWAY = 1;
|
||||||
const STATUS_SPORADIC = 2;
|
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() {
|
public function getStatusOptions() {
|
||||||
return array(
|
return array(
|
||||||
self::STATUS_AWAY => pht('Away'),
|
self::STATUS_AWAY => pht('Away'),
|
||||||
@@ -18,7 +27,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTextStatus() {
|
public function getHumanStatus() {
|
||||||
$options = $this->getStatusOptions();
|
$options = $this->getStatusOptions();
|
||||||
return $options[$this->status];
|
return $options[$this->status];
|
||||||
}
|
}
|
||||||
@@ -33,7 +42,7 @@ final class PhabricatorUserStatus extends PhabricatorUserDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setTextStatus($status) {
|
public function setTextStatus($status) {
|
||||||
$statuses = array_flip($this->getStatusOptions());
|
$statuses = array_flip(self::$statusTexts);
|
||||||
return $this->setStatus($statuses[$status]);
|
return $this->setStatus($statuses[$status]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ final class PhabricatorObjectHandle {
|
|||||||
private $timestamp;
|
private $timestamp;
|
||||||
private $alternateID;
|
private $alternateID;
|
||||||
private $status = PhabricatorObjectHandleStatus::STATUS_OPEN;
|
private $status = PhabricatorObjectHandleStatus::STATUS_OPEN;
|
||||||
|
private $title;
|
||||||
private $complete;
|
private $complete;
|
||||||
private $disabled;
|
private $disabled;
|
||||||
|
|
||||||
@@ -51,6 +52,11 @@ final class PhabricatorObjectHandle {
|
|||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setTitle($title) {
|
||||||
|
$this->title = $title;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setFullName($full_name) {
|
public function setFullName($full_name) {
|
||||||
$this->fullName = $full_name;
|
$this->fullName = $full_name;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -176,7 +182,7 @@ final class PhabricatorObjectHandle {
|
|||||||
|
|
||||||
if ($this->status != PhabricatorObjectHandleStatus::STATUS_OPEN) {
|
if ($this->status != PhabricatorObjectHandleStatus::STATUS_OPEN) {
|
||||||
$class .= ' handle-status-'.$this->status;
|
$class .= ' handle-status-'.$this->status;
|
||||||
$title = $this->status;
|
$title = (isset($this->title) ? $this->title : $this->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->disabled) {
|
if ($this->disabled) {
|
||||||
|
|||||||
@@ -223,12 +223,11 @@ final class PhabricatorObjectHandleData {
|
|||||||
$handle->setAlternateID($user->getID());
|
$handle->setAlternateID($user->getID());
|
||||||
$handle->setComplete(true);
|
$handle->setComplete(true);
|
||||||
if (isset($statuses[$phid])) {
|
if (isset($statuses[$phid])) {
|
||||||
$status = $statuses[$phid]->getTextStatus();
|
$handle->setStatus($statuses[$phid]->getTextStatus());
|
||||||
if ($this->viewer) {
|
if ($this->viewer) {
|
||||||
$date = $statuses[$phid]->getDateTo();
|
$handle->setTitle(
|
||||||
$status .= ' until '.phabricator_date($date, $this->viewer);
|
$statuses[$phid]->getTerseSummary($this->viewer));
|
||||||
}
|
}
|
||||||
$handle->setStatus($status);
|
|
||||||
}
|
}
|
||||||
$handle->setDisabled($user->getIsDisabled());
|
$handle->setDisabled($user->getIsDisabled());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user