Path: blob/master/src/applications/people/controller/PhabricatorPeopleWelcomeController.php
12262 views
<?php12final class PhabricatorPeopleWelcomeController3extends PhabricatorPeopleController {45public function shouldRequireAdmin() {6// You need to be an administrator to actually send welcome email, but7// we let anyone hit this page so they can get a nice error dialog8// explaining the issue.9return false;10}1112public function handleRequest(AphrontRequest $request) {13$admin = $this->getViewer();1415$user = id(new PhabricatorPeopleQuery())16->setViewer($admin)17->withIDs(array($request->getURIData('id')))18->executeOne();19if (!$user) {20return new Aphront404Response();21}2223$id = $user->getID();24$profile_uri = "/people/manage/{$id}/";2526$welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine())27->setSender($admin)28->setRecipient($user);2930try {31$welcome_engine->validateMail();32} catch (PhabricatorPeopleMailEngineException $ex) {33return $this->newDialog()34->setTitle($ex->getTitle())35->appendParagraph($ex->getBody())36->addCancelButton($profile_uri, pht('Done'));37}3839$v_message = $request->getStr('message');4041if ($request->isFormPost()) {42if (strlen($v_message)) {43$welcome_engine->setWelcomeMessage($v_message);44}4546$welcome_engine->sendMail();47return id(new AphrontRedirectResponse())->setURI($profile_uri);48}4950$default_message = PhabricatorAuthMessage::loadMessage(51$admin,52PhabricatorAuthWelcomeMailMessageType::MESSAGEKEY);53if ($default_message && strlen($default_message->getMessageText())) {54$message_instructions = pht(55'The email will identify you as the sender. You may optionally '.56'replace the [[ %s | default custom mail body ]] with different text '.57'by providing a message below.',58$default_message->getURI());59} else {60$message_instructions = pht(61'The email will identify you as the sender. You may optionally '.62'include additional text in the mail body by specifying it below.');63}6465$form = id(new AphrontFormView())66->setViewer($admin)67->appendRemarkupInstructions(68pht(69'This workflow will send this user ("%s") a copy of the "Welcome to '.70'%s" email that users normally receive when their '.71'accounts are created by an administrator.',72$user->getUsername(),73PlatformSymbols::getPlatformServerName()))74->appendRemarkupInstructions(75pht(76'The email will contain a link that the user may use to log in '.77'to their account. This link bypasses authentication requirements '.78'and allows them to log in without credentials. Sending a copy of '.79'this email can be useful if the original was lost or never sent.'))80->appendRemarkupInstructions($message_instructions)81->appendControl(82id(new PhabricatorRemarkupControl())83->setName('message')84->setLabel(pht('Custom Message'))85->setValue($v_message));8687return $this->newDialog()88->setTitle(pht('Send Welcome Email'))89->setWidth(AphrontDialogView::WIDTH_FORM)90->appendForm($form)91->addSubmitButton(pht('Send Email'))92->addCancelButton($profile_uri);93}9495}969798