From 1415e0591b05469ca5ce6edb022b831c5219e4f6 Mon Sep 17 00:00:00 2001 From: stefan Date: Thu, 11 Jan 2018 19:10:49 +0100 Subject: [PATCH 01/16] #184 Fixed SQLite Migrations Issue --- ...08_073114_create_auth_item_group_table.php | 40 ++++++++++++------- ...121_194858_split_browser_and_os_column.php | 18 ++++++++- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/migrations/m140808_073114_create_auth_item_group_table.php b/migrations/m140808_073114_create_auth_item_group_table.php index 1d96d863..98163bc1 100644 --- a/migrations/m140808_073114_create_auth_item_group_table.php +++ b/migrations/m140808_073114_create_auth_item_group_table.php @@ -16,20 +16,28 @@ public function safeUp() $table_name = \Yii::$app->getModule('user-management')->auth_item_group_table; if (\Yii::$app->db->schema->getTableSchema($table_name) === null) { - // Create auth_item_group_table table - $this->createTable($table_name, [ - 'code' => 'varchar(64) NOT NULL', - 'name' => 'varchar(255) NOT NULL', - - 'created_at' => 'int', - 'updated_at' => 'int', - 'PRIMARY KEY (code)', - - ], $tableOptions); - - $this->addColumn(Yii::$app->getModule('user-management')->auth_item_table, 'group_code', 'varchar(64)'); - $this->addForeignKey('fk_auth_item_group_code', Yii::$app->getModule('user-management')->auth_item_table, 'group_code', Yii::$app->getModule('user-management')->auth_item_group_table, 'code', 'SET NULL', 'CASCADE'); - } + // Columns + $columns=array( + 'code' => 'varchar(64) NOT NULL', + 'name' => 'varchar(255) NOT NULL', + 'created_at' => 'int', + 'updated_at' => 'int', + 'PRIMARY KEY (code)', + ); + if ( $this->db->driverName === 'sqlite' ) + { + $columns[]='FOREIGN KEY(code) REFERENCES '.\Yii::$app->getModule('user-management')->auth_item_table.'(group_code)'; + } + + // Create auth_item_group_table table + $this->createTable($table_name, $columns, $tableOptions); + + $this->addColumn(Yii::$app->getModule('user-management')->auth_item_table, 'group_code', 'varchar(64)'); + if ( $this->db->driverName !== 'sqlite' ) + { + $this->addForeignKey('fk_auth_item_group_code', Yii::$app->getModule('user-management')->auth_item_table, 'group_code', Yii::$app->getModule('user-management')->auth_item_group_table, 'code', 'SET NULL', 'CASCADE'); + } + } if (Yii::$app->cache) { Yii::$app->cache->flush(); @@ -38,7 +46,9 @@ public function safeUp() public function safeDown() { - $this->dropForeignKey('fk_auth_item_group_code', Yii::$app->getModule('user-management')->auth_item_table); + if ( $this->db->driverName !== 'sqlite' ) { + $this->dropForeignKey('fk_auth_item_group_code', Yii::$app->getModule('user-management')->auth_item_table); + } $this->dropColumn(Yii::$app->getModule('user-management')->auth_item_table, 'group_code'); $this->dropTable(Yii::$app->getModule('user-management')->auth_item_group_table); diff --git a/migrations/m141121_194858_split_browser_and_os_column.php b/migrations/m141121_194858_split_browser_and_os_column.php index aa1a3cf4..74d4a996 100644 --- a/migrations/m141121_194858_split_browser_and_os_column.php +++ b/migrations/m141121_194858_split_browser_and_os_column.php @@ -8,7 +8,14 @@ public function safeUp() { $this->addColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser', 'varchar(30)'); $this->addColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'os', 'varchar(20)'); - $this->renameColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser_and_os', 'user_agent'); + if ( $this->db->driverName === 'sqlite' ) + { + $this->execute('ALTER '.Yii::$app->getModule('user-management')->user_visit_log_table.' CHANGE COLUMN browser_and_os user_agent'); + } + else + { + $this->renameColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser_and_os', 'user_agent'); + } if (Yii::$app->cache) { Yii::$app->cache->flush(); @@ -19,7 +26,14 @@ public function safeDown() { $this->dropColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'os'); $this->dropColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser'); - $this->renameColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'user_agent', 'browser_and_os'); + if ( $this->db->driverName === 'sqlite' ) + { + $this->execute('ALTER '.Yii::$app->getModule('user-management')->user_visit_log_table.' CHANGE COLUMN user_agent browser_and_os'); + } + else + { + $this->renameColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'user_agent', 'browser_and_os'); + } if (Yii::$app->cache) { Yii::$app->cache->flush(); From 410da6a2dded7d12047023a89384776a862cdc60 Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 14 Jan 2018 19:07:05 +0100 Subject: [PATCH 02/16] Change to namespace wpler from webvimark for forking with working sqlite --- README.md | 31 ++++++++++--------- UserManagementModule.php | 8 ++--- components/AbstractItemEvent.php | 2 +- components/AuthHelper.php | 12 +++---- components/GhostAccessControl.php | 6 ++-- components/GhostHtml.php | 6 ++-- components/GhostMenu.php | 6 ++-- components/GhostNav.php | 6 ++-- components/UserAuthEvent.php | 10 +++--- components/UserConfig.php | 6 ++-- components/UserIdentity.php | 4 +-- composer.json | 2 +- controllers/AuthController.php | 20 ++++++------ controllers/AuthItemGroupController.php | 12 +++---- controllers/PermissionController.php | 20 ++++++------ controllers/RoleController.php | 20 ++++++------ controllers/UserController.php | 12 +++---- controllers/UserPermissionController.php | 12 +++---- controllers/UserVisitLogController.php | 12 +++---- ...40809_072112_insert_superadmin_to_user.php | 2 +- ..._insert_common_permisison_to_auth_item.php | 2 +- ...7_001649_create_basic_user_permissions.php | 8 ++--- models/User.php | 18 +++++------ models/UserVisitLog.php | 8 ++--- models/forms/ChangeOwnPasswordForm.php | 6 ++-- models/forms/ConfirmEmailForm.php | 6 ++-- models/forms/LoginForm.php | 8 ++--- models/forms/PasswordRecoveryForm.php | 6 ++-- models/forms/RegistrationForm.php | 8 ++--- models/rbacDB/AbstractItem.php | 8 ++--- models/rbacDB/AuthItemGroup.php | 4 +-- models/rbacDB/Permission.php | 4 +-- models/rbacDB/Role.php | 4 +-- models/rbacDB/Route.php | 4 +-- models/rbacDB/search/AbstractItemSearch.php | 8 ++--- models/rbacDB/search/AuthItemGroupSearch.php | 4 +-- models/rbacDB/search/PermissionSearch.php | 2 +- models/rbacDB/search/RoleSearch.php | 2 +- models/search/UserSearch.php | 6 ++-- models/search/UserVisitLogSearch.php | 8 ++--- views/auth-item-group/_form.php | 4 +-- views/auth-item-group/create.php | 4 +-- views/auth-item-group/index.php | 10 +++--- views/auth-item-group/update.php | 4 +-- views/auth-item-group/view.php | 4 +-- views/auth/changeOwnPassword.php | 4 +-- views/auth/changeOwnPasswordSuccess.php | 2 +- views/auth/confirmEmail.php | 4 +-- views/auth/confirmEmailSuccess.php | 4 +-- views/auth/login.php | 6 ++-- views/auth/passwordRecovery.php | 4 +-- views/auth/passwordRecoverySuccess.php | 2 +- views/auth/registration.php | 4 +-- .../registrationWaitForEmailConfirmation.php | 4 +-- views/layouts/loginLayout.php | 2 +- views/mail/emailConfirmationMail.php | 2 +- views/mail/passwordRecoveryMail.php | 2 +- views/mail/registrationEmailConfirmation.php | 2 +- views/permission/_form.php | 6 ++-- views/permission/create.php | 4 +-- views/permission/index.php | 14 ++++----- views/permission/update.php | 4 +-- views/permission/view.php | 4 +-- views/role/_form.php | 6 ++-- views/role/create.php | 4 +-- views/role/index.php | 14 ++++----- views/role/update.php | 4 +-- views/role/view.php | 6 ++-- views/user-permission/set.php | 8 ++--- views/user-visit-log/index.php | 8 ++--- views/user-visit-log/view.php | 4 +-- views/user/_form.php | 8 ++--- views/user/_search.php | 2 +- views/user/changePassword.php | 4 +-- views/user/create.php | 4 +-- views/user/index.php | 20 ++++++------ views/user/update.php | 8 ++--- views/user/view.php | 10 +++--- 78 files changed, 272 insertions(+), 271 deletions(-) diff --git a/README.md b/README.md index b1be3183..01cec7e6 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ User management module for Yii 2 Perks --- +* This is a fork of [wpler/user-management-module](https://github.com/wpler/user-management) passed for SQLite * User management * RBAC (roles, permissions and stuff) with web interface * Registration, authorization, password recovery and so on @@ -20,13 +21,13 @@ The preferred way to install this extension is through [composer](http://getcomp Either run ``` -composer require webvimark/module-user-management +composer require wpler/module-user-management ``` or add ``` -"webvimark/module-user-management": "^1" +"wpler/module-user-management": "^1" ``` to the require section of your `composer.json` file. @@ -40,18 +41,18 @@ Configuration 'components'=>[ 'user' => [ - 'class' => 'webvimark\modules\UserManagement\components\UserConfig', + 'class' => 'wpler\modules\UserManagement\components\UserConfig', // Comment this if you don't want to record user logins 'on afterLogin' => function($event) { - \webvimark\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id); + \wpler\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id); } ], ], 'modules'=>[ 'user-management' => [ - 'class' => 'webvimark\modules\UserManagement\UserManagementModule', + 'class' => 'wpler\modules\UserManagement\UserManagementModule', // 'enableRegistration' => true, @@ -96,8 +97,8 @@ To see full list of options check *UserManagementModule* file 'modules'=>[ 'user-management' => [ - 'class' => 'webvimark\modules\UserManagement\UserManagementModule', - 'controllerNamespace'=>'vendor\webvimark\modules\UserManagement\controllers', // To prevent yii help from crashing + 'class' => 'wpler\modules\UserManagement\UserManagementModule', + 'controllerNamespace'=>'vendor\wpler\modules\UserManagement\controllers', // To prevent yii help from crashing ], ], @@ -107,7 +108,7 @@ To see full list of options check *UserManagementModule* file ```php -./yii migrate --migrationPath=vendor/webvimark/module-user-management/migrations/ +./yii migrate --migrationPath=vendor/wpler/module-user-management/migrations/ ``` @@ -119,7 +120,7 @@ public function behaviors() { return [ 'ghost-access'=> [ - 'class' => 'webvimark\modules\UserManagement\components\GhostAccessControl', + 'class' => 'wpler\modules\UserManagement\components\GhostAccessControl', ], ]; } @@ -132,8 +133,8 @@ Where you can go ```php false, @@ -231,7 +232,7 @@ Events can be handled via config file like following 'modules'=>[ 'user-management' => [ - 'class' => 'webvimark\modules\UserManagement\UserManagementModule', + 'class' => 'wpler\modules\UserManagement\UserManagementModule', 'on afterRegistration' => function(UserAuthEvent $event) { // Here you can do your own stuff like assign roles, send emails and so on }, @@ -247,7 +248,7 @@ FAQ **Question**: Do you have API docs? -**Answer**: Check this one http://opensource.id5.com.br/webvimark/doc/index.html (Credits to [lukBarros](https://github.com/lukBarros)) +**Answer**: Check this one on webvimark original module http://opensource.id5.com.br/webvimark/doc/index.html (Credits to [lukBarros](https://github.com/lukBarros)) **Question**: I want users to register and login with they e-mails! Mmmmm... And they should confirm it too! @@ -255,13 +256,13 @@ FAQ **Question**: I want to have profile for user with avatar, birthday and stuff. What should I do ? -**Answer**: Profiles are to project-specific, so you'll have to implement them yourself (but you can find example here - https://github.com/webvimark/user-management/wiki/Profile-and-custom-registration). Here is how to do it without modifying this module +**Answer**: Profiles are to project-specific, so you'll have to implement them yourself (but you can find example here on webvimark original module - https://github.com/webvimark/user-management/wiki/Profile-and-custom-registration). Here is how to do it without modifying this module 1) Create table and model for profile, that have user_id (connect with "user" table) 2) Check AuthController::actionRegistration() how it works (*you can skip this part*) -3) Define your layout for registration. Check example in *AuthHelper::layoutHandler()*. Now use theming to change registraion.php file +3) Define your layout for registration. Check example in *AuthHelper::layoutHandler()*. Now use theming to change registration.php file 4) Define your own UserManagementModule::$registrationFormClass. In this class you can do whatever you want like validating custom forms and saving profiles diff --git a/UserManagementModule.php b/UserManagementModule.php index 75717919..aa3586d1 100644 --- a/UserManagementModule.php +++ b/UserManagementModule.php @@ -1,6 +1,6 @@ i18n->translations['modules/user-management/*'] = [ 'class' => 'yii\i18n\PhpMessageSource', 'sourceLanguage' => 'en', - 'basePath' => '@vendor/webvimark/module-user-management/messages', + 'basePath' => '@vendor/wpler/module-user-management/messages', 'fileMap' => [ 'modules/user-management/back' => 'back.php', 'modules/user-management/front' => 'front.php', diff --git a/components/AbstractItemEvent.php b/components/AbstractItemEvent.php index d5afecf1..808ac8f5 100644 --- a/components/AbstractItemEvent.php +++ b/components/AbstractItemEvent.php @@ -1,5 +1,5 @@ ['webvimark\modules\UserManagement\components\AuthHelper', 'layoutHandler'], + * 'on beforeAction'=>['wpler\modules\UserManagement\components\AuthHelper', 'layoutHandler'], * * @param \yii\base\ActionEvent $event */ diff --git a/components/GhostAccessControl.php b/components/GhostAccessControl.php index fd7d7e5b..5f5de13e 100644 --- a/components/GhostAccessControl.php +++ b/components/GhostAccessControl.php @@ -1,9 +1,9 @@ User::canRoute($item['url') will be added * - * @package webvimark\modules\UserManagement\components + * @package wpler\modules\UserManagement\components */ class GhostMenu extends Menu { diff --git a/components/GhostNav.php b/components/GhostNav.php index 2417705e..e3c1fc95 100644 --- a/components/GhostNav.php +++ b/components/GhostNav.php @@ -1,7 +1,7 @@ User::canRoute($item['url') will be added * - * @package webvimark\modules\UserManagement\components + * @package wpler\modules\UserManagement\components */ class GhostNav extends Nav { diff --git a/components/UserAuthEvent.php b/components/UserAuthEvent.php index c713a20e..16495399 100644 --- a/components/UserAuthEvent.php +++ b/components/UserAuthEvent.php @@ -1,10 +1,10 @@ 'webvimark\modules\UserManagement\models\User', + 'targetClass' => 'wpler\modules\UserManagement\models\User', 'targetAttribute' => 'username', ], diff --git a/models/rbacDB/AbstractItem.php b/models/rbacDB/AbstractItem.php index fae8ae59..954b1c05 100644 --- a/models/rbacDB/AbstractItem.php +++ b/models/rbacDB/AbstractItem.php @@ -1,9 +1,9 @@ diff --git a/views/auth-item-group/create.php b/views/auth-item-group/create.php index f1214c58..d3d2f204 100644 --- a/views/auth-item-group/create.php +++ b/views/auth-item-group/create.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('back', 'Creating permission group'); diff --git a/views/auth-item-group/index.php b/views/auth-item-group/index.php index 51a37134..f7177788 100644 --- a/views/auth-item-group/index.php +++ b/views/auth-item-group/index.php @@ -1,19 +1,19 @@ title = UserManagementModule::t('back', 'Permission groups'); diff --git a/views/auth-item-group/update.php b/views/auth-item-group/update.php index 1d3520c7..8d7eb245 100644 --- a/views/auth-item-group/update.php +++ b/views/auth-item-group/update.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('back', 'Editing permission group') . ': ' . $model->name; diff --git a/views/auth-item-group/view.php b/views/auth-item-group/view.php index b3b289a3..390d9c7e 100644 --- a/views/auth-item-group/view.php +++ b/views/auth-item-group/view.php @@ -1,12 +1,12 @@ title = $model->name; diff --git a/views/auth/changeOwnPassword.php b/views/auth/changeOwnPassword.php index 9985fec8..7b1e6c33 100644 --- a/views/auth/changeOwnPassword.php +++ b/views/auth/changeOwnPassword.php @@ -1,12 +1,12 @@ title = UserManagementModule::t('back', 'Change own password'); diff --git a/views/auth/changeOwnPasswordSuccess.php b/views/auth/changeOwnPasswordSuccess.php index 88e0a4f9..5d9772ac 100644 --- a/views/auth/changeOwnPasswordSuccess.php +++ b/views/auth/changeOwnPasswordSuccess.php @@ -1,6 +1,6 @@ title = UserManagementModule::t('front', 'Confirm E-mail'); diff --git a/views/auth/confirmEmailSuccess.php b/views/auth/confirmEmailSuccess.php index 7bd4c0e7..6654111d 100644 --- a/views/auth/confirmEmailSuccess.php +++ b/views/auth/confirmEmailSuccess.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('front', 'E-mail confirmed'); diff --git a/views/auth/login.php b/views/auth/login.php index 25d7b088..1a3ee2ce 100644 --- a/views/auth/login.php +++ b/views/auth/login.php @@ -1,11 +1,11 @@ diff --git a/views/auth/passwordRecovery.php b/views/auth/passwordRecovery.php index b834c6d0..a3de02e4 100644 --- a/views/auth/passwordRecovery.php +++ b/views/auth/passwordRecovery.php @@ -1,13 +1,13 @@ title = UserManagementModule::t('front', 'Password recovery'); diff --git a/views/auth/passwordRecoverySuccess.php b/views/auth/passwordRecoverySuccess.php index bc7b678f..d18d22b2 100644 --- a/views/auth/passwordRecoverySuccess.php +++ b/views/auth/passwordRecoverySuccess.php @@ -1,6 +1,6 @@ title = UserManagementModule::t('front', 'Registration'); diff --git a/views/auth/registrationWaitForEmailConfirmation.php b/views/auth/registrationWaitForEmailConfirmation.php index 05805288..336b99b5 100644 --- a/views/auth/registrationWaitForEmailConfirmation.php +++ b/views/auth/registrationWaitForEmailConfirmation.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('front', 'Registration - confirm your e-mail'); diff --git a/views/layouts/loginLayout.php b/views/layouts/loginLayout.php index a728287d..ab539f57 100644 --- a/views/layouts/loginLayout.php +++ b/views/layouts/loginLayout.php @@ -1,6 +1,6 @@ title = UserManagementModule::t('back', 'Permission creation'); $this->params['breadcrumbs'][] = ['label' => UserManagementModule::t('back', 'Permissions'), 'url' => ['index']]; diff --git a/views/permission/index.php b/views/permission/index.php index 4f8796a2..5bc8e1c3 100644 --- a/views/permission/index.php +++ b/views/permission/index.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Permissions'); diff --git a/views/permission/update.php b/views/permission/update.php index b2736079..fa155f4c 100644 --- a/views/permission/update.php +++ b/views/permission/update.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Editing permission: ') . ' ' . $model->name; $this->params['breadcrumbs'][] = ['label' => UserManagementModule::t('back', 'Permissions'), 'url' => ['index']]; diff --git a/views/permission/view.php b/views/permission/view.php index a28af200..e4b50cfd 100644 --- a/views/permission/view.php +++ b/views/permission/view.php @@ -9,8 +9,8 @@ * @var yii\rbac\Permission $item */ -use webvimark\modules\UserManagement\components\GhostHtml; -use webvimark\modules\UserManagement\UserManagementModule; +use wpler\modules\UserManagement\components\GhostHtml; +use wpler\modules\UserManagement\UserManagementModule; use yii\helpers\ArrayHelper; use yii\helpers\Html; diff --git a/views/role/_form.php b/views/role/_form.php index 764e92ff..d7e04579 100644 --- a/views/role/_form.php +++ b/views/role/_form.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Role creation'); $this->params['breadcrumbs'][] = ['label' => UserManagementModule::t('back', 'Roles'), 'url' => ['index']]; diff --git a/views/role/index.php b/views/role/index.php index 6d09e1b3..799e862e 100644 --- a/views/role/index.php +++ b/views/role/index.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Roles'); diff --git a/views/role/update.php b/views/role/update.php index 8c28b7b1..15f83020 100644 --- a/views/role/update.php +++ b/views/role/update.php @@ -1,10 +1,10 @@ title = UserManagementModule::t('back', 'Editing role: ') . ' ' . $model->name; $this->params['breadcrumbs'][] = ['label' => UserManagementModule::t('back', 'Roles'), 'url' => ['index']]; diff --git a/views/role/view.php b/views/role/view.php index 2754628e..ff64ada9 100644 --- a/views/role/view.php +++ b/views/role/view.php @@ -10,9 +10,9 @@ * @var yii\rbac\Role $role */ -use webvimark\modules\UserManagement\components\GhostHtml; -use webvimark\modules\UserManagement\models\rbacDB\Role; -use webvimark\modules\UserManagement\UserManagementModule; +use wpler\modules\UserManagement\components\GhostHtml; +use wpler\modules\UserManagement\models\rbacDB\Role; +use wpler\modules\UserManagement\UserManagementModule; use yii\helpers\ArrayHelper; use yii\helpers\Html; diff --git a/views/user-permission/set.php b/views/user-permission/set.php index 462a72d2..66f36521 100644 --- a/views/user-permission/set.php +++ b/views/user-permission/set.php @@ -2,12 +2,12 @@ /** * @var yii\web\View $this * @var array $permissionsByGroup - * @var webvimark\modules\UserManagement\models\User $user + * @var wpler\modules\UserManagement\models\User $user */ -use webvimark\modules\UserManagement\components\GhostHtml; -use webvimark\modules\UserManagement\models\rbacDB\Role; -use webvimark\modules\UserManagement\UserManagementModule; +use wpler\modules\UserManagement\components\GhostHtml; +use wpler\modules\UserManagement\models\rbacDB\Role; +use wpler\modules\UserManagement\UserManagementModule; use yii\bootstrap\BootstrapPluginAsset; use yii\helpers\ArrayHelper; use yii\helpers\Html; diff --git a/views/user-visit-log/index.php b/views/user-visit-log/index.php index 4d70a702..813d75bb 100644 --- a/views/user-visit-log/index.php +++ b/views/user-visit-log/index.php @@ -1,16 +1,16 @@ title = UserManagementModule::t('back', 'Visit log'); diff --git a/views/user-visit-log/view.php b/views/user-visit-log/view.php index ce7a0731..1d01122f 100644 --- a/views/user-visit-log/view.php +++ b/views/user-visit-log/view.php @@ -1,12 +1,12 @@ title = $model->id; diff --git a/views/user/_form.php b/views/user/_form.php index e828d60f..d182e7bd 100644 --- a/views/user/_form.php +++ b/views/user/_form.php @@ -1,14 +1,14 @@ diff --git a/views/user/_search.php b/views/user/_search.php index d5f0c455..7887d9e4 100644 --- a/views/user/_search.php +++ b/views/user/_search.php @@ -5,7 +5,7 @@ /** * @var yii\web\View $this - * @var webvimark\modules\UserManagement\models\search\UserSearch $model + * @var wpler\modules\UserManagement\models\search\UserSearch $model * @var yii\widgets\ActiveForm $form */ ?> diff --git a/views/user/changePassword.php b/views/user/changePassword.php index 1ec181c0..b5cbfe3d 100644 --- a/views/user/changePassword.php +++ b/views/user/changePassword.php @@ -1,12 +1,12 @@ title = UserManagementModule::t('back', 'Changing password for user: ') . ' ' . $model->username; diff --git a/views/user/create.php b/views/user/create.php index f890c518..3545ca33 100644 --- a/views/user/create.php +++ b/views/user/create.php @@ -1,11 +1,11 @@ title = UserManagementModule::t('back', 'User creation'); diff --git a/views/user/index.php b/views/user/index.php index 2c5a6565..446abc90 100644 --- a/views/user/index.php +++ b/views/user/index.php @@ -1,21 +1,21 @@ title = UserManagementModule::t('back', 'Users'); @@ -73,7 +73,7 @@ ['class' => 'yii\grid\SerialColumn', 'options'=>['style'=>'width:10px'] ], [ - 'class'=>'webvimark\components\StatusColumn', + 'class'=>'wpler\components\StatusColumn', 'attribute'=>'superadmin', 'visible'=>Yii::$app->user->isSuperadmin, ], @@ -91,7 +91,7 @@ 'visible'=>User::hasPermission('viewUserEmail'), ], [ - 'class'=>'webvimark\components\StatusColumn', + 'class'=>'wpler\components\StatusColumn', 'attribute'=>'email_confirmed', 'visible'=>User::hasPermission('viewUserEmail'), ], @@ -138,7 +138,7 @@ ], ], [ - 'class'=>'webvimark\components\StatusColumn', + 'class'=>'wpler\components\StatusColumn', 'attribute'=>'status', 'optionsArray'=>[ [User::STATUS_ACTIVE, UserManagementModule::t('back', 'Active'), 'success'], diff --git a/views/user/update.php b/views/user/update.php index 0a4ef0a1..d5ba859e 100644 --- a/views/user/update.php +++ b/views/user/update.php @@ -1,14 +1,14 @@ title = UserManagementModule::t('back', 'Editing user: ') . ' ' . $model->username; diff --git a/views/user/view.php b/views/user/view.php index 5623a29b..733a9327 100644 --- a/views/user/view.php +++ b/views/user/view.php @@ -1,16 +1,16 @@ title = $model->username; From ac986efc520122e001609721adfc78eeb4b3a0ac Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 14 Jan 2018 19:42:26 +0100 Subject: [PATCH 03/16] Change composer.json --- README.md | 4 +++- composer.json | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 01cec7e6..bf010cfc 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ User management module for Yii 2 ===== +This is a fork of [wpler/user-management-module](https://github.com/webvimark/user-management) passed for SQLite and fixed some new +issues of the original. Also this fork will include some new widgets for working with Bootstrap-4 (beta) into the next updates. + Perks --- -* This is a fork of [wpler/user-management-module](https://github.com/wpler/user-management) passed for SQLite * User management * RBAC (roles, permissions and stuff) with web interface * Registration, authorization, password recovery and so on diff --git a/composer.json b/composer.json index 0480c895..8a7e65af 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,26 @@ { "name": "wpler/module-user-management", + "type": "yii2-extension", + "keywords": ["yii2","yii2-user","user-management"], "description": "User with improved RBAC", + "authors": [ + { + "name": "WPLer", + "email": "support@wpler.com" + }, + { + "name": "webvimark" + } + ], + "license": "BSD-3-Clause", + "support": { + "issues": "https://github.com/Stefan39/user-management/issues", + "source": "https://github.com/Stefan39/user-management", + "docs": "https://github.com/Stefan39/user-management/wiki" + }, "autoload": { "psr-4": { - "webvimark\\modules\\UserManagement\\": "" + "wpler\\modules\\UserManagement\\": "" } }, "require": { From 117fa3aeb24c0bcd5109339e7b97fc7f0f19700c Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 14 Jan 2018 20:00:24 +0100 Subject: [PATCH 04/16] Change composer.json --- UserManagementModule.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UserManagementModule.php b/UserManagementModule.php index aa3586d1..8eebf29f 100644 --- a/UserManagementModule.php +++ b/UserManagementModule.php @@ -5,6 +5,12 @@ use Yii; use yii\helpers\ArrayHelper; +/** + * Class UserManagementModule + * + * @package wpler\modules\UserManagement + */ + class UserManagementModule extends \yii\base\Module { const SESSION_LAST_ATTEMPT = '_um_last_attempt'; From 716f0bce9b27dd5b1998374deb01d3b51c33f75c Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 14 Jan 2018 20:22:55 +0100 Subject: [PATCH 05/16] Change Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bf010cfc..3c47d5dc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ User management module for Yii 2 ===== -This is a fork of [wpler/user-management-module](https://github.com/webvimark/user-management) passed for SQLite and fixed some new +This is a fork of [webvimark/user-management-module](https://github.com/webvimark/user-management) passed for SQLite and fixed some new issues of the original. Also this fork will include some new widgets for working with Bootstrap-4 (beta) into the next updates. Perks @@ -29,7 +29,7 @@ composer require wpler/module-user-management or add ``` -"wpler/module-user-management": "^1" +"wpler/module-user-management": "~1" ``` to the require section of your `composer.json` file. From 09ece1181d933d7ea36389e6ee0fce032838c12f Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 14 Jan 2018 20:30:00 +0100 Subject: [PATCH 06/16] Change Migration of table user_visit_log for SQLite --- .../m141023_141535_create_user_visit_log.php | 2 +- ...121_194858_split_browser_and_os_column.php | 22 ++----------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/migrations/m141023_141535_create_user_visit_log.php b/migrations/m141023_141535_create_user_visit_log.php index c9e93b71..88a7a02c 100644 --- a/migrations/m141023_141535_create_user_visit_log.php +++ b/migrations/m141023_141535_create_user_visit_log.php @@ -22,7 +22,7 @@ public function safeUp() 'token' => 'string not null', 'ip' => 'varchar(15) not null', 'language' => 'char(2) not null', - 'browser_and_os' => 'string not null', + 'user_agent' => 'string not null', 'user_id' => 'int', 'visit_time' => 'int not null', 0 => 'FOREIGN KEY (user_id) REFERENCES '.Yii::$app->getModule('user-management')->user_table.' (id) ON DELETE SET NULL ON UPDATE CASCADE', diff --git a/migrations/m141121_194858_split_browser_and_os_column.php b/migrations/m141121_194858_split_browser_and_os_column.php index 74d4a996..0051af0a 100644 --- a/migrations/m141121_194858_split_browser_and_os_column.php +++ b/migrations/m141121_194858_split_browser_and_os_column.php @@ -8,16 +8,7 @@ public function safeUp() { $this->addColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser', 'varchar(30)'); $this->addColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'os', 'varchar(20)'); - if ( $this->db->driverName === 'sqlite' ) - { - $this->execute('ALTER '.Yii::$app->getModule('user-management')->user_visit_log_table.' CHANGE COLUMN browser_and_os user_agent'); - } - else - { - $this->renameColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser_and_os', 'user_agent'); - } - - if (Yii::$app->cache) { + if (Yii::$app->cache) { Yii::$app->cache->flush(); } } @@ -26,16 +17,7 @@ public function safeDown() { $this->dropColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'os'); $this->dropColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'browser'); - if ( $this->db->driverName === 'sqlite' ) - { - $this->execute('ALTER '.Yii::$app->getModule('user-management')->user_visit_log_table.' CHANGE COLUMN user_agent browser_and_os'); - } - else - { - $this->renameColumn(Yii::$app->getModule('user-management')->user_visit_log_table, 'user_agent', 'browser_and_os'); - } - - if (Yii::$app->cache) { + if (Yii::$app->cache) { Yii::$app->cache->flush(); } } From 8902d99db42eaae0852e8affcd484c8568058b5f Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 14 Jan 2018 21:14:58 +0100 Subject: [PATCH 07/16] Fix some broken namespace requirements by webvimarks components --- controllers/AuthController.php | 2 +- controllers/AuthItemGroupController.php | 2 +- controllers/PermissionController.php | 2 +- controllers/RoleController.php | 2 +- controllers/UserController.php | 2 +- controllers/UserPermissionController.php | 2 +- controllers/UserVisitLogController.php | 2 +- models/User.php | 4 ++-- models/UserVisitLog.php | 4 ++-- models/forms/LoginForm.php | 2 +- views/auth-item-group/_search.php | 2 +- views/auth-item-group/index.php | 4 ++-- views/permission/index.php | 4 ++-- views/role/index.php | 4 ++-- views/user-visit-log/index.php | 4 ++-- views/user/_form.php | 2 +- views/user/index.php | 10 +++++----- views/user/update.php | 2 +- 18 files changed, 28 insertions(+), 28 deletions(-) diff --git a/controllers/AuthController.php b/controllers/AuthController.php index 20a57bc6..fe2281a0 100644 --- a/controllers/AuthController.php +++ b/controllers/AuthController.php @@ -2,7 +2,7 @@ namespace wpler\modules\UserManagement\controllers; -use wpler\components\BaseController; +use \webvimark\components\BaseController; use wpler\modules\UserManagement\components\UserAuthEvent; use wpler\modules\UserManagement\models\forms\ChangeOwnPasswordForm; use wpler\modules\UserManagement\models\forms\ConfirmEmailForm; diff --git a/controllers/AuthItemGroupController.php b/controllers/AuthItemGroupController.php index 18543799..c4cf5f6f 100644 --- a/controllers/AuthItemGroupController.php +++ b/controllers/AuthItemGroupController.php @@ -5,7 +5,7 @@ use wpler\modules\UserManagement\models\rbacDB\AuthItemGroup; use wpler\modules\UserManagement\models\rbacDB\search\AuthItemGroupSearch; use Yii; -use wpler\components\AdminDefaultController; +use \webvimark\components\AdminDefaultController; /** * AuthItemGroupController implements the CRUD actions for AuthItemGroup model. diff --git a/controllers/PermissionController.php b/controllers/PermissionController.php index 2ff5d982..303a525a 100644 --- a/controllers/PermissionController.php +++ b/controllers/PermissionController.php @@ -8,7 +8,7 @@ use wpler\modules\UserManagement\models\rbacDB\Permission; use wpler\modules\UserManagement\models\rbacDB\Route; use wpler\modules\UserManagement\models\rbacDB\search\PermissionSearch; -use wpler\components\AdminDefaultController; +use \webvimark\components\AdminDefaultController; use wpler\modules\UserManagement\UserManagementModule; use Yii; diff --git a/controllers/RoleController.php b/controllers/RoleController.php index 671d7b3e..a3e44388 100644 --- a/controllers/RoleController.php +++ b/controllers/RoleController.php @@ -6,7 +6,7 @@ use wpler\modules\UserManagement\models\rbacDB\Permission; use wpler\modules\UserManagement\models\rbacDB\Role; use wpler\modules\UserManagement\models\rbacDB\search\RoleSearch; -use wpler\components\AdminDefaultController; +use \webvimark\components\AdminDefaultController; use wpler\modules\UserManagement\UserManagementModule; use Yii; use yii\rbac\DbManager; diff --git a/controllers/UserController.php b/controllers/UserController.php index 7a010326..ac84f6fb 100644 --- a/controllers/UserController.php +++ b/controllers/UserController.php @@ -2,7 +2,7 @@ namespace wpler\modules\UserManagement\controllers; -use wpler\components\AdminDefaultController; +use \webvimark\components\AdminDefaultController; use Yii; use wpler\modules\UserManagement\models\User; use wpler\modules\UserManagement\models\search\UserSearch; diff --git a/controllers/UserPermissionController.php b/controllers/UserPermissionController.php index 49d68a59..84997b6a 100644 --- a/controllers/UserPermissionController.php +++ b/controllers/UserPermissionController.php @@ -2,7 +2,7 @@ namespace wpler\modules\UserManagement\controllers; -use wpler\components\BaseController; +use \webvimark\components\BaseController; use wpler\modules\UserManagement\models\rbacDB\Permission; use wpler\modules\UserManagement\models\rbacDB\Role; use wpler\modules\UserManagement\models\User; diff --git a/controllers/UserVisitLogController.php b/controllers/UserVisitLogController.php index 49821945..3f009361 100644 --- a/controllers/UserVisitLogController.php +++ b/controllers/UserVisitLogController.php @@ -5,7 +5,7 @@ use Yii; use wpler\modules\UserManagement\models\UserVisitLog; use wpler\modules\UserManagement\models\search\UserVisitLogSearch; -use wpler\components\AdminDefaultController; +use \webvimark\components\AdminDefaultController; /** * UserVisitLogController implements the CRUD actions for UserVisitLog model. diff --git a/models/User.php b/models/User.php index 6428abe9..e74c081a 100644 --- a/models/User.php +++ b/models/User.php @@ -2,8 +2,8 @@ namespace wpler\modules\UserManagement\models; -use wpler\helpers\LittleBigHelper; -use wpler\helpers\Singleton; +use \webvimark\helpers\LittleBigHelper; +use \webvimark\helpers\Singleton; use wpler\modules\UserManagement\components\AuthHelper; use wpler\modules\UserManagement\components\UserIdentity; use wpler\modules\UserManagement\models\rbacDB\Role; diff --git a/models/UserVisitLog.php b/models/UserVisitLog.php index 643c095f..14a066ab 100644 --- a/models/UserVisitLog.php +++ b/models/UserVisitLog.php @@ -3,7 +3,7 @@ namespace wpler\modules\UserManagement\models; use Ikimea\Browser\Browser; -use wpler\helpers\LittleBigHelper; +use \webvimark\helpers\LittleBigHelper; use wpler\modules\UserManagement\UserManagementModule; use Yii; @@ -22,7 +22,7 @@ * * @property User $user */ -class UserVisitLog extends \wpler\components\BaseActiveRecord +class UserVisitLog extends \webvimark\components\BaseActiveRecord { CONST SESSION_TOKEN = '__visitorToken'; diff --git a/models/forms/LoginForm.php b/models/forms/LoginForm.php index a3ff84ff..1cd1c221 100644 --- a/models/forms/LoginForm.php +++ b/models/forms/LoginForm.php @@ -1,7 +1,7 @@ diff --git a/views/auth-item-group/index.php b/views/auth-item-group/index.php index f7177788..60e9b5d4 100644 --- a/views/auth-item-group/index.php +++ b/views/auth-item-group/index.php @@ -6,8 +6,8 @@ use yii\helpers\Url; use yii\helpers\ArrayHelper; use yii\widgets\Pjax; -use wpler\extensions\GridBulkActions\GridBulkActions; -use wpler\extensions\GridPageSize\GridPageSize; +use \webvimark\extensions\GridBulkActions\GridBulkActions; +use \webvimark\extensions\GridPageSize\GridPageSize; use yii\grid\GridView; /** diff --git a/views/permission/index.php b/views/permission/index.php index 5bc8e1c3..1a7ecbd7 100644 --- a/views/permission/index.php +++ b/views/permission/index.php @@ -1,6 +1,6 @@ 'yii\grid\SerialColumn', 'options'=>['style'=>'width:10px'] ], [ - 'class'=>'wpler\components\StatusColumn', + 'class'=>'\webvimark\components\StatusColumn', 'attribute'=>'superadmin', 'visible'=>Yii::$app->user->isSuperadmin, ], @@ -91,7 +91,7 @@ 'visible'=>User::hasPermission('viewUserEmail'), ], [ - 'class'=>'wpler\components\StatusColumn', + 'class'=>'\webvimark\components\StatusColumn', 'attribute'=>'email_confirmed', 'visible'=>User::hasPermission('viewUserEmail'), ], @@ -138,7 +138,7 @@ ], ], [ - 'class'=>'wpler\components\StatusColumn', + 'class'=>'\webvimark\components\StatusColumn', 'attribute'=>'status', 'optionsArray'=>[ [User::STATUS_ACTIVE, UserManagementModule::t('back', 'Active'), 'success'], diff --git a/views/user/update.php b/views/user/update.php index d5ba859e..9d4e4b79 100644 --- a/views/user/update.php +++ b/views/user/update.php @@ -1,7 +1,7 @@ Date: Mon, 15 Jan 2018 17:09:06 +0100 Subject: [PATCH 08/16] Translate the email templates in german and spanish --- README.md | 11 +++++++++-- messages/cs/front.php | 6 ++++++ messages/de/front.php | 6 ++++++ messages/es/front.php | 6 ++++++ messages/fr/front.php | 6 ++++++ messages/ko-KR/front.php | 6 ++++++ messages/pl/front.php | 6 ++++++ messages/pt-BR/front.php | 6 ++++++ messages/pt-PT/front.php | 6 ++++++ messages/ru/front.php | 6 ++++++ views/mail/emailConfirmationMail.php | 5 +++-- views/mail/passwordRecoveryMail.php | 5 +++-- views/mail/registrationEmailConfirmation.php | 7 ++++--- 13 files changed, 73 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3c47d5dc..14906a6d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ User management module for Yii 2 ===== -This is a fork of [webvimark/user-management-module](https://github.com/webvimark/user-management) passed for SQLite and fixed some new -issues of the original. Also this fork will include some new widgets for working with Bootstrap-4 (beta) into the next updates. +This is a fork of [webvimark/user-management-module](https://github.com/webvimark/user-management) to further development for using SQLite +and NoSQL databases. + +In addition, this extension is to be extended to use Bootstrap 4 Styles by given module setting. + +[![Latest Stable Version](https://poser.pugx.org/wpler/module-user-management/v/stable)](https://packagist.org/packages/wpler/module-user-management) +[![Latest Unstable Version](https://poser.pugx.org/wpler/module-user-management/v/unstable)](https://packagist.org/packages/wpler/module-user-management) +[![Total Downloads](https://poser.pugx.org/wpler/module-user-management/downloads)](https://packagist.org/packages/wpler/module-user-management) + Perks --- diff --git a/messages/cs/front.php b/messages/cs/front.php index 5f7152a2..f252b440 100644 --- a/messages/cs/front.php +++ b/messages/cs/front.php @@ -49,4 +49,10 @@ 'Unable to send message for email provided' => '', 'Username' => '', 'You could not login from this IP' => '', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/de/front.php b/messages/de/front.php index d3e33b48..ffc0ff16 100644 --- a/messages/de/front.php +++ b/messages/de/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Zu viele Versuche', 'Unable to send message for email provided' => 'Es war nicht möglich, die Nachricht an die angegebene E-Mail-Adresse zu senden', 'You could not login from this IP' => 'Sie können sich von dieser IP nicht anmelden', + 'Hello {username}, follow this link to confirm your E-mail address:' => 'Hallo {username}, folge den folgenden Link um deine E-Mail Adresse zu bestätigen:', + 'Confirm E-mail' => 'E-Mail bestätigen', + 'Hello {username}, follow this link to reset your password:' => 'Hallo {username}, folge den folgenden Link um dein Passwort zurückzusetzen:', + 'Reset password' => 'Passwort zurücksetzen', + 'Hello, you have been registered on {hostinfo}' => 'Hallo, Du wurdest auf {hostinfo} erfolgreich registriert.', + 'Follow this link to confirm your E-mail address and activate your account:' => 'Folge den folgenden Link um deine E-Mail Adresse zu bestätigen und dein Konto zu aktivieren:', ]; diff --git a/messages/es/front.php b/messages/es/front.php index 45c34b9c..18483147 100644 --- a/messages/es/front.php +++ b/messages/es/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Demasiados intentos', 'Unable to send message for email provided' => 'Deshabilitado para enviar mensaje por correo electrónico proveído', 'You could not login from this IP' => 'Usted no puede iniciar sesión desde esta dirección IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => 'Hola {username}, siga este enlace para confirmar su correo electrónico:', + 'Confirm E-mail' => 'Confirmar correo electrónico', + 'Hello {username}, follow this link to reset your password:' => 'Hola {username}, siga este enlace para restablecer su contraseña', + 'Reset password' => 'Restablecer contraseña', + 'Hello, you have been registered on {hostinfo}' => 'Hola, te has registrado en {hostinfo}.', + 'Follow this link to confirm your E-mail address and activate your account:' => 'Siga este enlace para confirmar su correo electrónico y activar su cuenta:', ]; diff --git a/messages/fr/front.php b/messages/fr/front.php index 935af0de..14186f08 100644 --- a/messages/fr/front.php +++ b/messages/fr/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Trop de tentatives', 'Unable to send message for email provided' => 'Impossible d\'envoyer le message pour l\'email fournit', 'You could not login from this IP' => 'Vous ne pouvez pas vous identifier à partir de cette adresse IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/ko-KR/front.php b/messages/ko-KR/front.php index 747b0827..d9fee166 100644 --- a/messages/ko-KR/front.php +++ b/messages/ko-KR/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => '너무 많은 시도를 했습니다', 'Unable to send message for email provided' => '제출된 주소로 메일을 보낼수 없습니다', 'You could not login from this IP' => '이 아이피로 로그인 할 수 없습니다', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/pl/front.php b/messages/pl/front.php index 1aad993f..f84835a9 100644 --- a/messages/pl/front.php +++ b/messages/pl/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Zbyt wiele prób', 'Unable to send message for email provided' => 'Nie udało się wysłać wiadomości na podany adres e-mail', 'You could not login from this IP' => 'Nie możesz się zalogować z tego IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/pt-BR/front.php b/messages/pt-BR/front.php index 5d4c7fe7..d47add56 100644 --- a/messages/pt-BR/front.php +++ b/messages/pt-BR/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Muitas tentativas', 'Unable to send message for email provided' => 'Não foi possível enviar mensagem para o e-mail informado', 'You could not login from this IP' => 'Você não pode logar a partir deste endereço IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/pt-PT/front.php b/messages/pt-PT/front.php index 7b57a575..f1349ff0 100644 --- a/messages/pt-PT/front.php +++ b/messages/pt-PT/front.php @@ -49,4 +49,10 @@ 'Unable to send message for email provided' => 'Não foi possível enviar mensagem para o e-mail indicado', 'Username' => 'Nome de Utilizador', 'You could not login from this IP' => 'Não é possível autenticar-se a partir deste endereço de IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/messages/ru/front.php b/messages/ru/front.php index b4f9fd54..3bf81891 100644 --- a/messages/ru/front.php +++ b/messages/ru/front.php @@ -49,4 +49,10 @@ 'Too many attempts' => 'Лимит попыток превышен', 'Unable to send message for email provided' => 'Не удалось отправить письмо на указанный email', 'You could not login from this IP' => 'Вы не можете входить с этого IP', + 'Hello {username}, follow this link to confirm your E-mail address:' => '', + 'Confirm E-mail' => '', + 'Hello {username}, follow this link to reset your password:' => '', + 'Reset password' => '', + 'Hello, you have been registered on {hostinfo}' => '', + 'Follow this link to confirm your E-mail address and activate your account:' => '', ]; diff --git a/views/mail/emailConfirmationMail.php b/views/mail/emailConfirmationMail.php index ec9eeb26..26096dcd 100644 --- a/views/mail/emailConfirmationMail.php +++ b/views/mail/emailConfirmationMail.php @@ -4,12 +4,13 @@ * @var $user wpler\modules\UserManagement\models\User */ use yii\helpers\Html; +use wpler\modules\UserManagement\UserManagementModule; ?> urlManager->createAbsoluteUrl(['/user-management/auth/confirm-email-receive', 'token' => $user->confirmation_token]); ?> -Hello username) ?>, follow this link to confirm your email: +Html::encode($user->username))); ?> - \ No newline at end of file + \ No newline at end of file diff --git a/views/mail/passwordRecoveryMail.php b/views/mail/passwordRecoveryMail.php index b0fcad48..cdbd7f0c 100644 --- a/views/mail/passwordRecoveryMail.php +++ b/views/mail/passwordRecoveryMail.php @@ -4,12 +4,13 @@ * @var $user wpler\modules\UserManagement\models\User */ use yii\helpers\Html; +use wpler\modules\UserManagement\UserManagementModule; ?> urlManager->createAbsoluteUrl(['/user-management/auth/password-recovery-receive', 'token' => $user->confirmation_token]); ?> -Hello username) ?>, follow this link to reset your password: +Html::encode($user->username))); ?> - \ No newline at end of file + \ No newline at end of file diff --git a/views/mail/registrationEmailConfirmation.php b/views/mail/registrationEmailConfirmation.php index ed3a51eb..d338a5df 100644 --- a/views/mail/registrationEmailConfirmation.php +++ b/views/mail/registrationEmailConfirmation.php @@ -4,6 +4,7 @@ * @var $user wpler\modules\UserManagement\models\User */ use yii\helpers\Html; +use wpler\modules\UserManagement\UserManagementModule; ?> urlManager->createAbsoluteUrl(['/user-management/auth/confirm-registration-email', 'token' => $user->confirmation_token, 'returnUrl'=>$returnUrl]); ?> -Hello, you have been registered on urlManager->hostInfo ?> +Yii::$app->urlManager->hostInfo)); ?>

