DisabledPost.php 863 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace common\modules\rbac\rules;
  3. use yii\rbac\Item;
  4. use yii\rbac\Rule;
  5. class DisabledPost extends Rule
  6. {
  7. /**
  8. * Executes the rule.
  9. *
  10. * @param string|integer $user the user ID. This should be either an integer or a string representing
  11. * the unique identifier of a user. See [[\yii\web\User::id]].
  12. * @param Item $item the role or permission that this rule is associated with
  13. * @param array $params parameters passed to [[ManagerInterface::checkAccess()]].
  14. * @return boolean a value indicating whether the rule permits the auth item it is associated with.
  15. */
  16. public function execute($user, $item, $params)
  17. {
  18. if (\Yii::$app->user->isGuest) {
  19. return true;
  20. }
  21. if(\Yii::$app->getRequest()->isGet){
  22. return true;
  23. }
  24. return false;
  25. }
  26. }
  27. ?>