@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Mukunda Modell and committed by
Mukunda Modell
7ed35123 1ba5c8c2

+25
+4
src/applications/countdown/application/PhabricatorCountdownApplication.php
··· 50 50 51 51 protected function getCustomCapabilities() { 52 52 return array( 53 + PhabricatorCountdownCreateCapability::CAPABILITY => array( 54 + 'default' => PhabricatorPolicies::POLICY_USER, 55 + 'caption' => pht('Default create policy for countdowns.'), 56 + ), 53 57 PhabricatorCountdownDefaultViewCapability::CAPABILITY => array( 54 58 'caption' => pht('Default view policy for new countdowns.'), 55 59 'template' => PhabricatorCountdownCountdownPHIDType::TYPECONST,
+16
src/applications/countdown/capability/PhabricatorCountdownCreateCapability.php
··· 1 + <?php 2 + 3 + final class PhabricatorCountdownCreateCapability 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'countdown.create'; 7 + 8 + public function getCapabilityName() { 9 + return pht('Can Create Countdowns'); 10 + } 11 + 12 + public function describeCapabilityRejection() { 13 + return pht('You do not have permission to create a countdown.'); 14 + } 15 + 16 + }
+5
src/applications/countdown/editor/PhabricatorCountdownEditEngine.php
··· 70 70 return $object->getURI(); 71 71 } 72 72 73 + protected function getCreateNewObjectPolicy() { 74 + return $this->getApplication()->getPolicy( 75 + PhabricatorCountdownCreateCapability::CAPABILITY); 76 + } 77 + 73 78 protected function buildCustomEditFields($object) { 74 79 $epoch_value = $object->getEpoch(); 75 80 if ($epoch_value === null) {