Changeset View
Changeset View
Standalone View
Standalone View
src/applications/ponder/controller/PonderQuestionEditController.php
Show All 26 Lines | if ($id) { | ||||
$question = PonderQuestion::initializeNewQuestion($viewer); | $question = PonderQuestion::initializeNewQuestion($viewer); | ||||
$v_projects = array(); | $v_projects = array(); | ||||
} | } | ||||
$v_title = $question->getTitle(); | $v_title = $question->getTitle(); | ||||
$v_content = $question->getContent(); | $v_content = $question->getContent(); | ||||
$v_view = $question->getViewPolicy(); | $v_view = $question->getViewPolicy(); | ||||
$v_edit = $question->getEditPolicy(); | $v_edit = $question->getEditPolicy(); | ||||
$v_space = $question->getSpacePHID(); | |||||
$errors = array(); | $errors = array(); | ||||
$e_title = true; | $e_title = true; | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$v_title = $request->getStr('title'); | $v_title = $request->getStr('title'); | ||||
$v_content = $request->getStr('content'); | $v_content = $request->getStr('content'); | ||||
$v_projects = $request->getArr('projects'); | $v_projects = $request->getArr('projects'); | ||||
$v_view = $request->getStr('viewPolicy'); | $v_view = $request->getStr('viewPolicy'); | ||||
$v_edit = $request->getStr('editPolicy'); | $v_edit = $request->getStr('editPolicy'); | ||||
$v_space = $request->getStr('spacePHID'); | |||||
$len = phutil_utf8_strlen($v_title); | $len = phutil_utf8_strlen($v_title); | ||||
if ($len < 1) { | if ($len < 1) { | ||||
$errors[] = pht('Title must not be empty.'); | $errors[] = pht('Title must not be empty.'); | ||||
$e_title = pht('Required'); | $e_title = pht('Required'); | ||||
} else if ($len > 255) { | } else if ($len > 255) { | ||||
$errors[] = pht('Title is too long.'); | $errors[] = pht('Title is too long.'); | ||||
$e_title = pht('Too Long'); | $e_title = pht('Too Long'); | ||||
Show All 14 Lines | if ($request->isFormPost()) { | ||||
$xactions[] = id(clone $template) | $xactions[] = id(clone $template) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ||||
->setNewValue($v_view); | ->setNewValue($v_view); | ||||
$xactions[] = id(clone $template) | $xactions[] = id(clone $template) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) | ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) | ||||
->setNewValue($v_edit); | ->setNewValue($v_edit); | ||||
$xactions[] = id(clone $template) | |||||
->setTransactionType(PhabricatorTransactions::TYPE_SPACE) | |||||
->setNewValue($v_space); | |||||
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; | $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; | ||||
$xactions[] = id(new PonderQuestionTransaction()) | $xactions[] = id(new PonderQuestionTransaction()) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | ||||
->setMetadataValue('edge:type', $proj_edge_type) | ->setMetadataValue('edge:type', $proj_edge_type) | ||||
->setNewValue(array('=' => array_fuse($v_projects))); | ->setNewValue(array('=' => array_fuse($v_projects))); | ||||
$editor = id(new PonderQuestionEditor()) | $editor = id(new PonderQuestionEditor()) | ||||
->setActor($viewer) | ->setActor($viewer) | ||||
Show All 27 Lines | $form = id(new AphrontFormView()) | ||||
->setID('content') | ->setID('content') | ||||
->setValue($v_content) | ->setValue($v_content) | ||||
->setLabel(pht('Description')) | ->setLabel(pht('Description')) | ||||
->setUser($viewer)) | ->setUser($viewer)) | ||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormPolicyControl()) | id(new AphrontFormPolicyControl()) | ||||
->setName('viewPolicy') | ->setName('viewPolicy') | ||||
->setPolicyObject($question) | ->setPolicyObject($question) | ||||
->setSpacePHID($v_space) | |||||
->setPolicies($policies) | ->setPolicies($policies) | ||||
->setValue($v_view) | ->setValue($v_view) | ||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)) | ->setCapability(PhabricatorPolicyCapability::CAN_VIEW)) | ||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormPolicyControl()) | id(new AphrontFormPolicyControl()) | ||||
->setName('editPolicy') | ->setName('editPolicy') | ||||
->setPolicyObject($question) | ->setPolicyObject($question) | ||||
->setPolicies($policies) | ->setPolicies($policies) | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |