make pull work on an event with just one attribute.
pull/63/head
noud 2012-11-09 13:01:00 +01:00
parent 911c9a8da6
commit dd979f7325
1 changed files with 15 additions and 2 deletions

View File

@ -189,8 +189,7 @@ class ServersController extends AppController {
if ($event['Event']['distribution'] == 'All') {
$event['Event']['distribution'] = 'Community';
}
if (is_array($event['Event']['Attribute'])) {
if (is_array($event['Event']['Attribute']) && !isset($event['Event']['Attribute']['id'])) {
$toRemove = array();
$size = sizeof($event['Event']['Attribute']);
for ($i = 0; $i < $size; $i++) {
@ -212,6 +211,20 @@ class ServersController extends AppController {
unset($event['Event']['Attribute'][$thisRemove]);
}
$event['Event']['Attribute'] = array_values($event['Event']['Attribute']);
} elseif (is_array($event['Event']['Attribute']) && isset($event['Event']['Attribute']['id'])) {
switch($event['Event']['Attribute']['distribution']) {
case 'Org':
unset($event['Event']['Attribute']);
break;
case 'Community':
$event['Event']['Attribute']['private'] = true;
$event['Event']['Attribute']['distribution'] = 'Org';
break;
case 'All':
$event['Event']['Attribute']['cluster'] = true;
$event['Event']['Attribute']['distribution'] = 'Community';
break;
}
}
// Distribution, set reporter of the event, being the admin that initiated the pull
$event['Event']['user_id'] = $this->Auth->user('id');