fixes download-sync-bug when only one event is present on the remote

instance
pull/61/head
Christophe Vandeplas 2012-10-22 15:53:36 +02:00
parent 311a09e2b0
commit 9ae92ddd5c
1 changed files with 12 additions and 4 deletions

View File

@ -413,11 +413,19 @@ class Event extends AppModel {
$xml = Xml::build($response->body);
$eventArray = Xml::toArray($xml);
$eventIds = array();
foreach ($eventArray['response']['Event'] as &$event) {
if (1 != $event['published']) {
continue; // do not keep non-published events
// different actions if it's only 1 event or more
// only one event.
if (isset($eventArray['response']['Event']['id'])) {
$eventIds[] = $eventArray['response']['Event']['id'];
}
else {
// multiple events, iterate over the array
foreach ($eventArray['response']['Event'] as &$event) {
if (1 != $event['published']) {
continue; // do not keep non-published events
}
$eventIds[] = $event['id'];
}
$eventIds[] = $event['id'];
}
return $eventIds;
}