diff --git a/ajax/addcard.php b/ajax/addcard.php index ee955137..70e0f0a8 100644 --- a/ajax/addcard.php +++ b/ajax/addcard.php @@ -44,9 +44,10 @@ $vcard->add(new Sabre_VObject_Property('UID',OC_Contacts_VCard::createUID())); $id = OC_Contacts_VCard::add($aid,$vcard->serialize()); $details = OC_Contacts_VCard::structureContact($vcard); +$name = $details['FN'][0]['value']; $tmpl = new OC_Template('contacts','part.details'); $tmpl->assign('details',$details); $tmpl->assign('id',$id); $page = $tmpl->fetchPage(); -OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page ))); +OC_JSON::success(array('data' => array( 'id' => $id, 'name' => $name, 'page' => $page ))); diff --git a/ajax/addproperty.php b/ajax/addproperty.php index 0b218c62..68c4f65f 100644 --- a/ajax/addproperty.php +++ b/ajax/addproperty.php @@ -53,16 +53,7 @@ $name = $_POST['name']; $value = $_POST['value']; $parameters = isset($_POST['parameteres'])?$_POST['parameters']:array(); -if(is_array($value)){ - $value = OC_Contacts_VCard::escapeSemicolons($value); -} -$property = new Sabre_VObject_Property( $name, $value ); -$parameternames = array_keys($parameters); -foreach($parameternames as $i){ - $property->parameters[] = new Sabre_VObject_Parameter($i,$parameters[$i]); -} - -$vcard->add($property); +OC_Contacts_VCard::addVCardProperty($vcard, $name, $value, $parameters); $line = count($vcard->children) - 1; $checksum = md5($property->serialize()); diff --git a/lib/vcard.php b/lib/vcard.php index 1c9a8049..78327ab1 100644 --- a/lib/vcard.php +++ b/lib/vcard.php @@ -272,6 +272,26 @@ class OC_Contacts_VCard{ return $array; } + /** + * @brief Add property to vcard object + * @param object $vcard + * @param object $name of property + * @param object $value of property + * @param object $paramerters of property + */ + public static function addVCardProperty($vcard, $name, $value, $parameters=array()){ + if(is_array($value)){ + $value = OC_Contacts_VCard::escapeSemicolons($value); + } + $property = new Sabre_VObject_Property( $name, $value ); + $parameternames = array_keys($parameters); + foreach($parameternames as $i){ + $property->parameters[] = new Sabre_VObject_Parameter($i,$parameters[$i]); + } + + $vcard->add($property); + } + /** * @brief Data structure of vCard * @param object $property diff --git a/templates/part.addcardform.php b/templates/part.addcardform.php index e87c6450..c7d668fa 100644 --- a/templates/part.addcardform.php +++ b/templates/part.addcardform.php @@ -11,5 +11,41 @@
+ +
+ +

+

+

+

+

+

+

+
+ +
+ + +
+ +
+ +
+ +
+ +