1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

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
This commit is contained in:
epriestley 2013-07-10 05:10:54 -07:00
parent b92fe7dbda
commit 0125984226

View file

@ -7,8 +7,6 @@ final class PhabricatorPeopleProfileController
private $page; private $page;
public function shouldRequireAdmin() { public function shouldRequireAdmin() {
// Default for people app is true
// We desire public access here
return false; return false;
} }
@ -28,12 +26,12 @@ final class PhabricatorPeopleProfileController
} }
public function processRequest() { public function processRequest() {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();
$user = id(new PhabricatorUser())->loadOneWhere( $user = id(new PhabricatorPeopleQuery())
'userName = %s', ->setViewer($viewer)
$this->username); ->withUsernames(array($this->username))
->executeOne();
if (!$user) { if (!$user) {
return new Aphront404Response(); return new Aphront404Response();
} }
@ -61,10 +59,7 @@ final class PhabricatorPeopleProfileController
$event->setUser($viewer); $event->setUser($viewer);
PhutilEventEngine::dispatchEvent($event); PhutilEventEngine::dispatchEvent($event);
$nav = AphrontSideNavFilterView::newFromMenu($event->getValue('menu')); $nav = AphrontSideNavFilterView::newFromMenu($event->getValue('menu'));
$nav->selectFilter($this->page, 'feed');
$this->page = $nav->selectFilter($this->page, 'feed');
$content = $this->renderUserFeed($user);
$picture = $user->loadProfileImageURI(); $picture = $user->loadProfileImageURI();
@ -74,13 +69,38 @@ final class PhabricatorPeopleProfileController
->setImage($picture); ->setImage($picture);
if ($user->getIsDisabled()) { if ($user->getIsDisabled()) {
$header->setStatus(pht('Disabled')); $header->addTag(
} else { id(new PhabricatorTagView())
$statuses = id(new PhabricatorUserStatus())->loadCurrentStatuses( ->setType(PhabricatorTagView::TYPE_STATE)
array($user->getPHID())); ->setBackgroundColor(PhabricatorTagView::COLOR_GREY)
if ($statuses) { ->setName(pht('Disabled')));
$header->setStatus(reset($statuses)->getTerseSummary($viewer));
} }
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()) $actions = id(new PhabricatorActionListView())
@ -117,7 +137,7 @@ final class PhabricatorPeopleProfileController
$nav->appendChild($header); $nav->appendChild($header);
$nav->appendChild($actions); $nav->appendChild($actions);
$nav->appendChild($properties); $nav->appendChild($properties);
$nav->appendChild($content); $nav->appendChild($this->renderUserFeed($user));
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,