From 978a08ab1c5e425210e8128e6d8efa432d593571 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 9 Jan 2012 01:17:04 +0100 Subject: [PATCH] Fixed Phone types not being saved correctly when adding them. --- apps/contacts/ajax/addproperty.php | 20 ++++++++++++++++++- apps/contacts/templates/part.property.php | 5 ++--- .../templates/part.setpropertyform.php | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 98877805b46..0122cf019c7 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -34,13 +34,31 @@ $name = $_POST['name']; $value = $_POST['value']; $parameters = isset($_POST['parameters'])?$_POST['parameters']:array(); -$property = $vcard->addProperty($name, $value, $parameters); +$property = $vcard->addProperty($name, $value); //, $parameters); $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? + // And it probably shouldn't be done here anyways :-/ + foreach($element as $e){ + if($e != '' && !is_null($e)){ + $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$e); + } + } + } +} + OC_Contacts_VCard::edit($id,$vcard->serialize()); +$adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); +$phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); + $tmpl = new OC_Template('contacts','part.property'); +$tmpl->assign('adr_types',$adr_types); +$tmpl->assign('phone_types',$phone_types); $tmpl->assign('property',OC_Contacts_VCard::structureProperty($property,$line)); $page = $tmpl->fetchPage(); diff --git a/apps/contacts/templates/part.property.php b/apps/contacts/templates/part.property.php index d930a9ca99d..e4010397500 100644 --- a/apps/contacts/templates/part.property.php +++ b/apps/contacts/templates/part.property.php @@ -25,15 +25,14 @@ t(ucwords(strtolower($type))); } - endforeach; + } $label = join(' ', $types); ?> () diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php index 8635d7db1ce..3e0b8d49b52 100644 --- a/apps/contacts/templates/part.setpropertyform.php +++ b/apps/contacts/templates/part.setpropertyform.php @@ -45,7 +45,7 @@

-- 2.39.5