Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13970032
D13704.id33118.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
D13704.id33118.diff
View Options
diff --git a/resources/sql/autopatches/20150724.badges.comments.1.sql b/resources/sql/autopatches/20150724.badges.comments.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20150724.badges.comments.1.sql
@@ -0,0 +1,18 @@
+CREATE TABLE {$NAMESPACE}_badges.badges_transaction_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
@@ -1620,6 +1620,7 @@
'PhabricatorBadgeHasRecipientEdgeType' => 'applications/badges/edge/PhabricatorBadgeHasRecipientEdgeType.php',
'PhabricatorBadgesApplication' => 'applications/badges/application/PhabricatorBadgesApplication.php',
'PhabricatorBadgesBadge' => 'applications/badges/storage/PhabricatorBadgesBadge.php',
+ 'PhabricatorBadgesCommentController' => 'applications/badges/controller/PhabricatorBadgesCommentController.php',
'PhabricatorBadgesController' => 'applications/badges/controller/PhabricatorBadgesController.php',
'PhabricatorBadgesCreateCapability' => 'applications/badges/capability/PhabricatorBadgesCreateCapability.php',
'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php',
@@ -1638,6 +1639,7 @@
'PhabricatorBadgesSchemaSpec' => 'applications/badges/storage/PhabricatorBadgesSchemaSpec.php',
'PhabricatorBadgesSearchEngine' => 'applications/badges/query/PhabricatorBadgesSearchEngine.php',
'PhabricatorBadgesTransaction' => 'applications/badges/storage/PhabricatorBadgesTransaction.php',
+ 'PhabricatorBadgesTransactionComment' => 'applications/badges/storage/PhabricatorBadgesTransactionComment.php',
'PhabricatorBadgesTransactionQuery' => 'applications/badges/query/PhabricatorBadgesTransactionQuery.php',
'PhabricatorBadgesViewController' => 'applications/badges/controller/PhabricatorBadgesViewController.php',
'PhabricatorBarePageUIExample' => 'applications/uiexample/examples/PhabricatorBarePageUIExample.php',
@@ -5373,6 +5375,7 @@
'PhabricatorFlaggableInterface',
'PhabricatorDestructibleInterface',
),
+ 'PhabricatorBadgesCommentController' => 'PhabricatorBadgesController',
'PhabricatorBadgesController' => 'PhabricatorController',
'PhabricatorBadgesCreateCapability' => 'PhabricatorPolicyCapability',
'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO',
@@ -5391,6 +5394,7 @@
'PhabricatorBadgesSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorBadgesSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorBadgesTransaction' => 'PhabricatorApplicationTransaction',
+ 'PhabricatorBadgesTransactionComment' => 'PhabricatorApplicationTransactionComment',
'PhabricatorBadgesTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorBadgesViewController' => 'PhabricatorBadgesController',
'PhabricatorBarePageUIExample' => 'PhabricatorUIExample',
diff --git a/src/applications/badges/application/PhabricatorBadgesApplication.php b/src/applications/badges/application/PhabricatorBadgesApplication.php
--- a/src/applications/badges/application/PhabricatorBadgesApplication.php
+++ b/src/applications/badges/application/PhabricatorBadgesApplication.php
@@ -41,6 +41,8 @@
=> 'PhabricatorBadgesListController',
'create/'
=> 'PhabricatorBadgesEditController',
+ 'comment/(?P<id>[1-9]\d*)/'
+ => 'PhabricatorBadgesCommentController',
'edit/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesEditController',
'view/(?:(?P<id>\d+)/)?'
diff --git a/src/applications/badges/controller/PhabricatorBadgesCommentController.php b/src/applications/badges/controller/PhabricatorBadgesCommentController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/badges/controller/PhabricatorBadgesCommentController.php
@@ -0,0 +1,63 @@
+<?php
+
+final class PhabricatorBadgesCommentController
+ extends PhabricatorBadgesController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
+
+ if (!$request->isFormPost()) {
+ return new Aphront400Response();
+ }
+
+ $badge = id(new PhabricatorBadgesQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ if (!$badge) {
+ return new Aphront404Response();
+ }
+
+ $is_preview = $request->isPreviewRequest();
+ $draft = PhabricatorDraft::buildFromRequest($request);
+
+ $view_uri = $this->getApplicationURI('view/'.$badge->getID());
+
+ $xactions = array();
+ $xactions[] = id(new PhabricatorBadgesTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
+ ->attachComment(
+ id(new PhabricatorBadgesTransactionComment())
+ ->setContent($request->getStr('comment')));
+
+ $editor = id(new PhabricatorBadgesEditor())
+ ->setActor($viewer)
+ ->setContinueOnNoEffect($request->isContinueRequest())
+ ->setContentSourceFromRequest($request)
+ ->setIsPreview($is_preview);
+
+ try {
+ $xactions = $editor->applyTransactions($badge, $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/badges/controller/PhabricatorBadgesViewController.php b/src/applications/badges/controller/PhabricatorBadgesViewController.php
--- a/src/applications/badges/controller/PhabricatorBadgesViewController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesViewController.php
@@ -52,8 +52,6 @@
$timeline = $this->buildTransactionTimeline(
$badge,
new PhabricatorBadgesTransactionQuery());
- $timeline
- ->setShouldTerminate(true);
$recipient_phids = $badge->getRecipientPHIDs();
$recipient_phids = array_reverse($recipient_phids);
@@ -64,12 +62,15 @@
->setHandles($handles)
->setUser($viewer);
+ $add_comment = $this->buildCommentForm($badge);
+
return $this->buildApplicationPage(
array(
$crumbs,
$box,
$recipient_list,
$timeline,
+ $add_comment,
),
array(
'title' => $title,
@@ -154,4 +155,24 @@
return $view;
}
+ private function buildCommentForm(PhabricatorBadgesBadge $badge) {
+ $viewer = $this->getViewer();
+
+ $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
+
+ $add_comment_header = $is_serious
+ ? pht('Add Comment')
+ : pht('Render Honors');
+
+ $draft = PhabricatorDraft::newFromUserAndKey($viewer, $badge->getPHID());
+
+ return id(new PhabricatorApplicationTransactionCommentView())
+ ->setUser($viewer)
+ ->setObjectPHID($badge->getPHID())
+ ->setDraft($draft)
+ ->setHeaderText($add_comment_header)
+ ->setAction($this->getApplicationURI('/comment/'.$badge->getID().'/'))
+ ->setSubmitButtonName(pht('Add Comment'));
+ }
+
}
diff --git a/src/applications/badges/editor/PhabricatorBadgesEditor.php b/src/applications/badges/editor/PhabricatorBadgesEditor.php
--- a/src/applications/badges/editor/PhabricatorBadgesEditor.php
+++ b/src/applications/badges/editor/PhabricatorBadgesEditor.php
@@ -21,6 +21,7 @@
$types[] = PhabricatorBadgesTransaction::TYPE_STATUS;
$types[] = PhabricatorBadgesTransaction::TYPE_QUALITY;
+ $types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhabricatorTransactions::TYPE_EDGE;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
diff --git a/src/applications/badges/storage/PhabricatorBadgesTransaction.php b/src/applications/badges/storage/PhabricatorBadgesTransaction.php
--- a/src/applications/badges/storage/PhabricatorBadgesTransaction.php
+++ b/src/applications/badges/storage/PhabricatorBadgesTransaction.php
@@ -19,9 +19,10 @@
}
public function getApplicationTransactionCommentObject() {
- return null;
+ return new PhabricatorBadgesTransactionComment();
}
+
public function getTitle() {
$author_phid = $this->getAuthorPHID();
$object_phid = $this->getObjectPHID();
diff --git a/src/applications/badges/storage/PhabricatorBadgesTransactionComment.php b/src/applications/badges/storage/PhabricatorBadgesTransactionComment.php
new file mode 100644
--- /dev/null
+++ b/src/applications/badges/storage/PhabricatorBadgesTransactionComment.php
@@ -0,0 +1,10 @@
+<?php
+
+final class PhabricatorBadgesTransactionComment
+ extends PhabricatorApplicationTransactionComment {
+
+ public function getApplicationTransactionObject() {
+ return new PhabricatorBadgesTransaction();
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 18, 5:19 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6718934
Default Alt Text
D13704.id33118.diff (9 KB)
Attached To
Mode
D13704: Add commenting to Badges
Attached
Detach File
Event Timeline
Log In to Comment