mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Countdown: add a capability to decide who can Create
Summary: This change adds the `countdown.create` capability to allow to limit countdown creation. This change comes from the Wikimedia Phabricator and was originally proposed by v.bozzolan and implemented by the kind user 20after4. https://phabricator.wikimedia.org/T258599 Closes T15208 Ref T15081 Test Plan: - go to the page /applications/view/PhabricatorCountdownApplication/ - play a bit with the "Can Create Countdowns" option - note that it is respected Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, Matthew, Cigaryno Tags: #countdown, #policy_archived Maniphest Tasks: T15208, T15081 Differential Revision: https://we.phorge.it/D25101
This commit is contained in:
parent
1ba5c8c260
commit
7ed35123a3
3 changed files with 25 additions and 0 deletions
|
@ -50,6 +50,10 @@ final class PhabricatorCountdownApplication extends PhabricatorApplication {
|
|||
|
||||
protected function getCustomCapabilities() {
|
||||
return array(
|
||||
PhabricatorCountdownCreateCapability::CAPABILITY => array(
|
||||
'default' => PhabricatorPolicies::POLICY_USER,
|
||||
'caption' => pht('Default create policy for countdowns.'),
|
||||
),
|
||||
PhabricatorCountdownDefaultViewCapability::CAPABILITY => array(
|
||||
'caption' => pht('Default view policy for new countdowns.'),
|
||||
'template' => PhabricatorCountdownCountdownPHIDType::TYPECONST,
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCountdownCreateCapability
|
||||
extends PhabricatorPolicyCapability {
|
||||
|
||||
const CAPABILITY = 'countdown.create';
|
||||
|
||||
public function getCapabilityName() {
|
||||
return pht('Can Create Countdowns');
|
||||
}
|
||||
|
||||
public function describeCapabilityRejection() {
|
||||
return pht('You do not have permission to create a countdown.');
|
||||
}
|
||||
|
||||
}
|
|
@ -70,6 +70,11 @@ final class PhabricatorCountdownEditEngine
|
|||
return $object->getURI();
|
||||
}
|
||||
|
||||
protected function getCreateNewObjectPolicy() {
|
||||
return $this->getApplication()->getPolicy(
|
||||
PhabricatorCountdownCreateCapability::CAPABILITY);
|
||||
}
|
||||
|
||||
protected function buildCustomEditFields($object) {
|
||||
$epoch_value = $object->getEpoch();
|
||||
if ($epoch_value === null) {
|
||||
|
|
Loading…
Reference in a new issue