new: Added getEventInfoById API

pull/3161/head
iglocska 2018-04-17 13:43:47 +02:00
parent 00aab4a81e
commit 9b2e212b3d
2 changed files with 26 additions and 0 deletions

View File

@ -104,6 +104,7 @@ class ACLComponent extends Component {
'filterEventIdsForPush' => array('perm_sync'),
'filterEventIndex' => array('*'),
'freeTextImport' => array('perm_add'),
'getEventInfoById' => array('*'),
'getReferences' => array('*'),
'getReferenceData' => array('*'),
'hids' => array('*'),

View File

@ -4738,4 +4738,29 @@ class EventsController extends AppController {
$this->redirect($this->referer());
}
}
public function getEventInfoById($id) {
$conditions = array('Event.id' => $id);
if (Validation::uuid($id)) {
$conditions = array('Event.uuid' => $id);
}
$event = $this->Event->find('first', array(
'conditions' => $conditions,
'fields' => array('Event.id', 'Event.distribution', 'Event.sharing_group_id', 'Event.info', 'Event.org_id'),
'recursive' => -1
));
if (!empty($event) && !$this->_isSiteAdmin() && $event['Event']['org_id'] != $this->Auth->user('org_id')) {
if (!in_array($event['Event']['distribution'], array(1, 2, 3))) {
if ($event['Event']['distribution'] == 4) {
$sharingGroups = $this->Event->SharingGroup->fetchAllAuthorised($this->Auth->user());
if (!in_array($event['Event']['sharing_group_id'], $sharingGroups)) {
$event = array();
}
} else {
$event = array();
}
}
}
return $this->RestResponse->viewData($event, $this->response->type());
}
}