Hi,

I'm a new owncloud users since few weeks ; and it's a great framework.
Now I can sync my playbook with evolution and owncloud in using carddav
and caldav.

I have added some workaround for playbook in waiting that the playbook
issues are fixed. But most of, I have added some fix for owncloud and I
wish share with you for integration or code review.

In attachment my fix and new features.

And to read my git repository from the web :
http://www.progweb.com/gitweb/?p=owncloud.git;a=summary

Regards,

Nicolas

>From bebb907c065d5763b69683e936236b1e6f8f1c1f Mon Sep 17 00:00:00 2001
From: Nicolas VIVIEN <[email protected]>
Date: Mon, 23 Apr 2012 16:03:48 +0200
Subject: [PATCH 01/11] VObject: fix RFC implementation about parameter

There is an issue into the serialization. Seen when you work with
CardDAV, since vCard format is set from the client (in my test,
blackberry device and/or Evolution)

--

RFC 2426:

2.3 Predefined VALUE Type Usage

   The predefined data type values specified in [MIME-DIR] MUST NOT be
   repeated in COMMA separated value lists except within the N,
   NICKNAME, ADR and CATEGORIES value types.

   The text value type defined in [MIME-DIR] is further restricted such
   that any SEMI-COLON character (ASCII decimal 59) in the value MUST be
   escaped with the BACKSLASH character (ASCII decimal 92).

Sample :

3.2.1 ADR Type Definition

[...]

      ADR;TYPE=dom,home,postal,parcel:;;123 Main
          Street;Any Town;CA;91921-1234

3.3.1 TEL Type Definition

[...]

      TEL;TYPE=work,voice,pref,msg:+1-213-555-1234
---
 3rdparty/Sabre/VObject/Parameter.php |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/3rdparty/Sabre/VObject/Parameter.php b/3rdparty/Sabre/VObject/Parameter.php
index 9ebab6e..c3e017b 100644
--- a/3rdparty/Sabre/VObject/Parameter.php
+++ b/3rdparty/Sabre/VObject/Parameter.php
@@ -54,13 +54,13 @@ class Sabre_VObject_Parameter extends Sabre_VObject_Node {
             '\\',
             "\n",
             ';',
-            ',',
+//            ',',
         );
         $out = array(
             '\\\\',
             '\n',
             '\;',
-            '\,',
+//            '\,',
         );
 
         return $this->name . '=' . str_replace($src, $out, $this->value);
-- 
1.7.10

>From e024a49e2aeccc888fcbccf1cabb039bd1a26c75 Mon Sep 17 00:00:00 2001
From: Nicolas VIVIEN <[email protected]>
Date: Mon, 23 Apr 2012 16:25:09 +0200
Subject: [PATCH 02/11] Contacts: Fix retrieve apps version in using API

