mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 20:22:18 +00:00
Allow to use DB tables prefix
This commit is contained in:
parent
ffdfdc7449
commit
00af40ab14
@ -607,13 +607,13 @@ class PermissionService
|
|||||||
*/
|
*/
|
||||||
public function filterRestrictedEntityRelations($query, string $tableName, string $entityIdColumn, string $entityTypeColumn, string $action = 'view')
|
public function filterRestrictedEntityRelations($query, string $tableName, string $entityIdColumn, string $entityTypeColumn, string $action = 'view')
|
||||||
{
|
{
|
||||||
$tableDetails = ['tableName' => $tableName, 'entityIdColumn' => $entityIdColumn, 'entityTypeColumn' => $entityTypeColumn];
|
$tableDetails = ['tableName' => $this->db->getTablePrefix() . $tableName, 'entityIdColumn' => $entityIdColumn, 'entityTypeColumn' => $entityTypeColumn];
|
||||||
|
|
||||||
$q = $query->where(function ($query) use ($tableDetails, $action) {
|
$q = $query->where(function ($query) use ($tableDetails, $action) {
|
||||||
$query->whereExists(function ($permissionQuery) use (&$tableDetails, $action) {
|
$query->whereExists(function ($permissionQuery) use (&$tableDetails, $action) {
|
||||||
$permissionQuery->select(['role_id'])->from('joint_permissions')
|
$permissionQuery->select(['role_id'])->from('joint_permissions')
|
||||||
->whereRaw('joint_permissions.entity_id=' . $tableDetails['tableName'] . '.' . $tableDetails['entityIdColumn'])
|
->whereRaw($this->db->getTablePrefix() . 'joint_permissions.entity_id=' . $tableDetails['tableName'] . '.' . $tableDetails['entityIdColumn'])
|
||||||
->whereRaw('joint_permissions.entity_type=' . $tableDetails['tableName'] . '.' . $tableDetails['entityTypeColumn'])
|
->whereRaw($this->db->getTablePrefix() . 'joint_permissions.entity_type=' . $tableDetails['tableName'] . '.' . $tableDetails['entityTypeColumn'])
|
||||||
->where('action', '=', $action)
|
->where('action', '=', $action)
|
||||||
->whereIn('role_id', $this->getCurrentUserRoles())
|
->whereIn('role_id', $this->getCurrentUserRoles())
|
||||||
->where(function (QueryBuilder $query) {
|
->where(function (QueryBuilder $query) {
|
||||||
@ -640,7 +640,7 @@ class PermissionService
|
|||||||
$query->where(function ($query) use (&$tableDetails, $morphClass) {
|
$query->where(function ($query) use (&$tableDetails, $morphClass) {
|
||||||
$query->whereExists(function ($permissionQuery) use (&$tableDetails, $morphClass) {
|
$query->whereExists(function ($permissionQuery) use (&$tableDetails, $morphClass) {
|
||||||
$permissionQuery->select('id')->from('joint_permissions')
|
$permissionQuery->select('id')->from('joint_permissions')
|
||||||
->whereRaw('joint_permissions.entity_id=' . $tableDetails['tableName'] . '.' . $tableDetails['entityIdColumn'])
|
->whereRaw($this->db->getTablePrefix() . 'joint_permissions.entity_id=' . $tableDetails['tableName'] . '.' . $tableDetails['entityIdColumn'])
|
||||||
->where('entity_type', '=', $morphClass)
|
->where('entity_type', '=', $morphClass)
|
||||||
->where('action', '=', 'view')
|
->where('action', '=', 'view')
|
||||||
->whereIn('role_id', $this->getCurrentUserRoles())
|
->whereIn('role_id', $this->getCurrentUserRoles())
|
||||||
|
Loading…
Reference in New Issue
Block a user