<?php
 namespace App\RemoteData\InfoBox; class Field_EntityInfoBox extends \Engine\RemoteData\InfoBox\Field_EntityInfoBox { protected $entityType; protected $idEntity; public function setEntity($type, $id) { if ( !in_array( $type, ['amadeusService', 'autoProcessRule', 'balance', 'bank', 'bankOffice', 'bspPeriod', 'calendarEvent', 'cashBookDocument', 'city', 'contactPerson', 'corporate', 'corporateContact', 'corporateOffice', 'customer', 'document', 'documentSeries', 'documentTemplate', 'extResSystem', 'frequentBuyerCard', 'galileoService', 'importedDocument', 'importedDocumentsSystem', 'importedOrder', 'importedService', 'invoice', 'invoiceCashing', 'miceProject', 'office', 'order', 'sabreService', 'service', 'serviceCalculation', 'supplier', 'supplierInvoice', 'supplierInvoicePayment', 'supplierProduct', 'task', 'user', 'worldspanService' ] ) ) { throw new Exception('No valid entity type set.'); } return parent::setEntity($type, $id); } public function exportAsArray() { $arr = parent::exportAsArray(); if ($this->entityType=='user' and $this->idEntity!=CURRENT_ID_USER and !\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('userCanSeeUsersDetails')) { $arr['type'] = 'string'; unset($arr['entity']); } elseif ($this->entityType=='customer' and !\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('Modules/Partners/Customers-remoteDetails')) { $arr['type'] = 'string'; unset($arr['entity']); } elseif ($this->entityType == 'supplier' && !\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('Modules/Partners/Suppliers-remoteDetails')) { $arr['type'] = 'string'; unset($arr['entity']); } elseif ($this->entityType == 'corporate' && !\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('Modules/Partners/Corporates-remoteDetails')) { $arr['type'] = 'string'; unset($arr['entity']); } elseif ($this->entityType == 'corporateOffice' && !\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('Modules/Partners/Corporates-remoteDetails')) { $arr['type'] = 'string'; unset($arr['entity']); } else { $arr['entity']['type'] = $this->entityType; $arr['entity']['id'] = $this->idEntity; } return $arr; } }