forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorSettingsListController.php
48 lines (40 loc) · 1.35 KB
/
PhabricatorSettingsListController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
final class PhabricatorSettingsListController
extends PhabricatorController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
// If the viewer isn't an administrator, just redirect them to their own
// settings panel.
if (!$viewer->getIsAdmin()) {
$settings_uri = '/user/'.$viewer->getUsername().'/';
$settings_uri = $this->getApplicationURI($settings_uri);
return id(new AphrontRedirectResponse())
->setURI($settings_uri);
}
return id(new PhabricatorUserPreferencesSearchEngine())
->setController($this)
->buildResponse();
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$viewer = $this->getViewer();
if ($viewer->getIsAdmin()) {
$builtin_global = PhabricatorUserPreferences::BUILTIN_GLOBAL_DEFAULT;
$global_settings = id(new PhabricatorUserPreferencesQuery())
->setViewer($viewer)
->withBuiltinKeys(
array(
$builtin_global,
))
->execute();
if (!$global_settings) {
$action = id(new PHUIListItemView())
->setName(pht('Create Global Defaults'))
->setHref('/settings/builtin/'.$builtin_global.'/')
->setIcon('fa-plus');
$crumbs->addAction($action);
}
}
return $crumbs;
}
}