Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/policy/ManiphestTaskPolicyCodex.php
12256 views
1
<?php
2
3
final class ManiphestTaskPolicyCodex
4
extends PhabricatorPolicyCodex {
5
6
public function getPolicyShortName() {
7
$object = $this->getObject();
8
9
if ($object->areEditsLocked()) {
10
return pht('Edits Locked');
11
}
12
13
return null;
14
}
15
16
public function getPolicyIcon() {
17
$object = $this->getObject();
18
19
if ($object->areEditsLocked()) {
20
return 'fa-lock';
21
}
22
23
return null;
24
}
25
26
public function getPolicyTagClasses() {
27
$object = $this->getObject();
28
$classes = array();
29
30
if ($object->areEditsLocked()) {
31
$classes[] = 'policy-adjusted-locked';
32
}
33
34
return $classes;
35
}
36
37
public function getPolicySpecialRuleDescriptions() {
38
$object = $this->getObject();
39
40
$rules = array();
41
42
$rules[] = $this->newRule()
43
->setCapabilities(
44
array(
45
PhabricatorPolicyCapability::CAN_VIEW,
46
PhabricatorPolicyCapability::CAN_EDIT,
47
))
48
->setDescription(
49
pht('The owner of a task can always view and edit it.'));
50
51
$rules[] = $this->newRule()
52
->setCapabilities(
53
array(
54
PhabricatorPolicyCapability::CAN_EDIT,
55
))
56
->setIsActive($object->areEditsLocked())
57
->setDescription(
58
pht(
59
'Tasks with edits locked may only be edited by their owner.'));
60
61
return $rules;
62
}
63
64
public function getPolicyForEdit($capability) {
65
66
// When a task has its edits locked, the effective edit policy is locked
67
// to "No One". However, the task owner may still bypass the lock and edit
68
// the task. When they do, we want the control in the UI to have the
69
// correct value. Return the real value stored on the object.
70
71
switch ($capability) {
72
case PhabricatorPolicyCapability::CAN_EDIT:
73
return $this->getObject()->getEditPolicy();
74
}
75
76
return parent::getPolicyForEdit($capability);
77
}
78
79
}
80
81