mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Allow administrators to provide custom welcome text when welcoming users on the profile workflow
Summary: See PHI1027. Currently, we allow you to customize invite email, but not most other types of email (approve, welcome). As a step forward, also allow welcome email to be customized with a message. I considered separating the custom text from the main text with something heavyhanded ("alice added this custom message:") or a beautiful ASCII art divider like one of these: https://www.asciiart.eu/art-and-design/dividers ...but nothing truly sung to me. This only works on the profile flow for now. I'm planning to let you set a default message. I may or may not let you customize from "Create New User", seems like the default message probably covers most of that. Probably won't touch `scripts/user/add_user.php` since that's not really exactly super supported. Test Plan: Sent mail with and without custom messages, reviewed it with `bin/mail show-outbound`. {F6137410} Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D19991
This commit is contained in:
parent
7f950f520b
commit
ab7aceaabf
3 changed files with 63 additions and 18 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,9 +99,14 @@ final class PhabricatorPeopleWelcomeMailEngine
|
|||
$message[] = pht(' %s', $base_uri);
|
||||
}
|
||||
|
||||
$custom_body = $this->getWelcomeMessage();
|
||||
if (strlen($custom_body)) {
|
||||
$message[] = $custom_body;
|
||||
} else {
|
||||
if (!$is_serious) {
|
||||
$message[] = pht("Love,\nPhabricator");
|
||||
}
|
||||
}
|
||||
|
||||
$message = implode("\n\n", $message);
|
||||
|
||||
|
|
Loading…
Reference in a new issue