MCPcopy Create free account
hub / github.com/Rello/analytics / index

Method index

lib/Service/PanoramaService.php:69–102  ·  view source on GitHub ↗

* get all reports * * @return array * @throws PreConditionNotMetException * @throws Exception */

()

Source from the content-addressed store, hash-verified

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

Callers 1

getOwnFavoriteReportsMethod · 0.45

Calls 4

getSharedItemsMethod · 0.80
getFavoritesMethod · 0.80
replaceTextVariablesMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected