Skip to content

Commit

Permalink
Change Author
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladylain committed Aug 4, 2023
1 parent 630130f commit 315132b
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 85 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nuxt.isNuxtApp": false
}
80 changes: 40 additions & 40 deletions Plugin.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php namespace JBonnyDev\UserPermissions;
<?php namespace Ladylain\UserPermissions;

use Exception;
use Event;
use Backend;
use JBonnyDev\UserPermissions\Models\Permission as PermissionModel;
use Ladylain\UserPermissions\Models\Permission as PermissionModel;
use Rainlab\User\Models\User as UserModel;
use Rainlab\User\Models\UserGroup as UserGroupModel;
use October\Rain\Exception\ApplicationException;
Expand All @@ -21,8 +21,8 @@ class Plugin extends \System\Classes\PluginBase
public function pluginDetails()
{
return [
'name' => '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'
];
Expand All @@ -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'
],
];
}
Expand All @@ -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'),
]
]);
});
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
});
});
Expand All @@ -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,
Expand Down Expand Up @@ -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'],
Expand All @@ -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'],
Expand All @@ -254,7 +254,7 @@ protected function extendUserGroupController()
public function registerFormWidgets()
{
return [
'JBonnyDev\UserPermissions\FormWidgets\UserPermissionEditor' => 'userpermissioneditor',
'Ladylain\UserPermissions\FormWidgets\UserPermissionEditor' => 'userpermissioneditor',
];
}
}
6 changes: 3 additions & 3 deletions controllers/Permissions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace JBonnyDev\UserPermissions\Controllers;
<?php namespace Ladylain\UserPermissions\Controllers;

use BackendMenu;
use Rainlab\User\Models\User as UserModel;
Expand All @@ -7,7 +7,7 @@
class Permissions extends \Backend\Classes\Controller
{
public $requiredPermissions = [
'jbonnydev.userpermissions.access_permissions'
'ladylain.userpermissions.access_permissions'
];

public $implement = [
Expand All @@ -23,6 +23,6 @@ public function __construct()
{
parent::__construct();
BackendMenu::setContext('RainLab.User', 'user', 'permissions');
$this->addCss('/plugins/JBonnyDev/userpermissions/assets/css/form.css');
$this->addCss('/plugins/Ladylain/userpermissions/assets/css/form.css');
}
}
4 changes: 2 additions & 2 deletions controllers/permissions/_list_toolbar.htm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div data-control="toolbar">
<a href="<?= Backend::url('jbonnydev/userpermissions/permissions/create') ?>"
class="btn btn-primary oc-icon-plus"><?= e(trans('jbonnydev.userpermissions::lang.permissions.create_permission')) ?></a>
<a href="<?= Backend::url('ladylain/userpermissions/permissions/create') ?>"
class="btn btn-primary oc-icon-plus"><?= e(trans('ladylain.userpermissions::lang.permissions.create_permission')) ?></a>
</div>
2 changes: 1 addition & 1 deletion controllers/permissions/create.htm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<?= e(trans('backend::lang.form.create_and_close')) ?>
</button>
<span class="btn-text">
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('jbonnydev/userpermissions/permissions') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('ladylain/userpermissions/permissions') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
</span>
</div>
</div>
Expand Down
22 changes: 11 additions & 11 deletions controllers/permissions/form_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions controllers/permissions/list_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions controllers/permissions/update.htm
Original file line number Diff line number Diff line change
Expand Up @@ -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="<?= e(trans('jbonnydev.userpermissions::lang.permissions.delete_confirm')) ?>">
data-request-confirm="<?= e(trans('ladylain.userpermissions::lang.permissions.delete_confirm')) ?>">
</button>
<span class="btn-text">
or <a href="<?= Backend::url('jbonnydev/userpermissions/permissions') ?>">Cancel</a>
or <a href="<?= Backend::url('ladylain/userpermissions/permissions') ?>">Cancel</a>
</span>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions formwidgets/UserPermissionEditor.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace JBonnyDev\UserPermissions\FormWidgets;
<?php namespace Ladylain\UserPermissions\FormWidgets;

use Backend\Classes\FormWidgetBase;
use JBonnyDev\UserPermissions\Models\Permission as PermissionModel;
use Ladylain\UserPermissions\Models\Permission as PermissionModel;
/*
* This is a modified version of the OctoberCMS backend permissions editor, see
* the original file here:
Expand Down
8 changes: 4 additions & 4 deletions models/Permission.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace JBonnyDev\UserPermissions\Models;
<?php namespace Ladylain\UserPermissions\Models;

use Model;
use Rainlab\User\Models\User as UserModel;
Expand All @@ -12,7 +12,7 @@ class Permission extends Model
*
* @var string
*/
protected $table = 'jbonnydev_userpermissions_permissions';
protected $table = 'ladylain_userpermissions_permissions';

/*
* Validation
Expand All @@ -23,14 +23,14 @@ class Permission extends Model

public $belongsToMany = [
'users' => ['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,
Expand Down
8 changes: 4 additions & 4 deletions models/permission/columns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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%
10 changes: 5 additions & 5 deletions models/permission/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 315132b

Please sign in to comment.