Add ApplicaionTransactions and a mutable view policy to Slowvote
Summary: Schema changes to modernize this app. Test Plan: Ran schema changes, created a new slowvote. No real effects yet. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6453
This commit is contained in:
@@ -26,6 +26,9 @@ final class PhabricatorSlowvoteCreateController
|
||||
$poll->setShuffle((int)$request->getBool('shuffle', false));
|
||||
$poll->setMethod($request->getInt('method'));
|
||||
|
||||
$poll->setDescription('');
|
||||
$poll->setViewPolicy(PhabricatorPolicies::POLICY_USER);
|
||||
|
||||
if (!strlen($poll->getQuestion())) {
|
||||
$e_question = pht('Required');
|
||||
$errors[] = pht('You must ask a poll question.');
|
||||
|
||||
@@ -14,10 +14,12 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
||||
const METHOD_APPROVAL = 1;
|
||||
|
||||
protected $question;
|
||||
protected $description;
|
||||
protected $authorPHID;
|
||||
protected $responseVisibility;
|
||||
protected $shuffle;
|
||||
protected $method;
|
||||
protected $viewPolicy;
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
@@ -42,7 +44,12 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
||||
}
|
||||
|
||||
public function getPolicy($capability) {
|
||||
return PhabricatorPolicies::POLICY_USER;
|
||||
switch ($capability) {
|
||||
case PhabricatorPolicyCapability::CAN_VIEW:
|
||||
return $this->viewPolicy;
|
||||
case PhabricatorPolicyCapability::CAN_EDIT:
|
||||
return PhabricatorPolicies::POLICY_NOONE;
|
||||
}
|
||||
}
|
||||
|
||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorSlowvoteTransaction
|
||||
extends PhabricatorApplicationTransaction {
|
||||
|
||||
const TYPE_NAME = 'vote:name';
|
||||
const TYPE_DESCRIPTION = 'vote:description';
|
||||
const TYPE_OPTION = 'vote:option';
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'slowvote';
|
||||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorPHIDConstants::PHID_TYPE_POLL;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionCommentObject() {
|
||||
return new PhabricatorMacroTransactionComment();
|
||||
}
|
||||
|
||||
public function getApplicationObjectTypeName() {
|
||||
return pht('vote');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorSlowvoteTransactionComment
|
||||
extends PhabricatorApplicationTransactionComment {
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
return new PhabricatorSlowvoteTransaction();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1442,6 +1442,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
||||
'type' => 'php',
|
||||
'name' => $this->getPatchPath('20130711.trimrealnames.php'),
|
||||
),
|
||||
'20130714.votexactions.sql' => array(
|
||||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('20130714.votexactions.sql'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user