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; |
14
|
|
|
|
15
|
|
|
use Yii; |
16
|
|
|
use yii\filters\AccessControl; |
17
|
|
|
use yii\filters\VerbFilter; |
18
|
|
|
use yii\web\Controller; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @version 1.0 |
22
|
|
|
* @author vistart <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class MyController extends Controller |
25
|
|
|
{ |
26
|
|
|
public $layout = 'main'; |
27
|
|
|
|
28
|
|
|
public function actions() |
29
|
|
|
{ |
30
|
|
|
return [ |
31
|
|
|
'index' => [ |
32
|
|
|
'class' => 'rhosocial\organization\web\organization\controllers\my\IndexAction', |
33
|
|
|
], |
34
|
|
|
'set-up-organization' => [ |
35
|
|
|
'class' => 'rhosocial\organization\web\organization\controllers\my\SetUpOrganizationAction', |
36
|
|
|
], |
37
|
|
|
'revoke' => [ |
38
|
|
|
'class' => 'rhosocial\organization\web\organization\controllers\my\RevokeAction', |
39
|
|
|
], |
40
|
|
|
'member' => [ |
41
|
|
|
'class' => 'rhosocial\organization\web\organization\controllers\my\MemberAction', |
42
|
|
|
], |
43
|
|
|
'add-member' => [ |
44
|
|
|
'class' => 'rhosocial\organization\web\organization\controllers\my\AddMemberAction', |
45
|
|
|
], |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function behaviors() |
50
|
|
|
{ |
51
|
|
|
return [ |
52
|
|
|
'access' => [ |
53
|
|
|
'class' => AccessControl::class, |
54
|
|
|
'rules' => [ |
55
|
|
|
[ |
56
|
|
|
'allow' => false, |
57
|
|
|
'roles' => ['?'], |
58
|
|
|
], |
59
|
|
|
[ // Disallow user who does not have `setUpOrganization` permission to access this `set-up-organization` action. |
60
|
|
|
'actions' => ['set-up-organization'], |
61
|
|
|
'allow' => false, |
62
|
|
|
'matchCallback' => function ($rule, $action) { |
|
|
|
|
63
|
|
|
return !Yii::$app->user->can('setUpOrganization'); |
64
|
|
|
}, |
65
|
|
|
'denyCallback' => function ($rule, $action) { |
|
|
|
|
66
|
|
|
throw new UnauthorizedHttpException(Yii::t('organization', 'You do not have access to set up new organization.')); |
67
|
|
|
}, |
68
|
|
|
], |
69
|
|
|
[ |
70
|
|
|
'allow' => true, |
71
|
|
|
'roles' => ['@'], |
72
|
|
|
] |
73
|
|
|
], |
74
|
|
|
], |
75
|
|
|
'verbs' => [ |
76
|
|
|
'class' => VerbFilter::class, |
77
|
|
|
'actions' => [ |
78
|
|
|
'revoke' => ['post'], |
79
|
|
|
] |
80
|
|
|
], |
81
|
|
|
]; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.