mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 18:22:41 +01:00
Have Badges use getMostOpenPolicy for View
Summary: Fixes T8938. Sets by default for new badges, getMostOpenPolicy. Removes ability to edit viewPolicy. Test Plan: Create a new badge, see its public, assign it, log out, still able to view it. Reviewers: btrahan, epriestley Reviewed By: btrahan Subscribers: epriestley, Korvin Maniphest Tasks: T8938 Differential Revision: https://secure.phabricator.com/D13702
This commit is contained in:
parent
0ba6569959
commit
2ada395ea9
6 changed files with 2 additions and 39 deletions
|
@ -1625,7 +1625,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorBadgesCreateCapability' => 'applications/badges/capability/PhabricatorBadgesCreateCapability.php',
|
'PhabricatorBadgesCreateCapability' => 'applications/badges/capability/PhabricatorBadgesCreateCapability.php',
|
||||||
'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php',
|
'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php',
|
||||||
'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php',
|
'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php',
|
||||||
'PhabricatorBadgesDefaultViewCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultViewCapability.php',
|
|
||||||
'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php',
|
'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php',
|
||||||
'PhabricatorBadgesEditIconController' => 'applications/badges/controller/PhabricatorBadgesEditIconController.php',
|
'PhabricatorBadgesEditIconController' => 'applications/badges/controller/PhabricatorBadgesEditIconController.php',
|
||||||
'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php',
|
'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php',
|
||||||
|
@ -5380,7 +5379,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorBadgesCreateCapability' => 'PhabricatorPolicyCapability',
|
'PhabricatorBadgesCreateCapability' => 'PhabricatorPolicyCapability',
|
||||||
'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO',
|
||||||
'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
||||||
'PhabricatorBadgesDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
|
||||||
'PhabricatorBadgesEditController' => 'PhabricatorBadgesController',
|
'PhabricatorBadgesEditController' => 'PhabricatorBadgesController',
|
||||||
'PhabricatorBadgesEditIconController' => 'PhabricatorBadgesController',
|
'PhabricatorBadgesEditIconController' => 'PhabricatorBadgesController',
|
||||||
'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController',
|
'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController',
|
||||||
|
|
|
@ -71,10 +71,6 @@ final class PhabricatorBadgesApplication extends PhabricatorApplication {
|
||||||
'caption' => pht('Default edit policy for badges.'),
|
'caption' => pht('Default edit policy for badges.'),
|
||||||
'template' => PhabricatorBadgesPHIDType::TYPECONST,
|
'template' => PhabricatorBadgesPHIDType::TYPECONST,
|
||||||
),
|
),
|
||||||
PhabricatorBadgesDefaultViewCapability::CAPABILITY => array(
|
|
||||||
'caption' => pht('Default view policy for badges.'),
|
|
||||||
'template' => PhabricatorBadgesPHIDType::TYPECONST,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorBadgesDefaultViewCapability extends
|
|
||||||
PhabricatorPolicyCapability {
|
|
||||||
|
|
||||||
const CAPABILITY = 'badges.default.view';
|
|
||||||
|
|
||||||
public function getCapabilityName() {
|
|
||||||
return pht('Default View Policy');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shouldAllowPublicPolicySetting() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -49,7 +49,6 @@ final class PhabricatorBadgesEditController
|
||||||
$v_stat = $badge->getStatus();
|
$v_stat = $badge->getStatus();
|
||||||
|
|
||||||
$v_edit = $badge->getEditPolicy();
|
$v_edit = $badge->getEditPolicy();
|
||||||
$v_view = $badge->getViewPolicy();
|
|
||||||
|
|
||||||
$validation_exception = null;
|
$validation_exception = null;
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
|
@ -70,7 +69,6 @@ final class PhabricatorBadgesEditController
|
||||||
$type_qual = PhabricatorBadgesTransaction::TYPE_QUALITY;
|
$type_qual = PhabricatorBadgesTransaction::TYPE_QUALITY;
|
||||||
$type_stat = PhabricatorBadgesTransaction::TYPE_STATUS;
|
$type_stat = PhabricatorBadgesTransaction::TYPE_STATUS;
|
||||||
|
|
||||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
|
||||||
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
@ -99,10 +97,6 @@ final class PhabricatorBadgesEditController
|
||||||
->setTransactionType($type_stat)
|
->setTransactionType($type_stat)
|
||||||
->setNewValue($v_stat);
|
->setNewValue($v_stat);
|
||||||
|
|
||||||
$xactions[] = id(new PhabricatorBadgesTransaction())
|
|
||||||
->setTransactionType($type_view)
|
|
||||||
->setNewValue($v_view);
|
|
||||||
|
|
||||||
$xactions[] = id(new PhabricatorBadgesTransaction())
|
$xactions[] = id(new PhabricatorBadgesTransaction())
|
||||||
->setTransactionType($type_edit)
|
->setTransactionType($type_edit)
|
||||||
->setNewValue($v_edit);
|
->setNewValue($v_edit);
|
||||||
|
@ -175,13 +169,6 @@ final class PhabricatorBadgesEditController
|
||||||
->setName('description')
|
->setName('description')
|
||||||
->setLabel(pht('Description'))
|
->setLabel(pht('Description'))
|
||||||
->setValue($v_desc))
|
->setValue($v_desc))
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormPolicyControl())
|
|
||||||
->setName('viewPolicy')
|
|
||||||
->setPolicyObject($badge)
|
|
||||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
|
||||||
->setValue($v_view)
|
|
||||||
->setPolicies($policies))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormPolicyControl())
|
id(new AphrontFormPolicyControl())
|
||||||
->setName('editPolicy')
|
->setName('editPolicy')
|
||||||
|
|
|
@ -23,7 +23,6 @@ final class PhabricatorBadgesEditor
|
||||||
|
|
||||||
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
|
||||||
return $types;
|
return $types;
|
||||||
|
|
|
@ -63,8 +63,7 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
|
||||||
->withClasses(array('PhabricatorBadgesApplication'))
|
->withClasses(array('PhabricatorBadgesApplication'))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
||||||
$view_policy =
|
$view_policy = PhabricatorPolicies::getMostOpenPolicy();
|
||||||
$app->getPolicy(PhabricatorBadgesDefaultViewCapability::CAPABILITY);
|
|
||||||
|
|
||||||
$edit_policy =
|
$edit_policy =
|
||||||
$app->getPolicy(PhabricatorBadgesDefaultEditCapability::CAPABILITY);
|
$app->getPolicy(PhabricatorBadgesDefaultEditCapability::CAPABILITY);
|
||||||
|
@ -129,7 +128,7 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
|
||||||
public function getPolicy($capability) {
|
public function getPolicy($capability) {
|
||||||
switch ($capability) {
|
switch ($capability) {
|
||||||
case PhabricatorPolicyCapability::CAN_VIEW:
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
||||||
return $this->getViewPolicy();
|
return PhabricatorPolicies::getMostOpenPolicy();
|
||||||
case PhabricatorPolicyCapability::CAN_EDIT:
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
||||||
return $this->getEditPolicy();
|
return $this->getEditPolicy();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue