From 0125984226f30dc00b25242266a9daaef23761b1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 10 Jul 2013 05:10:54 -0700 Subject: [PATCH] Use tags to show user status Summary: I'll probably move "away" to a custom field, but this is technically broken right now. Test Plan: {F49416} Reviewers: chad, btrahan Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D6402 --- .../PhabricatorPeopleProfileController.php | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/applications/people/controller/PhabricatorPeopleProfileController.php b/src/applications/people/controller/PhabricatorPeopleProfileController.php index 58a352d21a..97a0c5af64 100644 --- a/src/applications/people/controller/PhabricatorPeopleProfileController.php +++ b/src/applications/people/controller/PhabricatorPeopleProfileController.php @@ -7,8 +7,6 @@ final class PhabricatorPeopleProfileController private $page; public function shouldRequireAdmin() { - // Default for people app is true - // We desire public access here return false; } @@ -28,12 +26,12 @@ final class PhabricatorPeopleProfileController } public function processRequest() { - $viewer = $this->getRequest()->getUser(); - $user = id(new PhabricatorUser())->loadOneWhere( - 'userName = %s', - $this->username); + $user = id(new PhabricatorPeopleQuery()) + ->setViewer($viewer) + ->withUsernames(array($this->username)) + ->executeOne(); if (!$user) { return new Aphront404Response(); } @@ -61,10 +59,7 @@ final class PhabricatorPeopleProfileController $event->setUser($viewer); PhutilEventEngine::dispatchEvent($event); $nav = AphrontSideNavFilterView::newFromMenu($event->getValue('menu')); - - $this->page = $nav->selectFilter($this->page, 'feed'); - - $content = $this->renderUserFeed($user); + $nav->selectFilter($this->page, 'feed'); $picture = $user->loadProfileImageURI(); @@ -74,13 +69,38 @@ final class PhabricatorPeopleProfileController ->setImage($picture); if ($user->getIsDisabled()) { - $header->setStatus(pht('Disabled')); - } else { - $statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( - array($user->getPHID())); - if ($statuses) { - $header->setStatus(reset($statuses)->getTerseSummary($viewer)); - } + $header->addTag( + id(new PhabricatorTagView()) + ->setType(PhabricatorTagView::TYPE_STATE) + ->setBackgroundColor(PhabricatorTagView::COLOR_GREY) + ->setName(pht('Disabled'))); + } + + if ($user->getIsAdmin()) { + $header->addTag( + id(new PhabricatorTagView()) + ->setType(PhabricatorTagView::TYPE_STATE) + ->setBackgroundColor(PhabricatorTagView::COLOR_RED) + ->setName(pht('Administrator'))); + } + + if ($user->getIsSystemAgent()) { + $header->addTag( + id(new PhabricatorTagView()) + ->setType(PhabricatorTagView::TYPE_STATE) + ->setBackgroundColor(PhabricatorTagView::COLOR_BLUE) + ->setName(pht('Bot'))); + } + + + $statuses = id(new PhabricatorUserStatus()) + ->loadCurrentStatuses(array($user->getPHID())); + if ($statuses) { + $header->addTag( + id(new PhabricatorTagView()) + ->setType(PhabricatorTagView::TYPE_STATE) + ->setBackgroundColor(PhabricatorTagView::COLOR_ORANGE) + ->setName(head($statuses)->getTerseSummary($viewer))); } $actions = id(new PhabricatorActionListView()) @@ -117,7 +137,7 @@ final class PhabricatorPeopleProfileController $nav->appendChild($header); $nav->appendChild($actions); $nav->appendChild($properties); - $nav->appendChild($content); + $nav->appendChild($this->renderUserFeed($user)); return $this->buildApplicationPage( $nav,