mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 03:20:59 +01:00
Allow customizing default Phurl view and edit policies
Summary: | Before | After | |----------|----------| |{F2669862}|{F2669861}| Closes T15970 Test Plan: * Go to http://phorge.localhost/applications/view/PhabricatorPhurlApplication/ and see two additional settings "Default View Policy" and "Default Edit Policy" * Go to http://phorge.localhost/applications/view/PhabricatorPhurlApplication/ and select "Edit Policies" to see and set two additional settings * Go to http://phorge.localhost/phurl/url/edit/form/default/ and check the "Visible To" and "Editable By" fields now showing the default page * Check existing Phurls which did not have their policies changed as that's stored in the database * run `arc liberate` again and see that it's already updated Reviewers: O1 Blessed Committers, aklapper, valerio.bozzolan Reviewed By: O1 Blessed Committers, aklapper, valerio.bozzolan Subscribers: aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15970 Differential Revision: https://we.phorge.it/D25850
This commit is contained in:
parent
4accca8420
commit
18336f0b9a
5 changed files with 48 additions and 2 deletions
|
@ -4262,6 +4262,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPhurlURLAliasTransaction' => 'applications/phurl/xaction/PhabricatorPhurlURLAliasTransaction.php',
|
||||
'PhabricatorPhurlURLCreateCapability' => 'applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php',
|
||||
'PhabricatorPhurlURLDatasource' => 'applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php',
|
||||
'PhabricatorPhurlURLDefaultEditCapability' => 'applications/phurl/capability/PhabricatorPhurlURLDefaultEditCapability.php',
|
||||
'PhabricatorPhurlURLDefaultViewCapability' => 'applications/phurl/capability/PhabricatorPhurlURLDefaultViewCapability.php',
|
||||
'PhabricatorPhurlURLDescriptionTransaction' => 'applications/phurl/xaction/PhabricatorPhurlURLDescriptionTransaction.php',
|
||||
'PhabricatorPhurlURLEditConduitAPIMethod' => 'applications/phurl/conduit/PhabricatorPhurlURLEditConduitAPIMethod.php',
|
||||
'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php',
|
||||
|
@ -10866,6 +10868,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPhurlURLAliasTransaction' => 'PhabricatorPhurlURLTransactionType',
|
||||
'PhabricatorPhurlURLCreateCapability' => 'PhabricatorPolicyCapability',
|
||||
'PhabricatorPhurlURLDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'PhabricatorPhurlURLDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
||||
'PhabricatorPhurlURLDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
||||
'PhabricatorPhurlURLDescriptionTransaction' => 'PhabricatorPhurlURLTransactionType',
|
||||
'PhabricatorPhurlURLEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
|
||||
'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController',
|
||||
|
|
|
@ -73,6 +73,15 @@ final class PhabricatorPhurlApplication extends PhabricatorApplication {
|
|||
PhabricatorPhurlURLCreateCapability::CAPABILITY => array(
|
||||
'default' => PhabricatorPolicies::POLICY_USER,
|
||||
),
|
||||
PhabricatorPhurlURLDefaultViewCapability::CAPABILITY => array(
|
||||
'template' => PhabricatorPhurlURLPHIDType::TYPECONST,
|
||||
'capability' => PhabricatorPolicyCapability::CAN_VIEW,
|
||||
),
|
||||
PhabricatorPhurlURLDefaultEditCapability::CAPABILITY => array(
|
||||
'default' => PhabricatorPolicies::POLICY_USER,
|
||||
'template' => PhabricatorPhurlURLPHIDType::TYPECONST,
|
||||
'capability' => PhabricatorPolicyCapability::CAN_EDIT,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorPhurlURLDefaultEditCapability
|
||||
extends PhabricatorPolicyCapability {
|
||||
|
||||
const CAPABILITY = 'phurl.url.default.edit';
|
||||
|
||||
public function getCapabilityName() {
|
||||
return pht('Default Edit Policy');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorPhurlURLDefaultViewCapability
|
||||
extends PhabricatorPolicyCapability {
|
||||
|
||||
const CAPABILITY = 'phurl.url.default.view';
|
||||
|
||||
public function getCapabilityName() {
|
||||
return pht('Default View Policy');
|
||||
}
|
||||
|
||||
public function shouldAllowPublicPolicySetting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -34,10 +34,15 @@ final class PhabricatorPhurlURL extends PhabricatorPhurlDAO
|
|||
->withClasses(array('PhabricatorPhurlApplication'))
|
||||
->executeOne();
|
||||
|
||||
$view_policy = $app->getPolicy(
|
||||
PhabricatorPhurlURLDefaultViewCapability::CAPABILITY);
|
||||
$edit_policy = $app->getPolicy(
|
||||
PhabricatorPhurlURLDefaultEditCapability::CAPABILITY);
|
||||
|
||||
return id(new PhabricatorPhurlURL())
|
||||
->setAuthorPHID($actor->getPHID())
|
||||
->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy())
|
||||
->setEditPolicy($actor->getPHID())
|
||||
->setViewPolicy($view_policy)
|
||||
->setEditPolicy($edit_policy)
|
||||
->setSpacePHID($actor->getDefaultSpacePHID());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue