Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php final class PhameInheritBlogPolicyRule extends PhabricatorPolicyRule { public ..

Decoded Output download

<?php

final class PhameInheritBlogPolicyRule
  extends PhabricatorPolicyRule {

  public function getObjectPolicyKey() {
    return 'phame.blog';
  }

  public function getObjectPolicyName() {
    return pht('Same as Blog');
  }

  public function getPolicyExplanation() {
    return pht('Use the same policy as the parent blog.');
  }

  public function getRuleDescription() {
    return pht('inherit from blog');
  }

  public function getObjectPolicyIcon() {
    return 'fa-feed';
  }

  public function canApplyToObject(PhabricatorPolicyInterface $object) {
    return ($object instanceof PhamePost);
  }

  public function applyRule(
    PhabricatorUser $viewer,
    $value,
    PhabricatorPolicyInterface $object) {

    // TODO: This is incorrect in the general case, but: "PolicyRule" currently
    // does not know which capability it is evaluating (so we can't test for
    // the correct capability); and "PhamePost" currently has immutable view
    // and edit policies (so we can only arrive here when evaluating the
    // interact policy).

    return PhabricatorPolicyFilter::hasCapability(
      $viewer,
      $object->getBlog(),
      PhabricatorPolicyCapability::CAN_INTERACT);
  }

  public function getValueControlType() {
    return self::CONTROL_TYPE_NONE;
  }

}
 ?>

Did this file decode correctly?

Original Code

<?php

final class PhameInheritBlogPolicyRule
  extends PhabricatorPolicyRule {

  public function getObjectPolicyKey() {
    return 'phame.blog';
  }

  public function getObjectPolicyName() {
    return pht('Same as Blog');
  }

  public function getPolicyExplanation() {
    return pht('Use the same policy as the parent blog.');
  }

  public function getRuleDescription() {
    return pht('inherit from blog');
  }

  public function getObjectPolicyIcon() {
    return 'fa-feed';
  }

  public function canApplyToObject(PhabricatorPolicyInterface $object) {
    return ($object instanceof PhamePost);
  }

  public function applyRule(
    PhabricatorUser $viewer,
    $value,
    PhabricatorPolicyInterface $object) {

    // TODO: This is incorrect in the general case, but: "PolicyRule" currently
    // does not know which capability it is evaluating (so we can't test for
    // the correct capability); and "PhamePost" currently has immutable view
    // and edit policies (so we can only arrive here when evaluating the
    // interact policy).

    return PhabricatorPolicyFilter::hasCapability(
      $viewer,
      $object->getBlog(),
      PhabricatorPolicyCapability::CAN_INTERACT);
  }

  public function getValueControlType() {
    return self::CONTROL_TYPE_NONE;
  }

}

Function Calls

None

Variables

None

Stats

MD5 f5916f5281f7faf4d0620cd62917db35
Eval Count 0
Decode Time 77 ms