Path: blob/master/src/applications/people/controller/PhabricatorPeopleCreateController.php
12256 views
<?php12final class PhabricatorPeopleCreateController3extends PhabricatorPeopleController {45public function handleRequest(AphrontRequest $request) {6$admin = $request->getUser();78id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession(9$admin,10$request,11$this->getApplicationURI());1213$v_type = 'standard';14if ($request->isFormPost()) {15$v_type = $request->getStr('type');1617if ($v_type == 'standard' || $v_type == 'bot' || $v_type == 'list') {18return id(new AphrontRedirectResponse())->setURI(19$this->getApplicationURI('new/'.$v_type.'/'));20}21}2223$title = pht('Create New User');2425$standard_caption = pht(26'Create a standard user account. These users can log in, '.27'use the web interface and API, and receive email.');2829$standard_admin = pht(30'Administrators are limited in their ability to access or edit these '.31'accounts after account creation.');3233$bot_caption = pht(34'Create a bot/script user account, to automate interactions with other '.35'systems. These users can not use the web interface, but can use the '.36'API.');3738$bot_admin = pht(39'Administrators have greater access to edit these accounts.');4041$types = array();4243$can_create = $this->hasApplicationCapability(44PeopleCreateUsersCapability::CAPABILITY);45if ($can_create) {46$types[] = array(47'type' => 'standard',48'name' => pht('Create Standard User'),49'help' => pht('Create a standard user account.'),50);51}5253$types[] = array(54'type' => 'bot',55'name' => pht('Create Bot User'),56'help' => pht('Create a new user for use with automated scripts.'),57);5859$types[] = array(60'type' => 'list',61'name' => pht('Create Mailing List User'),62'help' => pht(63'Create a mailing list user to represent an existing, external '.64'mailing list like a Google Group or a Mailman list.'),65);6667$buttons = id(new AphrontFormRadioButtonControl())68->setLabel(pht('Account Type'))69->setName('type')70->setValue($v_type);7172foreach ($types as $type) {73$buttons->addButton($type['type'], $type['name'], $type['help']);74}7576$form = id(new AphrontFormView())77->setUser($admin)78->appendRemarkupInstructions(79pht(80'Choose the type of user account to create. For a detailed '.81'explanation of user account types, see [[ %s | User Guide: '.82'Account Roles ]].',83PhabricatorEnv::getDoclink('User Guide: Account Roles')))84->appendChild($buttons)85->appendChild(86id(new AphrontFormSubmitControl())87->addCancelButton($this->getApplicationURI())88->setValue(pht('Continue')));8990$crumbs = $this->buildApplicationCrumbs();91$crumbs->addTextCrumb($title);92$crumbs->setBorder(true);9394$box = id(new PHUIObjectBoxView())95->setHeaderText($title)96->setBackground(PHUIObjectBoxView::WHITE_CONFIG)97->setForm($form);9899$guidance_context = new PhabricatorPeopleCreateGuidanceContext();100101$guidance = id(new PhabricatorGuidanceEngine())102->setViewer($admin)103->setGuidanceContext($guidance_context)104->newInfoView();105106$view = id(new PHUITwoColumnView())107->setFooter(108array(109$guidance,110$box,111));112113return $this->newPage()114->setTitle($title)115->setCrumbs($crumbs)116->appendChild($view);117}118119}120121122