summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-05-11 01:13:19 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-05-11 01:14:11 +0200
commite5840e1fe27bbeec8ce4894c70c50d5c9b787982 (patch)
tree3d72a875583464725baf9437985f80ac57a87b5e /apps
parentaa516392710fc09961f3c4e3b7dd3d07b13b1e00 (diff)
downloadnextcloud-server-e5840e1fe27bbeec8ce4894c70c50d5c9b787982.tar.gz
nextcloud-server-e5840e1fe27bbeec8ce4894c70c50d5c9b787982.zip
Contacts: Hack to add structured name from formatted name.
Diffstat (limited to 'apps')
-rw-r--r--apps/contacts/js/contacts.js20
-rwxr-xr-xapps/contacts/lib/vcard.php19
2 files changed, 27 insertions, 12 deletions
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 2c9cb68b003..b37383a12f4 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/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($('<option></option>')
.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/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index c2ab0e07e91..91ae3a7514d 100755
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/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 = '';