2011-01-24 03:09:16 +01:00
|
|
|
<?php
|
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
abstract class PhabricatorPeopleProfileController
|
2012-03-10 00:46:25 +01:00
|
|
|
extends PhabricatorPeopleController {
|
2011-01-24 03:09:16 +01:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
private $user;
|
|
|
|
private $profileMenu;
|
2015-07-22 18:32:54 +02:00
|
|
|
|
2013-03-19 21:48:50 +01:00
|
|
|
public function shouldRequireAdmin() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
public function setUser(PhabricatorUser $user) {
|
|
|
|
$this->user = $user;
|
|
|
|
return $this;
|
2013-02-05 22:46:02 +01:00
|
|
|
}
|
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
public function getUser() {
|
|
|
|
return $this->user;
|
2011-06-18 10:13:56 +02:00
|
|
|
}
|
2011-02-20 02:33:53 +01:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
public function buildApplicationMenu() {
|
|
|
|
$menu = $this->newApplicationMenu();
|
2011-02-20 03:28:41 +01:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
$profile_menu = $this->getProfileMenu();
|
|
|
|
if ($profile_menu) {
|
|
|
|
$menu->setProfileMenu($profile_menu);
|
|
|
|
}
|
2013-07-10 14:09:59 +02:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
return $menu;
|
2011-12-24 03:17:40 +01:00
|
|
|
}
|
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
protected function getProfileMenu() {
|
|
|
|
if (!$this->profileMenu) {
|
|
|
|
$user = $this->getUser();
|
|
|
|
if ($user) {
|
|
|
|
$viewer = $this->getViewer();
|
2015-07-23 20:46:34 +02:00
|
|
|
|
2016-12-11 18:00:44 +01:00
|
|
|
$engine = id(new PhabricatorPeopleProfileMenuEngine())
|
2015-07-23 20:46:34 +02:00
|
|
|
->setViewer($viewer)
|
2016-01-14 15:47:06 +01:00
|
|
|
->setProfileObject($user);
|
2015-07-23 20:46:34 +02:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
$this->profileMenu = $engine->buildNavigation();
|
2015-07-23 20:46:34 +02:00
|
|
|
}
|
2016-01-14 15:47:06 +01:00
|
|
|
}
|
[Redesign] People, Profile, Feed UI
Summary: Ref T8099, Mostly a Feed cleanup, removing old CSS, relying on modern display objects, adds back the feed to profile (I miss it, but maybe you don't).
Test Plan: Visit Feed on Profiles, Projects, Feed, and Dashboards. Same UI Everywhere. TODO, "Public Feed".
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D13101
2015-06-01 20:28:01 +02:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
return $this->profileMenu;
|
|
|
|
}
|
[Redesign] People, Profile, Feed UI
Summary: Ref T8099, Mostly a Feed cleanup, removing old CSS, relying on modern display objects, adds back the feed to profile (I miss it, but maybe you don't).
Test Plan: Visit Feed on Profiles, Projects, Feed, and Dashboards. Same UI Everywhere. TODO, "Public Feed".
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D13101
2015-06-01 20:28:01 +02:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
protected function buildApplicationCrumbs() {
|
|
|
|
$crumbs = parent::buildApplicationCrumbs();
|
[Redesign] People, Profile, Feed UI
Summary: Ref T8099, Mostly a Feed cleanup, removing old CSS, relying on modern display objects, adds back the feed to profile (I miss it, but maybe you don't).
Test Plan: Visit Feed on Profiles, Projects, Feed, and Dashboards. Same UI Everywhere. TODO, "Public Feed".
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D13101
2015-06-01 20:28:01 +02:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
$user = $this->getUser();
|
|
|
|
if ($user) {
|
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
$user->getUsername(),
|
|
|
|
urisprintf('/p/%s/', $user->getUsername()));
|
|
|
|
}
|
[Redesign] People, Profile, Feed UI
Summary: Ref T8099, Mostly a Feed cleanup, removing old CSS, relying on modern display objects, adds back the feed to profile (I miss it, but maybe you don't).
Test Plan: Visit Feed on Profiles, Projects, Feed, and Dashboards. Same UI Everywhere. TODO, "Public Feed".
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D13101
2015-06-01 20:28:01 +02:00
|
|
|
|
2016-01-14 15:47:06 +01:00
|
|
|
return $crumbs;
|
[Redesign] People, Profile, Feed UI
Summary: Ref T8099, Mostly a Feed cleanup, removing old CSS, relying on modern display objects, adds back the feed to profile (I miss it, but maybe you don't).
Test Plan: Visit Feed on Profiles, Projects, Feed, and Dashboards. Same UI Everywhere. TODO, "Public Feed".
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D13101
2015-06-01 20:28:01 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 17:58:33 +01:00
|
|
|
public function buildProfileHeader() {
|
|
|
|
$user = $this->user;
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$profile = $user->loadUserProfile();
|
|
|
|
$picture = $user->getProfileImageURI();
|
|
|
|
|
|
|
|
$profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon());
|
|
|
|
$profile_title = $profile->getDisplayTitle();
|
|
|
|
|
|
|
|
$roles = array();
|
|
|
|
if ($user->getIsAdmin()) {
|
|
|
|
$roles[] = pht('Administrator');
|
|
|
|
}
|
|
|
|
if ($user->getIsDisabled()) {
|
|
|
|
$roles[] = pht('Disabled');
|
|
|
|
}
|
|
|
|
if (!$user->getIsApproved()) {
|
|
|
|
$roles[] = pht('Not Approved');
|
|
|
|
}
|
|
|
|
if ($user->getIsSystemAgent()) {
|
|
|
|
$roles[] = pht('Bot');
|
|
|
|
}
|
|
|
|
if ($user->getIsMailingList()) {
|
|
|
|
$roles[] = pht('Mailing List');
|
|
|
|
}
|
2017-02-24 22:15:30 +01:00
|
|
|
if (!$user->getIsEmailVerified()) {
|
|
|
|
$roles[] = pht('Email Not Verified');
|
|
|
|
}
|
2017-01-31 17:58:33 +01:00
|
|
|
|
|
|
|
$tag = null;
|
|
|
|
if ($roles) {
|
|
|
|
$tag = id(new PHUITagView())
|
|
|
|
->setName(implode(', ', $roles))
|
|
|
|
->addClass('project-view-header-tag')
|
|
|
|
->setType(PHUITagView::TYPE_SHADE);
|
|
|
|
}
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(array($user->getFullName(), $tag))
|
|
|
|
->setImage($picture)
|
2017-02-02 06:21:08 +01:00
|
|
|
->setProfileHeader(true)
|
|
|
|
->addClass('people-profile-header');
|
2017-01-31 17:58:33 +01:00
|
|
|
|
2017-02-24 22:15:30 +01:00
|
|
|
require_celerity_resource('project-view-css');
|
|
|
|
|
2017-01-31 17:58:33 +01:00
|
|
|
if ($user->getIsDisabled()) {
|
|
|
|
$header->setStatus('fa-ban', 'red', pht('Disabled'));
|
|
|
|
} else {
|
|
|
|
$header->setStatus($profile_icon, 'bluegrey', $profile_title);
|
|
|
|
}
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$user,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
if ($can_edit) {
|
|
|
|
$id = $user->getID();
|
|
|
|
$header->setImageEditURL($this->getApplicationURI("picture/{$id}/"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $header;
|
|
|
|
}
|
|
|
|
|
2011-01-24 03:09:16 +01:00
|
|
|
}
|