-Follow this link to confirm your E-mail and activate account: + - \ No newline at end of file + \ No newline at end of file From 53cdfda8792489ba8e5974a7b2d68a8e834f67db Mon Sep 17 00:00:00 2001 From: stefan Date: Mon, 15 Jan 2018 17:16:24 +0100 Subject: [PATCH 09/16] Completed german translation --- messages/de/back.php | 18 +++++++++--------- messages/de/front.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/messages/de/back.php b/messages/de/back.php index 16965e3f..a236027e 100644 --- a/messages/de/back.php +++ b/messages/de/back.php @@ -19,7 +19,7 @@ return [ 'Active' => 'Aktiv', 'Are you sure you want to delete this user?' => 'Wollen Sie diesen Benutzer wirklich löschen?', - 'Banned' => '', + 'Banned' => 'Gebannt', 'Bind to IP' => 'An IP binden', 'Browser' => '', 'Change own password' => 'Eigenes Passwort ändern', @@ -29,7 +29,7 @@ 'Child permissions' => 'Kind-Berechtigungen', 'Child roles' => 'Kind-Rollen', 'Code' => '', - 'Confirmation Token' => '', + 'Confirmation Token' => 'Bestätigungs-Token', 'Create' => 'Erstellen', 'Created' => 'Erstellt', 'Creating permission group' => 'Erstelle Berechtigungs-Gruppe', @@ -39,7 +39,7 @@ 'Description' => 'Beschreibung', 'E-mail' => '', 'E-mail confirmed' => 'E-Mail bestätigt', - 'E-mail with activation link has been sent to {email}. This link will expire in {minutes} min.' => '', + 'E-mail with activation link has been sent to {email}. This link will expire in {minutes} min.' => 'Eine Email mit Aktivierungslink wurde an {email} gesendet. Der Link wird in {minutes} min. ablaufen.', 'Edit' => 'Bearbeiten', 'Editing' => 'Bearbeite', 'Editing permission group' => 'Bearbeite Berechtigungs-Gruppe', @@ -61,8 +61,8 @@ 'Permission groups' => 'Berechtigungs-Gruppen', 'Permissions' => 'Berechtigungen', 'Permissions for role:' => 'Berechtigungen für Rolle', - 'Refresh routes' => '', - 'Refresh routes (and delete unused)' => '', + 'Refresh routes' => 'Routen aktualisieren', + 'Refresh routes (and delete unused)' => 'Routen aktualisieren (& unbenutzte löschen)', 'Registration IP' => 'Registrierung IP', 'Repeat password' => 'Passwort wiederholen', 'Reset' => 'Zurücksetzen', @@ -70,15 +70,15 @@ 'Roles' => 'Rollen', 'Roles and permissions' => 'Rollen und Berechtigungen', 'Roles and permissions for user:' => 'Rollen und Berechtigungen von Benutzer:', - 'Routes that are not exists in this application will be deleted. Do not recommended for application with "advanced" structure, because frontend and backend have they own set of routes.' => '', + 'Routes that are not exists in this application will be deleted. Do not recommended for application with "advanced" structure, because frontend and backend have they own set of routes.' => 'Routen die nicht in der Anwendung benutzt werden, werden gelöscht. Dies ist nicht im Advanced-Template Struktur empfohlen, weil das Frontend sowie Backend seine eigenen Sets der Routen enthalten.', 'Rule' => 'Rolle', 'Save' => 'Speichern', 'Saved' => 'Gespeichert', 'Search' => 'Suchen', - 'Search route' => '', + 'Search route' => 'Route suchen', 'Settings for permission' => 'Einstellungen für Berechtigung', - 'Show all' => '', - 'Show only selected' => '', + 'Show all' => 'Zeige alle', + 'Show only selected' => 'Zeige nur markierte', 'Status' => '', 'Superadmin' => 'Super-Administrator', 'Token' => '', diff --git a/messages/de/front.php b/messages/de/front.php index ffc0ff16..dbe0ce11 100644 --- a/messages/de/front.php +++ b/messages/de/front.php @@ -20,7 +20,7 @@ 'Captcha' => '', 'E-mail' => '', 'Login' => '', - 'Username' => '', + 'Username' => 'Benutzername', 'Authorization' => 'Autorisierung', 'Check your E-mail for further instructions' => 'Überprüfen Sie Ihre E-Mail-Adresse für weitere Anweisungen', 'Check your e-mail {email} for instructions to activate account' => 'Überprüfen Sie Ihre E-Mail-Adresse {email} für weitere Anweisungen zur Kontoaktivierung', From d7b984db9687f2f5e15a4415bd941a12f6ca41b2 Mon Sep 17 00:00:00 2001 From: "Jacomeit, Stefan" Date: Tue, 16 Jan 2018 12:05:09 +0100 Subject: [PATCH 10/16] Controller failed with Ghost-Access behavior --- components/BaseController.php | 41 +++ controllers/AdminDefaultController.php | 353 +++++++++++++++++++++++ controllers/AuthController.php | 2 +- controllers/AuthItemGroupController.php | 2 +- controllers/PermissionController.php | 2 +- controllers/RoleController.php | 2 +- controllers/UserController.php | 2 +- controllers/UserPermissionController.php | 2 +- controllers/UserVisitLogController.php | 2 +- 9 files changed, 401 insertions(+), 7 deletions(-) create mode 100644 components/BaseController.php create mode 100644 controllers/AdminDefaultController.php diff --git a/components/BaseController.php b/components/BaseController.php new file mode 100644 index 00000000..fb0cf9fb --- /dev/null +++ b/components/BaseController.php @@ -0,0 +1,41 @@ + [ + 'class' => GhostAccessControl::className(), + ], + ]; + } + + /** + * Render ajax or usual depends on request + * + * @param string $view + * @param array $params + * + * @return string|\yii\web\Response + */ + protected function renderIsAjax($view, $params = []) + { + if ( Yii::$app->request->isAjax ) + { + return $this->renderAjax($view, $params); + } + else + { + return $this->render($view, $params); + } + } +} \ No newline at end of file diff --git a/controllers/AdminDefaultController.php b/controllers/AdminDefaultController.php new file mode 100644 index 00000000..9ed8c6cf --- /dev/null +++ b/controllers/AdminDefaultController.php @@ -0,0 +1,353 @@ +modelSearchClass ? new $this->modelSearchClass : null; + + if ( $searchModel ) + { + $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); + } + else + { + $modelClass = $this->modelClass; + $dataProvider = new ActiveDataProvider([ + 'query' => $modelClass::find(), + ]); + } + + return $this->renderIsAjax('index', compact('dataProvider', 'searchModel')); + } + + /** + * Displays a single model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->renderIsAjax('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new $this->modelClass; + + if ( $this->scenarioOnCreate ) + { + $model->scenario = $this->scenarioOnCreate; + } + + if ( $model->load(Yii::$app->request->post()) && $model->save() ) + { + $redirect = $this->getRedirectPage('create', $model); + + return $redirect === false ? '' : $this->redirect($redirect); + } + + return $this->renderIsAjax('create', compact('model')); + } + + /** + * Updates an existing model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ( $this->scenarioOnUpdate ) + { + $model->scenario = $this->scenarioOnUpdate; + } + + if ( $model->load(Yii::$app->request->post()) AND $model->save()) + { + $redirect = $this->getRedirectPage('update', $model); + + return $redirect === false ? '' : $this->redirect($redirect); + } + + return $this->renderIsAjax('update', compact('model')); + } + + /** + * Deletes an existing model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $model = $this->findModel($id); + $model->delete(); + + $redirect = $this->getRedirectPage('delete', $model); + + return $redirect === false ? '' : $this->redirect($redirect); + } + /** + * @param string $attribute + * @param int $id + */ + public function actionToggleAttribute($attribute, $id) + { + $model = $this->findModel($id); + $model->{$attribute} = ($model->{$attribute} == 1) ? 0 : 1; + $model->save(false); + } + + + /** + * Activate all selected grid items + */ + public function actionBulkActivate($attribute = 'active') + { + if ( Yii::$app->request->post('selection') ) + { + $modelClass = $this->modelClass; + + $modelClass::updateAll( + [$attribute=>1], + ['id'=>Yii::$app->request->post('selection', [])] + ); + } + } + + + /** + * Deactivate all selected grid items + */ + public function actionBulkDeactivate($attribute = 'active') + { + if ( Yii::$app->request->post('selection') ) + { + $modelClass = $this->modelClass; + + $modelClass::updateAll( + [$attribute=>0], + ['id'=>Yii::$app->request->post('selection', [])] + ); + } + } + + /** + * Deactivate all selected grid items + */ + public function actionBulkDelete() + { + if ( Yii::$app->request->post('selection') ) + { + $modelClass = $this->modelClass; + + foreach (Yii::$app->request->post('selection', []) as $id) + { + $model = $modelClass::findOne($id); + + if ( $model ) + $model->delete(); + } + } + } + + + /** + * Sorting items in grid + */ + public function actionGridSort() + { + if ( Yii::$app->request->post('sorter') ) + { + $sortArray = Yii::$app->request->post('sorter',[]); + + $modelClass = $this->modelClass; + + $models = $modelClass::findAll(array_keys($sortArray)); + + foreach ($models as $model) + { + $model->sorter = $sortArray[$model->id]; + $model->save(false); + } + + } + } + + + /** + * Set page size for grid + */ + public function actionGridPageSize() + { + if ( Yii::$app->request->post('grid-page-size') ) + { + $cookie = new Cookie([ + 'name' => '_grid_page_size', + 'value' => Yii::$app->request->post('grid-page-size'), + 'expire' => time() + 86400 * 365, // 1 year + ]); + + Yii::$app->response->cookies->add($cookie); + } + } + + /** + * Finds the model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param mixed $id + * + * @return ActiveRecord the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + $modelClass = $this->modelClass; + + if ( ($model = $modelClass::findOne($id)) !== null ) + { + return $model; + } + else + { + throw new NotFoundHttpException(Yii::t('yii', 'Page not found.')); + } + } + + + /** + * Define redirect page after update, create, delete, etc + * + * @param string $action + * @param ActiveRecord $model + * + * @return string|array + */ + protected function getRedirectPage($action, $model = null) + { + switch ($action) + { + case 'delete': + // Post and ajax request used in grid with pjax. To render normal page we have to redirect request to ['index'] + return Yii::$app->request->isAjax && !Yii::$app->request->isPost ? false : ['index']; + break; + case 'update': + return Yii::$app->request->isAjax ? false : ['view', 'id'=>$model->id]; + break; + case 'create': + return Yii::$app->request->isAjax ? false : ['view', 'id'=>$model->id]; + break; + default: + return ['index']; + } + } + + /** + * @inheritdoc + */ + public function beforeAction($action) + { + if ( parent::beforeAction($action) ) + { + if ( $this->enableOnlyActions !== [] AND in_array($action->id, $this->_implementedActions) AND !in_array($action->id, $this->enableOnlyActions) ) + { + throw new NotFoundHttpException('Page not found'); + } + + if ( in_array($action->id, $this->disabledActions) ) + { + throw new NotFoundHttpException('Page not found'); + } + + return true; + } + + return false; + + } +} \ No newline at end of file diff --git a/controllers/AuthController.php b/controllers/AuthController.php index fe2281a0..a1150d92 100644 --- a/controllers/AuthController.php +++ b/controllers/AuthController.php @@ -2,7 +2,7 @@ namespace wpler\modules\UserManagement\controllers; -use \webvimark\components\BaseController; +use wpler\modules\UserManagement\components\BaseController; use wpler\modules\UserManagement\components\UserAuthEvent; use wpler\modules\UserManagement\models\forms\ChangeOwnPasswordForm; use wpler\modules\UserManagement\models\forms\ConfirmEmailForm; diff --git a/controllers/AuthItemGroupController.php b/controllers/AuthItemGroupController.php index c4cf5f6f..bac9f92b 100644 --- a/controllers/AuthItemGroupController.php +++ b/controllers/AuthItemGroupController.php @@ -5,7 +5,7 @@ use wpler\modules\UserManagement\models\rbacDB\AuthItemGroup; use wpler\modules\UserManagement\models\rbacDB\search\AuthItemGroupSearch; use Yii; -use \webvimark\components\AdminDefaultController; +use wpler\modules\UserManagement\components\AdminDefaultController; /** * AuthItemGroupController implements the CRUD actions for AuthItemGroup model. diff --git a/controllers/PermissionController.php b/controllers/PermissionController.php index 303a525a..b084aa4a 100644 --- a/controllers/PermissionController.php +++ b/controllers/PermissionController.php @@ -8,7 +8,7 @@ use wpler\modules\UserManagement\models\rbacDB\Permission; use wpler\modules\UserManagement\models\rbacDB\Route; use wpler\modules\UserManagement\models\rbacDB\search\PermissionSearch; -use \webvimark\components\AdminDefaultController; +use wpler\modules\UserManagement\components\AdminDefaultController; use wpler\modules\UserManagement\UserManagementModule; use Yii; diff --git a/controllers/RoleController.php b/controllers/RoleController.php index a3e44388..7803cedc 100644 --- a/controllers/RoleController.php +++ b/controllers/RoleController.php @@ -6,7 +6,7 @@ use wpler\modules\UserManagement\models\rbacDB\Permission; use wpler\modules\UserManagement\models\rbacDB\Role; use wpler\modules\UserManagement\models\rbacDB\search\RoleSearch; -use \webvimark\components\AdminDefaultController; +use wpler\modules\UserManagement\components\AdminDefaultController; use wpler\modules\UserManagement\UserManagementModule; use Yii; use yii\rbac\DbManager; diff --git a/controllers/UserController.php b/controllers/UserController.php index ac84f6fb..6154148d 100644 --- a/controllers/UserController.php +++ b/controllers/UserController.php @@ -2,7 +2,7 @@ namespace wpler\modules\UserManagement\controllers; -use \webvimark\components\AdminDefaultController; +use wpler\modules\UserManagement\components\AdminDefaultController; use Yii; use wpler\modules\UserManagement\models\User; use wpler\modules\UserManagement\models\search\UserSearch; diff --git a/controllers/UserPermissionController.php b/controllers/UserPermissionController.php index 84997b6a..0409b021 100644 --- a/controllers/UserPermissionController.php +++ b/controllers/UserPermissionController.php @@ -2,7 +2,7 @@ namespace wpler\modules\UserManagement\controllers; -use \webvimark\components\BaseController; +use wpler\modules\UserManagement\components\BaseController; use wpler\modules\UserManagement\models\rbacDB\Permission; use wpler\modules\UserManagement\models\rbacDB\Role; use wpler\modules\UserManagement\models\User; diff --git a/controllers/UserVisitLogController.php b/controllers/UserVisitLogController.php index 3f009361..2b6b7da0 100644 --- a/controllers/UserVisitLogController.php +++ b/controllers/UserVisitLogController.php @@ -5,7 +5,7 @@ use Yii; use wpler\modules\UserManagement\models\UserVisitLog; use wpler\modules\UserManagement\models\search\UserVisitLogSearch; -use \webvimark\components\AdminDefaultController; +use wpler\modules\UserManagement\components\AdminDefaultController; /** * UserVisitLogController implements the CRUD actions for UserVisitLog model. From b6ba7db32099784f1797f6ac660508b80924a478 Mon Sep 17 00:00:00 2001 From: "Jacomeit, Stefan" Date: Tue, 16 Jan 2018 12:31:37 +0100 Subject: [PATCH 11/16] Move AdminDefaultController to components --- {controllers => components}/AdminDefaultController.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {controllers => components}/AdminDefaultController.php (100%) diff --git a/controllers/AdminDefaultController.php b/components/AdminDefaultController.php similarity index 100% rename from controllers/AdminDefaultController.php rename to components/AdminDefaultController.php From 4714cb4d70c0e0d0d2f41beb52d25978b6b3e346 Mon Sep 17 00:00:00 2001 From: "Jacomeit, Stefan" Date: Tue, 16 Jan 2018 12:40:26 +0100 Subject: [PATCH 12/16] Move AdminDefaultController to components --- components/AdminDefaultController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/AdminDefaultController.php b/components/AdminDefaultController.php index 9ed8c6cf..0fa82514 100644 --- a/components/AdminDefaultController.php +++ b/components/AdminDefaultController.php @@ -3,7 +3,7 @@ * Admin Default Controller */ -namespace wpler\modules\UserManagement\controllers; +namespace wpler\modules\UserManagement\components; use yii\data\ActiveDataProvider; use yii\db\ActiveRecord; From b610fbee3af4dab86d180d7a7c4a2a2323af1390 Mon Sep 17 00:00:00 2001 From: "Jacomeit, Stefan" Date: Wed, 17 Jan 2018 11:32:32 +0100 Subject: [PATCH 13/16] Change menuItems to ask for the permission and using glyphicons instead of font-awesome --- UserManagementModule.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/UserManagementModule.php b/UserManagementModule.php index 8eebf29f..c078da47 100644 --- a/UserManagementModule.php +++ b/UserManagementModule.php @@ -2,6 +2,7 @@ namespace wpler\modules\UserManagement; +use wpler\modules\UserManagement\models\User; use Yii; use yii\helpers\ArrayHelper; @@ -208,6 +209,20 @@ public function init() */ public static function menuItems() { + $menuItems=[]; + if (User::hasPermission('viewUsers')) { + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Users'),'url'=>['/user-management/user/index']]; + } + if (User::hasPermission('viewUserRoles')) { + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Roles'),'url'=>['/user-management/role/index']]; + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Permissions'),'url'=>['/user-management/permission/index']]; + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Permission groups'),'url'=>['/user-management/auth-item-group/index']]; + } + if (User::hasPermission('viewVisitLog')) { + $menuItems[]=['label'=>' '.UserManagementModule::t('back','Visit log'),'url'=>['/user-management/user-visit-log/index']]; + } + return $menuItems; + /* return [ ['label' => ' ' . UserManagementModule::t('back', 'Users'), 'url' => ['/user-management/user/index']], ['label' => ' ' . UserManagementModule::t('back', 'Roles'), 'url' => ['/user-management/role/index']], @@ -215,6 +230,7 @@ public static function menuItems() ['label' => ' ' . UserManagementModule::t('back', 'Permission groups'), 'url' => ['/user-management/auth-item-group/index']], ['label' => ' ' . UserManagementModule::t('back', 'Visit log'), 'url' => ['/user-management/user-visit-log/index']], ]; + */ } /** From e2fe4588cdea173dcc123a3bf13a8af8135b085b Mon Sep 17 00:00:00 2001 From: "Jacomeit, Stefan" Date: Thu, 15 Feb 2018 09:21:19 +0100 Subject: [PATCH 14/16] Failure on rbacDB class (wrong property isSuperadmin) --- models/rbacDB/Role.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/rbacDB/Role.php b/models/rbacDB/Role.php index 4043147e..e0df72ab 100644 --- a/models/rbacDB/Role.php +++ b/models/rbacDB/Role.php @@ -54,7 +54,7 @@ public static function getPermissionsByRole($roleName, $asArray = true) */ public static function getAvailableRoles($showAll = false, $asArray = false) { - $condition = (Yii::$app->user->isSuperAdmin OR $showAll) ? [] : ['name'=>Yii::$app->session->get(AuthHelper::SESSION_PREFIX_ROLES)]; + $condition = (Yii::$app->user->isSuperadmin OR $showAll) ? [] : ['name'=>Yii::$app->session->get(AuthHelper::SESSION_PREFIX_ROLES)]; $result = static::find()->andWhere($condition)->all(); From a04e866672b2c5ffbee44ac4e2d23a000012ea28 Mon Sep 17 00:00:00 2001 From: "Jacomeit, Stefan" Date: Thu, 15 Feb 2018 09:27:45 +0100 Subject: [PATCH 15/16] wrong property isSuperadmin --- views/user/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/user/index.php b/views/user/index.php index d0ea4def..4e249dd8 100644 --- a/views/user/index.php +++ b/views/user/index.php @@ -97,7 +97,7 @@ ], [ 'attribute'=>'gridRoleSearch', - 'filter'=>ArrayHelper::map(Role::getAvailableRoles(Yii::$app->user->isSuperAdmin),'name', 'description'), + 'filter'=>ArrayHelper::map(Role::getAvailableRoles(Yii::$app->user->isSuperadmin),'name', 'description'), 'value'=>function(User $model){ return implode(', ', ArrayHelper::map($model->roles, 'name', 'description')); }, From cb1313f2c3dab033d3a7c1b58b8668c8a7f67fb6 Mon Sep 17 00:00:00 2001 From: "Jacomeit, Stefan" Date: Thu, 15 Feb 2018 09:33:57 +0100 Subject: [PATCH 16/16] wrong property isSuperadmin --- models/rbacDB/Role.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/models/rbacDB/Role.php b/models/rbacDB/Role.php index e0df72ab..73ce3139 100644 --- a/models/rbacDB/Role.php +++ b/models/rbacDB/Role.php @@ -54,9 +54,14 @@ public static function getPermissionsByRole($roleName, $asArray = true) */ public static function getAvailableRoles($showAll = false, $asArray = false) { - $condition = (Yii::$app->user->isSuperadmin OR $showAll) ? [] : ['name'=>Yii::$app->session->get(AuthHelper::SESSION_PREFIX_ROLES)]; - - $result = static::find()->andWhere($condition)->all(); + //$condition = (Yii::$app->user->isSuperadmin OR $showAll) ? [] : ['name'=>Yii::$app->session->get(AuthHelper::SESSION_PREFIX_ROLES)]; + $condition = (Yii::$app->user->isSuperadmin OR $showAll) ? false : ['name'=>Yii::$app->session->get(AuthHelper::SESSION_PREFIX_ROLES)]; + + if (false===$condition) { + $result = static::find()->all(); + } else { + $result = static::find()->andWhere($condition)->all(); + } return $asArray ? ArrayHelper::map($result, 'name', 'name') : $result; }