diff --git a/resources/sql/patches/20130715.voteedges.sql b/resources/sql/patches/20130715.voteedges.sql new file mode 100644 index 0000000000..58d6e64f2c --- /dev/null +++ b/resources/sql/patches/20130715.voteedges.sql @@ -0,0 +1,15 @@ +CREATE TABLE {$NAMESPACE}_slowvote.edge ( + src VARCHAR(64) NOT NULL COLLATE utf8_bin, + type VARCHAR(64) NOT NULL COLLATE utf8_bin, + dst VARCHAR(64) NOT NULL COLLATE utf8_bin, + dateCreated INT UNSIGNED NOT NULL, + seq INT UNSIGNED NOT NULL, + dataID INT UNSIGNED, + PRIMARY KEY (src, type, dst), + KEY (src, type, dateCreated, seq) +) ENGINE=InnoDB, COLLATE utf8_general_ci; + +CREATE TABLE {$NAMESPACE}_slowvote.edgedata ( + id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + data LONGTEXT NOT NULL COLLATE utf8_bin +) ENGINE=InnoDB, COLLATE utf8_general_ci; diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php index 366bffa261..de876a857a 100644 --- a/src/applications/phid/PhabricatorObjectHandle.php +++ b/src/applications/phid/PhabricatorObjectHandle.php @@ -115,6 +115,7 @@ final class PhabricatorObjectHandle { PhabricatorPHIDConstants::PHID_TYPE_PSTE => 'Paste', PhabricatorPHIDConstants::PHID_TYPE_PROJ => 'Project', PhabricatorPHIDConstants::PHID_TYPE_LEGD => 'Legalpad Document', + PhabricatorPHIDConstants::PHID_TYPE_POLL => 'Slowvote', ); return idx($map, $this->getType(), $this->getType()); diff --git a/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php b/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php index 008bc5c204..784463a462 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvotePollController.php @@ -125,6 +125,9 @@ final class PhabricatorSlowvotePollController $header = id(new PhabricatorHeaderView()) ->setHeader($poll->getQuestion()); + $actions = $this->buildActionView($poll); + $properties = $this->buildPropertyView($poll); + $crumbs = $this->buildApplicationCrumbs(); $crumbs->addCrumb( id(new PhabricatorCrumbView()) @@ -146,6 +149,8 @@ final class PhabricatorSlowvotePollController array( $crumbs, $header, + $actions, + $properties, $content, $xactions, $add_comment, @@ -359,6 +364,45 @@ final class PhabricatorSlowvotePollController return $result_markup; } + private function buildActionView(PhabricatorSlowvotePoll $poll) { + $viewer = $this->getRequest()->getUser(); + + $view = id(new PhabricatorActionListView()) + ->setUser($viewer) + ->setObject($poll); + + return $view; + } + + private function buildPropertyView(PhabricatorSlowvotePoll $poll) { + $viewer = $this->getRequest()->getUser(); + + $view = id(new PhabricatorPropertyListView()) + ->setUser($viewer) + ->setObject($poll); + + $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( + $viewer, + $poll); + + $view->addProperty( + pht('Visible To'), + $descriptions[PhabricatorPolicyCapability::CAN_VIEW]); + + $view->invokeWillRenderEvent(); + + if (strlen($poll->getDescription())) { + $view->addTextSection( + $output = PhabricatorMarkupEngine::renderOneObject( + id(new PhabricatorMarkupOneOff())->setContent( + $poll->getDescription()), + 'default', + $viewer)); + } + + return $view; + } + private function buildTransactions(PhabricatorSlowvotePoll $poll) { $viewer = $this->getRequest()->getUser(); diff --git a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php index 6a76116c2f..729563b20e 100644 --- a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php +++ b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php @@ -4,7 +4,9 @@ * @group slowvote */ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO - implements PhabricatorPolicyInterface { + implements + PhabricatorPolicyInterface, + PhabricatorSubscribableInterface { const RESPONSES_VISIBLE = 0; const RESPONSES_VOTERS = 1; @@ -56,4 +58,13 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO return ($viewer->getPHID() == $this->getAuthorPHID()); } + +/* -( PhabricatorSubscribableInterface )----------------------------------- */ + + + public function isAutomaticallySubscribed($phid) { + return ($phid == $this->getAuthorPHID()); + } + + } diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index 0d402541de..d57fdaf3d5 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -161,6 +161,7 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { PhabricatorPHIDConstants::PHID_TYPE_CHRG => 'PhortuneCharge', PhabricatorPHIDConstants::PHID_TYPE_XOBJ => 'DoorkeeperExternalObject', PhabricatorPHIDConstants::PHID_TYPE_LEGD => 'LegalpadDocument', + PhabricatorPHIDConstants::PHID_TYPE_POLL => 'PhabricatorSlowvotePoll', ); $class = idx($class_map, $phid_type); diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index 60accec61e..6ce03e3ac2 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1450,6 +1450,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'php', 'name' => $this->getPatchPath('20130715.votecomments.php'), ), + '20130715.voteedges.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20130715.voteedges.sql'), + ), ); } }