@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+62 -17
+13 -5
src/applications/people/controller/PhabricatorPeopleProfileManageController.php
··· 157 157 158 158 $curtain->addAction( 159 159 id(new PhabricatorActionView()) 160 + ->setIcon('fa-envelope') 161 + ->setName(pht('Send Welcome Email')) 162 + ->setWorkflow(true) 163 + ->setDisabled(!$can_welcome) 164 + ->setHref($this->getApplicationURI('welcome/'.$user->getID().'/'))); 165 + 166 + $curtain->addAction( 167 + id(new PhabricatorActionView()) 168 + ->setType(PhabricatorActionView::TYPE_DIVIDER)); 169 + 170 + $curtain->addAction( 171 + id(new PhabricatorActionView()) 160 172 ->setIcon($disable_icon) 161 173 ->setName($disable_name) 162 174 ->setDisabled(!$can_disable) ··· 173 185 174 186 $curtain->addAction( 175 187 id(new PhabricatorActionView()) 176 - ->setIcon('fa-envelope') 177 - ->setName(pht('Send Welcome Email')) 178 - ->setWorkflow(true) 179 - ->setDisabled(!$can_welcome) 180 - ->setHref($this->getApplicationURI('welcome/'.$user->getID().'/'))); 188 + ->setType(PhabricatorActionView::TYPE_DIVIDER)); 181 189 182 190 return $curtain; 183 191 }
+31 -10
src/applications/people/controller/PhabricatorPeopleWelcomeController.php
··· 37 37 ->addCancelButton($profile_uri, pht('Done')); 38 38 } 39 39 40 + $v_message = $request->getStr('message'); 41 + 40 42 if ($request->isFormPost()) { 43 + if (strlen($v_message)) { 44 + $welcome_engine->setWelcomeMessage($v_message); 45 + } 46 + 41 47 $welcome_engine->sendMail(); 42 48 return id(new AphrontRedirectResponse())->setURI($profile_uri); 43 49 } 44 50 45 - return $this->newDialog() 46 - ->setTitle(pht('Send Welcome Email')) 47 - ->appendParagraph( 51 + $form = id(new AphrontFormView()) 52 + ->setViewer($admin) 53 + ->appendInstructions( 48 54 pht( 49 - 'This will send the user another copy of the "Welcome to '. 55 + 'This workflow will send this user ("%s") a copy of the "Welcome to '. 50 56 'Phabricator" email that users normally receive when their '. 51 - 'accounts are created.')) 52 - ->appendParagraph( 57 + 'accounts are created by an administrator.', 58 + $user->getUsername())) 59 + ->appendInstructions( 60 + pht( 61 + 'The email will contain a link that the user may use to log in '. 62 + 'to their account. This link bypasses authentication requirements '. 63 + 'and allows them to log in without credentials. Sending a copy of '. 64 + 'this email can be useful if the original was lost or never sent.')) 65 + ->appendInstructions( 53 66 pht( 54 - 'The email contains a link to log in to their account. Sending '. 55 - 'another copy of the email can be useful if the original was lost '. 56 - 'or never sent.')) 57 - ->appendParagraph(pht('The email will identify you as the sender.')) 67 + 'The email will identify you as the sender. You may optionally '. 68 + 'include additional text in the mail body by specifying it below.')) 69 + ->appendControl( 70 + id(new AphrontFormTextAreaControl()) 71 + ->setName('message') 72 + ->setLabel(pht('Custom Message')) 73 + ->setValue($v_message)); 74 + 75 + return $this->newDialog() 76 + ->setTitle(pht('Send Welcome Email')) 77 + ->setWidth(AphrontDialogView::WIDTH_FORM) 78 + ->appendForm($form) 58 79 ->addSubmitButton(pht('Send Email')) 59 80 ->addCancelButton($profile_uri); 60 81 }
+18 -2
src/applications/people/mail/PhabricatorPeopleWelcomeMailEngine.php
··· 3 3 final class PhabricatorPeopleWelcomeMailEngine 4 4 extends PhabricatorPeopleMailEngine { 5 5 6 + private $welcomeMessage; 7 + 8 + public function setWelcomeMessage($welcome_message) { 9 + $this->welcomeMessage = $welcome_message; 10 + return $this; 11 + } 12 + 13 + public function getWelcomeMessage() { 14 + return $this->welcomeMessage; 15 + } 16 + 6 17 public function validateMail() { 7 18 $sender = $this->getSender(); 8 19 $recipient = $this->getRecipient(); ··· 88 99 $message[] = pht(' %s', $base_uri); 89 100 } 90 101 91 - if (!$is_serious) { 92 - $message[] = pht("Love,\nPhabricator"); 102 + $custom_body = $this->getWelcomeMessage(); 103 + if (strlen($custom_body)) { 104 + $message[] = $custom_body; 105 + } else { 106 + if (!$is_serious) { 107 + $message[] = pht("Love,\nPhabricator"); 108 + } 93 109 } 94 110 95 111 $message = implode("\n\n", $message);