Conpherence - add "room" search UI and create UI
Summary: Ref T7584. This hits all the major bullets there. Next step on T7584 is figuring out how it integrates into the full UI and column UI. That said, this is a bit buggy feeling right now since Conpherence as is assumes you are a participant all over the place and rooms make no such assumption. I'll probably this bit up next. Test Plan: viewed /conpherence/room/ and saw stuff. viewed the "participant" query as two different users and saw different correct result sets. made a room via the button and it worked. tried to view a room I wasn't a participant in and it failed horribly, which is something to fix in a future diff created a thread via "send message" on a user profile and it worked Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7584 Differential Revision: https://secure.phabricator.com/D12113
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
final class ConpherenceNewRoomController extends ConpherenceController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
|
||||
$title = pht('New Room');
|
||||
$e_title = true;
|
||||
$validation_exception = null;
|
||||
|
||||
$conpherence = ConpherenceThread::initializeNewRoom($user);
|
||||
if ($request->isFormPost()) {
|
||||
|
||||
$xactions = array();
|
||||
$xactions[] = id(new ConpherenceTransaction())
|
||||
->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS)
|
||||
->setNewValue(array('+' => array($user->getPHID())));
|
||||
$xactions[] = id(new ConpherenceTransaction())
|
||||
->setTransactionType(ConpherenceTransactionType::TYPE_TITLE)
|
||||
->setNewValue($request->getStr('title'));
|
||||
$xactions[] = id(new ConpherenceTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
||||
->setNewValue($request->getStr('viewPolicy'));
|
||||
$xactions[] = id(new ConpherenceTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
|
||||
->setNewValue($request->getStr('editPolicy'));
|
||||
$xactions[] = id(new ConpherenceTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
|
||||
->setNewValue($request->getStr('joinPolicy'));
|
||||
|
||||
try {
|
||||
id(new ConpherenceEditor())
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setActor($user)
|
||||
->applyTransactions($conpherence, $xactions);
|
||||
|
||||
$uri = $this->getApplicationURI($conpherence->getID());
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($uri);
|
||||
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
||||
$validation_exception = $ex;
|
||||
|
||||
$e_title = $ex->getShortMessage(ConpherenceTransactionType::TYPE_TITLE);
|
||||
|
||||
$conpherence->setViewPolicy($request->getStr('viewPolicy'));
|
||||
$conpherence->setEditPolicy($request->getStr('editPolicy'));
|
||||
$conpherence->setJoinPolicy($request->getStr('joinPolicy'));
|
||||
}
|
||||
}
|
||||
|
||||
$policies = id(new PhabricatorPolicyQuery())
|
||||
->setViewer($user)
|
||||
->setObject($conpherence)
|
||||
->execute();
|
||||
|
||||
$submit_uri = $this->getApplicationURI('room/new/');
|
||||
$cancel_uri = $this->getApplicationURI('room/');
|
||||
|
||||
$dialog = $this->newDialog()
|
||||
->setWidth(AphrontDialogView::WIDTH_FORM)
|
||||
->setValidationException($validation_exception)
|
||||
->setUser($user)
|
||||
->setTitle($title)
|
||||
->addCancelButton($cancel_uri)
|
||||
->addSubmitButton(pht('Create Room'));
|
||||
|
||||
$form = id(new PHUIFormLayoutView())
|
||||
->setUser($user)
|
||||
->setFullWidth(true)
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setError($e_title)
|
||||
->setLabel(pht('Title'))
|
||||
->setName('title')
|
||||
->setValue($request->getStr('title')))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setName('viewPolicy')
|
||||
->setPolicyObject($conpherence)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
||||
->setPolicies($policies))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setName('editPolicy')
|
||||
->setPolicyObject($conpherence)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
||||
->setPolicies($policies))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setName('joinPolicy')
|
||||
->setPolicyObject($conpherence)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_JOIN)
|
||||
->setPolicies($policies));
|
||||
|
||||
$dialog->appendChild($form);
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user