Skip to content

Commit

Permalink
Merge pull request #1253 from nextcloud/backport/1248/stable0.7
Browse files Browse the repository at this point in the history
[stable0.7] Analytics: permission error on shared tables with non-shared views
  • Loading branch information
juliusknorr authored Aug 1, 2024
2 parents d764e0e + e69b3b5 commit dd12109
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/Analytics/AnalyticsDatasource.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,27 @@ public function getTemplate(): array {
$tables = $this->tableService->findAll($this->userId);
}

// concatenate the option-string. The format is tableId:viewId-title
// get all tables and subsequent views
foreach ($tables as $table) {
$tableString = $tableString . $table->getId() . '-' . $table->getTitle() . '/';
// get all views per table
$views = $this->viewService->findAll($this->tableService->find($table->getId()));
foreach ($views as $view) {
$tableString = $tableString . $table->getId() . ':' . $view->getId() . '-' . $view->getTitle() . '/';
try {
$views = $this->viewService->findAll($this->tableService->find($table->getId()), $this->userId);
foreach ($views as $view) {
// concatenate the option-string. The format is tableId:viewId-title
$tableString = $tableString . $table->getId() . ':' . $view->getId() . '-' . $view->getTitle() . '/';
}
} catch (PermissionError $e) {
// this is a shared table without shared views;
continue;
}
}

// get shared views without table authorization
$views = $this->viewService->findSharedViewsWithMe($this->userId);
foreach ($views as $view) {
$tableString = $tableString . $view->getTableId() . ':' . $view->getId() . '-' . $view->getTitle() . '/';
}
// add the tables to a dropdown in the data source settings
$template[] = ['id' => 'tableId', 'name' => $this->l10n->t('Select table'), 'type' => 'tf', 'placeholder' => $tableString];
$template[] = ['id' => 'columns', 'name' => $this->l10n->t('Select columns'), 'placeholder' => $this->l10n->t('e.g. 1,2,4 or leave empty'), 'type' => 'columnPicker'];
Expand Down

0 comments on commit dd12109

Please sign in to comment.