Files
phabricator/src/applications/conpherence/controller/ConpherenceNewController.php
epriestley d403700e1f Convert all tokenizers to take token/scalar inputs
Summary: Ref T7689. Ref T4100. This advances the goals of removing `loadViewerHandles()` (only 67 callsites remain!) and letting tokenizers some day take token functions like `viewer()` and `members(differential)`.

Test Plan:
- Sent a new message; used "To".
  - I simplified the cancel URI construction slightly because it's moot in all normal cases.
- Edited a thread; used "Add Participants".
- Searched rooms; used "Participants".
- Searched countdowns; used "Authors".
- Created a diff; used "Repository".
- Edited a revision; edited "Projects"; edited "Reveiwers"; edited "Subscribers".
- Searched for revisions; edited "responsible users"; "authors"; "reviwers"; "subscribers"; "repositories".
- Added revision comments; edited "Add Reveiwers"; "Add Subscribers".
- Commented on a commit; edited "Add Auditors"; "Add subscribers".
- Edited a commit; edited "Projects".
- Edited a repository; edited "Projects".
- Searched feed, used "include Users"; "include Proejcts".
- Searched files, used "authors".
- Edited initiative; edited "Projects".
- Searched backers; used "Backers".
- Searched initiatives; used "Owners".
- Edited build plans; edited "Run Command".
- Searched Herald; used "Authors".
- Added signature exemption in Legalpad.
- Searhced legalpad; used "creators"; used "contributors".
- Searched signatures; used "documents"; used "signers".
- Created meme.
- Searched macros; used "Authors".
- Used "Projects" in Maniphest reports.
- Used Maniphest comment actions.
- Edited Maniphest tasks; edited "Assigned To"; edited "CC"; edited "projects".
- Used "parent" in Maniphest task creation workflow.
- Searched for projects; used "assigned to"; "in any projec"; "in all projects"; "not in projects"; "in users' projects"; "authors"; "subscribers".
- Edited Maniphest bug filing domains, used "Default Author".
- Searched for OAuth applications, used "Creators".
- Edited Owners pacakge; edited "Primary Owner"; edited "Owners".
- Searched for Owners packages; used "Owner".
  - OMG this UI is OLD
- Edited a paste; edited "Projects".
- Searched for paste; used "Authors".
- Searched user activity log; used "Actors"; used "Users".
- Edited a mock; edited "Projects"; edited "CC".
- Searched for mocks; used "Authors".
- Edited Phortune account; edited "Members".
- Edited Phortune merchant account; edited "Members".
- Searched Phrequent; used "Users".
- Edited Ponder question; sued "projects".
- Searched Ponder; used "Authors"; used "Answered By".
- Added project members.
- Searched for projects; used "Members".
- Edited a Releeph product; edited "Pushers".
- Searched pull requests; searched "Requestors".
- Edited an arcanist project; used "Uses Symbols From".
- Searhced push logs; used "Repositories"; used "Pushers".
- Searched repositories; used "In nay project".
- Used global search; used Authors/owners/Subscribers/In Any Project.
- Edited a slowvote; used "Projects".
- Searched slovotes; used "Authors".
- Created a custom "Users" field; edited and searched for it.
- Made a whole lot of typos in this list. ^^^^^^

Did not test:

- Lint is nontrivial to test locally, I'll test it in production.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4100, T7689

Differential Revision: https://secure.phabricator.com/D12224
2015-03-31 14:10:55 -07:00

92 lines
2.7 KiB
PHP

<?php
final class ConpherenceNewController extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$title = pht('New Message');
$participants = array();
$participant_prefill = null;
$message = '';
$e_participants = null;
$e_message = null;
$errors = array();
// this comes from ajax requests from all over. should be a single phid.
if ($request->isFormPost()) {
$participants = $request->getArr('participants');
$message = $request->getStr('message');
list($error_codes, $conpherence) = ConpherenceEditor::createThread(
$user,
$participants,
$conpherence_title = null,
$message,
PhabricatorContentSource::newFromRequest($request));
if ($error_codes) {
foreach ($error_codes as $error_code) {
switch ($error_code) {
case ConpherenceEditor::ERROR_EMPTY_MESSAGE:
$e_message = pht('Required');
$errors[] = pht(
'You can not send an empty message.');
break;
case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
$e_participants = pht('Required');
$errors[] = pht(
'You must choose at least one recipient for your '.
'message.');
break;
}
}
} else {
$uri = $this->getApplicationURI($conpherence->getID());
return id(new AphrontRedirectResponse())
->setURI($uri);
}
} else {
$participant_prefill = $request->getStr('participant');
if ($participant_prefill) {
$participants[] = $participant_prefill;
}
}
$submit_uri = $this->getApplicationURI('new/');
$cancel_uri = $this->getApplicationURI();
$dialog = id(new AphrontDialogView())
->setWidth(AphrontDialogView::WIDTH_FORM)
->setErrors($errors)
->setUser($user)
->setTitle($title)
->addCancelButton($cancel_uri)
->addSubmitButton(pht('Send Message'));
$form = id(new AphrontFormView())
->setUser($user)
->setFullWidth(true)
->appendControl(
id(new AphrontFormTokenizerControl())
->setName('participants')
->setValue($participants)
->setUser($user)
->setDatasource(new PhabricatorPeopleDatasource())
->setLabel(pht('To'))
->setError($e_participants))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setName('message')
->setValue($message)
->setLabel(pht('Message'))
->setError($e_message));
$dialog->appendForm($form);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}