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 |
||
35 | 2 | public function execute($user, $item, $params) |
|
36 | { |
||
37 | 2 | $class = Yii::$app->user->identityClass; |
|
38 | 2 | if (is_numeric($user) || is_int($user)) { |
|
39 | $user = $class::find()->id($user)->one(); |
||
40 | } |
||
41 | 2 | if (is_string($user)) { |
|
42 | $user = $class::find()->guid($user)->one(); |
||
43 | } |
||
44 | 2 | $organization = $params['organization']; |
|
45 | /* @var $organization Organization */// The department to be revoked. |
||
46 | // If current user is creator of department, he is allowed to revoke it. |
||
47 | 2 | if ($user->isOrganizationCreator($organization)) { |
|
48 | 1 | return true; |
|
49 | } |
||
50 | // If current user is creator or administrator of parent one, he is allowed to revoke it. |
||
51 | 1 | $parent = $organization->parent; |
|
52 | 1 | if ($user->isOrganizationCreator($parent) || $user->isOrganizationAdministrator($parent)) { |
|
53 | 1 | return false; |
|
54 | } |
||
55 | return false; |
||
56 | } |
||
57 | } |
||
58 |