From 315132bdd2176a26272cba389dd378514e4d478a Mon Sep 17 00:00:00 2001 From: Ladylain Date: Fri, 4 Aug 2023 10:17:25 +0200 Subject: [PATCH] Change Author --- .vscode/settings.json | 3 + Plugin.php | 80 +++++++++++------------ controllers/Permissions.php | 6 +- controllers/permissions/_list_toolbar.htm | 4 +- controllers/permissions/create.htm | 2 +- controllers/permissions/form_config.yaml | 22 +++---- controllers/permissions/list_config.yaml | 8 +-- controllers/permissions/update.htm | 4 +- formwidgets/UserPermissionEditor.php | 4 +- models/Permission.php | 8 +-- models/permission/columns.yaml | 8 +-- models/permission/fields.yaml | 10 +-- updates/create_tables.php | 14 ++-- 13 files changed, 88 insertions(+), 85 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..13ee2b0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "nuxt.isNuxtApp": false +} \ No newline at end of file diff --git a/Plugin.php b/Plugin.php index bb1d734..1470717 100644 --- a/Plugin.php +++ b/Plugin.php @@ -1,9 +1,9 @@ - 'jbonnydev.userpermissions::lang.plugin.name', - 'description' => 'jbonnydev.userpermissions::lang.plugin.description', + 'name' => 'ladylain.userpermissions::lang.plugin.name', + 'description' => 'ladylain.userpermissions::lang.plugin.description', 'author' => 'JoakimBo', 'icon' => 'icon-unlock-alt' ]; @@ -41,17 +41,17 @@ public function boot() public function registerPermissions() { return [ - 'jbonnydev.userpermissions.access_permissions' => [ - 'tab' => 'jbonnydev.userpermissions::lang.plugin.tab', - 'label' => 'jbonnydev.userpermissions::lang.plugin.access_permissions' + 'ladylain.userpermissions.access_permissions' => [ + 'tab' => 'ladylain.userpermissions::lang.plugin.tab', + 'label' => 'ladylain.userpermissions::lang.plugin.access_permissions' ], - 'jbonnydev.userpermissions.access_user_permissions' => [ - 'tab' => 'jbonnydev.userpermissions::lang.plugin.tab', - 'label' => 'jbonnydev.userpermissions::lang.plugin.access_user_permissions' + 'ladylain.userpermissions.access_user_permissions' => [ + 'tab' => 'ladylain.userpermissions::lang.plugin.tab', + 'label' => 'ladylain.userpermissions::lang.plugin.access_user_permissions' ], - 'jbonnydev.userpermissions.access_group_permissions' => [ - 'tab' => 'jbonnydev.userpermissions::lang.plugin.tab', - 'label' => 'jbonnydev.userpermissions::lang.plugin.access_group_permissions' + 'ladylain.userpermissions.access_group_permissions' => [ + 'tab' => 'ladylain.userpermissions::lang.plugin.tab', + 'label' => 'ladylain.userpermissions::lang.plugin.access_group_permissions' ], ]; } @@ -61,10 +61,10 @@ protected function extendRainlabUserSideMenu() Event::listen('backend.menu.extendItems', function($manager) { $manager->addSideMenuItems('RainLab.User', 'user', [ 'permissions' => [ - 'label' => 'jbonnydev.userpermissions::lang.permissions.menu_label', + 'label' => 'ladylain.userpermissions::lang.permissions.menu_label', 'icon' => 'icon-unlock-alt', - 'permissions' => ['jbonnydev.userpermissions.access_permissions'], - 'url' => Backend::url('jbonnydev/userpermissions/permissions'), + 'permissions' => ['ladylain.userpermissions.access_permissions'], + 'url' => Backend::url('ladylain/userpermissions/permissions'), ] ]); }); @@ -76,29 +76,29 @@ function getAllowedPermissions($model) { if (!$model->is_activated) { return []; } - $groupPermissionsQuery = $model->user_permissions()->where('jbonnydev_userpermissions_user_permission.permission_state', 2) - ->join('users_groups', 'jbonnydev_userpermissions_user_permission.user_id', '=', 'users_groups.user_id') - ->join('jbonnydev_userpermissions_group_permission', function ($join) { - $join->on('users_groups.user_group_id', '=', 'jbonnydev_userpermissions_group_permission.group_id') + $groupPermissionsQuery = $model->user_permissions()->where('ladylain_userpermissions_user_permission.permission_state', 2) + ->join('users_groups', 'ladylain_userpermissions_user_permission.user_id', '=', 'users_groups.user_id') + ->join('ladylain_userpermissions_group_permission', function ($join) { + $join->on('users_groups.user_group_id', '=', 'ladylain_userpermissions_group_permission.group_id') ->on( - 'jbonnydev_userpermissions_group_permission.permission_id', + 'ladylain_userpermissions_group_permission.permission_id', '=', - 'jbonnydev_userpermissions_user_permission.permission_id' + 'ladylain_userpermissions_user_permission.permission_id' ) - ->where('jbonnydev_userpermissions_group_permission.permission_state', '=', 1); + ->where('ladylain_userpermissions_group_permission.permission_state', '=', 1); }) - ->join('jbonnydev_userpermissions_permissions as permissions', - 'jbonnydev_userpermissions_group_permission.permission_id', + ->join('ladylain_userpermissions_permissions as permissions', + 'ladylain_userpermissions_group_permission.permission_id', '=', 'permissions.id' )->select( 'permissions.id', 'permissions.code', - 'jbonnydev_userpermissions_user_permission.user_id', - 'jbonnydev_userpermissions_user_permission.permission_id', - 'jbonnydev_userpermissions_user_permission.permission_state', - 'jbonnydev_userpermissions_user_permission.created_at', - 'jbonnydev_userpermissions_user_permission.updated_at' + 'ladylain_userpermissions_user_permission.user_id', + 'ladylain_userpermissions_user_permission.permission_id', + 'ladylain_userpermissions_user_permission.permission_state', + 'ladylain_userpermissions_user_permission.created_at', + 'ladylain_userpermissions_user_permission.updated_at' ); $permissionsQueryResult = $model->user_permissions()->select('id', 'code')->where('permission_state', 1)->union($groupPermissionsQuery)->get(); if (!$permissionsQueryResult) { @@ -136,8 +136,8 @@ function normalizePermissionInput($permissions) { UserModel::extend(function($model) { $model->belongsToMany['user_permissions'] = [ - 'JBonnyDev\UserPermissions\Models\Permission', - 'table' => 'jbonnydev_userpermissions_user_permission', + 'Ladylain\UserPermissions\Models\Permission', + 'table' => 'ladylain_userpermissions_user_permission', 'key' => 'user_id', 'otherKey' => 'permission_id', 'timestamps' => true, @@ -174,7 +174,7 @@ function normalizePermissionInput($permissions) { } return false; }); - $model->addDynamicMethod(Config::get('jbonnydev.userpermissions::hasUserPermissionAlias', 'hasUserPermissionAlias'), function($permissionsInput, $match = 'all') use ($model) { + $model->addDynamicMethod(Config::get('ladylain.userpermissions::hasUserPermissionAlias', 'hasUserPermissionAlias'), function($permissionsInput, $match = 'all') use ($model) { return $model->hasUserPermission($permissionsInput, $match); }); }); @@ -183,8 +183,8 @@ function normalizePermissionInput($permissions) { protected function extendUserGroupModel() { UserGroupModel::extend(function($model) { - $model->belongsToMany['user_permissions'] = ['JBonnyDev\UserPermissions\Models\Permission', - 'table' => 'jbonnydev_userpermissions_group_permission', + $model->belongsToMany['user_permissions'] = ['Ladylain\UserPermissions\Models\Permission', + 'table' => 'ladylain_userpermissions_group_permission', 'key' => 'group_id', 'otherKey' => 'permission_id', 'timestamps' => true, @@ -213,10 +213,10 @@ protected function extendUserController() return; } // only add field if backend user has access - if (BackendAuth::getUser()->hasAccess('jbonnydev.userpermissions.access_user_permissions')) { + if (BackendAuth::getUser()->hasAccess('ladylain.userpermissions.access_user_permissions')) { $widget->addTabFields([ 'user_permissions' => [ - 'tab' => 'jbonnydev.userpermissions::lang.permissions.menu_label', + 'tab' => 'ladylain.userpermissions::lang.permissions.menu_label', 'type' => 'userpermissioneditor', 'mode' => 'radio', 'context' => ['create','preview','update'], @@ -238,10 +238,10 @@ protected function extendUserGroupController() return; } // only add field if backend user has access - if (BackendAuth::getUser()->hasAccess('jbonnydev.userpermissions.access_group_permissions')) { + if (BackendAuth::getUser()->hasAccess('ladylain.userpermissions.access_group_permissions')) { $widget->addTabFields([ 'user_permissions' => [ - 'tab' => 'jbonnydev.userpermissions::lang.permissions.menu_label', + 'tab' => 'ladylain.userpermissions::lang.permissions.menu_label', 'type' => 'userpermissioneditor', 'mode' => 'checkbox', 'context' => ['create','preview','update'], @@ -254,7 +254,7 @@ protected function extendUserGroupController() public function registerFormWidgets() { return [ - 'JBonnyDev\UserPermissions\FormWidgets\UserPermissionEditor' => 'userpermissioneditor', + 'Ladylain\UserPermissions\FormWidgets\UserPermissionEditor' => 'userpermissioneditor', ]; } } diff --git a/controllers/Permissions.php b/controllers/Permissions.php index 75b318b..b32224b 100644 --- a/controllers/Permissions.php +++ b/controllers/Permissions.php @@ -1,4 +1,4 @@ -addCss('/plugins/JBonnyDev/userpermissions/assets/css/form.css'); + $this->addCss('/plugins/Ladylain/userpermissions/assets/css/form.css'); } } diff --git a/controllers/permissions/_list_toolbar.htm b/controllers/permissions/_list_toolbar.htm index f013858..e28ad31 100644 --- a/controllers/permissions/_list_toolbar.htm +++ b/controllers/permissions/_list_toolbar.htm @@ -1,4 +1,4 @@
- +
diff --git a/controllers/permissions/create.htm b/controllers/permissions/create.htm index bcfc051..e445125 100644 --- a/controllers/permissions/create.htm +++ b/controllers/permissions/create.htm @@ -24,7 +24,7 @@ - + diff --git a/controllers/permissions/form_config.yaml b/controllers/permissions/form_config.yaml index 7ae190b..b98d90d 100644 --- a/controllers/permissions/form_config.yaml +++ b/controllers/permissions/form_config.yaml @@ -2,21 +2,21 @@ # Form Behavior Config # =================================== -name: jbonnydev.userpermissions::lang.permissions.menu_label -form: $/jbonnydev/userpermissions/models/permission/fields.yaml -modelClass: JBonnyDev\UserPermissions\Models\Permission +name: ladylain.userpermissions::lang.permissions.menu_label +form: $/ladylain/userpermissions/models/permission/fields.yaml +modelClass: Ladylain\UserPermissions\Models\Permission create: - title: jbonnydev.userpermissions::lang.permissions.create_permission - redirect: jbonnydev/userpermissions/permissions/update/:id - redirectClose: jbonnydev/userpermissions/permissions + title: ladylain.userpermissions::lang.permissions.create_permission + redirect: ladylain/userpermissions/permissions/update/:id + redirectClose: ladylain/userpermissions/permissions update: - title: jbonnydev.userpermissions::lang.permissions.update_permission - redirect: jbonnydev/userpermissions/permissions/update/:id - redirectClose: jbonnydev/userpermissions/permissions + title: ladylain.userpermissions::lang.permissions.update_permission + redirect: ladylain/userpermissions/permissions/update/:id + redirectClose: ladylain/userpermissions/permissions preview: - title: jbonnydev.userpermissions::lang.permissions.view_permission + title: ladylain.userpermissions::lang.permissions.view_permission -defaultRedirect: jbonnydev/userpermissions/permissions +defaultRedirect: ladylain/userpermissions/permissions diff --git a/controllers/permissions/list_config.yaml b/controllers/permissions/list_config.yaml index aeb93b2..4ee75e7 100644 --- a/controllers/permissions/list_config.yaml +++ b/controllers/permissions/list_config.yaml @@ -2,10 +2,10 @@ # List Behavior Config # =================================== -title: jbonnydev.userpermissions::lang.permissions.menu_label -list: ~/plugins/jbonnydev/userpermissions/models/permission/columns.yaml -modelClass: JBonnyDev\UserPermissions\Models\Permission -recordUrl: jbonnydev/userpermissions/permissions/update/:id +title: ladylain.userpermissions::lang.permissions.menu_label +list: ~/plugins/ladylain/userpermissions/models/permission/columns.yaml +modelClass: Ladylain\UserPermissions\Models\Permission +recordUrl: ladylain/userpermissions/permissions/update/:id noRecordsMessage: backend::lang.list.no_records diff --git a/controllers/permissions/update.htm b/controllers/permissions/update.htm index 4aba0ad..88b91b2 100644 --- a/controllers/permissions/update.htm +++ b/controllers/permissions/update.htm @@ -20,10 +20,10 @@ class="oc-icon-trash-o btn-icon danger pull-right" data-request="onDelete" data-load-indicator="Deleting Permission..." - data-request-confirm=""> + data-request-confirm=""> - or Cancel + or Cancel diff --git a/formwidgets/UserPermissionEditor.php b/formwidgets/UserPermissionEditor.php index fa2687a..4058726 100644 --- a/formwidgets/UserPermissionEditor.php +++ b/formwidgets/UserPermissionEditor.php @@ -1,7 +1,7 @@ - ['Rainlab\User\Models\User', - 'table' => 'jbonnydev_userpermissions_user_permission', + 'table' => 'ladylain_userpermissions_user_permission', 'key' => 'permission_id', 'otherKey' => 'user_id', 'timestamps' => true, 'pivot' => ['permission_state'], ], 'groups' => ['Rainlab\User\Models\UserGroup', - 'table' => 'jbonnydev_userpermissions_group_permission', + 'table' => 'ladylain_userpermissions_group_permission', 'key' => 'permission_id', 'otherKey' => 'group_id', 'timestamps' => true, diff --git a/models/permission/columns.yaml b/models/permission/columns.yaml index b83d2ee..7930348 100644 --- a/models/permission/columns.yaml +++ b/models/permission/columns.yaml @@ -4,20 +4,20 @@ columns: id: - label: jbonnydev.userpermissions::lang.permission.model_id + label: ladylain.userpermissions::lang.permission.model_id type: text searchable: true code: - label: jbonnydev.userpermissions::lang.permission.model_code + label: ladylain.userpermissions::lang.permission.model_code type: text width: 30% searchable: true name: - label: jbonnydev.userpermissions::lang.permission.model_name + label: ladylain.userpermissions::lang.permission.model_name type: text width: 30% searchable: true description: - label: jbonnydev.userpermissions::lang.permission.model_desc + label: ladylain.userpermissions::lang.permission.model_desc type: text width: 40% diff --git a/models/permission/fields.yaml b/models/permission/fields.yaml index 0b14add..2da9b43 100644 --- a/models/permission/fields.yaml +++ b/models/permission/fields.yaml @@ -4,23 +4,23 @@ fields: id: - label: jbonnydev.userpermissions::lang.permission.model_id + label: ladylain.userpermissions::lang.permission.model_id type: text cssClass: form-id description: Id of the permission disabled: true code: - label: jbonnydev.userpermissions::lang.permission.model_code + label: ladylain.userpermissions::lang.permission.model_code type: text cssClass: form-code description: Code for the permission - comment: jbonnydev.userpermissions::lang.permission.model_code_comment + comment: ladylain.userpermissions::lang.permission.model_code_comment attributes: maxlength: 128 name: - label: jbonnydev.userpermissions::lang.permission.model_name + label: ladylain.userpermissions::lang.permission.model_name type: text cssClass: form-name description: Name of the permission @@ -29,7 +29,7 @@ fields: maxlength: 128 description: - label: jbonnydev.userpermissions::lang.permission.model_desc + label: ladylain.userpermissions::lang.permission.model_desc type: textarea cssClass: form-desc description: Description of the permission diff --git a/updates/create_tables.php b/updates/create_tables.php index 748cf26..f2bb7fa 100644 --- a/updates/create_tables.php +++ b/updates/create_tables.php @@ -1,4 +1,4 @@ -engine = 'InnoDB'; $table->increments('id'); @@ -17,7 +17,7 @@ public function up() $table->timestamps(); }); - Schema::create('jbonnydev_userpermissions_user_permission', function($table) + Schema::create('ladylain_userpermissions_user_permission', function($table) { $table->engine = 'InnoDB'; $table->integer('user_id')->unsigned(); @@ -27,7 +27,7 @@ public function up() $table->timestamps(); }); - Schema::create('jbonnydev_userpermissions_group_permission', function($table) + Schema::create('ladylain_userpermissions_group_permission', function($table) { $table->engine = 'InnoDB'; $table->integer('group_id')->unsigned(); @@ -39,8 +39,8 @@ public function up() } public function down() { - Schema::dropIfExists('jbonnydev_userpermissions_group_permission'); - Schema::dropIfExists('jbonnydev_userpermissions_user_permission'); - Schema::dropIfExists('jbonnydev_userpermissions_permissions'); + Schema::dropIfExists('ladylain_userpermissions_group_permission'); + Schema::dropIfExists('ladylain_userpermissions_user_permission'); + Schema::dropIfExists('ladylain_userpermissions_permissions'); } }