diff --git a/src/applications/differential/field/specification/author/DifferentialAuthorFieldSpecification.php b/src/applications/differential/field/specification/author/DifferentialAuthorFieldSpecification.php index 54a9405ef2..1e0a666575 100644 --- a/src/applications/differential/field/specification/author/DifferentialAuthorFieldSpecification.php +++ b/src/applications/differential/field/specification/author/DifferentialAuthorFieldSpecification.php @@ -32,10 +32,7 @@ final class DifferentialAuthorFieldSpecification } public function renderValueForRevisionView() { - $author_phid = $this->getAuthorPHID(); - $handle = $this->getHandle($author_phid); - - return $handle->renderLink(); + return $this->renderUserList(array($this->getAuthorPHID())); } private function getAuthorPHID() { diff --git a/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php b/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php index 91f8b8e34b..6ed0b16eec 100644 --- a/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php +++ b/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php @@ -265,6 +265,45 @@ abstract class DifferentialFieldSpecification { } + /** + * Load users, their current statuses and return a markup with links to the + * user profiles and information about their current status. + * + * @return string Display markup. + * @task view + */ + public function renderUserList(array $user_phids) { + if (!$user_phids) { + return 'None'; + } + + $statuses = id(new PhabricatorUserStatus())->loadAllWhere( + 'userPHID IN (%Ls) AND UNIX_TIMESTAMP() BETWEEN dateFrom AND dateTo', + $user_phids); + $statuses = mpull($statuses, null, 'getUserPHID'); + + $links = array(); + foreach ($user_phids as $user_phid) { + $handle = $this->getHandle($user_phid); + $extra = null; + $status = idx($statuses, $handle->getPHID()); + if ($handle->isDisabled()) { + $extra = ' (disabled)'; + } else if ($status) { + $until = phabricator_date($status->getDateTo(), $this->getUser()); + if ($status->getStatus() == PhabricatorUserStatus::STATUS_SPORADIC) { + $extra = ' (sporadic)'; + } else { + $extra = ' (away)'; + } + } + $links[] = $handle->renderLink().$extra; + } + + return implode(', ', $links); + } + + /** * Return a markup block representing a warning to display with the comment * box when preparing to accept a diff. A return value of null indicates no diff --git a/src/applications/differential/field/specification/base/__init__.php b/src/applications/differential/field/specification/base/__init__.php index db188c4711..d6c462156f 100644 --- a/src/applications/differential/field/specification/base/__init__.php +++ b/src/applications/differential/field/specification/base/__init__.php @@ -11,6 +11,8 @@ phutil_require_module('phabricator', 'applications/differential/field/exception/ phutil_require_module('phabricator', 'applications/differential/field/exception/parse'); phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist'); phutil_require_module('phabricator', 'applications/people/storage/user'); +phutil_require_module('phabricator', 'applications/people/storage/userstatus'); +phutil_require_module('phabricator', 'view/utils'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/differential/field/specification/ccs/DifferentialCCsFieldSpecification.php b/src/applications/differential/field/specification/ccs/DifferentialCCsFieldSpecification.php index 44c3000345..41dabae4cb 100644 --- a/src/applications/differential/field/specification/ccs/DifferentialCCsFieldSpecification.php +++ b/src/applications/differential/field/specification/ccs/DifferentialCCsFieldSpecification.php @@ -34,17 +34,7 @@ final class DifferentialCCsFieldSpecification } public function renderValueForRevisionView() { - $cc_phids = $this->getCCPHIDs(); - if (!$cc_phids) { - return 'None'; - } - - $links = array(); - foreach ($cc_phids as $cc_phid) { - $links[] = $this->getHandle($cc_phid)->renderLink(); - } - - return implode(', ', $links); + return $this->renderUserList($this->getCCPHIDs()); } private function getCCPHIDs() { diff --git a/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php b/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php index a4f7ad2144..1d6546cd05 100644 --- a/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php +++ b/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php @@ -35,17 +35,7 @@ final class DifferentialReviewersFieldSpecification } public function renderValueForRevisionView() { - $reviewer_phids = $this->getReviewerPHIDs(); - if (!$reviewer_phids) { - return 'None'; - } - - $links = array(); - foreach ($reviewer_phids as $reviewer_phid) { - $links[] = $this->getHandle($reviewer_phid)->renderLink(); - } - - return implode(', ', $links); + return $this->renderUserList($this->getReviewerPHIDs()); } private function getReviewerPHIDs() {