2014-04-02 21:06:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorPeopleCreateController
|
|
|
|
extends PhabricatorPeopleController {
|
|
|
|
|
2015-01-13 00:18:16 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
2014-04-02 21:06:27 +02:00
|
|
|
$admin = $request->getUser();
|
|
|
|
|
2014-05-01 02:44:59 +02:00
|
|
|
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(
|
|
|
|
$admin,
|
|
|
|
$request,
|
|
|
|
$this->getApplicationURI());
|
|
|
|
|
2014-04-02 21:06:27 +02:00
|
|
|
$v_type = 'standard';
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$v_type = $request->getStr('type');
|
|
|
|
|
2015-06-02 17:52:00 +02:00
|
|
|
if ($v_type == 'standard' || $v_type == 'bot' || $v_type == 'list') {
|
2014-04-02 21:06:27 +02:00
|
|
|
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.');
|
|
|
|
|
2015-06-02 17:52:00 +02:00
|
|
|
$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']);
|
|
|
|
}
|
|
|
|
|
2014-04-02 21:06:27 +02:00
|
|
|
$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')))
|
2015-06-02 17:52:00 +02:00
|
|
|
->appendChild($buttons)
|
2014-04-02 21:06:27 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->addCancelButton($this->getApplicationURI())
|
|
|
|
->setValue(pht('Continue')));
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addTextCrumb($title);
|
2016-04-04 06:01:48 +02:00
|
|
|
$crumbs->setBorder(true);
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader($title)
|
|
|
|
->setHeaderIcon('fa-user');
|
2014-04-02 21:06:27 +02:00
|
|
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
2016-04-04 06:01:48 +02:00
|
|
|
->setHeaderText(pht('User'))
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
[Redesign] Add Table, Collapse support to ObjectBox
Summary: Converts most all tables to be directly set via `setTable` to an ObjectBox. I think this path is more flexible design wise, as we can change the box based on children, and not just CSS. We also already do this with PropertyList, Forms, ObjectList, and Header. `setCollapsed` is added to ObjectBox to all children objects to bleed to the edges (like diffs).
Test Plan: I did a grep of `appendChild($table)` as well as searches for `PHUIObjectBoxView`, also with manual opening of hundreds of files. I'm sure I missed 5-8 places. If you just appendChild($table) nothing breaks, it just looks a little funny.
Reviewers: epriestley, btrahan
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12955
2015-05-20 21:43:34 +02:00
|
|
|
->setForm($form);
|
2014-04-02 21:06:27 +02:00
|
|
|
|
2016-04-04 06:01:48 +02:00
|
|
|
$view = id(new PHUITwoColumnView())
|
|
|
|
->setHeader($header)
|
|
|
|
->setFooter($box);
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle($title)
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild($view);
|
2014-04-02 21:06:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|