mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
#47 Adds comment permission to each role.
This commit is contained in:
parent
70991fc1e5
commit
148350009c
@ -406,7 +406,7 @@ class PermissionService
|
|||||||
$action = end($explodedPermission);
|
$action = end($explodedPermission);
|
||||||
$this->currentAction = $action;
|
$this->currentAction = $action;
|
||||||
|
|
||||||
$nonJointPermissions = ['restrictions', 'image', 'attachment'];
|
$nonJointPermissions = ['restrictions', 'image', 'attachment', 'comment'];
|
||||||
|
|
||||||
// Handle non entity specific jointPermissions
|
// Handle non entity specific jointPermissions
|
||||||
if (in_array($explodedPermission[0], $nonJointPermissions)) {
|
if (in_array($explodedPermission[0], $nonJointPermissions)) {
|
||||||
|
@ -13,6 +13,9 @@ class CreateCommentsTable extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
|
if (Schema::hasTable('comments')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Schema::create('comments', function (Blueprint $table) {
|
Schema::create('comments', function (Blueprint $table) {
|
||||||
$table->increments('id')->unsigned();
|
$table->increments('id')->unsigned();
|
||||||
$table->integer('page_id')->unsigned();
|
$table->integer('page_id')->unsigned();
|
||||||
@ -23,6 +26,25 @@ class CreateCommentsTable extends Migration
|
|||||||
$table->integer('updated_by')->unsigned()->nullable();
|
$table->integer('updated_by')->unsigned()->nullable();
|
||||||
$table->index(['page_id', 'parent_id']);
|
$table->index(['page_id', 'parent_id']);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
|
// Get roles with permissions we need to change
|
||||||
|
$adminRoleId = DB::table('roles')->where('system_name', '=', 'admin')->first()->id;
|
||||||
|
|
||||||
|
// Create & attach new entity permissions
|
||||||
|
$ops = ['Create All', 'Create Own', 'Update All', 'Update Own', 'Delete All', 'Delete Own'];
|
||||||
|
$entity = 'Comment';
|
||||||
|
foreach ($ops as $op) {
|
||||||
|
$permissionId = DB::table('role_permissions')->insertGetId([
|
||||||
|
'name' => strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op)),
|
||||||
|
'display_name' => $op . ' ' . $entity . 's',
|
||||||
|
'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
|
||||||
|
'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
|
||||||
|
]);
|
||||||
|
DB::table('permission_role')->insert([
|
||||||
|
'role_id' => $adminRoleId,
|
||||||
|
'permission_id' => $permissionId
|
||||||
|
]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,5 +56,12 @@ class CreateCommentsTable extends Migration
|
|||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('comments');
|
Schema::dropIfExists('comments');
|
||||||
|
// Create & attach new entity permissions
|
||||||
|
$ops = ['Create All', 'Create Own', 'Update All', 'Update Own', 'Delete All', 'Delete Own'];
|
||||||
|
$entity = 'Comment';
|
||||||
|
foreach ($ops as $op) {
|
||||||
|
$permName = strtolower($entity) . '-' . strtolower(str_replace(' ', '-', $op));
|
||||||
|
DB::table('role_permissions')->where('name', '=', $permName)->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,4 +223,10 @@ return [
|
|||||||
'profile_not_created_pages' => ':userName has not created any pages',
|
'profile_not_created_pages' => ':userName has not created any pages',
|
||||||
'profile_not_created_chapters' => ':userName has not created any chapters',
|
'profile_not_created_chapters' => ':userName has not created any chapters',
|
||||||
'profile_not_created_books' => ':userName has not created any books',
|
'profile_not_created_books' => ':userName has not created any books',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comments
|
||||||
|
*/
|
||||||
|
'comment' => 'Comment',
|
||||||
|
'comments' => 'Comments'
|
||||||
];
|
];
|
@ -117,6 +117,19 @@
|
|||||||
<label>@include('settings/roles/checkbox', ['permission' => 'attachment-delete-all']) {{ trans('settings.role_all') }}</label>
|
<label>@include('settings/roles/checkbox', ['permission' => 'attachment-delete-all']) {{ trans('settings.role_all') }}</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ trans('entities.comments') }}</td>
|
||||||
|
<td>@include('settings/roles/checkbox', ['permission' => 'comment-create-all'])</td>
|
||||||
|
<td style="line-height:1.2;"><small class="faded">{{ trans('settings.role_controlled_by_asset') }}</small></td>
|
||||||
|
<td>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'comment-update-own']) {{ trans('settings.role_own') }}</label>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'comment-update-all']) {{ trans('settings.role_all') }}</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'comment-delete-own']) {{ trans('settings.role_own') }}</label>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'comment-delete-all']) {{ trans('settings.role_all') }}</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user