[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/policy/rule/ -> PhabricatorPolicyRuleUsers.php (source)

   1  <?php
   2  
   3  final class PhabricatorPolicyRuleUsers
   4    extends PhabricatorPolicyRule {
   5  
   6    public function getRuleDescription() {
   7      return pht('users');
   8    }
   9  
  10    public function applyRule(PhabricatorUser $viewer, $value) {
  11      foreach ($value as $phid) {
  12        if ($phid == $viewer->getPHID()) {
  13          return true;
  14        }
  15      }
  16      return false;
  17    }
  18  
  19    public function getValueControlType() {
  20      return self::CONTROL_TYPE_TOKENIZER;
  21    }
  22  
  23    public function getValueControlTemplate() {
  24      $users_datasource = new PhabricatorPeopleDatasource();
  25  
  26      return array(
  27        'markup' => new AphrontTokenizerTemplateView(),
  28        'uri' => $users_datasource->getDatasourceURI(),
  29        'placeholder' => $users_datasource->getPlaceholderText(),
  30      );
  31    }
  32  
  33    public function getRuleOrder() {
  34      return 100;
  35    }
  36  
  37    public function getValueForStorage($value) {
  38      PhutilTypeSpec::newFromString('list<string>')->check($value);
  39      return array_values($value);
  40    }
  41  
  42    public function getValueForDisplay(PhabricatorUser $viewer, $value) {
  43      if (!$value) {
  44        return array();
  45      }
  46  
  47      $handles = id(new PhabricatorHandleQuery())
  48        ->setViewer($viewer)
  49        ->withPHIDs($value)
  50        ->execute();
  51  
  52      return mpull($handles, 'getFullName', 'getPHID');
  53    }
  54  
  55    public function ruleHasEffect($value) {
  56      return (bool)$value;
  57    }
  58  
  59  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1