Page MenuHomestyx hydra

No OneTemporary

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
@@ -1,186 +1,194 @@
<?php
final class PhabricatorPeopleProfileManageController
extends PhabricatorPeopleProfileController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withIDs(array($id))
->needProfile(true)
->needProfileImage(true)
->needAvailability(true)
->executeOne();
if (!$user) {
return new Aphront404Response();
}
$this->setUser($user);
$header = $this->buildProfileHeader();
$curtain = $this->buildCurtain($user);
$properties = $this->buildPropertyView($user);
$name = $user->getUsername();
$nav = $this->getProfileMenu();
$nav->selectFilter(PhabricatorPeopleProfileMenuEngine::ITEM_MANAGE);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Manage'));
$crumbs->setBorder(true);
$timeline = $this->buildTransactionTimeline(
$user,
new PhabricatorPeopleTransactionQuery());
$timeline->setShouldTerminate(true);
$manage = id(new PHUITwoColumnView())
->setHeader($header)
->addClass('project-view-home')
->addClass('project-view-people-home')
->setCurtain($curtain)
->addPropertySection(pht('Details'), $properties)
->setMainColumn($timeline);
return $this->newPage()
->setTitle(
array(
pht('Manage User'),
$user->getUsername(),
))
->setNavigation($nav)
->setCrumbs($crumbs)
->appendChild($manage);
}
private function buildPropertyView(PhabricatorUser $user) {
$viewer = $this->getRequest()->getUser();
$view = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($user);
$field_list = PhabricatorCustomField::getObjectFields(
$user,
PhabricatorCustomField::ROLE_VIEW);
$field_list->appendFieldsToPropertyList($user, $viewer, $view);
return $view;
}
private function buildCurtain(PhabricatorUser $user) {
$viewer = $this->getViewer();
$is_self = ($user->getPHID() === $viewer->getPHID());
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$user,
PhabricatorPolicyCapability::CAN_EDIT);
$is_admin = $viewer->getIsAdmin();
$can_admin = ($is_admin && !$is_self);
$has_disable = $this->hasApplicationCapability(
PeopleDisableUsersCapability::CAPABILITY);
$can_disable = ($has_disable && !$is_self);
$welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine())
->setSender($viewer)
->setRecipient($user);
$can_welcome = $welcome_engine->canSendMail();
$curtain = $this->newCurtainView($user);
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Profile'))
->setHref($this->getApplicationURI('editprofile/'.$user->getID().'/'))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-picture-o')
->setName(pht('Edit Profile Picture'))
->setHref($this->getApplicationURI('picture/'.$user->getID().'/'))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-wrench')
->setName(pht('Edit Settings'))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)
->setHref('/settings/user/'.$user->getUsername().'/'));
if ($user->getIsAdmin()) {
$empower_icon = 'fa-arrow-circle-o-down';
$empower_name = pht('Remove Administrator');
} else {
$empower_icon = 'fa-arrow-circle-o-up';
$empower_name = pht('Make Administrator');
}
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon($empower_icon)
->setName($empower_name)
->setDisabled(!$can_admin)
->setWorkflow(true)
->setHref($this->getApplicationURI('empower/'.$user->getID().'/')));
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-tag')
->setName(pht('Change Username'))
->setDisabled(!$is_admin)
->setWorkflow(true)
->setHref($this->getApplicationURI('rename/'.$user->getID().'/')));
if ($user->getIsDisabled()) {
$disable_icon = 'fa-check-circle-o';
$disable_name = pht('Enable User');
} else {
$disable_icon = 'fa-ban';
$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)
->setName($disable_name)
->setDisabled(!$can_disable)
->setWorkflow(true)
->setHref($this->getApplicationURI('disable/'.$user->getID().'/')));
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-times')
->setName(pht('Delete User'))
->setDisabled(!$can_admin)
->setWorkflow(true)
->setHref($this->getApplicationURI('delete/'.$user->getID().'/')));
$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
@@ -1,62 +1,83 @@
<?php
final class PhabricatorPeopleWelcomeController
extends PhabricatorPeopleController {
public function shouldRequireAdmin() {
// You need to be an administrator to actually send welcome email, but
// we let anyone hit this page so they can get a nice error dialog
// explaining the issue.
return false;
}
public function handleRequest(AphrontRequest $request) {
$admin = $this->getViewer();
$user = id(new PhabricatorPeopleQuery())
->setViewer($admin)
->withIDs(array($request->getURIData('id')))
->executeOne();
if (!$user) {
return new Aphront404Response();
}
$id = $user->getID();
$profile_uri = "/people/manage/{$id}/";
$welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine())
->setSender($admin)
->setRecipient($user);
try {
$welcome_engine->validateMail();
} catch (PhabricatorPeopleMailEngineException $ex) {
return $this->newDialog()
->setTitle($ex->getTitle())
->appendParagraph($ex->getBody())
->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);
}
- return $this->newDialog()
- ->setTitle(pht('Send Welcome Email'))
- ->appendParagraph(
+ $form = id(new AphrontFormView())
+ ->setViewer($admin)
+ ->appendInstructions(
pht(
- 'This will send the user another copy of the "Welcome to '.
+ 'This workflow will send this user ("%s") a copy of the "Welcome to '.
'Phabricator" email that users normally receive when their '.
- 'accounts are created.'))
- ->appendParagraph(
+ 'accounts are created by an administrator.',
+ $user->getUsername()))
+ ->appendInstructions(
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.'))
+ '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'))
+ ->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
@@ -1,103 +1,119 @@
<?php
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();
if (!$sender->getIsAdmin()) {
$this->throwValidationException(
pht('Not an Administrator'),
pht(
'You can not send welcome mail because you are not an '.
'administrator. Only administrators may send welcome mail.'));
}
if ($recipient->getIsDisabled()) {
$this->throwValidationException(
pht('User is Disabled'),
pht(
'You can not send welcome mail to this user because their account '.
'is disabled.'));
}
if (!$recipient->canEstablishWebSessions()) {
$this->throwValidationException(
pht('Not a Normal User'),
pht(
'You can not send this user welcome mail because they are not '.
'a normal user and can not log in to the web interface. Special '.
'users (like bots and mailing lists) are unable to establish '.
'web sessions.'));
}
}
protected function newMail() {
$sender = $this->getSender();
$recipient = $this->getRecipient();
$recipient_username = $recipient->getUserName();
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$base_uri = PhabricatorEnv::getProductionURI('/');
$engine = new PhabricatorAuthSessionEngine();
$uri = $engine->getOneTimeLoginURI(
$recipient,
$recipient->loadPrimaryEmail(),
PhabricatorAuthSessionEngine::ONETIME_WELCOME);
$message = array();
$message[] = pht('Welcome to Phabricator!');
$message[] = pht(
'%s (%s) has created an account for you.',
$sender->getUsername(),
$sender->getRealName());
$message[] = pht(
' Username: %s',
$recipient->getUsername());
// If password auth is enabled, give the user specific instructions about
// how to add a credential to their account.
// If we aren't sure what they're supposed to be doing and passwords are
// not enabled, just give them generic instructions.
$use_passwords = PhabricatorPasswordAuthProvider::getPasswordProvider();
if ($use_passwords) {
$message[] = pht(
'To log in to Phabricator, follow this link and set a password:');
$message[] = pht(' %s', $uri);
$message[] = pht(
'After you have set a password, you can log in to Phabricator in '.
'the future by going here:');
$message[] = pht(' %s', $base_uri);
} else {
$message[] = pht(
'To log in to your account for the first time, follow this link:');
$message[] = pht(' %s', $uri);
$message[] = pht(
'After you set up your account, you can log in to Phabricator in '.
'the future by going here:');
$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);
return id(new PhabricatorMetaMTAMail())
->addTos(array($recipient->getPHID()))
->setSubject(pht('[Phabricator] Welcome to Phabricator'))
->setBody($message);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 10, 5:19 PM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
140601
Default Alt Text
(14 KB)

Event Timeline