@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 PhabricatorFlag extends PhabricatorFlagDAO
4 implements PhabricatorPolicyInterface {
5
6 protected $ownerPHID;
7 protected $type;
8 protected $objectPHID;
9 protected $reasonPHID;
10 protected $color = PhabricatorFlagColor::COLOR_BLUE;
11 protected $note;
12
13 private $handle = self::ATTACHABLE;
14 private $object = self::ATTACHABLE;
15
16 protected function getConfiguration() {
17 return array(
18 self::CONFIG_COLUMN_SCHEMA => array(
19 'type' => 'text4',
20 'color' => 'uint32',
21 'note' => 'text',
22 ),
23 self::CONFIG_KEY_SCHEMA => array(
24 'ownerPHID' => array(
25 'columns' => array('ownerPHID', 'type', 'objectPHID'),
26 'unique' => true,
27 ),
28 'objectPHID' => array(
29 'columns' => array('objectPHID'),
30 ),
31 ),
32 ) + parent::getConfiguration();
33 }
34
35 public function getObject() {
36 return $this->assertAttached($this->object);
37 }
38
39 public function attachObject($object) {
40 $this->object = $object;
41 return $this;
42 }
43
44 public function getHandle() {
45 return $this->assertAttached($this->handle);
46 }
47
48 public function attachHandle(PhabricatorObjectHandle $handle) {
49 $this->handle = $handle;
50 return $this;
51 }
52
53
54/* -( PhabricatorPolicyInterface )----------------------------------------- */
55
56
57 public function getCapabilities() {
58 return array(
59 PhabricatorPolicyCapability::CAN_VIEW,
60 PhabricatorPolicyCapability::CAN_EDIT,
61 );
62 }
63
64 public function getPolicy($capability) {
65 return PhabricatorPolicies::POLICY_NOONE;
66 }
67
68 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
69 return ($viewer->getPHID() == $this->getOwnerPHID());
70 }
71
72 public function describeAutomaticCapability($capability) {
73 return pht('Flags are private. Only you can view or edit your flags.');
74 }
75
76}