示例#1
0
 private function canAuthorViewObject(HeraldRule $rule, HeraldAdapter $adapter)
 {
     // Authorship is irrelevant for global rules and object rules.
     if ($rule->isGlobalRule() || $rule->isObjectRule()) {
         return true;
     }
     // The author must be able to create rules for the adapter's content type.
     // In particular, this means that the application must be installed and
     // accessible to the user. For example, if a user writes a Differential
     // rule and then loses access to Differential, this disables the rule.
     $enabled = HeraldAdapter::getEnabledAdapterMap($rule->getAuthor());
     if (empty($enabled[$adapter->getAdapterContentType()])) {
         return false;
     }
     // Finally, the author must be able to see the object itself. You can't
     // write a personal rule that CC's you on revisions you wouldn't otherwise
     // be able to see, for example.
     $object = $adapter->getObject();
     return PhabricatorPolicyFilter::hasCapability($rule->getAuthor(), $object, PhabricatorPolicyCapability::CAN_VIEW);
 }