2011-01-24 03:09:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorPeopleController extends PhabricatorController {
|
|
|
|
|
2013-03-19 21:48:50 +01:00
|
|
|
public function shouldRequireAdmin() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-02 21:13:48 +01:00
|
|
|
public function buildSideNavView($for_app = false) {
|
2012-08-14 00:27:21 +02:00
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
|
|
|
|
2015-02-02 21:13:48 +01:00
|
|
|
$name = null;
|
|
|
|
if ($for_app) {
|
|
|
|
$name = $this->getRequest()->getURIData('username');
|
|
|
|
if ($name) {
|
|
|
|
$nav->setBaseURI(new PhutilURI('/p/'));
|
|
|
|
$nav->addFilter("{$name}/", $name);
|
|
|
|
$nav->addFilter("feed/{$name}/", pht('Feed'));
|
|
|
|
$nav->addFilter("calendar/{$name}/", pht('Calendar'));
|
|
|
|
}
|
|
|
|
}
|
2013-05-31 19:51:20 +02:00
|
|
|
|
2015-02-02 21:13:48 +01:00
|
|
|
if (!$name) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
id(new PhabricatorPeopleSearchEngine())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->addNavigationItems($nav->getMenu());
|
Provide an activity log for login and administrative actions
Summary: This isn't complete, but I figured I'd ship it for review while it's still smallish.
Provide an activity log for high-level system actions (logins, admin actions). This basically allows two things to happen:
- The log itself is useful if there are shenanigans.
- Password login can check it and start CAPTCHA'ing users after a few failed attempts.
I'm going to change how the admin stuff works a little bit too, since right now you can make someone an agent, grab their certificate, revert them back to a normal user, and then act on their behalf over Conduit. This is a little silly, I'm going to move "agent" to the create workflow instead. I'll also add a confirm/email step to the administrative password reset flow.
Test Plan: Took various administrative and non-administrative actions, they appeared in the logs. Filtered the logs in a bunch of different ways.
Reviewers: jungejason, tuomaspelkonen, aran
CC:
Differential Revision: 302
2011-05-18 03:42:21 +02:00
|
|
|
|
2015-02-02 21:13:48 +01:00
|
|
|
if ($viewer->getIsAdmin()) {
|
|
|
|
$nav->addLabel(pht('User Administration'));
|
|
|
|
if (PhabricatorLDAPAuthProvider::getLDAPProvider()) {
|
|
|
|
$nav->addFilter('ldap', pht('Import from LDAP'));
|
|
|
|
}
|
Provide an activity log for login and administrative actions
Summary: This isn't complete, but I figured I'd ship it for review while it's still smallish.
Provide an activity log for high-level system actions (logins, admin actions). This basically allows two things to happen:
- The log itself is useful if there are shenanigans.
- Password login can check it and start CAPTCHA'ing users after a few failed attempts.
I'm going to change how the admin stuff works a little bit too, since right now you can make someone an agent, grab their certificate, revert them back to a normal user, and then act on their behalf over Conduit. This is a little silly, I'm going to move "agent" to the create workflow instead. I'll also add a confirm/email step to the administrative password reset flow.
Test Plan: Took various administrative and non-administrative actions, they appeared in the logs. Filtered the logs in a bunch of different ways.
Reviewers: jungejason, tuomaspelkonen, aran
CC:
Differential Revision: 302
2011-05-18 03:42:21 +02:00
|
|
|
|
2015-02-02 21:13:48 +01:00
|
|
|
$nav->addFilter('logs', pht('Activity Logs'));
|
2015-02-11 15:05:53 +01:00
|
|
|
$nav->addFilter('invite', pht('Email Invitations'));
|
2015-02-02 21:13:48 +01:00
|
|
|
}
|
2013-05-31 19:51:20 +02:00
|
|
|
}
|
2011-01-24 03:09:16 +01:00
|
|
|
|
2012-08-14 00:27:21 +02:00
|
|
|
return $nav;
|
2011-01-24 03:09:16 +01:00
|
|
|
}
|
|
|
|
|
2015-01-15 21:41:26 +01:00
|
|
|
public function buildApplicationMenu() {
|
2015-02-02 21:13:48 +01:00
|
|
|
return $this->buildSideNavView(true)->getMenu();
|
2013-02-21 23:10:22 +01:00
|
|
|
}
|
|
|
|
|
2015-01-06 21:34:58 +01:00
|
|
|
protected function buildApplicationCrumbs() {
|
2015-02-02 21:13:48 +01:00
|
|
|
return parent::buildApplicationCrumbs();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildIconNavView(PhabricatorUser $user) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$picture = $user->getProfileImageURI();
|
|
|
|
$name = $user->getUsername();
|
2013-03-19 21:48:50 +01:00
|
|
|
|
2015-02-02 21:13:48 +01:00
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setIconNav(true);
|
|
|
|
$nav->setBaseURI(new PhutilURI('/p/'));
|
|
|
|
$nav->addIcon("{$name}/", $name, null, $picture);
|
|
|
|
$nav->addIcon("{$name}/feed/", pht('Feed'), 'fa-newspaper-o');
|
2013-05-31 19:51:20 +02:00
|
|
|
|
2015-02-02 21:13:48 +01:00
|
|
|
$class = 'PhabricatorCalendarApplication';
|
|
|
|
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
|
|
|
$nav->addIcon(
|
|
|
|
"{$name}/calendar/", pht('Calendar'), 'fa-calendar');
|
|
|
|
}
|
2013-02-21 23:10:22 +01:00
|
|
|
|
2015-02-02 21:13:48 +01:00
|
|
|
$class = 'PhabricatorManiphestApplication';
|
|
|
|
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
|
|
|
$phid = $user->getPHID();
|
|
|
|
$view_uri = sprintf(
|
|
|
|
'/maniphest/?statuses=%s&assigned=%s#R',
|
|
|
|
implode(',', ManiphestTaskStatus::getOpenStatusConstants()),
|
|
|
|
$phid);
|
|
|
|
$nav->addIcon(
|
|
|
|
'maniphest', pht('Open Tasks'), 'fa-anchor', null, $view_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
$class = 'PhabricatorDifferentialApplication';
|
|
|
|
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
|
|
|
$username = phutil_escape_uri($name);
|
|
|
|
$view_uri = '/differential/?authors='.$username;
|
|
|
|
$nav->addIcon(
|
|
|
|
'differential', pht('Revisions'), 'fa-cog', null, $view_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
$class = 'PhabricatorAuditApplication';
|
|
|
|
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
|
|
|
$username = phutil_escape_uri($name);
|
|
|
|
$view_uri = '/audit/?authors='.$username;
|
|
|
|
$nav->addIcon(
|
|
|
|
'audit', pht('Commits'), 'fa-code', null, $view_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $nav;
|
2013-02-21 23:10:22 +01:00
|
|
|
}
|
|
|
|
|
2011-01-24 03:09:16 +01:00
|
|
|
}
|