Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15443005
D15554.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D15554.diff
View Options
diff --git a/resources/sql/autopatches/20160331.fund.comments.1.sql b/resources/sql/autopatches/20160331.fund.comments.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160331.fund.comments.1.sql
@@ -0,0 +1,18 @@
+CREATE TABLE {$NAMESPACE}_fund.fund_initiativetransaction_comment (
+ id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ phid VARCHAR(64) NOT NULL,
+ transactionPHID VARCHAR(64),
+ authorPHID VARCHAR(64) NOT NULL,
+ viewPolicy VARCHAR(64) NOT NULL,
+ editPolicy VARCHAR(64) NOT NULL,
+ commentVersion INT UNSIGNED NOT NULL,
+ content LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
+ contentSource LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
+ isDeleted BOOL NOT NULL,
+ dateCreated INT UNSIGNED NOT NULL,
+ dateModified INT UNSIGNED NOT NULL,
+
+ UNIQUE KEY `key_phid` (phid),
+ UNIQUE KEY `key_version` (transactionPHID, commentVersion)
+
+) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1024,6 +1024,7 @@
'FundInitiative' => 'applications/fund/storage/FundInitiative.php',
'FundInitiativeBackController' => 'applications/fund/controller/FundInitiativeBackController.php',
'FundInitiativeCloseController' => 'applications/fund/controller/FundInitiativeCloseController.php',
+ 'FundInitiativeCommentController' => 'applications/fund/controller/FundInitiativeCommentController.php',
'FundInitiativeEditController' => 'applications/fund/controller/FundInitiativeEditController.php',
'FundInitiativeEditor' => 'applications/fund/editor/FundInitiativeEditor.php',
'FundInitiativeFulltextEngine' => 'applications/fund/search/FundInitiativeFulltextEngine.php',
@@ -1034,6 +1035,7 @@
'FundInitiativeReplyHandler' => 'applications/fund/mail/FundInitiativeReplyHandler.php',
'FundInitiativeSearchEngine' => 'applications/fund/query/FundInitiativeSearchEngine.php',
'FundInitiativeTransaction' => 'applications/fund/storage/FundInitiativeTransaction.php',
+ 'FundInitiativeTransactionComment' => 'applications/fund/storage/FundInitiativeTransactionComment.php',
'FundInitiativeTransactionQuery' => 'applications/fund/query/FundInitiativeTransactionQuery.php',
'FundInitiativeViewController' => 'applications/fund/controller/FundInitiativeViewController.php',
'FundSchemaSpec' => 'applications/fund/storage/FundSchemaSpec.php',
@@ -5238,6 +5240,7 @@
),
'FundInitiativeBackController' => 'FundController',
'FundInitiativeCloseController' => 'FundController',
+ 'FundInitiativeCommentController' => 'FundController',
'FundInitiativeEditController' => 'FundController',
'FundInitiativeEditor' => 'PhabricatorApplicationTransactionEditor',
'FundInitiativeFulltextEngine' => 'PhabricatorFulltextEngine',
@@ -5248,6 +5251,7 @@
'FundInitiativeReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'FundInitiativeSearchEngine' => 'PhabricatorApplicationSearchEngine',
'FundInitiativeTransaction' => 'PhabricatorApplicationTransaction',
+ 'FundInitiativeTransactionComment' => 'PhabricatorApplicationTransactionComment',
'FundInitiativeTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'FundInitiativeViewController' => 'FundController',
'FundSchemaSpec' => 'PhabricatorConfigSchemaSpec',
diff --git a/src/applications/fund/application/PhabricatorFundApplication.php b/src/applications/fund/application/PhabricatorFundApplication.php
--- a/src/applications/fund/application/PhabricatorFundApplication.php
+++ b/src/applications/fund/application/PhabricatorFundApplication.php
@@ -42,6 +42,7 @@
'/fund/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'FundInitiativeListController',
'create/' => 'FundInitiativeEditController',
+ 'comment/(?P<id>[1-9]\d*)/' => 'FundInitiativeCommentController',
'edit/(?:(?P<id>\d+)/)?' => 'FundInitiativeEditController',
'close/(?P<id>\d+)/' => 'FundInitiativeCloseController',
'back/(?P<id>\d+)/' => 'FundInitiativeBackController',
diff --git a/src/applications/fund/controller/FundInitiativeCommentController.php b/src/applications/fund/controller/FundInitiativeCommentController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/fund/controller/FundInitiativeCommentController.php
@@ -0,0 +1,63 @@
+<?php
+
+final class FundInitiativeCommentController
+ extends FundController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
+
+ if (!$request->isFormPost()) {
+ return new Aphront400Response();
+ }
+
+ $initiative = id(new FundInitiativeQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ if (!$initiative) {
+ return new Aphront404Response();
+ }
+
+ $is_preview = $request->isPreviewRequest();
+ $draft = PhabricatorDraft::buildFromRequest($request);
+
+ $view_uri = '/'.$initiative->getMonogram();
+
+ $xactions = array();
+ $xactions[] = id(new FundInitiativeTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
+ ->attachComment(
+ id(new FundInitiativeTransactionComment())
+ ->setContent($request->getStr('comment')));
+
+ $editor = id(new FundInitiativeEditor())
+ ->setActor($viewer)
+ ->setContinueOnNoEffect($request->isContinueRequest())
+ ->setContentSourceFromRequest($request)
+ ->setIsPreview($is_preview);
+
+ try {
+ $xactions = $editor->applyTransactions($initiative, $xactions);
+ } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
+ return id(new PhabricatorApplicationTransactionNoEffectResponse())
+ ->setCancelURI($view_uri)
+ ->setException($ex);
+ }
+
+ if ($draft) {
+ $draft->replaceOrDelete();
+ }
+
+ if ($request->isAjax() && $is_preview) {
+ return id(new PhabricatorApplicationTransactionResponse())
+ ->setViewer($viewer)
+ ->setTransactions($xactions)
+ ->setIsPreview($is_preview);
+ } else {
+ return id(new AphrontRedirectResponse())
+ ->setURI($view_uri);
+ }
+ }
+
+}
diff --git a/src/applications/fund/controller/FundInitiativeViewController.php b/src/applications/fund/controller/FundInitiativeViewController.php
--- a/src/applications/fund/controller/FundInitiativeViewController.php
+++ b/src/applications/fund/controller/FundInitiativeViewController.php
@@ -52,12 +52,16 @@
$timeline = $this->buildTransactionTimeline(
$initiative,
new FundInitiativeTransactionQuery());
- $timeline->setShouldTerminate(true);
+
+ $add_comment = $this->buildCommentForm($initiative);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
- ->setMainColumn($timeline)
+ ->setMainColumn(array(
+ $timeline,
+ $add_comment,
+ ))
->addPropertySection(pht('DETAILS'), $details);
return $this->newPage()
@@ -160,4 +164,27 @@
return $curtain;
}
+ private function buildCommentForm(FundInitiative $initiative) {
+ $viewer = $this->getViewer();
+
+ $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
+
+ $add_comment_header = $is_serious
+ ? pht('Add Comment')
+ : pht('Add Liquidity');
+
+ $draft = PhabricatorDraft::newFromUserAndKey(
+ $viewer, $initiative->getPHID());
+
+ return id(new PhabricatorApplicationTransactionCommentView())
+ ->setUser($viewer)
+ ->setObjectPHID($initiative->getPHID())
+ ->setDraft($draft)
+ ->setHeaderText($add_comment_header)
+ ->setAction(
+ $this->getApplicationURI('/comment/'.$initiative->getID().'/'))
+ ->setSubmitButtonName(pht('Add Comment'));
+ }
+
+
}
diff --git a/src/applications/fund/editor/FundInitiativeEditor.php b/src/applications/fund/editor/FundInitiativeEditor.php
--- a/src/applications/fund/editor/FundInitiativeEditor.php
+++ b/src/applications/fund/editor/FundInitiativeEditor.php
@@ -23,6 +23,7 @@
$types[] = FundInitiativeTransaction::TYPE_MERCHANT;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
+ $types[] = PhabricatorTransactions::TYPE_COMMENT;
return $types;
}
diff --git a/src/applications/fund/storage/FundInitiativeTransaction.php b/src/applications/fund/storage/FundInitiativeTransaction.php
--- a/src/applications/fund/storage/FundInitiativeTransaction.php
+++ b/src/applications/fund/storage/FundInitiativeTransaction.php
@@ -27,7 +27,7 @@
}
public function getApplicationTransactionCommentObject() {
- return null;
+ return new FundInitiativeTransactionComment();
}
public function getRequiredHandlePHIDs() {
diff --git a/src/applications/fund/storage/FundInitiativeTransactionComment.php b/src/applications/fund/storage/FundInitiativeTransactionComment.php
new file mode 100644
--- /dev/null
+++ b/src/applications/fund/storage/FundInitiativeTransactionComment.php
@@ -0,0 +1,10 @@
+<?php
+
+final class FundInitiativeTransactionComment
+ extends PhabricatorApplicationTransactionComment {
+
+ public function getApplicationTransactionObject() {
+ return new FundInitiativeTransaction();
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 28, 1:41 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7357894
Default Alt Text
D15554.diff (9 KB)
Attached To
Mode
D15554: Add commenting to Fund
Attached
Detach File
Event Timeline
Log In to Comment