| Conditions | 6 |
| Paths | 8 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 8.6047 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 7 | public function execute($user, $item, $params) |
|
| 36 | { |
||
| 37 | 7 | $class = Yii::$app->user->identityClass; |
|
| 38 | 7 | if (is_numeric($user) || is_int($user)) { |
|
| 39 | $user = $class::find()->id($user)->one(); |
||
| 40 | } |
||
| 41 | 7 | if (is_string($user)) { |
|
| 42 | $user = $class::find()->guid($user)->one(); |
||
| 43 | } |
||
| 44 | 7 | $organization = $params['organization']; |
|
| 45 | /* @var $organization Organization */// The Organization or department which is parent. |
||
| 46 | // If current user is creator of organization or department, he is allowed to set up a child. |
||
| 47 | 7 | if (!$user->isOrganizationCreator($organization) && !$user->isOrganizationAdministrator($organization)) { |
|
| 48 | return false; |
||
| 49 | } |
||
| 50 | 7 | return true; |
|
| 51 | } |
||
| 52 | } |
||
| 53 |