Advertisement
Guest User

Untitled

a guest
Oct 11th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: Paweł
  5.  * Date: 2015-10-10
  6.  * Time: 13:34
  7.  */
  8.  
  9. namespace console\rbac;
  10.  
  11. use yii\rbac\Rule;
  12.  
  13. /**
  14.  * Checks if authorID matches user passed via params
  15.  */
  16. class AuthorRule extends Rule
  17. {
  18.     public $name = 'isAuthor';
  19.  
  20.     /**
  21.      * @param string|integer $user the user ID.
  22.      * @param Item $item the role or permission that this rule is associated with
  23.      * @param array $params parameters passed to ManagerInterface::checkAccess().
  24.      * @return boolean a value indicating whether the rule permits the role or permission it is associated with.
  25.      */
  26.     public function execute($user, $item, $params)
  27.     {
  28.         return   isset($params['post']) ? $params['post']->id_user == $user : false;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement