2012-08-05 14:12:43 -07:00
|
|
|
<?php
|
|
|
|
|
2014-07-23 10:03:09 +10:00
|
|
|
final class PhabricatorPeopleApplication extends PhabricatorApplication {
|
2012-08-05 14:12:43 -07:00
|
|
|
|
2014-07-23 23:52:50 +10:00
|
|
|
public function getName() {
|
|
|
|
return pht('People');
|
|
|
|
}
|
|
|
|
|
2012-08-05 14:12:43 -07:00
|
|
|
public function getShortDescription() {
|
2014-05-29 12:17:54 -07:00
|
|
|
return pht('User Accounts and Profiles');
|
2012-08-05 14:12:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getBaseURI() {
|
|
|
|
return '/people/';
|
|
|
|
}
|
|
|
|
|
2012-08-13 15:27:21 -07:00
|
|
|
public function getTitleGlyph() {
|
|
|
|
return "\xE2\x99\x9F";
|
|
|
|
}
|
|
|
|
|
2015-01-24 23:41:43 -08:00
|
|
|
public function getFontIcon() {
|
|
|
|
return 'fa-users';
|
|
|
|
}
|
|
|
|
|
(Redesign) Clean up older "Tile" code
Summary:
This does some backend cleanup of the tile stuff, and some general cleanup of other application things:
- Users who haven't customized preferences get a small, specific set of pinned applications: Differential, Maniphest, Diffusion, Audit, Phriction, Projects (and, for administrators, Auth, Config and People).
- Old tile size methods are replaced with `isPinnnedByDefault()`.
- Shortened some short descriptions.
- `shouldAppearInLaunchView()` replaced by less ambiguous `isLaunchable()`.
- Added a marker for third-party / extension applications.
Test Plan: Faked away my preferences and viewed the home page, saw a smaller set of default pins.
Reviewers: chad
Reviewed By: chad
Subscribers: epriestley
Differential Revision: https://secure.phabricator.com/D9358
2014-06-03 15:47:27 -07:00
|
|
|
public function isPinnedByDefault(PhabricatorUser $viewer) {
|
|
|
|
return $viewer->getIsAdmin();
|
|
|
|
}
|
|
|
|
|
2012-10-03 15:16:26 -07:00
|
|
|
public function getFlavorText() {
|
|
|
|
return pht('Sort of a social utility.');
|
|
|
|
}
|
|
|
|
|
2013-01-29 09:14:03 -08:00
|
|
|
public function canUninstall() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-05 17:01:54 -07:00
|
|
|
public function getEventListeners() {
|
|
|
|
return array(
|
|
|
|
new PhabricatorPeopleHovercardEventListener(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-08-05 14:12:43 -07:00
|
|
|
public function getRoutes() {
|
|
|
|
return array(
|
|
|
|
'/people/' => array(
|
2013-05-31 10:51:20 -07:00
|
|
|
'(query/(?P<key>[^/]+)/)?' => 'PhabricatorPeopleListController',
|
2014-04-27 17:31:35 -07:00
|
|
|
'logs/(?:query/(?P<queryKey>[^/]+)/)?'
|
|
|
|
=> 'PhabricatorPeopleLogsController',
|
2015-02-11 06:05:53 -08:00
|
|
|
'invite/' => array(
|
|
|
|
'(?:query/(?P<queryKey>[^/]+)/)?'
|
|
|
|
=> 'PhabricatorPeopleInviteListController',
|
|
|
|
'send/'
|
|
|
|
=> 'PhabricatorPeopleInviteSendController',
|
|
|
|
),
|
2013-11-13 11:24:18 -08:00
|
|
|
'approve/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleApproveController',
|
2014-04-02 12:05:49 -07:00
|
|
|
'(?P<via>disapprove)/(?P<id>[1-9]\d*)/'
|
|
|
|
=> 'PhabricatorPeopleDisableController',
|
|
|
|
'(?P<via>disable)/(?P<id>[1-9]\d*)/'
|
|
|
|
=> 'PhabricatorPeopleDisableController',
|
|
|
|
'empower/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleEmpowerController',
|
2014-04-02 12:05:07 -07:00
|
|
|
'delete/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleDeleteController',
|
2014-04-02 12:05:19 -07:00
|
|
|
'rename/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleRenameController',
|
2014-04-02 12:06:17 -07:00
|
|
|
'welcome/(?P<id>[1-9]\d*)/' => 'PhabricatorPeopleWelcomeController',
|
2014-04-02 12:06:27 -07:00
|
|
|
'create/' => 'PhabricatorPeopleCreateController',
|
|
|
|
'new/(?P<type>[^/]+)/' => 'PhabricatorPeopleNewController',
|
2012-08-05 14:12:43 -07:00
|
|
|
'ldap/' => 'PhabricatorPeopleLdapController',
|
2013-06-07 09:55:55 -07:00
|
|
|
'editprofile/(?P<id>[1-9]\d*)/' =>
|
|
|
|
'PhabricatorPeopleProfileEditController',
|
2013-07-09 16:23:54 -07:00
|
|
|
'picture/(?P<id>[1-9]\d*)/' =>
|
|
|
|
'PhabricatorPeopleProfilePictureController',
|
2015-02-02 12:13:48 -08:00
|
|
|
),
|
2013-07-10 05:11:08 -07:00
|
|
|
'/p/(?P<username>[\w._-]+)/'
|
2012-08-05 14:12:43 -07:00
|
|
|
=> 'PhabricatorPeopleProfileController',
|
2014-02-24 10:04:23 -08:00
|
|
|
'/p/(?P<username>[\w._-]+)/calendar/'
|
|
|
|
=> 'PhabricatorPeopleCalendarController',
|
2015-02-02 12:13:48 -08:00
|
|
|
'/p/(?P<username>[\w._-]+)/feed/'
|
|
|
|
=> 'PhabricatorPeopleFeedController',
|
2012-08-05 14:12:43 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-07-09 16:23:33 -07:00
|
|
|
public function getRemarkupRules() {
|
|
|
|
return array(
|
2014-08-05 00:55:43 +10:00
|
|
|
new PhabricatorMentionRemarkupRule(),
|
2013-07-09 16:23:33 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-01-30 11:53:49 -08:00
|
|
|
protected function getCustomCapabilities() {
|
|
|
|
return array(
|
2015-01-12 15:18:16 -08:00
|
|
|
PeopleCreateUsersCapability::CAPABILITY => array(
|
|
|
|
'default' => PhabricatorPolicies::POLICY_ADMIN,
|
|
|
|
),
|
2014-07-25 08:20:39 +10:00
|
|
|
PeopleBrowseUserDirectoryCapability::CAPABILITY => array(),
|
2014-01-30 11:53:49 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-11-13 11:24:38 -08:00
|
|
|
public function loadStatus(PhabricatorUser $user) {
|
|
|
|
if (!$user->getIsAdmin()) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$need_approval = id(new PhabricatorPeopleQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIsApproved(false)
|
2014-03-10 16:20:49 -07:00
|
|
|
->withIsDisabled(false)
|
2014-12-12 12:02:25 -08:00
|
|
|
->setLimit(self::MAX_STATUS_ITEMS)
|
2013-11-13 11:24:38 -08:00
|
|
|
->execute();
|
|
|
|
|
|
|
|
if (!$need_approval) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$status = array();
|
|
|
|
|
|
|
|
$count = count($need_approval);
|
2014-12-12 12:02:25 -08:00
|
|
|
$count_str = self::formatStatusCount(
|
|
|
|
$count,
|
|
|
|
'%s Users Need Approval',
|
|
|
|
'%d User(s) Need Approval');
|
2013-11-13 11:24:38 -08:00
|
|
|
$type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
|
|
|
|
$status[] = id(new PhabricatorApplicationStatusView())
|
|
|
|
->setType($type)
|
2014-12-12 12:02:25 -08:00
|
|
|
->setText($count_str)
|
2013-11-13 11:24:38 -08:00
|
|
|
->setCount($count);
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
}
|
|
|
|
|
2012-08-05 14:12:43 -07:00
|
|
|
public function buildMainMenuItems(
|
|
|
|
PhabricatorUser $user,
|
2012-08-06 12:46:51 -07:00
|
|
|
PhabricatorController $controller = null) {
|
2012-08-05 14:12:43 -07:00
|
|
|
|
|
|
|
$items = array();
|
|
|
|
|
2013-11-13 11:24:38 -08:00
|
|
|
if ($user->isLoggedIn() && $user->isUserActivated()) {
|
2015-02-02 14:04:23 -08:00
|
|
|
$profile = id(new PhabricatorPeopleQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->needProfileImage(true)
|
|
|
|
->withPHIDs(array($user->getPHID()))
|
|
|
|
->executeOne();
|
|
|
|
$image = $profile->getProfileImageURI();
|
2012-08-10 12:11:24 -07:00
|
|
|
|
2014-01-28 20:18:01 -08:00
|
|
|
$item = id(new PHUIListItemView())
|
|
|
|
->setName($user->getUsername())
|
|
|
|
->setHref('/p/'.$user->getUsername().'/')
|
|
|
|
->addClass('core-menu-item')
|
Add support for aural-only and visual-only elements
Summary:
Ref T4843. This adds support to `javelin_tag()` for an `aural` attribute. When specified, `true` values mean "this content is aural-only", while `false` values mean "this content is not aural".
- I've attempted to find the best modern approaches for marking this content, but the `aural` attribute should let us change the mechanism later.
- Make the "beta" markers on application navigation visual only (see T4843). This information is of very low importance, the application navigation is accessed frequently, and the information is available on the application list.
- Partially convert the main navigation. This is mostly to test things, since I want to get more concrete feedback about approaches here.
- Add a `?__aural__=1` attribute, which renders the page with aural-only elements visible and visual-only elements colored.
Test Plan: {F146476}
Reviewers: btrahan, scp, chad
Reviewed By: chad
Subscribers: aklapper, qgil, epriestley
Maniphest Tasks: T4843
Differential Revision: https://secure.phabricator.com/D8830
2014-05-01 07:18:18 -07:00
|
|
|
->setAural(pht('Profile'))
|
2014-01-31 09:10:32 -08:00
|
|
|
->setOrder(100);
|
2012-12-07 13:33:03 -08:00
|
|
|
|
|
|
|
$classes = array(
|
|
|
|
'phabricator-core-menu-icon',
|
|
|
|
'phabricator-core-menu-profile-image',
|
|
|
|
);
|
|
|
|
|
|
|
|
$item->appendChild(
|
2013-01-17 18:57:09 -08:00
|
|
|
phutil_tag(
|
2012-12-07 13:33:03 -08:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
'style' => 'background-image: url('.$image.')',
|
|
|
|
),
|
|
|
|
''));
|
|
|
|
|
2012-08-05 14:12:43 -07:00
|
|
|
$items[] = $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $items;
|
|
|
|
}
|
|
|
|
|
2014-04-02 12:06:27 -07:00
|
|
|
|
|
|
|
public function getQuickCreateItems(PhabricatorUser $viewer) {
|
|
|
|
$items = array();
|
|
|
|
|
2015-02-05 16:47:09 -08:00
|
|
|
$can_create = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$this,
|
|
|
|
PeopleCreateUsersCapability::CAPABILITY);
|
|
|
|
|
|
|
|
if ($can_create) {
|
2014-04-02 12:06:27 -07:00
|
|
|
$item = id(new PHUIListItemView())
|
|
|
|
->setName(pht('User Account'))
|
2014-05-12 13:34:00 -07:00
|
|
|
->setIcon('fa-users')
|
2014-04-02 12:06:27 -07:00
|
|
|
->setHref($this->getBaseURI().'create/');
|
|
|
|
$items[] = $item;
|
2015-02-05 16:47:09 -08:00
|
|
|
} else if ($viewer->getIsAdmin()) {
|
|
|
|
$item = id(new PHUIListItemView())
|
|
|
|
->setName(pht('Bot Account'))
|
|
|
|
->setIcon('fa-android')
|
|
|
|
->setHref($this->getBaseURI().'new/bot/');
|
|
|
|
$items[] = $item;
|
2014-04-02 12:06:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return $items;
|
|
|
|
}
|
|
|
|
|
2012-08-05 14:12:43 -07:00
|
|
|
}
|