1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

Make slowvotes subscribable

Summary: Subscribing doesn't do anything yet, but you can subscribe!

Test Plan: {F50169}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6456
This commit is contained in:
epriestley 2013-07-15 05:21:36 -07:00
parent 05a807f417
commit d2f8c5b5e7
6 changed files with 77 additions and 1 deletions

View file

@ -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;

View file

@ -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());

View file

@ -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();

View file

@ -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());
}
}

View file

@ -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);

View file

@ -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'),
),
);
}
}