Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / people / controller / PhabricatorPeopleCreateController.php
blobc0b232645b23ccf615937977c0a5ac23c8cc47ba
1 <?php
3 final class PhabricatorPeopleCreateController
4 extends PhabricatorPeopleController {
6 public function handleRequest(AphrontRequest $request) {
7 $admin = $request->getUser();
9 id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
10 $admin,
11 $request,
12 $this->getApplicationURI());
14 $v_type = 'standard';
15 if ($request->isFormPost()) {
16 $v_type = $request->getStr('type');
18 if ($v_type == 'standard' || $v_type == 'bot' || $v_type == 'list') {
19 return id(new AphrontRedirectResponse())->setURI(
20 $this->getApplicationURI('new/'.$v_type.'/'));
24 $title = pht('Create New User');
26 $standard_caption = pht(
27 'Create a standard user account. These users can log in to Phabricator, '.
28 'use the web interface and API, and receive email.');
30 $standard_admin = pht(
31 'Administrators are limited in their ability to access or edit these '.
32 'accounts after account creation.');
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.');
39 $bot_admin = pht(
40 'Administrators have greater access to edit these accounts.');
42 $types = array();
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.'),
54 $types[] = array(
55 'type' => 'bot',
56 'name' => pht('Create Bot User'),
57 'help' => pht('Create a new user for use with automated scripts.'),
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.'),
68 $buttons = id(new AphrontFormRadioButtonControl())
69 ->setLabel(pht('Account Type'))
70 ->setName('type')
71 ->setValue($v_type);
73 foreach ($types as $type) {
74 $buttons->addButton($type['type'], $type['name'], $type['help']);
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')));
91 $crumbs = $this->buildApplicationCrumbs();
92 $crumbs->addTextCrumb($title);
93 $crumbs->setBorder(true);
95 $box = id(new PHUIObjectBoxView())
96 ->setHeaderText($title)
97 ->setBackground(PHUIObjectBoxView::WHITE_CONFIG)
98 ->setForm($form);
100 $guidance_context = new PhabricatorPeopleCreateGuidanceContext();
102 $guidance = id(new PhabricatorGuidanceEngine())
103 ->setViewer($admin)
104 ->setGuidanceContext($guidance_context)
105 ->newInfoView();
107 $view = id(new PHUITwoColumnView())
108 ->setFooter(
109 array(
110 $guidance,
111 $box,
114 return $this->newPage()
115 ->setTitle($title)
116 ->setCrumbs($crumbs)
117 ->appendChild($view);