3 final class PhabricatorPeopleWelcomeController
4 extends PhabricatorPeopleController
{
6 public function shouldRequireAdmin() {
7 // You need to be an administrator to actually send welcome email, but
8 // we let anyone hit this page so they can get a nice error dialog
9 // explaining the issue.
13 public function handleRequest(AphrontRequest
$request) {
14 $admin = $this->getViewer();
16 $user = id(new PhabricatorPeopleQuery())
18 ->withIDs(array($request->getURIData('id')))
21 return new Aphront404Response();
25 $profile_uri = "/people/manage/{$id}/";
27 $welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine())
29 ->setRecipient($user);
32 $welcome_engine->validateMail();
33 } catch (PhabricatorPeopleMailEngineException
$ex) {
34 return $this->newDialog()
35 ->setTitle($ex->getTitle())
36 ->appendParagraph($ex->getBody())
37 ->addCancelButton($profile_uri, pht('Done'));
40 $v_message = $request->getStr('message');
42 if ($request->isFormPost()) {
43 if (strlen($v_message)) {
44 $welcome_engine->setWelcomeMessage($v_message);
47 $welcome_engine->sendMail();
48 return id(new AphrontRedirectResponse())->setURI($profile_uri);
51 $default_message = PhabricatorAuthMessage
::loadMessage(
53 PhabricatorAuthWelcomeMailMessageType
::MESSAGEKEY
);
54 if ($default_message && strlen($default_message->getMessageText())) {
55 $message_instructions = pht(
56 'The email will identify you as the sender. You may optionally '.
57 'replace the [[ %s | default custom mail body ]] with different text '.
58 'by providing a message below.',
59 $default_message->getURI());
61 $message_instructions = pht(
62 'The email will identify you as the sender. You may optionally '.
63 'include additional text in the mail body by specifying it below.');
66 $form = id(new AphrontFormView())
68 ->appendRemarkupInstructions(
70 'This workflow will send this user ("%s") a copy of the "Welcome to '.
71 '%s" email that users normally receive when their '.
72 'accounts are created by an administrator.',
74 PlatformSymbols
::getPlatformServerName()))
75 ->appendRemarkupInstructions(
77 'The email will contain a link that the user may use to log in '.
78 'to their account. This link bypasses authentication requirements '.
79 'and allows them to log in without credentials. Sending a copy of '.
80 'this email can be useful if the original was lost or never sent.'))
81 ->appendRemarkupInstructions($message_instructions)
83 id(new PhabricatorRemarkupControl())
85 ->setLabel(pht('Custom Message'))
86 ->setValue($v_message));
88 return $this->newDialog()
89 ->setTitle(pht('Send Welcome Email'))
90 ->setWidth(AphrontDialogView
::WIDTH_FORM
)
92 ->addSubmitButton(pht('Send Email'))
93 ->addCancelButton($profile_uri);