1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
8
|
|
|
* @link https://vistart.me/ |
9
|
|
|
* @copyright Copyright (c) 2016 - 2017 vistart |
10
|
|
|
* @license https://vistart.me/license/ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace rhosocial\organization\web\organization\controllers\my; |
14
|
|
|
|
15
|
|
|
use rhosocial\organization\exceptions\UnauthorizedManageProfileException; |
16
|
|
|
use rhosocial\organization\forms\SettingsForm; |
17
|
|
|
use rhosocial\organization\rbac\permissions\ManageProfile; |
18
|
|
|
use rhosocial\organization\web\organization\Module; |
19
|
|
|
use Yii; |
20
|
|
|
use yii\base\Action; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class SettingsAction |
24
|
|
|
* @package rhosocial\organization\web\organization\controllers\my |
25
|
|
|
* @version 1.0 |
26
|
|
|
* @author vistart <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
class SettingsAction extends Action |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Check access. |
32
|
|
|
* @param $org |
33
|
|
|
* @param $user |
34
|
|
|
* @return bool |
35
|
|
|
* @throws UnauthorizedManageProfileException |
36
|
|
|
*/ |
37
|
|
|
public static function checkAccess($org, $user) |
38
|
|
|
{ |
39
|
|
|
MemberAction::checkAccess($org, $user); |
40
|
|
|
if (!Yii::$app->authManager->checkAccess($user->getGUID(), (new ManageProfile)->name, ['organization' => $org])) { |
41
|
|
|
throw new UnauthorizedManageProfileException(); |
42
|
|
|
} |
43
|
|
|
return true; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
|
|
public function run($id) |
50
|
|
|
{ |
51
|
|
|
$organization = Module::getOrganization($id); |
52
|
|
|
$user = Yii::$app->user->identity; |
53
|
|
|
static::checkAccess($organization, $user); |
54
|
|
|
$model = new SettingsForm([ |
55
|
|
|
'organization' => $organization, |
56
|
|
|
]); |
57
|
|
|
if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post())) { |
58
|
|
|
if ($model->validate() && $model->submit()) { |
59
|
|
|
return $this->controller->redirect('settings', ['id' => $id]); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
return $this->controller->render('settings', [ |
63
|
|
|
'organization' => $organization, |
64
|
|
|
'model' => $model |
65
|
|
|
]); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: