mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-02 05:45:13 +08:00
Notifications: Added role receive-notifications permission
This commit is contained in:
parent
100b28707c
commit
ff2674c464
@ -12,12 +12,11 @@ use Illuminate\Database\Eloquent\Collection;
|
|||||||
|
|
||||||
class PermissionsRepo
|
class PermissionsRepo
|
||||||
{
|
{
|
||||||
protected JointPermissionBuilder $permissionBuilder;
|
|
||||||
protected array $systemRoles = ['admin', 'public'];
|
protected array $systemRoles = ['admin', 'public'];
|
||||||
|
|
||||||
public function __construct(JointPermissionBuilder $permissionBuilder)
|
public function __construct(
|
||||||
{
|
protected JointPermissionBuilder $permissionBuilder
|
||||||
$this->permissionBuilder = $permissionBuilder;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,11 +13,9 @@ use Illuminate\Http\Request;
|
|||||||
|
|
||||||
class RoleController extends Controller
|
class RoleController extends Controller
|
||||||
{
|
{
|
||||||
protected PermissionsRepo $permissionsRepo;
|
public function __construct(
|
||||||
|
protected PermissionsRepo $permissionsRepo
|
||||||
public function __construct(PermissionsRepo $permissionsRepo)
|
) {
|
||||||
{
|
|
||||||
$this->permissionsRepo = $permissionsRepo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Create new receive-notifications permission and assign to admin role
|
||||||
|
$permissionId = DB::table('role_permissions')->insertGetId([
|
||||||
|
'name' => 'receive-notifications',
|
||||||
|
'display_name' => 'Receive & Manage Notifications',
|
||||||
|
'created_at' => Carbon::now()->toDateTimeString(),
|
||||||
|
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
|
||||||
|
DB::table('permission_role')->insert([
|
||||||
|
'role_id' => $adminRoleId,
|
||||||
|
'permission_id' => $permissionId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$permission = DB::table('role_permissions')
|
||||||
|
->where('name', '=', 'receive-notifications')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($permission) {
|
||||||
|
DB::table('permission_role')->where([
|
||||||
|
'permission_id' => $permission->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('role_permissions')
|
||||||
|
->where('name', '=', 'receive-notifications')
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
};
|
@ -163,6 +163,7 @@ return [
|
|||||||
'role_manage_settings' => 'Manage app settings',
|
'role_manage_settings' => 'Manage app settings',
|
||||||
'role_export_content' => 'Export content',
|
'role_export_content' => 'Export content',
|
||||||
'role_editor_change' => 'Change page editor',
|
'role_editor_change' => 'Change page editor',
|
||||||
|
'role_notifications' => 'Receive & manage notifications',
|
||||||
'role_asset' => 'Asset Permissions',
|
'role_asset' => 'Asset Permissions',
|
||||||
'roles_system_warning' => 'Be aware that access to any of the above three permissions can allow a user to alter their own privileges or the privileges of others in the system. Only assign roles with these permissions to trusted users.',
|
'roles_system_warning' => 'Be aware that access to any of the above three permissions can allow a user to alter their own privileges or the privileges of others in the system. Only assign roles with these permissions to trusted users.',
|
||||||
'role_asset_desc' => 'These permissions control default access to the assets within the system. Permissions on Books, Chapters and Pages will override these permissions.',
|
'role_asset_desc' => 'These permissions control default access to the assets within the system. Permissions on Books, Chapters and Pages will override these permissions.',
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<div>@include('settings.roles.parts.checkbox', ['permission' => 'access-api', 'label' => trans('settings.role_access_api')])</div>
|
<div>@include('settings.roles.parts.checkbox', ['permission' => 'access-api', 'label' => trans('settings.role_access_api')])</div>
|
||||||
<div>@include('settings.roles.parts.checkbox', ['permission' => 'content-export', 'label' => trans('settings.role_export_content')])</div>
|
<div>@include('settings.roles.parts.checkbox', ['permission' => 'content-export', 'label' => trans('settings.role_export_content')])</div>
|
||||||
<div>@include('settings.roles.parts.checkbox', ['permission' => 'editor-change', 'label' => trans('settings.role_editor_change')])</div>
|
<div>@include('settings.roles.parts.checkbox', ['permission' => 'editor-change', 'label' => trans('settings.role_editor_change')])</div>
|
||||||
|
<div>@include('settings.roles.parts.checkbox', ['permission' => 'receive-notifications', 'label' => trans('settings.role_notifications')])</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div>@include('settings.roles.parts.checkbox', ['permission' => 'settings-manage', 'label' => trans('settings.role_manage_settings')])</div>
|
<div>@include('settings.roles.parts.checkbox', ['permission' => 'settings-manage', 'label' => trans('settings.role_manage_settings')])</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user