Various bugfixes

pull/762/head
iglocska 2015-10-18 23:10:25 +02:00
parent ae4d0af532
commit e63d10f0d4
3 changed files with 13 additions and 13 deletions

View File

@ -624,14 +624,14 @@ class Event extends AppModel {
}
}
try { // TODO Xml::build() does not throw the XmlException
$xml = Xml::build($newTextBody);
} catch (XmlException $e) {
$json = json_decode($newTextBody);
} catch (Exception $e) {
//throw new InternalErrorException();
return false;
}
// get the remote event_id
foreach ($xml as $xmlEvent) {
foreach ($xmlEvent as $key => $value) {
foreach ($json as $jsonEvent) {
foreach ($jsonEvent as $key => $value) {
if ($key == 'id') {
$remoteId = (int)$value;
break;
@ -645,7 +645,7 @@ class Event extends AppModel {
$attribute['event_id'] = $remoteId;
}
// get the already existing attributes and delete the ones that are not there
foreach ($xml->Event->Attribute as $attribute) {
foreach ($json->Event->Attribute as $attribute) {
foreach ($attribute as $key => $value) {
if ($key == 'uuid') {
if (!in_array((string)$value, $newerUuids)) {

View File

@ -271,7 +271,8 @@ class SysLogLogableBehavior extends LogableBehavior {
}
$this->schema = $this->Log->schema();
App::import('Component', 'Auth');
if (!empty(AuthComponent::user())) $this->user[$this->settings[$Model->alias]['userModel']] = AuthComponent::user();
$user = AuthComponent::user();
if (!empty($user)) $this->user[$this->settings[$Model->alias]['userModel']] = AuthComponent::user();
else $this->user['User'] = array('email' => 'SYSTEM', 'Organisation' => array('name' => 'SYSTEM'), 'id' => 0);
}
}
}

View File

@ -1,12 +1,12 @@
<?php
foreach ($events as $key => &$event) {
foreach ($events as $key => $event) {
// rearrange things to be compatible with the Xml::fromArray()
$events[$key]['Event']['Org'] = $events[$key]['Org'];
$events[$key]['Event']['Orgc'] = $events[$key]['Orgc'];
$events[$key]['Event']['EventTag'] = $events[$key]['EventTag'];
$events[$key]['Event']['SharingGroup'] = $events[$key]['SharingGroup'];
$events[$key] = $events[$key]['Event'];
unset($events[$key]['Event']);
$events[$key]['Org'] = $event['Org'];
$events[$key]['Orgc'] = $event['Orgc'];
if (isset($event['EventTag'])) $events[$key]['EventTag'] = $event['EventTag'];
$events[$key]['SharingGroup'] = $event['SharingGroup'];
// cleanup the array from things we do not want to expose
unset($events[$key]['user_id']);
@ -15,6 +15,5 @@ foreach ($events as $key => &$event) {
unset($events[$key]['Org']);
unset($events[$key]['Orgc']);
}
}
echo json_encode($events);