diff --git a/js/contacts.js b/js/contacts.js index 2c9cb68b..b37383a1 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -443,7 +443,6 @@ Contacts={ } }); this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = ''; - var full = ''; var narray = undefined; if(this.data.FN) { this.fn = this.data.FN[0]['value']; @@ -453,7 +452,6 @@ Contacts={ } if(this.data.N == undefined) { narray = [this.fn,'','','','']; // Checking for non-existing 'N' property :-P - full = this.fn; } else { narray = this.data.N[0]['value']; } @@ -479,7 +477,6 @@ Contacts={ } $('#n').html(this.fullname); $('#fn_select option').remove(); - $('#fn_select').combobox('value', this.fn); var names = [this.fullname, this.givname + ' ' + this.famname, this.famname + ' ' + this.givname, this.famname + ', ' + this.givname]; if(this.data.ORG) { names[names.length]=this.data.ORG[0].value; @@ -489,6 +486,7 @@ Contacts={ .append($('') .text(value)); }); + $('#fn_select').combobox('value', this.fn); $('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']); if(this.data.FN) { $('#contact_identity').find('*[data-element="FN"]').data('checksum', this.data.FN[0]['checksum']); @@ -564,6 +562,22 @@ Contacts={ var checksum = container.data('checksum'); var name = container.data('element'); var fields = container.find('input.contacts_property,select.contacts_property').serializeArray(); + switch(name) { + case 'FN': + var nempty = true; + for(var i in Contacts.UI.Card.data.N[0]['value']) { + if(Contacts.UI.Card.data.N[0]['value'][i] != '') { + nempty = false; + break; + } + } + if(nempty) { + $('#n').val(fields[0].value + ';;;;'); + Contacts.UI.Card.data.N[0]['value'] = Array(fields[0].value, '', '', '', ''); + setTimeout(function() {Contacts.UI.Card.saveProperty($('#n'))}, 500); + } + break; + } var q = container.find('input.contacts_property,select.contacts_property,textarea.contacts_property').serialize(); if(q == '' || q == undefined) { OC.dialogs.alert(t('contacts', 'Couldn\'t serialize elements.'), t('contacts', 'Error')); diff --git a/lib/vcard.php b/lib/vcard.php index c2ab0e07..91ae3a75 100755 --- a/lib/vcard.php +++ b/lib/vcard.php @@ -241,15 +241,6 @@ class OC_Contacts_VCard{ if(self::trueUID($aid, $uid)) { $vcard->setString('UID', $uid); } - $vcard->setString('VERSION','3.0'); - // Add product ID is missing. - $prodid = trim($vcard->getAsString('PRODID')); - if(!$prodid) { - $appinfo = OCP\App::getAppInfo('contacts'); - $appversion = OCP\App::getAppVersion('contacts'); - $prodid = '-//ownCloud//NONSGML '.$appinfo['name'].' '.$appversion.'//EN'; - $vcard->setString('PRODID', $prodid); - } $now = new DateTime; $vcard->setString('REV', $now->format(DateTime::W3C)); } @@ -272,6 +263,16 @@ class OC_Contacts_VCard{ self::updateValuesFromAdd($aid, $card); } + $card->setString('VERSION','3.0'); + // Add product ID is missing. + $prodid = trim($card->getAsString('PRODID')); + if(!$prodid) { + $appinfo = OCP\App::getAppInfo('contacts'); + $appversion = OCP\App::getAppVersion('contacts'); + $prodid = '-//ownCloud//NONSGML '.$appinfo['name'].' '.$appversion.'//EN'; + $card->setString('PRODID', $prodid); + } + $fn = $card->getAsString('FN'); if (empty($fn)) { $fn = '';