Don't add empty property parameters.

This commit is contained in:
Thomas Tanghus 2012-08-23 01:18:59 +02:00
parent 1df596e758
commit 99d17c5190
2 changed files with 18 additions and 10 deletions

View File

@ -141,11 +141,15 @@ foreach ($parameters as $key=>$element) {
// And it probably shouldn't be done here anyways :-/ // And it probably shouldn't be done here anyways :-/
foreach($element as $e) { foreach($element as $e) {
if($e != '' && !is_null($e)) { if($e != '' && !is_null($e)) {
$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e); if(trim($e)) {
$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e);
}
} }
} }
} else { } else {
if(trim($element)) {
$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $element); $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $element);
}
} }
} }
$checksum = md5($vcard->children[$line]->serialize()); $checksum = md5($vcard->children[$line]->serialize());

View File

@ -133,17 +133,21 @@ if(!$value) {
debug('Adding parameter: '.$key); debug('Adding parameter: '.$key);
if(is_array($parameter)) { if(is_array($parameter)) {
foreach($parameter as $val) { foreach($parameter as $val) {
debug('Adding parameter: '.$key.'=>'.$val); if(trim($val)) {
$vcard->children[$line]->add(new Sabre_VObject_Parameter( debug('Adding parameter: '.$key.'=>'.$val);
$key, $vcard->children[$line]->add(new Sabre_VObject_Parameter(
strtoupper(strip_tags($val))) $key,
); strtoupper(strip_tags($val)))
);
}
} }
} else { } else {
$vcard->children[$line]->add(new Sabre_VObject_Parameter( if(trim($parameter)) {
$key, $vcard->children[$line]->add(new Sabre_VObject_Parameter(
strtoupper(strip_tags($parameter))) $key,
); strtoupper(strip_tags($parameter)))
);
}
} }
} }
} }