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 'Phabricator" email that users normally receive when their '.
72 'accounts are created by an administrator.',
73 $user->getUsername()))
74 ->appendRemarkupInstructions(
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)
82 id(new PhabricatorRemarkupControl())
84 ->setLabel(pht('Custom Message'))
85 ->setValue($v_message));
87 return $this->newDialog()
88 ->setTitle(pht('Send Welcome Email'))
89 ->setWidth(AphrontDialogView
::WIDTH_FORM
)
91 ->addSubmitButton(pht('Send Email'))
92 ->addCancelButton($profile_uri);