mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 23:40:57 +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',
|
||||
'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php',
|
||||
'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php',
|
||||
'PhabricatorBadgesDefaultViewCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultViewCapability.php',
|
||||
'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php',
|
||||
'PhabricatorBadgesEditIconController' => 'applications/badges/controller/PhabricatorBadgesEditIconController.php',
|
||||
'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php',
|
||||
|
@ -5380,7 +5379,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorBadgesCreateCapability' => 'PhabricatorPolicyCapability',
|
||||
'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
||||
'PhabricatorBadgesDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
||||
'PhabricatorBadgesEditController' => 'PhabricatorBadgesController',
|
||||
'PhabricatorBadgesEditIconController' => 'PhabricatorBadgesController',
|
||||
'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController',
|
||||
|
|
|
@ -71,10 +71,6 @@ final class PhabricatorBadgesApplication extends PhabricatorApplication {
|
|||
'caption' => pht('Default edit policy for badges.'),
|
||||
'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_edit = $badge->getEditPolicy();
|
||||
$v_view = $badge->getViewPolicy();
|
||||
|
||||
$validation_exception = null;
|
||||
if ($request->isFormPost()) {
|
||||
|
@ -70,7 +69,6 @@ final class PhabricatorBadgesEditController
|
|||
$type_qual = PhabricatorBadgesTransaction::TYPE_QUALITY;
|
||||
$type_stat = PhabricatorBadgesTransaction::TYPE_STATUS;
|
||||
|
||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
|
||||
$xactions = array();
|
||||
|
@ -99,10 +97,6 @@ final class PhabricatorBadgesEditController
|
|||
->setTransactionType($type_stat)
|
||||
->setNewValue($v_stat);
|
||||
|
||||
$xactions[] = id(new PhabricatorBadgesTransaction())
|
||||
->setTransactionType($type_view)
|
||||
->setNewValue($v_view);
|
||||
|
||||
$xactions[] = id(new PhabricatorBadgesTransaction())
|
||||
->setTransactionType($type_edit)
|
||||
->setNewValue($v_edit);
|
||||
|
@ -175,13 +169,6 @@ final class PhabricatorBadgesEditController
|
|||
->setName('description')
|
||||
->setLabel(pht('Description'))
|
||||
->setValue($v_desc))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setName('viewPolicy')
|
||||
->setPolicyObject($badge)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
||||
->setValue($v_view)
|
||||
->setPolicies($policies))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setName('editPolicy')
|
||||
|
|
|
@ -23,7 +23,6 @@ final class PhabricatorBadgesEditor
|
|||
|
||||
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
||||
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
|
||||
return $types;
|
||||
|
|
|
@ -63,8 +63,7 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
|
|||
->withClasses(array('PhabricatorBadgesApplication'))
|
||||
->executeOne();
|
||||
|
||||
$view_policy =
|
||||
$app->getPolicy(PhabricatorBadgesDefaultViewCapability::CAPABILITY);
|
||||
$view_policy = PhabricatorPolicies::getMostOpenPolicy();
|
||||
|
||||
$edit_policy =
|
||||
$app->getPolicy(PhabricatorBadgesDefaultEditCapability::CAPABILITY);
|
||||
|
@ -129,7 +128,7 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
|
|||
public function getPolicy($capability) {
|
||||
switch ($capability) {
|
||||
case PhabricatorPolicyCapability::CAN_VIEW:
|
||||
return $this->getViewPolicy();
|
||||
return PhabricatorPolicies::getMostOpenPolicy();
|
||||
case PhabricatorPolicyCapability::CAN_EDIT:
|
||||
return $this->getEditPolicy();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue