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

Method getSharedPanoramaReport

lib/Service/ShareService.php:274–306  ·  view source on GitHub ↗

* get metadata of a report, shared with current user as part of a panorama * used to check if user is allowed to execute current report * * @param $reportId * @return array * @throws Exception */

($reportId, ?int $panoramaId = null)

Source from the content-addressed store, hash-verified

272 * @throws Exception
273 */
274 public function getSharedPanoramaReport($reportId, ?int $panoramaId = null) {
275 $foundReportId = 0;
276 $panoramaOwner = null;
277 $sharedPanoramas = $this->getSharedItems(self::SHARE_ITEM_TYPE_PANORAMA);
278 foreach ($sharedPanoramas as $sharedPanorama) {
279 if ($panoramaId !== null && (int)$sharedPanorama['id'] !== $panoramaId) continue;
280 $panoramaOwner = $sharedPanorama['user_id'];
281 $pages = json_decode($sharedPanorama['pages'], true);
282 foreach ($pages as $page) {
283 $reports = $page['reports'];
284 foreach ($reports as $report) {
285 // only use report type 0 = report; not text or image
286 if ((int)$report['type'] === 0 && (int)$report['value'] === (int)$reportId) {
287 $foundReportId = $reportId;
288 break 3;
289 }
290 }
291 }
292 }
293
294 if ($foundReportId !== 0) {
295 $report = $this->ReportMapper->read($foundReportId);
296 // check against the original owner of the panorama
297 // This is needed to prevent getting other reports by modifying the panorama properties
298 if ($report['user_id'] === $panoramaOwner) {
299 return $report;
300 } else {
301 return [];
302 }
303 } else {
304 return [];
305 }
306 }
307
308 /**
309 * Delete an own share (sharee or receiver)

Calls 2

getSharedItemsMethod · 0.95
readMethod · 0.45