|
5 | 5 | * @var webvimark\modules\UserManagement\models\User $user |
6 | 6 | */ |
7 | 7 |
|
| 8 | +use webvimark\modules\UserManagement\components\GhostHtml; |
8 | 9 | use webvimark\modules\UserManagement\models\rbacDB\Role; |
9 | 10 | use webvimark\modules\UserManagement\UserManagementModule; |
10 | 11 | use yii\bootstrap\BootstrapPluginAsset; |
11 | 12 | use yii\helpers\ArrayHelper; |
12 | | -use webvimark\modules\UserManagement\models\rbacDB\Permission; |
13 | 13 | use yii\helpers\Html; |
14 | 14 |
|
15 | 15 | BootstrapPluginAsset::register($this); |
|
39 | 39 |
|
40 | 40 | <?= Html::beginForm(['set-roles', 'id'=>$user->id]) ?> |
41 | 41 |
|
42 | | - <?= Html::checkboxList( |
43 | | - 'roles', |
44 | | - ArrayHelper::map(Role::getUserRoles($user->id), 'name', 'name'), |
45 | | - ArrayHelper::map(Role::getAvailableRoles(), 'name', 'description'), |
46 | | - [ |
47 | | - 'item'=>function ($index, $label, $name, $checked, $value) { |
48 | | - $list = '<ul style="padding-left: 10px">'; |
49 | | - foreach (Role::getPermissionsByRole($value) as $permissionName => $permissionDescription) |
50 | | - { |
51 | | - $list .= $permissionDescription ? "<li>{$permissionDescription}</li>" : "<li>{$permissionName}</li>"; |
52 | | - } |
53 | | - $list .= '</ul>'; |
54 | | - |
55 | | - $helpIcon = Html::beginTag('span', [ |
56 | | - 'title' => UserManagementModule::t('back', 'Permissions for role - "{role}"',[ |
57 | | - 'role'=>$label, |
58 | | - ]), |
59 | | - 'data-content' => $list, |
60 | | - 'data-html' => 'true', |
61 | | - 'role' => 'button', |
62 | | - 'style' => 'margin-bottom: 5px; padding: 0 5px', |
63 | | - 'class' => 'btn btn-sm btn-default role-help-btn', |
64 | | - ]); |
65 | | - $helpIcon .= '?'; |
66 | | - $helpIcon .= Html::endTag('span'); |
67 | | - |
68 | | - $isChecked = $checked ? 'checked' : ''; |
69 | | - $checkbox = "<label><input type='checkbox' name='{$name}' value='{$value}' {$isChecked}> {$label}</label>"; |
70 | | - |
71 | | - return $helpIcon . ' ' . $checkbox; |
72 | | - }, |
73 | | - 'separator'=>'<br>', |
74 | | - ] |
75 | | - ) ?> |
| 42 | + <?php foreach (Role::getAvailableRoles() as $aRole): ?> |
| 43 | + <label> |
| 44 | + <?php $isChecked = in_array($aRole['name'], ArrayHelper::map(Role::getUserRoles($user->id), 'name', 'name')) ? 'checked' : '' ?> |
| 45 | + |
| 46 | + <?php if ( Yii::$app->getModule('user-management')->userCanHaveMultipleRoles ): ?> |
| 47 | + <input type="checkbox" <?= $isChecked ?> name="roles[]" value="<?= $aRole['name'] ?>"> |
| 48 | + |
| 49 | + <?php else: ?> |
| 50 | + <input type="radio" <?= $isChecked ?> name="roles" value="<?= $aRole['name'] ?>"> |
| 51 | + |
| 52 | + <?php endif; ?> |
| 53 | + |
| 54 | + <?= $aRole['description'] ?> |
| 55 | + </label> |
| 56 | + |
| 57 | + <?= GhostHtml::a( |
| 58 | + '<span class="glyphicon glyphicon-edit"></span>', |
| 59 | + ['/user-management/role/view', 'id'=>$aRole['name']], |
| 60 | + ['target'=>'_blank'] |
| 61 | + ) ?> |
| 62 | + <br/> |
| 63 | + <?php endforeach ?> |
| 64 | + |
76 | 65 | <br/> |
77 | 66 |
|
78 | 67 | <?php if ( Yii::$app->user->isSuperadmin OR Yii::$app->user->id != $user->id ): ?> |
|
111 | 100 |
|
112 | 101 | <ul> |
113 | 102 | <?php foreach ($permissions as $permission): ?> |
114 | | - <li><?= $permission->description ?></li> |
| 103 | + <li> |
| 104 | + <?= $permission->description ?> |
| 105 | + |
| 106 | + <?= GhostHtml::a( |
| 107 | + '<span class="glyphicon glyphicon-edit"></span>', |
| 108 | + ['/user-management/permission/view', 'id'=>$permission->name], |
| 109 | + ['target'=>'_blank'] |
| 110 | + ) ?> |
| 111 | + </li> |
115 | 112 | <?php endforeach ?> |
116 | 113 | </ul> |
117 | 114 | </fieldset> |
|
0 commit comments