@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<?php
2
3final class PhameInheritBlogPolicyRule
4 extends PhabricatorPolicyRule {
5
6 public function getObjectPolicyKey() {
7 return 'phame.blog';
8 }
9
10 public function getObjectPolicyName() {
11 return pht('Same as Blog');
12 }
13
14 public function getPolicyExplanation() {
15 return pht('Use the same policy as the parent blog.');
16 }
17
18 public function getRuleDescription() {
19 return pht('inherit from blog');
20 }
21
22 public function getObjectPolicyIcon() {
23 return 'fa-feed';
24 }
25
26 public function canApplyToObject(PhabricatorPolicyInterface $object) {
27 return ($object instanceof PhamePost);
28 }
29
30 public function applyRule(
31 PhabricatorUser $viewer,
32 $value,
33 PhabricatorPolicyInterface $object) {
34
35 // TODO: This is incorrect in the general case, but: "PolicyRule" currently
36 // does not know which capability it is evaluating (so we can't test for
37 // the correct capability); and "PhamePost" currently has immutable view
38 // and edit policies (so we can only arrive here when evaluating the
39 // interact policy).
40
41 return PhabricatorPolicyFilter::hasCapability(
42 $viewer,
43 $object->getBlog(),
44 PhabricatorPolicyCapability::CAN_INTERACT);
45 }
46
47 public function getValueControlType() {
48 return self::CONTROL_TYPE_NONE;
49 }
50
51}