@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 PhabricatorPeopleCreateController
4 extends PhabricatorPeopleController {
5
6 public function handleRequest(AphrontRequest $request) {
7 $admin = $request->getUser();
8
9 id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
10 $admin,
11 $request,
12 $this->getApplicationURI());
13
14 $v_type = 'standard';
15 if ($request->isFormPost()) {
16 $v_type = $request->getStr('type');
17
18 if ($v_type == 'standard' || $v_type == 'bot' || $v_type == 'list') {
19 return id(new AphrontRedirectResponse())->setURI(
20 $this->getApplicationURI('new/'.$v_type.'/'));
21 }
22 }
23
24 $title = pht('Create New User');
25
26 $standard_caption = pht(
27 'Create a standard user account. These users can log in, '.
28 'use the web interface and API, and receive email.');
29
30 $standard_admin = pht(
31 'Administrators are limited in their ability to access or edit these '.
32 'accounts after account creation.');
33
34 $bot_caption = pht(
35 'Create a bot/script user account, to automate interactions with other '.
36 'systems. These users can not use the web interface, but can use the '.
37 'API.');
38
39 $bot_admin = pht(
40 'Administrators have greater access to edit these accounts.');
41
42 $types = array();
43
44 $can_create = $this->hasApplicationCapability(
45 PeopleCreateUsersCapability::CAPABILITY);
46 if ($can_create) {
47 $types[] = array(
48 'type' => 'standard',
49 'name' => pht('Create Standard User'),
50 'help' => pht('Create a standard user account.'),
51 );
52 }
53
54 $types[] = array(
55 'type' => 'bot',
56 'name' => pht('Create Bot User'),
57 'help' => pht('Create a new user for use with automated scripts.'),
58 );
59
60 $types[] = array(
61 'type' => 'list',
62 'name' => pht('Create Mailing List User'),
63 'help' => pht(
64 'Create a mailing list user to represent an existing, external '.
65 'mailing list like a Google Group or a Mailman list.'),
66 );
67
68 $buttons = id(new AphrontFormRadioButtonControl())
69 ->setLabel(pht('Account Type'))
70 ->setName('type')
71 ->setValue($v_type);
72
73 foreach ($types as $type) {
74 $buttons->addButton($type['type'], $type['name'], $type['help']);
75 }
76
77 $form = id(new AphrontFormView())
78 ->setUser($admin)
79 ->appendRemarkupInstructions(
80 pht(
81 'Choose the type of user account to create. For a detailed '.
82 'explanation of user account types, see [[ %s | User Guide: '.
83 'Account Roles ]].',
84 PhabricatorEnv::getDoclink('User Guide: Account Roles')))
85 ->appendChild($buttons)
86 ->appendChild(
87 id(new AphrontFormSubmitControl())
88 ->addCancelButton($this->getApplicationURI())
89 ->setValue(pht('Continue')));
90
91 $crumbs = $this->buildApplicationCrumbs();
92 $crumbs->addTextCrumb($title);
93 $crumbs->setBorder(true);
94
95 $box = id(new PHUIObjectBoxView())
96 ->setHeaderText($title)
97 ->setBackground(PHUIObjectBoxView::WHITE_CONFIG)
98 ->setForm($form);
99
100 $guidance_context = new PhabricatorPeopleCreateGuidanceContext();
101
102 $guidance = id(new PhabricatorGuidanceEngine())
103 ->setViewer($admin)
104 ->setGuidanceContext($guidance_context)
105 ->newInfoView();
106
107 $view = id(new PHUITwoColumnView())
108 ->setFooter(
109 array(
110 $guidance,
111 $box,
112 ));
113
114 return $this->newPage()
115 ->setTitle($title)
116 ->setCrumbs($crumbs)
117 ->appendChild($view);
118 }
119
120}