Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions lib/Service/ColumnService.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,11 +786,12 @@ public function findOrCreateColumnsByTitleForTableAsArray(?int $tableId, ?int $v

/**
* @param int $tableId
* @param string|null $userId
* @return int
* @throws PermissionError
*/
public function getColumnsCount(int $tableId): int {
if ($this->permissionsService->canReadColumnsByTableId($tableId)) {
public function getColumnsCount(int $tableId, ?string $userId = null): int {
if ($this->permissionsService->canReadColumnsByTableId($tableId, $userId)) {
return $this->mapper->countColumns($tableId);
} else {
throw new PermissionError('no read access for counting to table id = ' . $tableId);
Expand Down
11 changes: 5 additions & 6 deletions lib/Service/NodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class NodeService {
'description',
'createdAt',
'lastEditAt',
'rowsCount',
'layout',
'viewSettings',
];
Expand All @@ -36,7 +35,7 @@ public function __construct(
/**
* @param 'table'|'view' $nodeType
* @param int $nodeId
* @return array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string, rowsCount: int, layout?: 'table'|'tiles'|'gallery', viewSettings?: array{cardBackgroundSource: int|null, cardTitleSource: int|null}}
* @return array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string, layout?: 'table'|'tiles'|'gallery', viewSettings?: array{cardBackgroundSource: int|null, cardTitleSource: int|null}}
* @throws InternalError
* @throws NotFoundError
* @throws PermissionError
Expand All @@ -53,26 +52,26 @@ public function getPublicDataOfNode(string $nodeType, int $nodeId): array {
}

/**
* @return array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string, rowsCount: int}
* @return array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string}
* @throws InternalError
* @throws NotFoundError
* @throws PermissionError
*/
private function publicDataOfTable(int $id): array {
$table = $this->tableService->find($id, false, '');
/** @var array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string, rowsCount: int} */
/** @var array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string} */
return array_filter($table->jsonSerialize(), static fn (string $key): bool => in_array($key, self::PUBLIC_NODE_KEYS, true), ARRAY_FILTER_USE_KEY);
}

/**
* @return array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string, rowsCount: int, layout: 'table'|'tiles'|'gallery', viewSettings: array{cardBackgroundSource: int|null, cardTitleSource: int|null}}
* @return array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string, layout: 'table'|'tiles'|'gallery', viewSettings: array{cardBackgroundSource: int|null, cardTitleSource: int|null}}
* @throws InternalError
* @throws NotFoundError
* @throws PermissionError
*/
private function publicDataOfView(int $id): array {
$view = $this->viewService->find($id, false, '');
/** @var array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string, rowsCount: int, layout: 'table'|'tiles'|'gallery', viewSettings: array{cardBackgroundSource: int|null, cardTitleSource: int|null}} */
/** @var array{title: string, emoji: string, description: string, createdAt: string, lastEditAt: string, layout: 'table'|'tiles'|'gallery', viewSettings: array{cardBackgroundSource: int|null, cardTitleSource: int|null}} */
return array_filter($view->jsonSerialize(), static fn (string $key): bool => in_array($key, self::PUBLIC_NODE_KEYS, true), ARRAY_FILTER_USE_KEY);
}
}
5 changes: 3 additions & 2 deletions lib/Service/RowService.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,13 @@ public function deleteColumnDataFromRows(Column $column):void {

/**
* @param int $tableId
* @param string|null $userId
* @return int
*
* @throws PermissionError
*/
public function getRowsCount(int $tableId): int {
if ($this->permissionsService->canReadRowsByElementId($tableId, 'table')) {
public function getRowsCount(int $tableId, ?string $userId = null): int {
if ($this->permissionsService->canReadRowsByElementId($tableId, 'table', $userId)) {
return $this->row2Mapper->countRowsForTable($tableId);
} else {
throw new PermissionError('no read access for counting to table id = ' . $tableId);
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/TableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ private function enhanceTable(Table $table, string $userId, ?array $rowCountsByT
$table->setRowsCount($rowCountsByTableId[$table->getId()] ?? 0);
} else {
try {
$table->setRowsCount($this->rowService->getRowsCount($table->getId()));
$table->setRowsCount($this->rowService->getRowsCount($table->getId(), $userId));
} catch (PermissionError) {
$table->setRowsCount(0);
}
}

// add the column count
try {
$table->setColumnsCount($this->columnService->getColumnsCount($table->getId()));
$table->setColumnsCount($this->columnService->getColumnsCount($table->getId(), $userId));
} catch (PermissionError) {
$table->setColumnsCount(0);
}
Expand Down
Loading