3 final class PhabricatorPeopleInviteSendController
4 extends PhabricatorPeopleInviteController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $this->getViewer();
9 $this->requireApplicationCapability(
10 PeopleCreateUsersCapability
::CAPABILITY
);
14 $confirm_errors = array();
17 $message = $request->getStr('message');
18 $emails = $request->getStr('emails');
19 $severity = PHUIInfoView
::SEVERITY_ERROR
;
20 if ($request->isFormPost()) {
21 // NOTE: We aren't using spaces as a delimiter here because email
22 // addresses with names often include spaces.
23 $email_list = preg_split('/[,;\n]+/', $emails);
24 foreach ($email_list as $key => $email) {
25 if (!strlen(trim($email))) {
26 unset($email_list[$key]);
33 $e_emails = pht('Required');
35 'To send invites, you must enter at least one email address.');
41 $actions = PhabricatorAuthInviteAction
::newActionListFromAddresses(
47 foreach ($actions as $action) {
48 if ($action->willSend()) {
56 $confirm_errors[] = pht(
57 'None of the provided addresses are valid invite recipients. '.
58 'Review the table below for details. Revise the address list '.
60 } else if ($all_valid) {
61 $confirm_errors[] = pht(
62 'All of the addresses appear to be valid invite recipients. '.
63 'Confirm the actions below to continue.');
64 $severity = PHUIInfoView
::SEVERITY_NOTICE
;
66 $confirm_errors[] = pht(
67 'Some of the addresses you entered do not appear to be '.
68 'valid recipients. Review the table below. You can revise '.
69 'the address list, or ignore these errors and continue.');
70 $severity = PHUIInfoView
::SEVERITY_WARNING
;
73 if ($any_valid && $request->getBool('confirm')) {
75 // TODO: The copywriting on this mail could probably be more
76 // engaging and we could have a fancy HTML version.
80 '%s has invited you to join Phabricator.',
81 $viewer->getFullName());
83 if (strlen(trim($message))) {
84 $template[] = $message;
88 'To register an account and get started, follow this link:');
90 // This isn't a variable; it will be replaced later on in the
91 // daemons once they generate the URI.
92 $template[] = '{$INVITE_URI}';
95 'If you already have an account, you can follow the link to '.
96 'quickly verify this email address.');
98 $template = implode("\n\n", $template);
100 foreach ($actions as $action) {
101 if ($action->willSend()) {
102 $action->sendInvite($viewer, $template);
106 // TODO: This is a bit anticlimactic. We don't really have anything
107 // to show the user because the action is happening in the background
108 // and the invites won't exist yet. After T5166 we can show a
109 // better progress bar.
110 return id(new AphrontRedirectResponse())
111 ->setURI($this->getApplicationURI());
117 $title = pht('Confirm Invites');
119 $title = pht('Invite Users');
122 $crumbs = $this->buildApplicationCrumbs();
124 $crumbs->addTextCrumb(pht('Confirm'));
126 $crumbs->addTextCrumb(pht('Invite Users'));
128 $crumbs->setBorder(true);
136 $handles = $this->loadViewerHandles(mpull($actions, 'getUserPHID'));
139 $invite_table = id(new PhabricatorAuthInviteActionTableView())
141 ->setInviteActions($actions)
142 ->setHandles($handles);
144 $confirm_form = null;
146 $confirm_form = id(new AphrontFormView())
148 ->addHiddenInput('message', $message)
149 ->addHiddenInput('emails', $emails)
150 ->addHiddenInput('confirm', true)
151 ->appendRemarkupInstructions(
153 'If everything looks good, click **Send Invitations** to '.
154 'deliver email invitations these users. Otherwise, edit the '.
155 'email list or personal message at the bottom of the page to '.
156 'revise the invitations.'))
158 id(new AphrontFormSubmitControl())
159 ->setValue(pht('Send Invitations')));
162 $info_view = id(new PHUIInfoView())
163 ->setErrors($confirm_errors)
164 ->setSeverity($severity);
166 $confirm_box = id(new PHUIObjectBoxView())
167 ->setHeaderText(pht('Confirm Invites'))
168 ->setTable($invite_table)
169 ->appendChild($confirm_form)
170 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
);
173 $form = id(new AphrontFormView())
175 ->appendRemarkupInstructions(
177 'To invite users to Phabricator, enter their email addresses below. '.
178 'Separate addresses with commas or newlines.'))
180 id(new AphrontFormTextAreaControl())
181 ->setLabel(pht('Email Addresses'))
182 ->setName(pht('emails'))
184 ->setError($e_emails)
185 ->setHeight(AphrontFormTextAreaControl
::HEIGHT_VERY_TALL
))
186 ->appendRemarkupInstructions(
188 'You can optionally include a heartfelt personal message in '.
191 id(new AphrontFormTextAreaControl())
192 ->setLabel(pht('Message'))
193 ->setName(pht('message'))
194 ->setValue($message))
196 id(new AphrontFormSubmitControl())
199 ?
pht('Update Preview')
201 ->addCancelButton($this->getApplicationURI('invite/')));
203 $header = id(new PHUIHeaderView())
205 ->setHeaderIcon('fa-group');
207 $box = id(new PHUIObjectBoxView())
210 ?
pht('Revise Invites')
211 : pht('Invite Users'))
212 ->setFormErrors($errors)
214 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
);
216 $view = id(new PHUITwoColumnView())
224 return $this->newPage()
227 ->appendChild($view);