diff --git a/src/applications/people/controller/PhabricatorPeopleProfileManageController.php b/src/applications/people/controller/PhabricatorPeopleProfileManageController.php index 3e6c4ffa6e..e9faae3d62 100644 --- a/src/applications/people/controller/PhabricatorPeopleProfileManageController.php +++ b/src/applications/people/controller/PhabricatorPeopleProfileManageController.php @@ -155,6 +155,18 @@ final class PhabricatorPeopleProfileManageController $disable_name = pht('Disable User'); } + $curtain->addAction( + id(new PhabricatorActionView()) + ->setIcon('fa-envelope') + ->setName(pht('Send Welcome Email')) + ->setWorkflow(true) + ->setDisabled(!$can_welcome) + ->setHref($this->getApplicationURI('welcome/'.$user->getID().'/'))); + + $curtain->addAction( + id(new PhabricatorActionView()) + ->setType(PhabricatorActionView::TYPE_DIVIDER)); + $curtain->addAction( id(new PhabricatorActionView()) ->setIcon($disable_icon) @@ -173,11 +185,7 @@ final class PhabricatorPeopleProfileManageController $curtain->addAction( id(new PhabricatorActionView()) - ->setIcon('fa-envelope') - ->setName(pht('Send Welcome Email')) - ->setWorkflow(true) - ->setDisabled(!$can_welcome) - ->setHref($this->getApplicationURI('welcome/'.$user->getID().'/'))); + ->setType(PhabricatorActionView::TYPE_DIVIDER)); return $curtain; } diff --git a/src/applications/people/controller/PhabricatorPeopleWelcomeController.php b/src/applications/people/controller/PhabricatorPeopleWelcomeController.php index 73ee5fd740..5ea4437d8a 100644 --- a/src/applications/people/controller/PhabricatorPeopleWelcomeController.php +++ b/src/applications/people/controller/PhabricatorPeopleWelcomeController.php @@ -37,24 +37,45 @@ final class PhabricatorPeopleWelcomeController ->addCancelButton($profile_uri, pht('Done')); } + $v_message = $request->getStr('message'); + if ($request->isFormPost()) { + if (strlen($v_message)) { + $welcome_engine->setWelcomeMessage($v_message); + } + $welcome_engine->sendMail(); return id(new AphrontRedirectResponse())->setURI($profile_uri); } + $form = id(new AphrontFormView()) + ->setViewer($admin) + ->appendInstructions( + pht( + 'This workflow will send this user ("%s") a copy of the "Welcome to '. + 'Phabricator" email that users normally receive when their '. + 'accounts are created by an administrator.', + $user->getUsername())) + ->appendInstructions( + pht( + 'The email will contain a link that the user may use to log in '. + 'to their account. This link bypasses authentication requirements '. + 'and allows them to log in without credentials. Sending a copy of '. + 'this email can be useful if the original was lost or never sent.')) + ->appendInstructions( + pht( + 'The email will identify you as the sender. You may optionally '. + 'include additional text in the mail body by specifying it below.')) + ->appendControl( + id(new AphrontFormTextAreaControl()) + ->setName('message') + ->setLabel(pht('Custom Message')) + ->setValue($v_message)); + return $this->newDialog() ->setTitle(pht('Send Welcome Email')) - ->appendParagraph( - pht( - 'This will send the user another copy of the "Welcome to '. - 'Phabricator" email that users normally receive when their '. - 'accounts are created.')) - ->appendParagraph( - pht( - 'The email contains a link to log in to their account. Sending '. - 'another copy of the email can be useful if the original was lost '. - 'or never sent.')) - ->appendParagraph(pht('The email will identify you as the sender.')) + ->setWidth(AphrontDialogView::WIDTH_FORM) + ->appendForm($form) ->addSubmitButton(pht('Send Email')) ->addCancelButton($profile_uri); } diff --git a/src/applications/people/mail/PhabricatorPeopleWelcomeMailEngine.php b/src/applications/people/mail/PhabricatorPeopleWelcomeMailEngine.php index 54c8f8fe30..761703e1b5 100644 --- a/src/applications/people/mail/PhabricatorPeopleWelcomeMailEngine.php +++ b/src/applications/people/mail/PhabricatorPeopleWelcomeMailEngine.php @@ -3,6 +3,17 @@ final class PhabricatorPeopleWelcomeMailEngine extends PhabricatorPeopleMailEngine { + private $welcomeMessage; + + public function setWelcomeMessage($welcome_message) { + $this->welcomeMessage = $welcome_message; + return $this; + } + + public function getWelcomeMessage() { + return $this->welcomeMessage; + } + public function validateMail() { $sender = $this->getSender(); $recipient = $this->getRecipient(); @@ -88,8 +99,13 @@ final class PhabricatorPeopleWelcomeMailEngine $message[] = pht(' %s', $base_uri); } - if (!$is_serious) { - $message[] = pht("Love,\nPhabricator"); + $custom_body = $this->getWelcomeMessage(); + if (strlen($custom_body)) { + $message[] = $custom_body; + } else { + if (!$is_serious) { + $message[] = pht("Love,\nPhabricator"); + } } $message = implode("\n\n", $message);