Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/mail/PhabricatorPeopleWelcomeMailEngine.php
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | protected function newMail() { | ||||
$uri = $engine->getOneTimeLoginURI( | $uri = $engine->getOneTimeLoginURI( | ||||
$recipient, | $recipient, | ||||
$recipient->loadPrimaryEmail(), | $recipient->loadPrimaryEmail(), | ||||
PhabricatorAuthSessionEngine::ONETIME_WELCOME); | PhabricatorAuthSessionEngine::ONETIME_WELCOME); | ||||
$message = array(); | $message = array(); | ||||
$message[] = pht('Welcome to Phabricator!'); | $message[] = pht('Welcome to %s!', PhabricatorPlatformSite::getName()); | ||||
$message[] = pht( | $message[] = pht( | ||||
'%s (%s) has created an account for you.', | '%s (%s) has created an account for you.', | ||||
$sender->getUsername(), | $sender->getUsername(), | ||||
$sender->getRealName()); | $sender->getRealName()); | ||||
$message[] = pht( | $message[] = pht( | ||||
' Username: %s', | ' Username: %s', | ||||
$recipient->getUsername()); | $recipient->getUsername()); | ||||
// If password auth is enabled, give the user specific instructions about | // If password auth is enabled, give the user specific instructions about | ||||
// how to add a credential to their account. | // how to add a credential to their account. | ||||
// If we aren't sure what they're supposed to be doing and passwords are | // If we aren't sure what they're supposed to be doing and passwords are | ||||
// not enabled, just give them generic instructions. | // not enabled, just give them generic instructions. | ||||
$use_passwords = PhabricatorPasswordAuthProvider::getPasswordProvider(); | $use_passwords = PhabricatorPasswordAuthProvider::getPasswordProvider(); | ||||
if ($use_passwords) { | if ($use_passwords) { | ||||
$message[] = pht( | $message[] = pht( | ||||
'To log in to Phabricator, follow this link and set a password:'); | 'To log in to %s, follow this link and set a password:', | ||||
PhabricatorPlatformSite::getName()); | |||||
$message[] = pht(' %s', $uri); | $message[] = pht(' %s', $uri); | ||||
$message[] = pht( | $message[] = pht( | ||||
'After you have set a password, you can log in to Phabricator in '. | 'After you have set a password, you can log in to %s in '. | ||||
'the future by going here:'); | 'the future by going here:', | ||||
PhabricatorPlatformSite::getName()); | |||||
$message[] = pht(' %s', $base_uri); | $message[] = pht(' %s', $base_uri); | ||||
} else { | } else { | ||||
$message[] = pht( | $message[] = pht( | ||||
'To log in to your account for the first time, follow this link:'); | 'To log in to your account for the first time, follow this link:'); | ||||
$message[] = pht(' %s', $uri); | $message[] = pht(' %s', $uri); | ||||
$message[] = pht( | $message[] = pht( | ||||
'After you set up your account, you can log in to Phabricator in '. | 'After you set up your account, you can log in to %s in '. | ||||
'the future by going here:'); | 'the future by going here:', | ||||
PhabricatorPlatformSite::getName()); | |||||
$message[] = pht(' %s', $base_uri); | $message[] = pht(' %s', $base_uri); | ||||
} | } | ||||
$message_body = $this->newBody(); | $message_body = $this->newBody(); | ||||
if ($message_body !== null) { | if ($message_body !== null) { | ||||
$message[] = $message_body; | $message[] = $message_body; | ||||
} | } | ||||
$message = implode("\n\n", $message); | $message = implode("\n\n", $message); | ||||
return id(new PhabricatorMetaMTAMail()) | return id(new PhabricatorMetaMTAMail()) | ||||
->setSubject(pht('[Phabricator] Welcome to Phabricator')) | ->setSubject(pht('[%s] Welcome to %s', | ||||
PhabricatorPlatformSite::getName(), | |||||
PhabricatorPlatformSite::getName())) | |||||
->setBody($message); | ->setBody($message); | ||||
} | } | ||||
private function newBody() { | private function newBody() { | ||||
$recipient = $this->getRecipient(); | $recipient = $this->getRecipient(); | ||||
$custom_body = $this->getWelcomeMessage(); | $custom_body = $this->getWelcomeMessage(); | ||||
if (strlen($custom_body)) { | if (strlen($custom_body)) { | ||||
return $this->newRemarkupText($custom_body); | return $this->newRemarkupText($custom_body); | ||||
} | } | ||||
$default_body = PhabricatorAuthMessage::loadMessageText( | $default_body = PhabricatorAuthMessage::loadMessageText( | ||||
$recipient, | $recipient, | ||||
PhabricatorAuthWelcomeMailMessageType::MESSAGEKEY); | PhabricatorAuthWelcomeMailMessageType::MESSAGEKEY); | ||||
if (strlen($default_body)) { | if (strlen($default_body)) { | ||||
return $this->newRemarkupText($default_body); | return $this->newRemarkupText($default_body); | ||||
} | } | ||||
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); | $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); | ||||
if (!$is_serious) { | if (!$is_serious) { | ||||
return pht("Love,\nPhabricator"); | return pht("Love,\n%s", PhabricatorPlatformSite::getName()); | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0