Remove product literal strings in "pht()", part 18
[phabricator.git] / src / applications / people / policyrule / PhabricatorUsersPolicyRule.php
blobaa75027cb1c8bf658e6eeed5784bc54edd75cf95
1 <?php
3 final class PhabricatorUsersPolicyRule extends PhabricatorPolicyRule {
5 public function getRuleDescription() {
6 return pht('users');
9 public function applyRule(
10 PhabricatorUser $viewer,
11 $value,
12 PhabricatorPolicyInterface $object) {
14 foreach ($value as $phid) {
15 if ($phid == $viewer->getPHID()) {
16 return true;
20 return false;
23 public function getValueControlType() {
24 return self::CONTROL_TYPE_TOKENIZER;
27 public function getValueControlTemplate() {
28 return $this->getDatasourceTemplate(new PhabricatorPeopleDatasource());
31 public function getRuleOrder() {
32 return 100;
35 public function getValueForStorage($value) {
36 PhutilTypeSpec::newFromString('list<string>')->check($value);
37 return array_values($value);
40 public function getValueForDisplay(PhabricatorUser $viewer, $value) {
41 if (!$value) {
42 return array();
45 $handles = id(new PhabricatorHandleQuery())
46 ->setViewer($viewer)
47 ->withPHIDs($value)
48 ->execute();
50 return mpull($handles, 'getFullName', 'getPHID');
53 public function ruleHasEffect($value) {
54 return (bool)$value;