mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 11:12:42 +01:00
3d6049d0da
Summary: Fixes T12178, Fixes T11704 Not sure this feature gets any use and I can't find a similar option in other software, so removing it I think simiplifies a number of things. Removes CAN_JOIN and joinable is basically now CAN_VIEW and !$participating. Also removed some old transaction strings for other policies. Don't seem used. Test Plan: Create a new room, edit room policies, see changes. Log into second account, search for rooms, everything now is visible. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12178, T11704 Differential Revision: https://secure.phabricator.com/D17675
116 lines
4 KiB
PHP
116 lines
4 KiB
PHP
<?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);
|
|
$participants = array();
|
|
if ($request->isFormPost()) {
|
|
$editor = new ConpherenceEditor();
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
->setTransactionType(ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
|
|
->setNewValue($request->getStr('title'));
|
|
|
|
$participants = $request->getArr('participants');
|
|
$participants[] = $user->getPHID();
|
|
$participants = array_unique($participants);
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)
|
|
->setNewValue(array('+' => $participants));
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
->setTransactionType(ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
|
|
->setNewValue($request->getStr('topic'));
|
|
$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'));
|
|
|
|
try {
|
|
$editor
|
|
->setContentSourceFromRequest($request)
|
|
->setContinueOnNoEffect(true)
|
|
->setActor($user)
|
|
->applyTransactions($conpherence, $xactions);
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
->setURI('/'.$conpherence->getMonogram());
|
|
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
|
$validation_exception = $ex;
|
|
|
|
$e_title = $ex->getShortMessage(
|
|
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE);
|
|
|
|
$conpherence->setViewPolicy($request->getStr('viewPolicy'));
|
|
$conpherence->setEditPolicy($request->getStr('editPolicy'));
|
|
}
|
|
} else {
|
|
if ($request->getStr('participant')) {
|
|
$participants[] = $request->getStr('participant');
|
|
}
|
|
}
|
|
|
|
$policies = id(new PhabricatorPolicyQuery())
|
|
->setViewer($user)
|
|
->setObject($conpherence)
|
|
->execute();
|
|
|
|
$submit_uri = $this->getApplicationURI('new/');
|
|
$cancel_uri = $this->getApplicationURI('search/');
|
|
|
|
$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)
|
|
->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setError($e_title)
|
|
->setLabel(pht('Name'))
|
|
->setName('title')
|
|
->setValue($request->getStr('title')))
|
|
->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setLabel(pht('Topic'))
|
|
->setName('topic')
|
|
->setValue($request->getStr('topic')))
|
|
->appendChild(
|
|
id(new AphrontFormTokenizerControl())
|
|
->setName('participants')
|
|
->setUser($user)
|
|
->setDatasource(new PhabricatorPeopleDatasource())
|
|
->setValue($participants)
|
|
->setLabel(pht('Other Participants')))
|
|
->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));
|
|
|
|
$dialog->appendChild($form);
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
}
|