@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 PhabricatorGuideInstallModule extends PhabricatorGuideModule {
4
5 public function getModuleKey() {
6 return 'install';
7 }
8
9 public function getModuleName() {
10 return pht('Install');
11 }
12
13 public function getModulePosition() {
14 return 20;
15 }
16
17 public function getIsModuleEnabled() {
18 if (PhabricatorEnv::getEnvConfig('cluster.instance')) {
19 return false;
20 }
21 return true;
22 }
23
24 public function renderModuleStatus(AphrontRequest $request) {
25 $viewer = $request->getViewer();
26
27 $guide_items = new PhabricatorGuideListView();
28
29 $title = pht('Resolve Setup Issues');
30 $issues_resolved = !PhabricatorSetupCheck::getOpenSetupIssueKeys();
31 $href = PhabricatorEnv::getURI('/config/issue/');
32 if ($issues_resolved) {
33 $icon = 'fa-check';
34 $icon_bg = 'bg-green';
35 $description = pht(
36 "You've resolved (or ignored) all outstanding setup issues.");
37 } else {
38 $icon = 'fa-warning';
39 $icon_bg = 'bg-red';
40 $description =
41 pht('You have some unresolved setup issues to take care of.');
42 }
43
44 $item = id(new PhabricatorGuideItemView())
45 ->setTitle($title)
46 ->setHref($href)
47 ->setIcon($icon)
48 ->setIconBackground($icon_bg)
49 ->setDescription($description);
50 $guide_items->addItem($item);
51
52 $configs = id(new PhabricatorAuthProviderConfigQuery())
53 ->setViewer(PhabricatorUser::getOmnipotentUser())
54 ->execute();
55
56 $title = pht('Login and Registration');
57 $href = PhabricatorEnv::getURI('/auth/');
58 $have_auth = (bool)$configs;
59 if ($have_auth) {
60 $icon = 'fa-check';
61 $icon_bg = 'bg-green';
62 $description = pht(
63 "You've configured at least one authentication provider.");
64 } else {
65 $icon = 'fa-key';
66 $icon_bg = 'bg-sky';
67 $description = pht(
68 'Authentication providers allow users to register accounts and '.
69 'log in.');
70 }
71
72 $item = id(new PhabricatorGuideItemView())
73 ->setTitle($title)
74 ->setHref($href)
75 ->setIcon($icon)
76 ->setIconBackground($icon_bg)
77 ->setDescription($description);
78 $guide_items->addItem($item);
79
80
81 $title = pht('Configure');
82 $href = PhabricatorEnv::getURI('/config/');
83
84 // Just load any config value at all; if one exists the install has figured
85 // out how to configure things.
86 $have_config = (bool)id(new PhabricatorConfigEntry())->loadAllWhere(
87 '1 = 1 LIMIT 1');
88
89 if ($have_config) {
90 $icon = 'fa-check';
91 $icon_bg = 'bg-green';
92 $description = pht(
93 "You've configured at least one setting from the web interface.");
94 } else {
95 $icon = 'fa-sliders';
96 $icon_bg = 'bg-sky';
97 $description = pht(
98 'Learn how to configure mail and other options.');
99 }
100
101 $item = id(new PhabricatorGuideItemView())
102 ->setTitle($title)
103 ->setHref($href)
104 ->setIcon($icon)
105 ->setIconBackground($icon_bg)
106 ->setDescription($description);
107 $guide_items->addItem($item);
108
109
110 $title = pht('Personalize your Install');
111 $wordmark = PhabricatorEnv::getEnvConfig('ui.logo');
112 $href = PhabricatorEnv::getURI('/config/edit/ui.logo/');
113 if ($wordmark) {
114 $icon = 'fa-check';
115 $icon_bg = 'bg-green';
116 $description = pht(
117 'It looks amazing, good work. Home Sweet Home.');
118 } else {
119 $icon = 'fa-home';
120 $icon_bg = 'bg-sky';
121 $description =
122 pht('Change the name and add your company logo, just to give it a '.
123 'little extra polish.');
124 }
125
126 $item = id(new PhabricatorGuideItemView())
127 ->setTitle($title)
128 ->setHref($href)
129 ->setIcon($icon)
130 ->setIconBackground($icon_bg)
131 ->setDescription($description);
132 $guide_items->addItem($item);
133
134
135 $title = pht('Notification Server');
136 $href = PhabricatorEnv::getURI('/config/edit/notification.servers/');
137 $have_notifications = PhabricatorEnv::getEnvConfig('notification.servers');
138 if ($have_notifications) {
139 $icon = 'fa-check';
140 $icon_bg = 'bg-green';
141 $description = pht(
142 "You've set up a real-time notification server.");
143 } else {
144 $icon = 'fa-bell';
145 $icon_bg = 'bg-sky';
146 $description = pht(
147 'Real-time notifications can be delivered with WebSockets.');
148 }
149
150 $item = id(new PhabricatorGuideItemView())
151 ->setTitle($title)
152 ->setHref($href)
153 ->setIcon($icon)
154 ->setIconBackground($icon_bg)
155 ->setDescription($description);
156
157 $guide_items->addItem($item);
158
159 $intro = pht(
160 '%s has been successfully installed. These next guides will '.
161 'take you through configuration and new user orientation. '.
162 'These steps are optional, and you can go through them in any order. '.
163 'If you want to get back to this guide later on, you can find it in '.
164 '{icon globe} **Applications** under {icon map-o} **Guides**.',
165 PlatformSymbols::getPlatformServerName());
166
167 $intro = new PHUIRemarkupView($viewer, $intro);
168
169 $intro = id(new PHUIDocumentView())
170 ->appendChild($intro);
171
172 return array($intro, $guide_items);
173
174 }
175
176}