Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 7 |
| UnassignedUserRule | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 7 |
| execute | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 7 |
|||
| <?php | |
| namespace common\rbac; | |
| use common\models\User; | |
| use yii\rbac\Rule; | |
| /** | |
| * Checks if user is not assigned to any organization and supervisor | |
| */ | |
| class UnassignedUserRule extends Rule | |
| { | |
| public $name = 'isUnassignedUser'; | |
| /** | |
| * @param string|integer $user the user ID. | |
| * @param Item $item the role or permission that this rule is associated with | |
| * @param array $params parameters passed to ManagerInterface::checkAccess(). | |
| * @return boolean a value indicating whether the rule permits the role or permission it is associated with. | |
| */ | |
| public function execute($user, $item, $params) | |
| { | |
| $user = User::findOne($user); | |
| if(empty($params) && $user instanceof User){ | |
| return $user->participant === null && $user->supervisor === null; | |
| } | |
| return false; | |
| } | |
| } |