3 final class PhabricatorUserPreferencesSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
6 public function getResultTypeDescription() {
7 return pht('User Preferences');
10 public function getApplicationClassName() {
11 return 'PhabricatorSettingApplication';
14 public function newQuery() {
15 return id(new PhabricatorUserPreferencesQuery())
16 ->withHasUserPHID(false);
19 protected function buildQueryFromParameters(array $map) {
20 $query = $this->newQuery();
25 protected function buildCustomSearchFields() {
29 protected function getURI($path) {
30 return '/settings/'.$path;
33 protected function getBuiltinQueryNames() {
35 'all' => pht('All Settings'),
41 public function buildSavedQueryFromBuiltin($query_key) {
42 $query = $this->newSavedQuery();
43 $query->setQueryKey($query_key);
50 return parent
::buildSavedQueryFromBuiltin($query_key);
53 protected function renderResultList(
55 PhabricatorSavedQuery
$query,
57 assert_instances_of($settings, 'PhabricatorUserPreferences');
59 $viewer = $this->requireViewer();
61 $list = id(new PHUIObjectItemListView())
63 foreach ($settings as $setting) {
65 $icon = id(new PHUIIconView())
67 ->setBackground('bg-sky');
69 $item = id(new PHUIObjectItemView())
70 ->setHeader($setting->getDisplayName())
71 ->setHref($setting->getEditURI())
73 ->addAttribute(pht('Edit global default settings for all users.'));
75 $list->addItem($item);
79 id(new PHUIObjectItemView())
80 ->setHeader(pht('Personal Account Settings'))
81 ->addAttribute(pht('Edit settings for your personal account.'))
82 ->setImageURI($viewer->getProfileImageURI())
83 ->setHref('/settings/user/'.$viewer->getUsername().'/'));
85 return id(new PhabricatorApplicationSearchResultView())
86 ->setObjectList($list);