Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/policyrule/PhabricatorUsersPolicyRule.php
12256 views
1
<?php
2
3
final class PhabricatorUsersPolicyRule extends PhabricatorPolicyRule {
4
5
public function getRuleDescription() {
6
return pht('users');
7
}
8
9
public function applyRule(
10
PhabricatorUser $viewer,
11
$value,
12
PhabricatorPolicyInterface $object) {
13
14
foreach ($value as $phid) {
15
if ($phid == $viewer->getPHID()) {
16
return true;
17
}
18
}
19
20
return false;
21
}
22
23
public function getValueControlType() {
24
return self::CONTROL_TYPE_TOKENIZER;
25
}
26
27
public function getValueControlTemplate() {
28
return $this->getDatasourceTemplate(new PhabricatorPeopleDatasource());
29
}
30
31
public function getRuleOrder() {
32
return 100;
33
}
34
35
public function getValueForStorage($value) {
36
PhutilTypeSpec::newFromString('list<string>')->check($value);
37
return array_values($value);
38
}
39
40
public function getValueForDisplay(PhabricatorUser $viewer, $value) {
41
if (!$value) {
42
return array();
43
}
44
45
$handles = id(new PhabricatorHandleQuery())
46
->setViewer($viewer)
47
->withPHIDs($value)
48
->execute();
49
50
return mpull($handles, 'getFullName', 'getPHID');
51
}
52
53
public function ruleHasEffect($value) {
54
return (bool)$value;
55
}
56
57
}
58
59