mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-24 05:28:18 +01:00
7097abbe57
Summary: Ref T9304. This adds a "GuidanceEngine" which can generate "Guidance". In practice, this lets third-party code (rSERVICES) remove and replace instructions in the UI, which is basically only usefulf or us to tell users to go read the documentation in the Phacility cluster. The next diff tailors the help on the "Auth Providers" and "Create New User" pages to say "PHACILITY PHACILITY PHACILITY PHACILITY". Test Plan: Browed to "Auth Providers" and "Create New User" on instanced and non-instanced installs, saw appropriate guidance. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9304 Differential Revision: https://secure.phabricator.com/D16861
125 lines
3.6 KiB
PHP
125 lines
3.6 KiB
PHP
<?php
|
|
|
|
final class PhabricatorPeopleCreateController
|
|
extends PhabricatorPeopleController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$admin = $request->getUser();
|
|
|
|
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
|
|
$admin,
|
|
$request,
|
|
$this->getApplicationURI());
|
|
|
|
$v_type = 'standard';
|
|
if ($request->isFormPost()) {
|
|
$v_type = $request->getStr('type');
|
|
|
|
if ($v_type == 'standard' || $v_type == 'bot' || $v_type == 'list') {
|
|
return id(new AphrontRedirectResponse())->setURI(
|
|
$this->getApplicationURI('new/'.$v_type.'/'));
|
|
}
|
|
}
|
|
|
|
$title = pht('Create New User');
|
|
|
|
$standard_caption = pht(
|
|
'Create a standard user account. These users can log in to Phabricator, '.
|
|
'use the web interface and API, and receive email.');
|
|
|
|
$standard_admin = pht(
|
|
'Administrators are limited in their ability to access or edit these '.
|
|
'accounts after account creation.');
|
|
|
|
$bot_caption = pht(
|
|
'Create a bot/script user account, to automate interactions with other '.
|
|
'systems. These users can not use the web interface, but can use the '.
|
|
'API.');
|
|
|
|
$bot_admin = pht(
|
|
'Administrators have greater access to edit these accounts.');
|
|
|
|
$types = array();
|
|
|
|
$can_create = $this->hasApplicationCapability(
|
|
PeopleCreateUsersCapability::CAPABILITY);
|
|
if ($can_create) {
|
|
$types[] = array(
|
|
'type' => 'standard',
|
|
'name' => pht('Create Standard User'),
|
|
'help' => pht('Create a standard user account.'),
|
|
);
|
|
}
|
|
|
|
$types[] = array(
|
|
'type' => 'bot',
|
|
'name' => pht('Create Bot User'),
|
|
'help' => pht('Create a new user for use with automated scripts.'),
|
|
);
|
|
|
|
$types[] = array(
|
|
'type' => 'list',
|
|
'name' => pht('Create Mailing List User'),
|
|
'help' => pht(
|
|
'Create a mailing list user to represent an existing, external '.
|
|
'mailing list like a Google Group or a Mailman list.'),
|
|
);
|
|
|
|
$buttons = id(new AphrontFormRadioButtonControl())
|
|
->setLabel(pht('Account Type'))
|
|
->setName('type')
|
|
->setValue($v_type);
|
|
|
|
foreach ($types as $type) {
|
|
$buttons->addButton($type['type'], $type['name'], $type['help']);
|
|
}
|
|
|
|
$form = id(new AphrontFormView())
|
|
->setUser($admin)
|
|
->appendRemarkupInstructions(
|
|
pht(
|
|
'Choose the type of user account to create. For a detailed '.
|
|
'explanation of user account types, see [[ %s | User Guide: '.
|
|
'Account Roles ]].',
|
|
PhabricatorEnv::getDoclink('User Guide: Account Roles')))
|
|
->appendChild($buttons)
|
|
->appendChild(
|
|
id(new AphrontFormSubmitControl())
|
|
->addCancelButton($this->getApplicationURI())
|
|
->setValue(pht('Continue')));
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
$crumbs->addTextCrumb($title);
|
|
$crumbs->setBorder(true);
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
->setHeader($title)
|
|
->setHeaderIcon('fa-user');
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
->setHeaderText(pht('User'))
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
->setForm($form);
|
|
|
|
$guidance_context = new PhabricatorPeopleCreateGuidanceContext();
|
|
|
|
$guidance = id(new PhabricatorGuidanceEngine())
|
|
->setViewer($admin)
|
|
->setGuidanceContext($guidance_context)
|
|
->newInfoView();
|
|
|
|
$view = id(new PHUITwoColumnView())
|
|
->setHeader($header)
|
|
->setFooter(
|
|
array(
|
|
$guidance,
|
|
$box,
|
|
));
|
|
|
|
return $this->newPage()
|
|
->setTitle($title)
|
|
->setCrumbs($crumbs)
|
|
->appendChild($view);
|
|
}
|
|
|
|
}
|