This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @link http://www.writesdown.com/ |
||
4 | * @author Agiel K. Saputra <[email protected]> |
||
5 | * @copyright Copyright (c) 2015 WritesDown |
||
6 | * @license http://www.writesdown.com/license/ |
||
7 | */ |
||
8 | |||
9 | use yii\grid\GridView; |
||
10 | use yii\helpers\ArrayHelper; |
||
11 | use yii\helpers\Html; |
||
12 | use yii\helpers\Url; |
||
13 | use yii\widgets\Pjax; |
||
14 | |||
15 | /* @var $this yii\web\View */ |
||
16 | /* @var $searchModel common\models\search\User */ |
||
17 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
||
18 | |||
19 | $this->title = Yii::t('writesdown', 'Users'); |
||
20 | $this->params['breadcrumbs'][] = $this->title; |
||
21 | ?> |
||
22 | <div class="user-index"> |
||
23 | <div class="form-inline grid-nav" role="form"> |
||
24 | <div class="form-group"> |
||
25 | <?= Html::dropDownList('bulk-action', null, [ |
||
26 | 'active' => Yii::t('writesdown', 'Active'), |
||
27 | 'not-active' => Yii::t('writesdown', 'Not Active'), |
||
28 | 'removed' => Yii::t('writesdown', 'Removed'), |
||
29 | 'deleted' => Yii::t('writesdown', 'Delete Permanently'), |
||
30 | ], [ |
||
31 | 'class' => 'bulk-action form-control', |
||
32 | 'prompt' => Yii::t('writesdown', 'Change Status'), |
||
33 | ]) ?> |
||
34 | |||
35 | <?= Html::button(Yii::t('writesdown', 'Apply'), ['class' => 'btn btn-flat btn-warning bulk-button']) ?> |
||
36 | |||
37 | <?php |
||
38 | $role = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'name'); |
||
39 | unset($role['superadmin']); |
||
40 | |||
41 | View Code Duplication | if (Yii::$app->user->can('administrator') && !Yii::$app->authManager->checkAccess(Yii::$app->user->id, |
|
0 ignored issues
–
show
|
|||
42 | 'superadmin') |
||
43 | ) { |
||
44 | unset($role['administrator']); |
||
45 | } |
||
46 | |||
47 | echo Html::dropDownList('bulk-role', null, $role, [ |
||
48 | 'class' => 'bulk-role form-control', |
||
49 | 'prompt' => Yii::t('writesdown', 'Change Role'), |
||
50 | ]); |
||
51 | ?> |
||
52 | |||
53 | <?= Html::button(Yii::t('writesdown', 'Apply'), ['class' => 'btn btn-flat btn-warning role-button']) ?> |
||
54 | |||
55 | <?= Html::a(Yii::t('writesdown', 'Add New User'), ['create'], |
||
56 | ['class' => 'btn btn-flat btn-primary']) ?> |
||
57 | |||
58 | <?= Html::button(Html::tag('i', '', ['class' => 'fa fa-search']), [ |
||
59 | 'class' => 'btn btn-flat btn-info', |
||
60 | 'data-toggle' => 'collapse', |
||
61 | 'data-target' => '#user-search', |
||
62 | ]) ?> |
||
63 | |||
64 | </div> |
||
65 | </div> |
||
66 | <?php Pjax::begin() ?> |
||
67 | <?= $this->render('_search', ['model' => $searchModel]) ?> |
||
68 | <?= GridView::widget([ |
||
69 | 'dataProvider' => $dataProvider, |
||
70 | 'filterModel' => $searchModel, |
||
71 | 'id' => 'user-grid-view', |
||
72 | 'columns' => [ |
||
73 | [ |
||
74 | 'class' => 'yii\grid\CheckboxColumn', |
||
75 | 'checkboxOptions' => function ($model) { |
||
76 | /* @var $model \common\models\User */ |
||
77 | if ($model->checkPermission()) { |
||
78 | return ['value' => $model->id]; |
||
79 | } |
||
80 | |||
81 | return ['disabled' => 'disabled']; |
||
82 | }, |
||
83 | ], |
||
84 | |||
85 | 'username', |
||
86 | 'email:email', |
||
87 | [ |
||
88 | 'attribute' => 'role', |
||
89 | 'value' => function ($model) { |
||
90 | return implode( |
||
91 | ', ', |
||
92 | ArrayHelper::getColumn(Yii::$app->authManager->getRolesByUser($model->id), 'name') |
||
93 | ); |
||
94 | }, |
||
95 | ], |
||
96 | [ |
||
97 | 'attribute' => 'status', |
||
98 | 'value' => function ($model) { |
||
99 | return $model->statustext; |
||
100 | }, |
||
101 | 'filter' => $searchModel->getStatuses(), |
||
102 | ], |
||
103 | [ |
||
104 | 'class' => 'yii\grid\ActionColumn', |
||
105 | 'buttons' => [ |
||
106 | View Code Duplication | 'update' => function ($url, $model) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
107 | /* @var $model \common\models\User */ |
||
108 | if ($model->checkPermission()) { |
||
109 | return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ |
||
110 | 'title' => Yii::t('writesdown', 'Update'), |
||
111 | 'data-pjax' => '0', |
||
112 | ]); |
||
113 | } |
||
114 | |||
115 | return ''; |
||
116 | }, |
||
117 | View Code Duplication | 'delete' => function ($url, $model) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
118 | /* @var $model \common\models\User */ |
||
119 | if ($model->checkPermission()) { |
||
120 | return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ |
||
121 | 'title' => Yii::t('writesdown', 'Delete'), |
||
122 | 'data-confirm' => Yii::t('writesdown', 'Are you sure you want to delete this item?'), |
||
123 | 'data-method' => 'post', |
||
124 | 'data-pjax' => '0', |
||
125 | ]); |
||
126 | } |
||
127 | |||
128 | return ''; |
||
129 | }, |
||
130 | ], |
||
131 | ], |
||
132 | ], |
||
133 | ]) ?> |
||
134 | |||
135 | <?php Pjax::end() ?> |
||
136 | |||
137 | </div> |
||
138 | <?php $this->registerJs('jQuery(".bulk-button").click(function(e){ |
||
139 | e.preventDefault(); |
||
140 | if(confirm("' . Yii::t("writesdown", "Are you sure?") . '")){ |
||
141 | var ids = $("#user-grid-view").yiiGridView("getSelectedRows"); |
||
142 | var action = $(this).parents(".form-group").find(".bulk-action").val(); |
||
143 | $.ajax({ |
||
144 | url: "' . Url::to(['bulk-action']) . '", |
||
145 | data: { ids: ids, action: action, _csrf: yii.getCsrfToken() }, |
||
146 | type:"POST", |
||
147 | success: function(response){ |
||
148 | $.pjax.reload({container:"#user-grid-view"}); |
||
149 | } |
||
150 | }); |
||
151 | } |
||
152 | }); |
||
153 | jQuery(".role-button").click(function(e){ |
||
154 | e.preventDefault(); |
||
155 | if(confirm("' . Yii::t("writesdown", "Are you sure?") . '")){ |
||
156 | var ids = $("#user-grid-view").yiiGridView("getSelectedRows"); |
||
157 | var role = $(this).parents(".form-group").find(".bulk-role").val(); |
||
158 | $.ajax({ |
||
159 | url: "' . Url::to(['bulk-action']) . '", |
||
160 | data: { ids: ids, action: "changerole", role: role, _csrf: yii.getCsrfToken() }, |
||
161 | type:"POST", |
||
162 | success: function(response){ |
||
163 | $.pjax.reload({container:"#user-grid-view"}); |
||
164 | } |
||
165 | }); |
||
166 | } |
||
167 | });') ?> |
||
168 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.