Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionEditController.php
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
require_celerity_resource('phriction-document-css'); | require_celerity_resource('phriction-document-css'); | ||||
$e_title = true; | $e_title = true; | ||||
$e_content = true; | $e_content = true; | ||||
$validation_exception = null; | $validation_exception = null; | ||||
$notes = null; | $notes = null; | ||||
$title = $content->getTitle(); | $title = $content->getTitle(); | ||||
$overwrite = false; | $overwrite = false; | ||||
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID( | |||||
$document->getPHID()); | |||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$title = $request->getStr('title'); | $title = $request->getStr('title'); | ||||
$content_text = $request->getStr('content'); | $content_text = $request->getStr('content'); | ||||
$notes = $request->getStr('description'); | $notes = $request->getStr('description'); | ||||
$current_version = $request->getInt('contentVersion'); | $current_version = $request->getInt('contentVersion'); | ||||
$v_view = $request->getStr('viewPolicy'); | $v_view = $request->getStr('viewPolicy'); | ||||
$v_edit = $request->getStr('editPolicy'); | $v_edit = $request->getStr('editPolicy'); | ||||
$v_cc = $request->getArr('cc'); | |||||
$xactions = array(); | $xactions = array(); | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
->setTransactionType(PhrictionTransaction::TYPE_TITLE) | ->setTransactionType(PhrictionTransaction::TYPE_TITLE) | ||||
->setNewValue($title); | ->setNewValue($title); | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
->setTransactionType(PhrictionTransaction::TYPE_CONTENT) | ->setTransactionType(PhrictionTransaction::TYPE_CONTENT) | ||||
->setNewValue($content_text); | ->setNewValue($content_text); | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ||||
->setNewValue($v_view); | ->setNewValue($v_view); | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) | ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) | ||||
->setNewValue($v_edit); | ->setNewValue($v_edit); | ||||
$xactions[] = id(new PhrictionTransaction()) | |||||
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) | |||||
->setNewValue(array('=' => $v_cc)); | |||||
$editor = id(new PhrictionTransactionEditor()) | $editor = id(new PhrictionTransactionEditor()) | ||||
->setActor($viewer) | ->setActor($viewer) | ||||
->setContentSourceFromRequest($request) | ->setContentSourceFromRequest($request) | ||||
->setContinueOnNoEffect(true) | ->setContinueOnNoEffect(true) | ||||
->setDescription($notes) | ->setDescription($notes) | ||||
->setProcessContentVersionError(!$request->getBool('overwrite')) | ->setProcessContentVersionError(!$request->getBool('overwrite')) | ||||
->setContentVersion($current_version); | ->setContentVersion($current_version); | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | $form = id(new AphrontFormView()) | ||||
id(new PhabricatorRemarkupControl()) | id(new PhabricatorRemarkupControl()) | ||||
->setLabel(pht('Content')) | ->setLabel(pht('Content')) | ||||
->setValue($content_text) | ->setValue($content_text) | ||||
->setError($e_content) | ->setError($e_content) | ||||
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) | ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) | ||||
->setName('content') | ->setName('content') | ||||
->setID('document-textarea') | ->setID('document-textarea') | ||||
->setUser($viewer)) | ->setUser($viewer)) | ||||
->appendControl( | |||||
id(new AphrontFormTokenizerControl()) | |||||
->setLabel(pht('Subscribers')) | |||||
->setName('cc') | |||||
->setValue($v_cc) | |||||
->setUser($viewer) | |||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource())) | |||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormPolicyControl()) | id(new AphrontFormPolicyControl()) | ||||
->setName('viewPolicy') | ->setName('viewPolicy') | ||||
->setPolicyObject($document) | ->setPolicyObject($document) | ||||
->setCapability($view_capability) | ->setCapability($view_capability) | ||||
->setPolicies($policies) | ->setPolicies($policies) | ||||
->setCaption( | ->setCaption( | ||||
$document->describeAutomaticCapability($view_capability))) | $document->describeAutomaticCapability($view_capability))) | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |