Path: blob/master/src/applications/people/policyrule/PhabricatorUsersPolicyRule.php
12256 views
<?php12final class PhabricatorUsersPolicyRule extends PhabricatorPolicyRule {34public function getRuleDescription() {5return pht('users');6}78public function applyRule(9PhabricatorUser $viewer,10$value,11PhabricatorPolicyInterface $object) {1213foreach ($value as $phid) {14if ($phid == $viewer->getPHID()) {15return true;16}17}1819return false;20}2122public function getValueControlType() {23return self::CONTROL_TYPE_TOKENIZER;24}2526public function getValueControlTemplate() {27return $this->getDatasourceTemplate(new PhabricatorPeopleDatasource());28}2930public function getRuleOrder() {31return 100;32}3334public function getValueForStorage($value) {35PhutilTypeSpec::newFromString('list<string>')->check($value);36return array_values($value);37}3839public function getValueForDisplay(PhabricatorUser $viewer, $value) {40if (!$value) {41return array();42}4344$handles = id(new PhabricatorHandleQuery())45->setViewer($viewer)46->withPHIDs($value)47->execute();4849return mpull($handles, 'getFullName', 'getPHID');50}5152public function ruleHasEffect($value) {53return (bool)$value;54}5556}575859