Page MenuHomePhabricator

D9447.id22576.diff
No OneTemporary

D9447.id22576.diff

diff --git a/src/applications/ponder/controller/PonderQuestionEditController.php b/src/applications/ponder/controller/PonderQuestionEditController.php
--- a/src/applications/ponder/controller/PonderQuestionEditController.php
+++ b/src/applications/ponder/controller/PonderQuestionEditController.php
@@ -25,6 +25,10 @@
if (!$question) {
return new Aphront404Response();
}
+ $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $question->getPHID(),
+ PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
+ $v_projects = array_reverse($v_projects);
} else {
$question = id(new PonderQuestion())
->setStatus(PonderQuestionStatus::STATUS_OPEN)
@@ -32,6 +36,7 @@
->setVoteCount(0)
->setAnswerCount(0)
->setHeat(0.0);
+ $v_projects = array();
}
$v_title = $question->getTitle();
@@ -42,6 +47,7 @@
if ($request->isFormPost()) {
$v_title = $request->getStr('title');
$v_content = $request->getStr('content');
+ $v_projects = $request->getArr('projects');
$len = phutil_utf8_strlen($v_title);
if ($len < 1) {
@@ -64,6 +70,12 @@
->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT)
->setNewValue($v_content);
+ $proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
+ $xactions[] = id(new PonderQuestionTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
+ ->setMetadataValue('edge:type', $proj_edge_type)
+ ->setNewValue(array('=' => array_fuse($v_projects)));
+
$editor = id(new PonderQuestionEditor())
->setActor($user)
->setContentSourceFromRequest($request)
@@ -90,11 +102,25 @@
->setID('content')
->setValue($v_content)
->setLabel(pht('Description'))
- ->setUser($user))
- ->appendChild(
- id(new AphrontFormSubmitControl())
- ->addCancelButton($this->getApplicationURI())
- ->setValue(pht('Ask Away!')));
+ ->setUser($user));
+
+ if ($v_projects) {
+ $project_handles = $this->loadViewerHandles($v_projects);
+ } else {
+ $project_handles = array();
+ }
+
+ $form->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setLabel(pht('Projects'))
+ ->setName('projects')
+ ->setValue($project_handles)
+ ->setDatasource('/typeahead/common/projects/'));
+
+ $form ->appendChild(
+ id(new AphrontFormSubmitControl())
+ ->addCancelButton($this->getApplicationURI())
+ ->setValue(pht('Ask Away!')));
$preview = id(new PHUIRemarkupPreviewPanel())
->setHeader(pht('Question Preview'))
diff --git a/src/applications/ponder/editor/PonderQuestionEditor.php b/src/applications/ponder/editor/PonderQuestionEditor.php
--- a/src/applications/ponder/editor/PonderQuestionEditor.php
+++ b/src/applications/ponder/editor/PonderQuestionEditor.php
@@ -141,6 +141,8 @@
$object->setAnswerCount($count);
break;
+ case PhabricatorTransactions::TYPE_EDGE:
+ return;
}
}
diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php
--- a/src/applications/ponder/storage/PonderQuestion.php
+++ b/src/applications/ponder/storage/PonderQuestion.php
@@ -7,7 +7,8 @@
PhabricatorSubscribableInterface,
PhabricatorFlaggableInterface,
PhabricatorPolicyInterface,
- PhabricatorTokenReceiverInterface {
+ PhabricatorTokenReceiverInterface,
+ PhabricatorProjectInterface {
const MARKUP_FIELD_CONTENT = 'markup:content';

File Metadata

Mime Type
text/plain
Expires
Sat, Jun 8, 3:42 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6281860
Default Alt Text
D9447.id22576.diff (3 KB)

Event Timeline