Don't add address if none of the fields are filled out.
This commit is contained in:
parent
b71ea287aa
commit
c6eeb4a808
|
@ -35,10 +35,22 @@ $name = $_POST['name'];
|
||||||
$value = $_POST['value'];
|
$value = $_POST['value'];
|
||||||
if(!is_array($value)){
|
if(!is_array($value)){
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
if(!$value && in_array($name, array('TEL', 'EMAIL'))) {
|
if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG'))) {
|
||||||
OC_JSON::error(array('data' => array('message' => $l->t('Cannot add empty property.'))));
|
OC_JSON::error(array('data' => array('message' => $l->t('Cannot add empty property.'))));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
} elseif($name === 'ADR') { // only add if non-empty elements.
|
||||||
|
$empty = true;
|
||||||
|
foreach($value as $part) {
|
||||||
|
if(trim($part) != '') {
|
||||||
|
$empty = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($empty) {
|
||||||
|
OC_JSON::error(array('data' => array('message' => $l->t('At least one of the address fields has to be filled out.'))));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$parameters = isset($_POST['parameters']) ? $_POST['parameters'] : array();
|
$parameters = isset($_POST['parameters']) ? $_POST['parameters'] : array();
|
||||||
|
|
||||||
|
@ -49,7 +61,7 @@ $line = count($vcard->children) - 1;
|
||||||
// Apparently Sabre_VObject_Parameter doesn't do well with multiple values or I don't know how to do it. Tanghus.
|
// Apparently Sabre_VObject_Parameter doesn't do well with multiple values or I don't know how to do it. Tanghus.
|
||||||
foreach ($parameters as $key=>$element) {
|
foreach ($parameters as $key=>$element) {
|
||||||
if(is_array($element) && strtoupper($key) == 'TYPE') {
|
if(is_array($element) && strtoupper($key) == 'TYPE') {
|
||||||
// FIXME: Maybe this doesn't only apply for TYPE?
|
// NOTE: Maybe this doesn't only apply for TYPE?
|
||||||
// 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)){
|
||||||
|
|
Loading…
Reference in New Issue