Conditions | 7 |
Paths | 12 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 7.6024 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
36 | 2 | public function execute($user, $item, $params) |
|
37 | { |
||
38 | 2 | $class = Yii::$app->user->identityClass; |
|
39 | 2 | if (is_numeric($user) || is_int($user)) { |
|
40 | $user = $class::find()->id($user)->one(); |
||
41 | } |
||
42 | 2 | if (is_string($user)) { |
|
43 | $user = $class::find()->guid($user)->one(); |
||
44 | } |
||
45 | 2 | $organization = $params['organization']; |
|
46 | /* @var $organization Organization */// The department to be revoked. |
||
47 | // If current user is creator of department, he is allowed to revoke it. |
||
48 | 2 | if ($user->isOrganizationCreator($organization)) { |
|
49 | 1 | return true; |
|
50 | } |
||
51 | // If current user is creator or administrator of parent one, he is allowed to revoke it. |
||
52 | 1 | $parent = $organization->parent; |
|
53 | 1 | if ($user->isOrganizationCreator($parent) || $user->isOrganizationAdministrator($parent)) { |
|
54 | 1 | return false; |
|
55 | } |
||
56 | return false; |
||
57 | } |
||
58 | } |
||
59 |