summaryrefslogtreecommitdiffstats
path: root/apps/contacts
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-01-12 02:34:22 +0100
committerThomas Tanghus <thomas@tanghus.net>2012-01-12 02:39:33 +0100
commitc6eeb4a8080487075fca587653879a3308f7597a (patch)
tree4a5ddcebd8c810d6fd8c430f09247fdf808a1ace /apps/contacts
parentb71ea287aac37237c948ae9f8c825ddda0601857 (diff)
downloadnextcloud-server-c6eeb4a8080487075fca587653879a3308f7597a.tar.gz
nextcloud-server-c6eeb4a8080487075fca587653879a3308f7597a.zip
Don't add address if none of the fields are filled out.
Diffstat (limited to 'apps/contacts')
-rw-r--r--apps/contacts/ajax/addproperty.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 6e3ba3566c0..0050f5f49aa 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -35,10 +35,22 @@ $name = $_POST['name'];
$value = $_POST['value'];
if(!is_array($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.'))));
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();
@@ -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.
foreach ($parameters as $key=>$element) {
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 :-/
foreach($element as $e){
if($e != '' && !is_null($e)){