* get all reports * * @return array * @throws PreConditionNotMetException * @throws Exception */
()
| 62 | * @throws Exception |
| 63 | */ |
| 64 | public function index(): array { |
| 65 | $ownPanorama = $this->PanoramaMapper->index(); |
| 66 | // Set permissions for all own panoramas |
| 67 | foreach ($ownPanorama as &$panorama) { |
| 68 | $panorama['permissions'] = \OCP\Constants::PERMISSION_UPDATE; |
| 69 | } |
| 70 | unset($panorama); |
| 71 | |
| 72 | $sharedPanoramas = $this->ShareService->getSharedItems(ShareService::SHARE_ITEM_TYPE_PANORAMA); |
| 73 | $keysToKeep = array('id', 'name', 'dataset', 'favorite', 'parent', 'type', 'pages', 'isShare', 'shareId', 'permissions'); |
| 74 | |
| 75 | // get shared reports and remove duplicates |
| 76 | foreach ($sharedPanoramas as $sharedPanorama) { |
| 77 | if (!array_search($sharedPanorama['id'], array_column($ownPanorama, 'id'))) { |
| 78 | // ToDo: panoramas do not have an edit logic. to be added later |
| 79 | $sharedPanorama['permissions'] = \OCP\Constants::PERMISSION_READ; |
| 80 | // just keep the necessary fields |
| 81 | $ownPanorama[] = array_intersect_key($sharedPanorama, array_flip($keysToKeep));; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | $favorites = $this->tagManager->load('analyticsPanorama')->getFavorites(); |
| 86 | foreach ($ownPanorama as &$ownReport) { |
| 87 | $hasTag = 0; |
| 88 | if (is_array($favorites) and in_array($ownReport['id'], $favorites)) { |
| 89 | $hasTag = 1; |
| 90 | } |
| 91 | $ownReport['favorite'] = $hasTag; |
| 92 | $ownReport['item_type'] = ShareService::SHARE_ITEM_TYPE_PANORAMA; |
| 93 | $ownReport = $this->VariableService->replaceTextVariables($ownReport); |
| 94 | } |
| 95 | |
| 96 | return $ownPanorama; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * get own report details |
no test coverage detected