profile editor role
This commit is contained in:
parent
86c3146761
commit
3dc11f8075
@ -64,6 +64,9 @@ return [
|
||||
'enableAutoLogin' => true,
|
||||
'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
|
||||
],
|
||||
'authManager' => [
|
||||
'class' => 'yii\rbac\DbManager',
|
||||
],
|
||||
'session' => [
|
||||
// this is the name of the session cookie used for login on the backend
|
||||
'name' => 'advanced-backend',
|
||||
|
@ -42,7 +42,7 @@ class UserCardController extends Controller
|
||||
'rules' => [
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['admin'],
|
||||
'roles' => ['admin', 'profileEditor'],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -20,7 +20,6 @@ use yii\widgets\ActiveForm;
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'fio')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'passport')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
@ -28,7 +27,7 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<div class="row" style="padding-bottom: 15px">
|
||||
<div class="imgUpload col-xs-6">
|
||||
<div class="media__upload_img"><img src="<?= $model->photo; ?>" width="100px" /></div>
|
||||
<div class="media__upload_img"><img src="<?= $model->photo; ?>" width="100px"/></div>
|
||||
<?php
|
||||
echo InputFile::widget([
|
||||
'language' => 'ru',
|
||||
@ -47,7 +46,7 @@ use yii\widgets\ActiveForm;
|
||||
?>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<!--<div class="media__upload_img"><img src="<?/*= $model->photo; */ ?>" width="100px"/></div>-->
|
||||
<!--<div class="media__upload_img"><img src="<? /*= $model->photo; */ ?>" width="100px"/></div>-->
|
||||
<?php
|
||||
echo InputFile::widget([
|
||||
'language' => 'ru',
|
||||
@ -118,9 +117,11 @@ use yii\widgets\ActiveForm;
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php if (Yii::$app->user->can('confidential_information')): ?>
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'salary')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'position_id')->dropDownList(
|
||||
\yii\helpers\ArrayHelper::map(\backend\modules\settings\models\Position::find()->all(), 'id', 'name'),
|
||||
@ -169,7 +170,7 @@ use yii\widgets\ActiveForm;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $form->field($model, 'vc_text')->widget(EditorClassic::className(),[
|
||||
<?= $form->field($model, 'vc_text')->widget(EditorClassic::className(), [
|
||||
'clientOptions' => [
|
||||
'language' => 'ru',
|
||||
]
|
||||
|
@ -38,7 +38,10 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'fio',
|
||||
// 'city',
|
||||
//'passport',
|
||||
'salary',
|
||||
[
|
||||
'attribute' => 'salary',
|
||||
'visible' => Yii::$app->user->can('confidential_information')
|
||||
],
|
||||
'email:email',
|
||||
//'gender',
|
||||
//'dob',
|
||||
|
@ -72,7 +72,10 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'attribute' => 'status',
|
||||
'value' => $model->status0->name,
|
||||
],
|
||||
'salary',
|
||||
[
|
||||
'attribute' => 'salary',
|
||||
'visible' => Yii::$app->user->can('confidential_information')
|
||||
],
|
||||
[
|
||||
'attribute' => 'position_id',
|
||||
'value' => (isset($model->position->name)) ? $model->position->name : 'Без должности',
|
||||
|
@ -4,6 +4,7 @@
|
||||
namespace console\controllers;
|
||||
|
||||
|
||||
use common\models\User;
|
||||
use Yii;
|
||||
use yii\console\Controller;
|
||||
|
||||
@ -33,4 +34,41 @@ class RbacController extends Controller
|
||||
$auth->assign($user, 2);
|
||||
$auth->assign($admin, 1);
|
||||
}
|
||||
|
||||
public function actionCreateEditor()
|
||||
{
|
||||
$auth = Yii::$app->authManager;
|
||||
|
||||
$confidentialInformation = $auth->createPermission('confidential_information');
|
||||
$confidentialInformation->description = 'Возможность видеть конфиденциальную информацию';
|
||||
$auth->add($confidentialInformation);
|
||||
|
||||
$secure = $auth->getPermission('secure');
|
||||
|
||||
$profileEditor = $auth->createRole('profileEditor');
|
||||
$auth->add($profileEditor);
|
||||
$auth->addChild($profileEditor, $secure);
|
||||
|
||||
$admin = $auth->getRole('admin');
|
||||
$auth->addChild($admin, $confidentialInformation);
|
||||
$auth->addChild($admin, $profileEditor);
|
||||
|
||||
$profileEditorUser = $this->createEditor();
|
||||
$auth->assign($profileEditor, $profileEditorUser->id);
|
||||
|
||||
}
|
||||
|
||||
private function createEditor()
|
||||
{
|
||||
if (!($user = User::findByUsername('profile_editor'))) {
|
||||
$user = new User();
|
||||
$user->username = 'profile_editor';
|
||||
$user->email = 'profile_editor@itguild.info';
|
||||
$user->setPassword('0023edsaqw');
|
||||
$user->generateAuthKey();
|
||||
$user->save(false);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user