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

Method getSharedPanoramaReport

lib/Service/ShareService.php:252–283  ·  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)

Source from the content-addressed store, hash-verified

250 * @throws Exception
251 */
252 public function getSharedPanoramaReport($reportId) {
253 $foundReportId = 0;
254 $panoramaOwner = null;
255 $sharedPanoramas = $this->getSharedItems(self::SHARE_ITEM_TYPE_PANORAMA);
256 foreach ($sharedPanoramas as $sharedPanorama) {
257 $panoramaOwner = $sharedPanorama['user_id'];
258 $pages = json_decode($sharedPanorama['pages'], true);
259 foreach ($pages as $page) {
260 $reports = $page['reports'];
261 foreach ($reports as $report) {
262 // only use report type 0 = report; not text or image
263 if ($report['type'] === 0 && $report['value'] === $reportId) {
264 $foundReportId = $reportId;
265 break 3;
266 }
267 }
268 }
269 }
270
271 if ($foundReportId !== 0) {
272 $report = $this->ReportMapper->read($foundReportId);
273 // check against the original owner of the panorama
274 // This is needed to prevent getting other reports by modifying the panorama properties
275 if ($report['user_id'] === $panoramaOwner) {
276 return $report;
277 } else {
278 return [];
279 }
280 } else {
281 return [];
282 }
283 }
284
285 /**
286 * Delete an own share (sharee or receiver)

Callers 1

readPanoramaMethod · 0.80

Calls 2

getSharedItemsMethod · 0.95
readMethod · 0.45

Tested by

no test coverage detected