---
 apps/contacts/lib/vcard.php |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index 90b037f..53c9526 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -214,7 +214,8 @@ class OC_Contacts_VCard{
 		$prodid = trim($vcard->getAsString('PRODID'));
 		if(!$prodid) {
 			$appinfo = OC_App::getAppInfo('contacts');
-			$prodid = '-//ownCloud//NONSGML '.$appinfo['name'].' '.$appinfo['version'].'//EN';
+			$appversion = OC_App::getAppVersion('contacts');
+			$prodid = '-//ownCloud//NONSGML '.$appinfo['name'].' '.$appversion.'//EN';
 			$vcard->setString('PRODID', $prodid);
 		}
 		$now = new DateTime;
-- 
1.7.10

>From 67938248589983b06e6b4d61c4f44eb6b06a42d3 Mon Sep 17 00:00:00 2001
From: Nicolas VIVIEN <[email protected]>
Date: Mon, 23 Apr 2012 17:06:40 +0200
Subject: [PATCH 03/11] Contacts: Fix JavaScript contacts type tests.

JavaScript implementation isn't compliant with RFC.

--

RFC 2426:

Indeed, from RFC, we can have :

TYPE=CELL;TYPE=MSG;TYPE=HOME
or
TYPE=cell;TYPE=msg;TYPE=home
or
TYPE=cell,msg,home

The third case wasn't managed
---
 apps/contacts/js/contacts.js |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index f03ae1e..8e831ad 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -1263,7 +1263,7 @@ Contacts={
 							for(ptype in this.data.TEL[phone]['parameters'][param]) {
 								var pt = this.data.TEL[phone]['parameters'][param][ptype];
 								$('#phonelist li:last-child').find('select option').each(function(){
-									if ($(this).val().toUpperCase() == pt.toUpperCase()) {
+									if ($.inArray($(this).val().toUpperCase(), pt.toUpperCase().split(',')) > -1) {
 										$(this).attr('selected', 'selected');
 									}
 								});
-- 
1.7.10

>From d0df99cb0f0f58d4ff43879fbaa2c889d0bd66c6 Mon Sep 17 00:00:00 2001
From: Nicolas VIVIEN <[email protected]>
Date: Mon, 23 Apr 2012 17:10:06 +0200
Subject: [PATCH 04/11] Contacts: Add parameter MSG type

It permits to avoid the information when it set from a carddav client.
---
 apps/contacts/lib/app.php |    1 +
 1 file changed, 1 insertion(+)

diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
index 475d2c8..2c2cc33 100644
--- a/apps/contacts/lib/app.php
+++ b/apps/contacts/lib/app.php
@@ -149,6 +149,7 @@ class OC_Contacts_App {
 				'WORK'  =>  $l->t('Work'),
 				'TEXT'  =>  $l->t('Text'),
 				'VOICE' =>  $l->t('Voice'),
+				'MSG'   =>  $l->t('Message'),
 				'FAX'   =>  $l->t('Fax'),
 				'VIDEO' =>  $l->t('Video'),
 				'PAGER' =>  $l->t('Pager'),
-- 
1.7.10

>From 173b99e0fde40f93ab552d1c29eb2a9d6df75c15 Mon Sep 17 00:00:00 2001
From: Nicolas VIVIEN <[email protected]>
Date: Mon, 23 Apr 2012 19:30:42 +0200
Subject: [PATCH 05/11] Contacts: Add email type fields (WORK,HOME...)

---
 apps/contacts/ajax/loadcard.php          |    2 ++
 apps/contacts/ajax/loadintro.php         |    2 ++
 apps/contacts/ajax/newcontact.php        |    2 ++
 apps/contacts/css/contacts.css           |    6 +++---
 apps/contacts/index.php                  |    2 ++
 apps/contacts/js/contacts.js             |   31 ++++++++++++++++++++++++++++++
 apps/contacts/lib/app.php                |    8 ++++++++
 apps/contacts/templates/part.contact.php |    6 +++++-
 8 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php
index 037fe2a..5890eef 100644
--- a/apps/contacts/ajax/loadcard.php
+++ b/apps/contacts/ajax/loadcard.php
@@ -46,12 +46,14 @@ $freeSpace=OC_Filesystem::free_space('/');
 $freeSpace=max($freeSpace,0);
 $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
 $adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
+$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
 $phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
 
 $tmpl = new OC_Template('contacts','part.contact');
 $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
 $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
 $tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('email_types',$email_types);
 $tmpl->assign('phone_types',$phone_types);
 $tmpl->assign('id','');
 $page = $tmpl->fetchPage();
diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php
index 8e56736..ba8aba4 100644
--- a/apps/contacts/ajax/loadintro.php
+++ b/apps/contacts/ajax/loadintro.php
@@ -48,12 +48,14 @@ OC_JSON::checkAppEnabled('contacts');
 // $freeSpace=max($freeSpace,0);
 // $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
 // $adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
+// $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
 // $phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
 
 $tmpl = new OC_Template('contacts','part.no_contacts');
 // $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
 // $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
 // $tmpl->assign('adr_types',$adr_types);
+// $tmpl->assign('email_types',$email_types);
 // $tmpl->assign('phone_types',$phone_types);
 // $tmpl->assign('addressbooks',$addressbooks);
 // $tmpl->assign('id','');
diff --git a/apps/contacts/ajax/newcontact.php b/apps/contacts/ajax/newcontact.php
index fcfd12c..32ba4e1 100644
--- a/apps/contacts/ajax/newcontact.php
+++ b/apps/contacts/ajax/newcontact.php
@@ -48,12 +48,14 @@ $freeSpace=OC_Filesystem::free_space('/');
 $freeSpace=max($freeSpace,0);
 $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
 $adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
+$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
 $phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
 
 $tmpl = new OC_Template('contacts','part.contact');
 $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
 $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
 $tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('email_types',$email_types);
 $tmpl->assign('phone_types',$phone_types);
 $tmpl->assign('addressbooks',$addressbooks);
 $tmpl->assign('id','');
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index b0c68c9..96a6893 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -91,9 +91,9 @@ dl.addresscard dd > ul { margin: 0.3em; padding: 0.3em; }
 input[type="checkbox"] { width: 20px; height: 20px; vertical-align: bottom; }
 .big { font-weight:bold; font-size:1.2em; }
 .huge { font-weight:bold; font-size:1.5em; }
-.propertycontainer dd { float: left; width: 25em; }
-.propertylist { clear: none; max-width: 28em; }
-.propertylist li { /*background-color: cyan; */ min-width: 25em; /*max-width: 30em;*/ display: block; clear: right; }
+.propertycontainer dd { float: left; width: 35em; }
+.propertylist { clear: none; max-width: 38em; }
+.propertylist li { /*background-color: cyan; */ min-width: 35em; /*max-width: 30em;*/ display: block; clear: right; }
 .propertylist li > input[type="text"],input[type="email"],input[type="tel"] { float: left; max-width: 15em; }
 .propertylist li > input[type="checkbox"],input[type="radio"] { float: left; clear: left; width: 20px; height: 20px; vertical-align: middle; }
 .propertylist li > select { float: left; max-width: 8em; }
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 4039b8a..1355af7 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -34,6 +34,7 @@ if(!is_null($id)) {
 }
 $property_types = OC_Contacts_App::getAddPropertyOptions();
 $phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
+$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
 $categories = OC_Contacts_App::getCategories();
 
 $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
@@ -61,6 +62,7 @@ $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
 $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
 $tmpl->assign('property_types', $property_types);
 $tmpl->assign('phone_types', $phone_types);
+$tmpl->assign('email_types', $email_types);
 $tmpl->assign('categories', $categories);
 $tmpl->assign('addressbooks', $addressbooks);
 $tmpl->assign('contacts', $contacts);
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 8e831ad..ee20750 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -162,6 +162,13 @@ Contacts={
 										selectedList: 6,
 										classes: 'categories'
 									});*/
+			// Style email types
+			$('#emaillist').find('select.contacts_property').multiselect({
+													noneSelectedText: t('contacts', 'Select type'),
+													header: false,
+													selectedList: 4,
+													classes: 'typelist'
+												});
 			// Style phone types
 			$('#phonelist').find('select.contacts_property').multiselect({
 													noneSelectedText: t('contacts', 'Select type'),
@@ -1204,9 +1211,17 @@ Contacts={
 			addMail:function() {
 				//alert('addMail');
 				$('#emaillist li.template:first-child').clone().appendTo($('#emaillist')).show();
+				$('#emaillist li.template:last-child').find('select').addClass('contacts_property');
 				$('#emaillist li.template:last-child').removeClass('template').addClass('propertycontainer');
 				$('#emaillist li:last-child').find('input[type="email"]').focus();
 				Contacts.UI.loadListHandlers();
+				$('#emaillist li:last-child').find('select').multiselect({
+														noneSelectedText: t('contacts', 'Select type'),
+														header: false,
+														selectedList: 4,
+														classes: 'typelist'
+													});
+				$('#emaillist li:last-child').show();
 				return false;
 			},
 			loadMails:function() {
@@ -1215,13 +1230,29 @@ Contacts={
 				for(var mail in this.data.EMAIL) {
 					this.addMail();
 					//$('#emaillist li:first-child').clone().appendTo($('#emaillist')).show();
+					$('#emaillist li:last-child').find('select').multiselect('destroy');
 					$('#emaillist li:last-child').data('checksum', this.data.EMAIL[mail]['checksum'])
 					$('#emaillist li:last-child').find('input[type="email"]').val(this.data.EMAIL[mail]['value']);
 					for(var param in this.data.EMAIL[mail]['parameters']) {
 						if(param.toUpperCase() == 'PREF') {
 							$('#emaillist li:last-child').find('input[type="checkbox"]').attr('checked', 'checked')
 						}
+						else if(param.toUpperCase() == 'TYPE') {
+							var p = this.data.EMAIL[mail]['parameters'][param];
+							$('#emaillist li:last-child').find('select option').each(function(){
+							var t = $(this).val().toUpperCase();
+								if ($.inArray($(this).val().toUpperCase(), p.toUpperCase().split(',')) > -1) {
+									$(this).attr('selected', 'selected');
+								}
+							});
+						}
 					}
+					$('#emaillist li:last-child').find('select').multiselect({
+														noneSelectedText: t('contacts', 'Select type'),
+														header: false,
+														selectedList: 4,
+														classes: 'typelist'
+													});
 				}
 				if($('#emaillist li').length > 1) {
 					$('#emails').show();
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
index 2c2cc33..f84c8df 100644
--- a/apps/contacts/lib/app.php
+++ b/apps/contacts/lib/app.php
@@ -23,6 +23,7 @@ class OC_Contacts_App {
 	public static function renderDetails($id, $vcard, $new=false) {
 		$property_types = self::getAddPropertyOptions();
 		$adr_types = self::getTypesOfProperty('ADR');
+		$email_types = self::getTypesOfProperty('EMAIL');
 		$phone_types = self::getTypesOfProperty('TEL');
 		$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
 		$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
@@ -42,6 +43,7 @@ class OC_Contacts_App {
 		$tmpl->assign( 'uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
 		$tmpl->assign('property_types',$property_types);
 		$tmpl->assign('adr_types',$adr_types);
+		$tmpl->assign('email_types',$email_types);
 		$tmpl->assign('phone_types',$phone_types);
 		$page = $tmpl->fetchPage();
 
@@ -142,6 +144,12 @@ class OC_Contacts_App {
 				'WORK' => $l->t('Work'),
 				'HOME' => $l->t('Home'),
 			);
+		case 'EMAIL':
+			return array(
+				'WORK' => $l->t('Work'),
+				'HOME' => $l->t('Home'),
+				'INTERNET' => $l->t('Internet'),
+			);
 		case 'TEL':
 			return array(
 				'HOME'  =>  $l->t('Home'),
diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php
index b90fa92..8e104ef 100644
--- a/apps/contacts/templates/part.contact.php
+++ b/apps/contacts/templates/part.contact.php
@@ -73,7 +73,11 @@ $id = isset($_['id']) ? $_['id'] : '';
 			<ul id="emaillist" class="propertylist">
 			<li class="template" style="white-space: nowrap; display: none;" data-element="EMAIL">
 				<input type="checkbox" class="contacts_property tip" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" />
-				<input type="email" required="required" class="nonempty contacts_property" style="width:15em;" name="value" value="" x-moz-errormessage="<?php echo $l->t('Please specify a valid email address.'); ?>" placeholder="<?php echo $l->t('Enter email address'); ?>" /><span class="listactions"><a onclick="Contacts.UI.mailTo(this)" class="action mail" title="<?php echo $l->t('Mail to address'); ?>"></a>
+				<input type="email" required="required" class="nonempty contacts_property" style="width:15em;" name="value" value="" x-moz-errormessage="<?php echo $l->t('Please specify a valid email address.'); ?>" placeholder="<?php echo $l->t('Enter email address'); ?>" />
+				<select multiple="multiple" name="parameters[TYPE][]">
+					<?php echo html_select_options($_['email_types'], array()) ?>
+				</select>
+				<span class="listactions"><a onclick="Contacts.UI.mailTo(this)" class="action mail" title="<?php echo $l->t('Mail to address'); ?>"></a>
 				<a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'list');" title="<?php echo $l->t('Delete email address'); ?>"></a></span></li>
 			</ul><!-- a id="add_email" class="add" title="<?php echo $l->t('Add email address'); ?>"></a -->
 		</div> <!-- email addresses-->
-- 
1.7.10

_______________________________________________
Owncloud mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/owncloud

Reply via email to