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

Method getSharedPanoramaReport

lib/Service/ShareService.php:270–302  ·  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

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

Calls 2

getSharedItemsMethod · 0.95
readMethod · 0.45