1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Rolled out new permissions system throughout application

This commit is contained in:
Dan Brown
2016-04-24 16:54:20 +01:00
parent ada7c83e96
commit a81a56706e
18 changed files with 295 additions and 95 deletions

View File

@ -4,6 +4,7 @@
use BookStack\Exceptions\PermissionsException;
use BookStack\Permission;
use BookStack\Role;
use BookStack\Services\RestrictionService;
use Setting;
class PermissionsRepo
@ -11,16 +12,19 @@ class PermissionsRepo
protected $permission;
protected $role;
protected $restrictionService;
/**
* PermissionsRepo constructor.
* @param $permission
* @param $role
* @param Permission $permission
* @param Role $role
* @param RestrictionService $restrictionService
*/
public function __construct(Permission $permission, Role $role)
public function __construct(Permission $permission, Role $role, RestrictionService $restrictionService)
{
$this->permission = $permission;
$this->role = $role;
$this->restrictionService = $restrictionService;
}
/**
@ -69,6 +73,7 @@ class PermissionsRepo
$permissions = isset($roleData['permissions']) ? array_keys($roleData['permissions']) : [];
$this->assignRolePermissions($role, $permissions);
$this->restrictionService->buildEntityPermissionForRole($role);
return $role;
}
@ -91,6 +96,7 @@ class PermissionsRepo
$role->fill($roleData);
$role->save();
$this->restrictionService->buildEntityPermissionForRole($role);
}
/**
@ -136,6 +142,7 @@ class PermissionsRepo
}
}
$this->restrictionService->deleteEntityPermissionsForRole($role);
$role->delete();
}