tmp commit

This commit is contained in:
iIronside 2023-01-26 11:05:59 +03:00
parent 3ac2d54ec2
commit 10853b44f8
6 changed files with 273 additions and 85 deletions

View File

@ -45,5 +45,5 @@ environments/ contains environment-based overrides
php yii rbac/init <br> php yii rbac/init <br>
php yii rbac/create-editor <br> php yii rbac/create-editor <br>
php yii rbac/create-company-manager-role <br> php yii rbac/create-company-manager-role <br>
php yii rbac/create-default-access-rules <br> `php yii rbac/create-default-access-rules` <br>
</p> </p>

View File

@ -84,7 +84,7 @@ return [
'components' => [ 'components' => [
'request' => [ 'request' => [
'csrfParam' => '_csrf-backend', 'csrfParam' => '_csrf-backend',
'baseUrl' => '/secure', 'baseUrl' => '', // /secure TODO secure
'parsers' => [ 'parsers' => [
'application/json' => 'yii\web\JsonParser', 'application/json' => 'yii\web\JsonParser',
'text/xml' => 'yii/web/XmlParser', 'text/xml' => 'yii/web/XmlParser',

View File

@ -44,6 +44,9 @@ class UserCardSearch extends UserCard
*/ */
public function search($params) public function search($params)
{ {
// $userId = Yii::$app->user->;
// $userCard = UserCard::findOne($userId);
$query = UserCard::find(); $query = UserCard::find();
$query->where(['id'])->distinct() $query->where(['id'])->distinct()
->leftJoin('card_skill', 'card_skill.card_id=user_card.id') ->leftJoin('card_skill', 'card_skill.card_id=user_card.id')

View File

@ -20,8 +20,9 @@ use yii\widgets\ActiveForm;
'data' => Manager::find()->select(['fio', 'manager.id']) 'data' => Manager::find()->select(['fio', 'manager.id'])
->joinWith('userCard')->indexBy('manager.id')->column(), ->joinWith('userCard')->indexBy('manager.id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'], 'options' => ['placeholder' => '...','class' => 'form-control'],
'hideSearch' => false,
'pluginOptions' => [ 'pluginOptions' => [
'allowClear' => true 'allowClear' => true,
], ],
]) ?> ]) ?>
@ -30,9 +31,11 @@ use yii\widgets\ActiveForm;
'data' => UserCard::find()->select(['fio', 'user_card.id']) 'data' => UserCard::find()->select(['fio', 'user_card.id'])
->joinWith('manager')->where(['manager.user_card_id' => null])->indexBy('user_card.id')->column(), ->joinWith('manager')->where(['manager.user_card_id' => null])->indexBy('user_card.id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'], 'options' => ['placeholder' => '...','class' => 'form-control'],
'hideSearch' => false,
'pluginOptions' => [ 'pluginOptions' => [
'allowClear' => true, 'allowClear' => true,
'multiple' => true, 'multiple' => true,
'closeOnSelect' => false
], ],
]) ?> ]) ?>

View File

@ -43,6 +43,10 @@ YiiAsset::register($this);
], ],
]) ?> ]) ?>
<h2>
Сотрудники менеджера
</h2>
<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $managerEmployeeDataProvider, 'dataProvider' => $managerEmployeeDataProvider,
'columns' => [ 'columns' => [

View File

@ -86,112 +86,290 @@ class RbacController extends Controller
return $user; return $user;
} }
// public function actionCreateDefaultAccessRules()
// {
// $auth = Yii::$app->authManager;
// $admin = $auth->getRole('admin');
// $profileEditor = $auth->getRole('profileEditor');
//
// $test = $auth->createPermission('test');
// $test->description = 'Модуль "Тестовые задания"';
// $auth->add($test);
// $auth->addChild($admin, $test);
//
// $questionnaire = $auth->createPermission('questionnaire');
// $questionnaire->description = 'Модуль "Анкеты": Создание, редактирование анкет, категорий анкет, вопросов, проверка ответов пользователей';
// $auth->add($questionnaire);
// $auth->addChild($admin, $questionnaire);
//
// $interview = $auth->createPermission('interview');
// $interview->description = 'Модуль "Запрос интервью"';
// $auth->add($interview);
// $auth->addChild($admin, $interview);
//
// $options = $auth->createPermission('options');
// $options->description = 'Модуль "Опции"';
// $auth->add($options);
// $auth->addChild($admin, $options);
//
// $reports = $auth->createPermission('reports');
// $reports->description = 'Модуль "Отчёты"';
// $auth->add($reports);
// $auth->addChild($admin, $reports);
//
// $calendar = $auth->createPermission('calendar');
// $calendar->description = 'Модуль "Календарь ДР"';
// $auth->add($calendar);
// $auth->addChild($admin, $calendar);
//
// $notes = $auth->createPermission('notes');
// $notes->description = 'Модуль "Заметки"';
// $auth->add($notes);
// $auth->addChild($admin, $notes);
//
// $accesses = $auth->createPermission('accesses');
// $accesses->description = 'Модуль "Доступы"';
// $auth->add($accesses);
// $auth->addChild($admin, $accesses);
//
// $achievements = $auth->createPermission('achievements');
// $achievements->description = 'Модуль "Достижения"';
// $auth->add($achievements);
// $auth->addChild($admin, $achievements);
//
// $holiday = $auth->createPermission('holiday');
// $holiday->description = 'Модуль "Отпуска"';
// $auth->add($holiday);
// $auth->addChild($admin, $holiday);
//
// $balance = $auth->createPermission('balance');
// $balance->description = 'Модуль "Баланс"';
// $auth->add($balance);
// $auth->addChild($admin, $balance);
//
// $hh = $auth->createPermission('hh');
// $hh->description = 'Модуль "Hh.ru"';
// $auth->add($hh);
// $auth->addChild($admin, $hh);
//
// $company = $auth->createPermission('company');
// $company->description = 'Модуль "Компании"';
// $auth->add($company);
// $auth->addChild($admin, $company);
//
// $task = $auth->createPermission('task');
// $task->description = 'Модуль "Задачи"';
// $auth->add($task);
// $auth->addChild($admin, $task);
//
// $project = $auth->createPermission('project');
// $project->description = 'Модуль "Проекты"';
// $auth->add($project);
// $auth->addChild($admin, $project);
//
// $documents = $auth->createPermission('document');
// $documents->description = 'Модуль "Документы": Создание, редактирование документов, их полей и шаблонов';
// $auth->add($documents);
// $auth->addChild($admin, $documents);
//
// $employee = $auth->createPermission('employee');
// $employee->description = 'Модуль "Сотрудники"';
// $auth->add($employee);
// $auth->addChild($admin, $employee);
//
// $card = $auth->createPermission('card');
// $card->description = 'Модуль "Профили"';
// $auth->add($card);
// $auth->addChild($admin, $card);
// $auth->addChild($profileEditor, $card);
//
// $settings = $auth->createPermission('settings');
// $settings->description = 'Модуль "Настройки"';
// $auth->add($settings);
// $auth->addChild($admin, $settings);
//
// $skills = $auth->createPermission('settings/skill');
// $skills->description = 'Навыки';
// $auth->add($skills);
// $auth->addChild($admin, $skills);
// $auth->addChild($profileEditor, $skills);
// }
public function actionCreateDefaultAccessRules() public function actionCreateDefaultAccessRules()
{ {
$auth = Yii::$app->authManager; $auth = Yii::$app->authManager;
$admin = $auth->getRole('admin'); $admin = $auth->getRole('admin');
$profileEditor = $auth->getRole('profileEditor'); $profileEditor = $auth->getRole('profileEditor');
$test = $auth->createPermission('test'); if(!$auth->getPermission('test')) {
$test->description = 'Модуль "Тестовые задания"'; echo "create permission: test\n";
$auth->add($test); $test = $auth->createPermission('test');
$auth->addChild($admin, $test); $test->description = 'Модуль "Тестовые задания"';
$auth->add($test);
$auth->addChild($admin, $test);
}
$questionnaire = $auth->createPermission('questionnaire'); if(!$auth->getPermission('questionnaire')) {
$questionnaire->description = 'Модуль "Анкеты": Создание, редактирование анкет, категорий анкет, вопросов, проверка ответов пользователей'; echo "create permission: questionnaire\n";
$auth->add($questionnaire); $questionnaire = $auth->createPermission('questionnaire');
$auth->addChild($admin, $questionnaire); $questionnaire->description = 'Модуль "Анкеты": Создание, редактирование анкет, категорий анкет, вопросов, проверка ответов пользователей';
$auth->add($questionnaire);
$auth->addChild($admin, $questionnaire);
}
$interview = $auth->createPermission('interview'); if(!$auth->getPermission('interview')) {
$interview->description = 'Модуль "Запрос интервью"'; echo "create permission: interview\n";
$auth->add($interview); $interview = $auth->createPermission('interview');
$auth->addChild($admin, $interview); $interview->description = 'Модуль "Запрос интервью"';
$auth->add($interview);
$auth->addChild($admin, $interview);
}
$options = $auth->createPermission('options'); if(!$auth->getPermission('options')) {
$options->description = 'Модуль "Опции"'; echo "create permission: options\n";
$auth->add($options); $options = $auth->createPermission('options');
$auth->addChild($admin, $options); $options->description = 'Модуль "Опции"';
$auth->add($options);
$auth->addChild($admin, $options);
}
$reports = $auth->createPermission('reports'); if(!$auth->getPermission('reports')) {
$reports->description = 'Модуль "Отчёты"'; echo "create permission: reports\n";
$auth->add($reports); $reports = $auth->createPermission('reports');
$auth->addChild($admin, $reports); $reports->description = 'Модуль "Отчёты"';
$auth->add($reports);
$auth->addChild($admin, $reports);
}
if(!$auth->getPermission('calendar')) {
echo "create permission: calendar\n";
$calendar = $auth->createPermission('calendar');
$calendar->description = 'Модуль "Календарь ДР"';
$auth->add($calendar);
$auth->addChild($admin, $calendar);
}
$calendar = $auth->createPermission('calendar'); if(!$auth->getPermission('notes')) {
$calendar->description = 'Модуль "Календарь ДР"'; echo "create permission: notes\n";
$auth->add($calendar); $notes = $auth->createPermission('notes');
$auth->addChild($admin, $calendar); $notes->description = 'Модуль "Заметки"';
$auth->add($notes);
$auth->addChild($admin, $notes);
}
$notes = $auth->createPermission('notes'); if(!$auth->getPermission('accesses')) {
$notes->description = 'Модуль "Заметки"'; echo "create permission: accesses\n";
$auth->add($notes); $accesses = $auth->createPermission('accesses');
$auth->addChild($admin, $notes); $accesses->description = 'Модуль "Доступы"';
$auth->add($accesses);
$auth->addChild($admin, $accesses);
}
$accesses = $auth->createPermission('accesses'); if(!$auth->getPermission('achievements')) {
$accesses->description = 'Модуль "Доступы"'; echo "create permission: achievements\n";
$auth->add($accesses); $achievements = $auth->createPermission('achievements');
$auth->addChild($admin, $accesses); $achievements->description = 'Модуль "Достижения"';
$auth->add($achievements);
$auth->addChild($admin, $achievements);
}
$achievements = $auth->createPermission('achievements'); if(!$auth->getPermission('holiday')) {
$achievements->description = 'Модуль "Достижения"'; echo "create permission: holiday\n";
$auth->add($achievements); $holiday = $auth->createPermission('holiday');
$auth->addChild($admin, $achievements); $holiday->description = 'Модуль "Отпуска"';
$auth->add($holiday);
$auth->addChild($admin, $holiday);
}
if(!$auth->getPermission('balance')) {
echo "create permission: balance\n";
$balance = $auth->createPermission('balance');
$balance->description = 'Модуль "Баланс"';
$auth->add($balance);
$auth->addChild($admin, $balance);
}
$holiday = $auth->createPermission('holiday'); if(!$auth->getPermission('hh')) {
$holiday->description = 'Модуль "Отпуска"'; echo "create permission: hh\n";
$auth->add($holiday); $hh = $auth->createPermission('hh');
$auth->addChild($admin, $holiday); $hh->description = 'Модуль "Hh.ru"';
$auth->add($hh);
$auth->addChild($admin, $hh);
}
$balance = $auth->createPermission('balance'); if(!$auth->getPermission('company')) {
$balance->description = 'Модуль "Баланс"'; echo "create permission: company\n";
$auth->add($balance); $company = $auth->createPermission('company');
$auth->addChild($admin, $balance); $company->description = 'Модуль "Компании"';
$auth->add($company);
$auth->addChild($admin, $company);
}
$hh = $auth->createPermission('hh'); if(!$auth->getPermission('task')) {
$hh->description = 'Модуль "Hh.ru"'; echo "create permission: task\n";
$auth->add($hh); $task = $auth->createPermission('task');
$auth->addChild($admin, $hh); $task->description = 'Модуль "Задачи"';
$auth->add($task);
$auth->addChild($admin, $task);
}
$company = $auth->createPermission('company'); if(!$auth->getPermission('project')) {
$company->description = 'Модуль "Компании"'; echo "create permission: project\n";
$auth->add($company); $project = $auth->createPermission('project');
$auth->addChild($admin, $company); $project->description = 'Модуль "Проекты"';
$auth->add($project);
$auth->addChild($admin, $project);
}
$task = $auth->createPermission('task'); if(!$auth->getPermission('document')) {
$task->description = 'Модуль "Задачи"'; echo "create permission: document\n";
$auth->add($task); $documents = $auth->createPermission('document');
$auth->addChild($admin, $task); $documents->description = 'Модуль "Документы": Создание, редактирование документов, их полей и шаблонов';
$auth->add($documents);
$auth->addChild($admin, $documents);
}
$project = $auth->createPermission('project'); if(!$auth->getPermission('employee')) {
$project->description = 'Модуль "Проекты"'; echo "create permission: employee\n";
$auth->add($project); $employee = $auth->createPermission('employee');
$auth->addChild($admin, $project); $employee->description = 'Модуль "Сотрудники"';
$auth->add($employee);
$auth->addChild($admin, $employee);
}
$documents = $auth->createPermission('document'); if(!$auth->getPermission('card')) {
$documents->description = 'Модуль "Документы": Создание, редактирование документов, их полей и шаблонов'; echo "create permission: card\n";
$auth->add($documents); $card = $auth->createPermission('card');
$auth->addChild($admin, $documents); $card->description = 'Модуль "Профили"';
$auth->add($card);
$auth->addChild($admin, $card);
$auth->addChild($profileEditor, $card);
}
$employee = $auth->createPermission('employee'); if(!$auth->getPermission('settings')) {
$employee->description = 'Модуль "Сотрудники"'; echo "create permission: settings\n";
$auth->add($employee); $settings = $auth->createPermission('settings');
$auth->addChild($admin, $employee); $settings->description = 'Модуль "Настройки"';
$auth->add($settings);
$auth->addChild($admin, $settings);
}
$card = $auth->createPermission('card'); if(!$auth->getPermission('settings/skill')) {
$card->description = 'Модуль "Профили"'; echo "create permission: settings/skill\n";
$auth->add($card); $skills = $auth->createPermission('settings/skill');
$auth->addChild($admin, $card); $skills->description = 'Навыки';
$auth->addChild($profileEditor, $card); $auth->add($skills);
$auth->addChild($admin, $skills);
$auth->addChild($profileEditor, $skills);
}
$settings = $auth->createPermission('settings'); if(!$auth->getPermission('settings/mark')) {
$settings->description = 'Модуль "Настройки"'; echo "create permission: settings/mark\n";
$auth->add($settings); $mark = $auth->createPermission('settings/mark');
$auth->addChild($admin, $settings); $mark->description = 'Метки';
$auth->add($mark);
$auth->addChild($admin, $mark);
}
// var_dump($auth->getPermission('settings/mark'));
$skills = $auth->createPermission('settings/skill');
$skills->description = 'Навыки';
$auth->add($skills);
$auth->addChild($admin, $skills);
$auth->addChild($profileEditor, $skills);
} }
} }