Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/Service/RowService.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,15 @@ public function findAllByView(int $viewId, string $userId, ?int $limit = null, ?
if ($this->permissionsService->canReadRowsByElementId($viewId, 'view', $userId)) {
$view = $this->viewMapper->find($viewId);

return $this->row2Mapper->findAll($view->getColumnIds(), $view->getTableId(), $limit, $offset, $view->getFilterArray(), $view->getSortArray(), $userId);
return $this->row2Mapper->findAll(
$view->getColumnIds(),
$view->getTableId(),
$limit,
$offset,
$view->getFilterArray(),
$view->getSortArray(),
$this->resolveFilterUserId($userId, $view),
);
} else {
throw new PermissionError('no read access to view id = ' . $viewId);
}
Expand All @@ -114,6 +122,18 @@ public function findAllByView(int $viewId, string $userId, ?int $limit = null, ?
}


/**
* resolve user id used for field placeholders in view filters.
* if no user is in context (public link), use the view owner as fallback.
*/
private function resolveFilterUserId(string $userId, View $view): string {
if (in_array($userId, ['', null], true)) {
return $view->getCreatedBy() ?? '';
}

return $userId;
}

/**
* @param int $rowId
* @return Row2
Expand Down
Loading