@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorPeopleProfileMenuEngine
4 extends PhabricatorProfileMenuEngine {
5
6 const ITEM_PROFILE = 'people.profile';
7 const ITEM_MANAGE = 'people.manage';
8 const ITEM_PICTURE = 'people.picture';
9 const ITEM_BADGES = 'people.badges';
10 const ITEM_TASKS_ASSIGNED = 'people.tasks.assigned';
11 const ITEM_TASKS_AUTHORED = 'people.tasks.authored';
12 const ITEM_COMMITS = 'people.commits';
13 const ITEM_REVISIONS = 'people.revisions';
14
15 protected function isMenuEngineConfigurable() {
16 return false;
17 }
18
19 public function getItemURI($path) {
20 $user = $this->getProfileObject();
21 $username = $user->getUsername();
22 $username = phutil_escape_uri($username);
23 return "/p/{$username}/item/{$path}";
24 }
25
26 protected function getBuiltinProfileItems($object) {
27 $viewer = $this->getViewer();
28
29 $items = array();
30
31 $items[] = $this->newItem()
32 ->setBuiltinKey(self::ITEM_PICTURE)
33 ->setMenuItemKey(PhabricatorPeoplePictureProfileMenuItem::MENUITEMKEY);
34
35 $items[] = $this->newItem()
36 ->setBuiltinKey(self::ITEM_PROFILE)
37 ->setMenuItemKey(PhabricatorPeopleDetailsProfileMenuItem::MENUITEMKEY);
38
39 $have_maniphest = PhabricatorApplication::isClassInstalledForViewer(
40 PhabricatorManiphestApplication::class,
41 $viewer);
42 if ($have_maniphest) {
43 $items[] = $this->newItem()
44 ->setBuiltinKey(self::ITEM_TASKS_ASSIGNED)
45 ->setMenuItemKey(
46 PhabricatorPeopleTasksAssignedProfileMenuItem::MENUITEMKEY);
47 $items[] = $this->newItem()
48 ->setBuiltinKey(self::ITEM_TASKS_AUTHORED)
49 ->setMenuItemKey(
50 PhabricatorPeopleTasksAuthoredProfileMenuItem::MENUITEMKEY);
51 }
52
53 $have_differential = PhabricatorApplication::isClassInstalledForViewer(
54 PhabricatorDifferentialApplication::class,
55 $viewer);
56 if ($have_differential) {
57 $items[] = $this->newItem()
58 ->setBuiltinKey(self::ITEM_REVISIONS)
59 ->setMenuItemKey(
60 PhabricatorPeopleRevisionsProfileMenuItem::MENUITEMKEY);
61 }
62
63 $have_diffusion = PhabricatorApplication::isClassInstalledForViewer(
64 PhabricatorDiffusionApplication::class,
65 $viewer);
66 if ($have_diffusion) {
67 $items[] = $this->newItem()
68 ->setBuiltinKey(self::ITEM_COMMITS)
69 ->setMenuItemKey(PhabricatorPeopleCommitsProfileMenuItem::MENUITEMKEY);
70 }
71
72 $have_badges = PhabricatorApplication::isClassInstalledForViewer(
73 PhabricatorBadgesApplication::class,
74 $viewer);
75 if ($have_badges) {
76 $items[] = $this->newItem()
77 ->setBuiltinKey(self::ITEM_BADGES)
78 ->setMenuItemKey(PhabricatorPeopleBadgesProfileMenuItem::MENUITEMKEY);
79 }
80
81 $items[] = $this->newItem()
82 ->setBuiltinKey(self::ITEM_MANAGE)
83 ->setMenuItemKey(PhabricatorPeopleManageProfileMenuItem::MENUITEMKEY);
84
85 return $items;
86 }
87
88}