Differential D13123 Diff 31761 src/applications/people/controller/PhabricatorPeopleCreateController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/controller/PhabricatorPeopleCreateController.php
| <?php | <?php | ||||
| final class PhabricatorPeopleCreateController | final class PhabricatorPeopleCreateController | ||||
| extends PhabricatorPeopleController { | extends PhabricatorPeopleController { | ||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $this->requireApplicationCapability( | |||||
| PeopleCreateUsersCapability::CAPABILITY); | |||||
| $admin = $request->getUser(); | $admin = $request->getUser(); | ||||
| id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( | id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( | ||||
| $admin, | $admin, | ||||
| $request, | $request, | ||||
| $this->getApplicationURI()); | $this->getApplicationURI()); | ||||
| $v_type = 'standard'; | $v_type = 'standard'; | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $v_type = $request->getStr('type'); | $v_type = $request->getStr('type'); | ||||
| if ($v_type == 'standard' || $v_type == 'bot') { | if ($v_type == 'standard' || $v_type == 'bot' || $v_type == 'list') { | ||||
| return id(new AphrontRedirectResponse())->setURI( | return id(new AphrontRedirectResponse())->setURI( | ||||
| $this->getApplicationURI('new/'.$v_type.'/')); | $this->getApplicationURI('new/'.$v_type.'/')); | ||||
| } | } | ||||
| } | } | ||||
| $title = pht('Create New User'); | $title = pht('Create New User'); | ||||
| $standard_caption = pht( | $standard_caption = pht( | ||||
| 'Create a standard user account. These users can log in to Phabricator, '. | 'Create a standard user account. These users can log in to Phabricator, '. | ||||
| 'use the web interface and API, and receive email.'); | 'use the web interface and API, and receive email.'); | ||||
| $standard_admin = pht( | $standard_admin = pht( | ||||
| 'Administrators are limited in their ability to access or edit these '. | 'Administrators are limited in their ability to access or edit these '. | ||||
| 'accounts after account creation.'); | 'accounts after account creation.'); | ||||
| $bot_caption = pht( | $bot_caption = pht( | ||||
| 'Create a bot/script user account, to automate interactions with other '. | 'Create a bot/script user account, to automate interactions with other '. | ||||
| 'systems. These users can not use the web interface, but can use the '. | 'systems. These users can not use the web interface, but can use the '. | ||||
| 'API.'); | 'API.'); | ||||
| $bot_admin = pht( | $bot_admin = pht( | ||||
| 'Administrators have greater access to edit these accounts.'); | '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()) | $form = id(new AphrontFormView()) | ||||
| ->setUser($admin) | ->setUser($admin) | ||||
| ->appendRemarkupInstructions( | ->appendRemarkupInstructions( | ||||
| pht( | pht( | ||||
| 'Choose the type of user account to create. For a detailed '. | 'Choose the type of user account to create. For a detailed '. | ||||
| 'explanation of user account types, see [[ %s | User Guide: '. | 'explanation of user account types, see [[ %s | User Guide: '. | ||||
| 'Account Roles ]].', | 'Account Roles ]].', | ||||
| PhabricatorEnv::getDoclink('User Guide: Account Roles'))) | PhabricatorEnv::getDoclink('User Guide: Account Roles'))) | ||||
| ->appendChild( | ->appendChild($buttons) | ||||
| id(new AphrontFormRadioButtonControl()) | |||||
| ->setLabel(pht('Account Type')) | |||||
| ->setName('type') | |||||
| ->setValue($v_type) | |||||
| ->addButton( | |||||
| 'standard', | |||||
| pht('Create Standard User'), | |||||
| hsprintf('%s<br /><br />%s', $standard_caption, $standard_admin)) | |||||
| ->addButton( | |||||
| 'bot', | |||||
| pht('Create Bot/Script User'), | |||||
| hsprintf('%s<br /><br />%s', $bot_caption, $bot_admin))) | |||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
| ->addCancelButton($this->getApplicationURI()) | ->addCancelButton($this->getApplicationURI()) | ||||
| ->setValue(pht('Continue'))); | ->setValue(pht('Continue'))); | ||||
| $crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
| $crumbs->addTextCrumb($title); | $crumbs->addTextCrumb($title); | ||||
| Show All 15 Lines | |||||