From eae3e134ff9005e50ea4e611b2c2daba94ad49ea Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Wed, 11 Jan 2012 06:20:06 +0100 Subject: [PATCH] Make sure VERSION is set. Set REV for each edit. Download single VCard. --- apps/contacts/css/styles.css | 3 ++- apps/contacts/export.php | 2 +- apps/contacts/js/interface.js | 4 +++- apps/contacts/lib/vcard.php | 21 +++++++++++++++++---- apps/contacts/templates/part.details.php | 1 + 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/apps/contacts/css/styles.css b/apps/contacts/css/styles.css index dfc296a221..4fcd8fc113 100644 --- a/apps/contacts/css/styles.css +++ b/apps/contacts/css/styles.css @@ -4,7 +4,8 @@ #contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;} #contacts_details_photo { margin:.5em 0em .5em 25%; } -#contacts_deletecard {position:absolute;top:15px;right:15px;} +#contacts_deletecard {position:absolute;top:15px;right:25px;} +#contacts_downloadcard {position:absolute;top:15px;right:50px;} #contacts_details_list { list-style:none; } #contacts_details_list li { overflow:visible; } #contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em;color:#666; } diff --git a/apps/contacts/export.php b/apps/contacts/export.php index a1e974c962..735d1c5b63 100644 --- a/apps/contacts/export.php +++ b/apps/contacts/export.php @@ -33,7 +33,7 @@ if(isset($book)){ exit; } header('Content-Type: text/directory'); - header('Content-Disposition: inline; filename=' . $data['fullname'] . '.vcf'); + header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $data['fullname']) . '.vcf'); echo $data['carddata']; } ?> diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js index 9547c581c8..741483633d 100644 --- a/apps/contacts/js/interface.js +++ b/apps/contacts/js/interface.js @@ -197,6 +197,7 @@ $(document).ready(function(){ * Delete currently selected contact (and clear form?) */ $('#contacts_deletecard').live('click',function(){ + $('#contacts_deletecard').tipsy('hide'); var id = $('#rightcontent').data('id'); $.getJSON('ajax/deletecard.php',{'id':id},function(jsondata){ if(jsondata.status == 'success'){ @@ -401,7 +402,8 @@ $(document).ready(function(){ } }); - $('.action').tipsy(); + $('#contacts_deletecard').tipsy(); + $('#contacts_downloadcard').tipsy(); $('.button').tipsy(); //Contacts.UI.messageBox('Hello','Sailor'); }); diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 401f962254..726927013c 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -111,16 +111,21 @@ class OC_Contacts_VCard{ if(is_null($uid)){ $card->setUID(); $uid = $card->getAsString('UID'); - $data = $card->serialize(); + //$data = $card->serialize(); }; $uri = $uid.'.vcf'; // VCARD must have a version $version = $card->getAsString('VERSION'); // Add version if needed - if(is_null($version)){ + if(!$version){ $card->add(new Sabre_VObject_Property('VERSION','3.0')); - $data = $card->serialize(); - } + //$data = $card->serialize(); + }/* else { + OC_Log::write('contacts','OC_Contacts_VCard::add. Version already set as: '.$version,OC_Log::DEBUG); + }*/ + $now = new DateTime; + $card->setString('REV', $now->format(DateTime::W3C)); + $data = $card->serialize(); } else{ // that's hard. Creating a UID and not saving it @@ -182,7 +187,12 @@ class OC_Contacts_VCard{ break; } } + } else { + return false; } + $now = new DateTime; + $card->setString('REV', $now->format(DateTime::W3C)); + $data = $card->serialize(); $stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' ); $result = $stmt->execute(array($fn,$data,time(),$id)); @@ -212,6 +222,9 @@ class OC_Contacts_VCard{ } } } + $now = new DateTime; + $card->setString('REV', $now->format(DateTime::W3C)); + $data = $card->serialize(); $stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' ); $result = $stmt->execute(array($fn,$data,time(),$oldcard['id'])); diff --git a/apps/contacts/templates/part.details.php b/apps/contacts/templates/part.details.php index 1482c06368..fe0dac235b 100644 --- a/apps/contacts/templates/part.details.php +++ b/apps/contacts/templates/part.details.php @@ -1,5 +1,6 @@ inc('part.property.FN', array('property' => $_['details']['FN'][0])); ?> +