public function testGroupProperty() { $arr = array('Home', 'work', 'Friends, Family'); $property = \Sabre\VObject\Property::create('CATEGORIES'); $property->setParts($arr); // Test parsing and serializing $this->assertEquals('Home,work,Friends\\, Family', $property->value); $this->assertEquals('CATEGORIES:Home,work,Friends\\, Family' . "\r\n", $property->serialize()); $this->assertEquals(3, count($property->getParts())); // Test add $property->addGroup('Coworkers'); $this->assertTrue($property->hasGroup('coworkers')); $this->assertEquals(4, count($property->getParts())); $this->assertEquals('Home,work,Friends\\, Family,Coworkers', $property->value); // Test remove $this->assertTrue($property->hasGroup('Friends, fAmIlY')); $property->removeGroup('Friends, fAmIlY'); $this->assertEquals(3, count($property->getParts())); $parts = $property->getParts(); $this->assertEquals('Coworkers', $parts[2]); // Test rename $property->renameGroup('work', 'Work'); $parts = $property->getParts(); $this->assertEquals('Work', $parts[1]); //$this->assertEquals(true, false); }
/** * Create online calendar for user * * @Route("/{username}.ics") * * @param string $username User to create the calendar for * @return Symfony\Component\HttpFoundation\Response */ public function calendarAction($username) { $user = $this->get('user_provider')->loadUserByUsername($username); $om = $this->getObjectManager('VIB\\FliesBundle\\Entity\\Vial'); $calendar = VObject\Component::create('VCALENDAR'); $calendar->VERSION = '2.0'; $field = 'X-WR-CALNAME'; $calendar->{$field} = $user->getShortName() . '\'s flywork'; $stockDates = $om->getRepository('VIB\\FliesBundle\\Entity\\StockVial')->getFlipDates($user); foreach ($stockDates as $stockDate) { $event = VObject\Component::create('VEVENT'); $calendar->add($event); $event->SUMMARY = 'Transfer stocks'; $dtstart = VObject\Property::create('DTSTART'); $dtstart->setDateTime($stockDate, VObject\Property\DateTime::DATE); $event->DTSTART = $dtstart; $alarm = VObject\Component::create('VALARM'); $event->add($alarm); $alarm->TRIGGER = 'PT8H'; $alarm->ACTION = 'DISPLAY'; } $crossDates = $om->getRepository('VIB\\FliesBundle\\Entity\\CrossVial')->getFlipDates($user); foreach ($crossDates as $crossDate) { $crossDates[] = $crossDate; $event = VObject\Component::create('VEVENT'); $calendar->add($event); $event->SUMMARY = 'Check crosses'; $dtstart = VObject\Property::create('DTSTART'); $dtstart->setDateTime($crossDate, VObject\Property\DateTime::DATE); $event->DTSTART = $dtstart; $alarm = VObject\Component::create('VALARM'); $event->add($alarm); $alarm->TRIGGER = 'PT8H'; $alarm->ACTION = 'DISPLAY'; } return new Response($calendar->serialize(), 200, array('Content-Type' => 'text/calendar; charset=utf-8', 'Content-Disposition' => 'inline; filename="calendar.ics"')); }
/** * Set a property by the property name. * It is up to the caller to call ->save() * * @param string $name Property name * @param mixed $value * @param array $parameters * @return bool */ public function setPropertyByName($name, $value, $parameters = array()) { // TODO: parameters are ignored for now. switch ($name) { case 'BDAY': try { $date = new \DateTime($value); } catch (\Exception $e) { \OCP\Util::writeLog('contacts', __METHOD__ . ' DateTime exception: ' . $e->getMessage(), \OCP\Util::ERROR); return false; } $value = $date->format('Y-m-d'); $this->BDAY = $value; $this->BDAY->add('VALUE', 'DATE'); //\OCP\Util::writeLog('contacts', __METHOD__.' BDAY: '.$this->BDAY->serialize(), \OCP\Util::DEBUG); break; case 'CATEGORIES': case 'N': case 'ORG': $property = $this->select($name); if (count($property) === 0) { $property = \Sabre\VObject\Property::create($name); $this->add($property); } else { // Actually no idea why this works $property = array_shift($property); } if (is_array($value)) { $property->setParts($value); } else { $this->{$name} = $value; } break; default: \OCP\Util::writeLog('contacts', __METHOD__ . ' adding: ' . $name . ' ' . $value, \OCP\Util::DEBUG); $this->{$name} = $value; break; } $this->setSaved(false); return true; }
/** * @brief returns the vcard property corresponding to the parameter * creates the property if it doesn't exists yet * @param $vcard the vcard to get or create the properties with * @param $importEntry the parameter to find * @return the property|false */ protected function getOrCreateVCardProperty(&$vcard, $importEntry) { if (isset($vcard) && isset($importEntry)) { // looking for a property with the same name $properties = $vcard->select($importEntry['property']); foreach ($properties as $property) { if ($importEntry['type'] == null && !isset($importEntry->additional_property)) { return $property; } foreach ($property->parameters as $parameter) { // Filtering types if ($parameter->name == 'TYPE' && !strcmp($parameter->value, $importEntry['type'])) { $found = 0; if (isset($importEntry->additional_property)) { // Filtering additional properties if necessary (I know, there are a lot of inner loops, sorry) foreach ($importEntry->additional_property as $additional_property) { if ((string) $parameter->name == $additional_property['name']) { $found++; } } if ($found == count($importEntry->additional_property)) { return $property; } } return $property; } } if (isset($importEntry['group']) && $property->group == $importEntry['group']) { return $property; } } // Property not found, creating one $property = \Sabre\VObject\Property::create($importEntry['property']); $vcard->add($property); if ($importEntry['type'] != null) { $property->parameters[] = new \Sabre\VObject\Parameter('TYPE', '' . StringUtil::convertToUTF8($importEntry['type'])); switch ($importEntry['property']) { case "ADR": $property->setValue(";;;;;;"); break; case "FN": $property->setValue(";;;;"); break; } } if ($importEntry['group'] != null) { $property->group = $importEntry['group']; } return $property; } else { return false; } }
/** * @brief converts an LDIF element into a VCard property * and updates the VCard * @param $value the LDIF value * @param $importEntry the VCard entry to modify * @param $dest the VCard to modify (for adding a X-FAVOURITE property) */ private function convertElementToProperty($value, $importEntry, &$dest) { if (isset($importEntry->vcard_favourites)) { foreach ($importEntry->vcard_favourites as $vcardFavourite) { if (strcasecmp((string)$vcardFavourite, trim($value)) == 0) { $property = \Sabre\VObject\Property::create("X-FAVOURITES", 'yes'); $dest->add($property); } else { $property = $this->getOrCreateVCardProperty($dest, $importEntry->vcard_entry); if (isset($importEntry['image']) && $importEntry['image'] == "true") { $this->updateImageProperty($property, $value); } else { $this->updateProperty($property, $importEntry, $value); } } } } else { $property = $this->getOrCreateVCardProperty($dest, $importEntry->vcard_entry); if (isset($importEntry['image']) && $importEntry['image'] == "true") { $this->updateImageProperty($property, $value); } else { $this->updateProperty($property, $importEntry, $value); } } }
$vcard->add($property); $checksum = substr(md5($property->serialize()), 0, 8); try { VCard::edit($id, $vcard); } catch (Exception $e) { bailOut($e->getMessage()); } \OCP\JSON::success(array('data' => array('checksum' => $checksum, 'oldchecksum' => $_POST['checksum']))); exit; } } else { $element = $name; $property = $vcard->select($name); debug('propertylist: ' . get_class($property)); if (count($property) === 0) { $property = VObject\Property::create($name); $vcard->add($property); } else { $property = array_shift($property); } } /* preprocessing value */ switch ($element) { case 'BDAY': $date = new \DateTime($value); $value = $date->format('Y-m-d'); break; case 'FN': if (!$value) { // create a method thats returns an alternative for FN. //$value = getOtherValue();
/** * @param $properties * @return mixed */ public function createOrUpdate($properties) { $id = null; /** * @var \OCA\Contacts\VObject\VCard */ $vcard = null; if (array_key_exists('id', $properties)) { // TODO: test if $id belongs to this addressbook $id = $properties['id']; // TODO: Test $vcard $vcard = $this->addressBook->getChild($properties['id']); foreach (array_keys($properties) as $name) { if (isset($vcard->{$name})) { unset($vcard->{$name}); } } } else { $vcard = \Sabre\VObject\Component::create('VCARD'); $uid = substr(md5(rand() . time()), 0, 10); $vcard->add('UID', $uid); try { $id = $this->addressBook->addChild($vcard); } catch (\Exception $e) { \OCP\Util::writeLog('contacts', __METHOD__ . ' ' . $e->getMessage(), \OCP\Util::ERROR); return false; } } foreach ($properties as $name => $value) { switch ($name) { case 'ADR': case 'N': if (is_array($value)) { $property = \Sabre\VObject\Property::create($name); $property->setParts($value); $vcard->add($property); } else { $vcard->{$name} = $value; } break; case 'BDAY': // TODO: try/catch $date = new \DateTime($value); $vcard->BDAY = $date->format('Y-m-d'); $vcard->BDAY->VALUE = 'DATE'; break; case 'EMAIL': case 'TEL': case 'IMPP': // NOTE: We don't know if it's GTalk, Jabber etc. only the protocol // NOTE: We don't know if it's GTalk, Jabber etc. only the protocol case 'URL': if (is_array($value)) { foreach ($value as $val) { $vcard->add($name, strip_tags($val)); } } else { $vcard->add($name, strip_tags($value)); } default: $vcard->{$name} = $value; break; } } try { VCard::edit($id, $vcard); } catch (\Exception $e) { \OCP\Util::writeLog('contacts', __METHOD__ . ' ' . $e->getMessage(), \OCP\Util::ERROR); return false; } $asarray = VCard::structureContact($vcard); $asarray['id'] = $id; return $asarray; }
/** * @brief converts a VCard into a owncloud VCard * @param $element the VCard element to convert * @return VCard|false */ public function convertElementToVCard($element) { try { $source = VObject\Reader::read($element, VObject\Reader::OPTION_FORGIVING); } catch (VObject\ParseException $error) { return false; } $dest = \Sabre\VObject\Component::create('VCARD'); foreach ($source->children() as $sourceProperty) { $importEntry = $this->getImportEntry($sourceProperty, $source); if ($importEntry) { $value = $sourceProperty->value; if (isset($importEntry['remove'])) { $value = str_replace($importEntry['remove'], '', $sourceProperty->value); } $values = array($value); if (isset($importEntry['separator'])) { $values = explode($importEntry['separator'], $value); } foreach ($values as $oneValue) { if (isset($importEntry->vcard_favourites)) { foreach ($importEntry->vcard_favourites as $vcardFavourite) { if (strcasecmp((string)$vcardFavourite, trim($oneValue)) == 0) { $property = \Sabre\VObject\Property::create("X-FAVOURITES", 'yes'); $dest->add($property); } else { $property = $this->getOrCreateVCardProperty($dest, $importEntry->vcard_entry); $this->updateProperty($property, $importEntry, trim($oneValue)); } } } else { $property = $this->getOrCreateVCardProperty($dest, $importEntry->vcard_entry); $this->updateProperty($property, $importEntry, $sourceProperty->value); } } } else { $property = clone $sourceProperty; $dest->add($property); } } $dest->validate(\Sabre\VObject\Component\VCard::REPAIR); return $dest; }
/** * Build a valid iCal format block from the given event * * @param array Hash array with event/task properties from libkolab * @param object VCalendar object to append event to or false for directly sending data to stdout * @param callable Callback function to fetch attachment contents, false if no attachment export * @param object RECURRENCE-ID property when serializing a recurrence exception */ private function _to_ical($event, $vcal, $get_attachment, $recurrence_id = null) { $type = $event['_type'] ?: 'event'; $ve = VObject\Component::create($this->type_component_map[$type]); $ve->add('UID', $event['uid']); // set DTSTAMP according to RFC 5545, 3.8.7.2. $dtstamp = !empty($event['changed']) && !empty($this->method) ? $event['changed'] : new DateTime(); $ve->add($this->datetime_prop('DTSTAMP', $dtstamp, true)); // all-day events end the next day if ($event['allday'] && !empty($event['end'])) { $event['end'] = clone $event['end']; $event['end']->add(new \DateInterval('P1D')); $event['end']->_dateonly = true; } if (!empty($event['created'])) { $ve->add($this->datetime_prop('CREATED', $event['created'], true)); } if (!empty($event['changed'])) { $ve->add($this->datetime_prop('LAST-MODIFIED', $event['changed'], true)); } if (!empty($event['start'])) { $ve->add($this->datetime_prop('DTSTART', $event['start'], false, (bool) $event['allday'])); } if (!empty($event['end'])) { $ve->add($this->datetime_prop('DTEND', $event['end'], false, (bool) $event['allday'])); } if (!empty($event['due'])) { $ve->add($this->datetime_prop('DUE', $event['due'], false)); } // we're exporting a recurrence instance only if (!$recurrence_id && $event['recurrence_date'] && $event['recurrence_date'] instanceof DateTime) { $recurrence_id = $this->datetime_prop('RECURRENCE-ID', $event['recurrence_date'], false, (bool) $event['allday']); if ($event['thisandfuture']) { $recurrence_id->add('RANGE', 'THISANDFUTURE'); } } if ($recurrence_id) { $ve->add($recurrence_id); } $ve->add('SUMMARY', $event['title']); if ($event['location']) { $ve->add($this->is_apple() ? new vobject_location_property('LOCATION', $event['location']) : new VObject\Property('LOCATION', $event['location'])); } if ($event['description']) { $ve->add('DESCRIPTION', strtr($event['description'], array("\r\n" => "\n", "\r" => "\n"))); } // normalize line endings if (isset($event['sequence'])) { $ve->add('SEQUENCE', $event['sequence']); } if ($event['recurrence'] && !$recurrence_id) { $exdates = $rdates = null; if (isset($event['recurrence']['EXDATE'])) { $exdates = $event['recurrence']['EXDATE']; unset($event['recurrence']['EXDATE']); // don't serialize EXDATEs into RRULE value } if (isset($event['recurrence']['RDATE'])) { $rdates = $event['recurrence']['RDATE']; unset($event['recurrence']['RDATE']); // don't serialize RDATEs into RRULE value } if ($event['recurrence']['FREQ']) { $ve->add('RRULE', libcalendaring::to_rrule($event['recurrence'], (bool) $event['allday'])); } // add EXDATEs each one per line (for Thunderbird Lightning) if (is_array($exdates)) { foreach ($exdates as $ex) { if ($ex instanceof \DateTime) { $exd = clone $event['start']; $exd->setDate($ex->format('Y'), $ex->format('n'), $ex->format('j')); $exd->setTimeZone(new \DateTimeZone('UTC')); $ve->add(new VObject\Property('EXDATE', $exd->format('Ymd\\THis\\Z'))); } } } // add RDATEs if (is_array($rdates) && !empty($rdates)) { $sample = $this->datetime_prop('RDATE', $rdates[0]); $rdprop = new VObject\Property\MultiDateTime('RDATE', null); $rdprop->setDateTimes($rdates, $sample->getDateType()); $ve->add($rdprop); } } if ($event['categories']) { $cat = VObject\Property::create('CATEGORIES'); $cat->setParts((array) $event['categories']); $ve->add($cat); } if (!empty($event['free_busy'])) { $ve->add('TRANSP', $event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE'); // for Outlook clients we provide the X-MICROSOFT-CDO-BUSYSTATUS property if (stripos($this->agent, 'outlook') !== false) { $ve->add('X-MICROSOFT-CDO-BUSYSTATUS', $event['free_busy'] == 'outofoffice' ? 'OOF' : strtoupper($event['free_busy'])); } } if ($event['priority']) { $ve->add('PRIORITY', $event['priority']); } if ($event['cancelled']) { $ve->add('STATUS', 'CANCELLED'); } else { if ($event['free_busy'] == 'tentative') { $ve->add('STATUS', 'TENTATIVE'); } else { if ($event['complete'] == 100) { $ve->add('STATUS', 'COMPLETED'); } else { if (!empty($event['status'])) { $ve->add('STATUS', $event['status']); } } } } if (!empty($event['sensitivity'])) { $ve->add('CLASS', strtoupper($event['sensitivity'])); } if (!empty($event['complete'])) { $ve->add('PERCENT-COMPLETE', intval($event['complete'])); } // Apple iCal and BusyCal required the COMPLETED date to be set in order to consider a task complete if ($event['status'] == 'COMPLETED' || $event['complete'] == 100) { $ve->add($this->datetime_prop('COMPLETED', $event['changed'] ?: new DateTime('now - 1 hour'), true)); } if ($event['valarms']) { foreach ($event['valarms'] as $alarm) { $va = VObject\Component::create('VALARM'); $va->action = $alarm['action']; if ($alarm['trigger'] instanceof DateTime) { $va->add($this->datetime_prop('TRIGGER', $alarm['trigger'], true)); } else { $alarm_props = array(); if (strtoupper($alarm['related']) == 'END') { $alarm_props['RELATED'] = 'END'; } $va->add('TRIGGER', $alarm['trigger'], $alarm_props); } if ($alarm['action'] == 'EMAIL') { foreach ((array) $alarm['attendees'] as $attendee) { $va->add('ATTENDEE', 'mailto:' . $attendee); } } if ($alarm['description']) { $va->add('DESCRIPTION', $alarm['description'] ?: $event['title']); } if ($alarm['summary']) { $va->add('SUMMARY', $alarm['summary']); } if ($alarm['duration']) { $va->add('DURATION', $alarm['duration']); $va->add('REPEAT', intval($alarm['repeat'])); } if ($alarm['uri']) { $va->add('ATTACH', $alarm['uri'], array('VALUE' => 'URI')); } $ve->add($va); } } else { if ($event['alarms']) { $va = VObject\Component::create('VALARM'); list($trigger, $va->action) = explode(':', $event['alarms']); $val = libcalendaring::parse_alarm_value($trigger); if ($val[3]) { $va->add('TRIGGER', $val[3]); } else { if ($val[0] instanceof DateTime) { $va->add($this->datetime_prop('TRIGGER', $val[0])); } } $ve->add($va); } } foreach ((array) $event['attendees'] as $attendee) { if ($attendee['role'] == 'ORGANIZER') { if (empty($event['organizer'])) { $event['organizer'] = $attendee; } } else { if (!empty($attendee['email'])) { if (isset($attendee['rsvp'])) { $attendee['rsvp'] = $attendee['rsvp'] ? 'TRUE' : null; } $ve->add('ATTENDEE', 'mailto:' . $attendee['email'], array_filter(self::map_keys($attendee, $this->attendee_keymap))); } } } if ($event['organizer']) { $ve->add('ORGANIZER', 'mailto:' . $event['organizer']['email'], self::map_keys($event['organizer'], array('name' => 'CN'))); } foreach ((array) $event['url'] as $url) { if (!empty($url)) { $ve->add('URL', $url); } } if (!empty($event['parent_id'])) { $ve->add('RELATED-TO', $event['parent_id'], array('RELTYPE' => 'PARENT')); } if ($event['comment']) { $ve->add('COMMENT', $event['comment']); } $memory_limit = parse_bytes(ini_get('memory_limit')); // export attachments if (!empty($event['attachments'])) { foreach ((array) $event['attachments'] as $attach) { // check available memory and skip attachment export if we can't buffer it // @todo: use rcube_utils::mem_check() if (is_callable($get_attachment) && $memory_limit > 0 && ($memory_used = function_exists('memory_get_usage') ? memory_get_usage() : 16 * 1024 * 1024) && $attach['size'] && $memory_used + $attach['size'] * 3 > $memory_limit) { continue; } // embed attachments using the given callback function if (is_callable($get_attachment) && ($data = call_user_func($get_attachment, $attach['id'], $event))) { // embed attachments for iCal $ve->add('ATTACH', base64_encode($data), array_filter(array('VALUE' => 'BINARY', 'ENCODING' => 'BASE64', 'FMTTYPE' => $attach['mimetype'], 'X-LABEL' => $attach['name']))); unset($data); // attempt to free memory } else { if (!empty($this->attach_uri)) { $ve->add('ATTACH', strtr($this->attach_uri, array('{{id}}' => urlencode($attach['id']), '{{name}}' => urlencode($attach['name']), '{{mimetype}}' => urlencode($attach['mimetype']))), array('FMTTYPE' => $attach['mimetype'], 'VALUE' => 'URI')); } } } } foreach ((array) $event['links'] as $uri) { $ve->add('ATTACH', $uri); } // add custom properties foreach ((array) $event['x-custom'] as $prop) { $ve->add($prop[0], $prop[1]); } // append to vcalendar container if ($vcal) { $vcal->add($ve); } else { // serialize and send to stdout echo $ve->serialize(); } // append recurrence exceptions if (is_array($event['recurrence']) && $event['recurrence']['EXCEPTIONS']) { foreach ($event['recurrence']['EXCEPTIONS'] as $ex) { $exdate = $ex['recurrence_date'] ?: $ex['start']; $recurrence_id = $this->datetime_prop('RECURRENCE-ID', $exdate, false, (bool) $event['allday']); if ($ex['thisandfuture']) { $recurrence_id->add('RANGE', 'THISANDFUTURE'); } $this->_to_ical($ex, $vcal, $get_attachment, $recurrence_id); } } }
/** * @brief converts a unique element into a owncloud VCard * @param $element the element to convert * @return VCard, all unconverted elements are stored in X-Unknown-Element parameters */ public function convertElementToVCard($element, $title = null) { $vcard = \Sabre\VObject\Component::create('VCARD'); $nbElt = count($element); for ($i = 0; $i < $nbElt; $i++) { if ($element[$i] != '') { //$importEntry = false; // Look for the right import_entry if (isset($this->configContent->import_core->base_parsing)) { if (strcasecmp((string) $this->configContent->import_core->base_parsing, 'position') == 0) { $importEntry = $this->getImportEntryFromPosition((string) $i); } else { if (strcasecmp((string) $this->configContent->import_core->base_parsing, 'name') == 0 && isset($title[$i])) { $importEntry = $this->getImportEntryFromName($title[$i]); } } } if ($importEntry) { // Create a new property and attach it to the vcard $value = $element[$i]; if (isset($importEntry['remove'])) { $value = str_replace($importEntry['remove'], '', $element[$i]); } $values = array($value); if (isset($importEntry['separator'])) { $values = explode($importEntry['separator'], $value); } foreach ($values as $oneValue) { if (isset($importEntry->vcard_favourites)) { foreach ($importEntry->vcard_favourites as $vcardFavourite) { if (strcasecmp((string) $vcardFavourite, trim($oneValue)) == 0) { $property = \Sabre\VObject\Property::create("X-FAVOURITES", 'yes'); $vcard->add($property); } else { $property = $this->getOrCreateVCardProperty($vcard, $importEntry->vcard_entry); $this->updateProperty($property, $importEntry, trim($oneValue)); } } } else { $property = $this->getOrCreateVCardProperty($vcard, $importEntry->vcard_entry); $this->updateProperty($property, $importEntry, trim($oneValue)); } } } else { if (isset($element[$i]) && isset($title[$i])) { $property = \Sabre\VObject\Property::create("X-Unknown-Element", StringUtil::convertToUTF8($element[$i])); $property->parameters[] = new \Sabre\VObject\Parameter('TYPE', '' . StringUtil::convertToUTF8($title[$i])); $vcard->add($property); } } } } $vcard->validate(\Sabre\VObject\Component\VCard::REPAIR); return $vcard; }
/** * @brief returns the vcard property corresponding to the ldif parameter * creates the property if it doesn't exists yet * @param $vcard the vcard to get or create the properties with * @param $v_param the parameter the find * @param $index the position of the property in the vcard to find */ public function getOrCreateVCardProperty(&$vcard, $v_param, $index) { // looking for one //OCP\Util::writeLog('ldap_vcard_connector', __METHOD__.' entering '.$vcard->serialize(), \OCP\Util::DEBUG); $properties = $vcard->select($v_param['property']); $counter = 0; foreach ($properties as $property) { if ($v_param['type'] == null) { //OCP\Util::writeLog('ldap_vcard_connector', __METHOD__.' property '.$v_param['type'].' found', \OCP\Util::DEBUG); return $property; } foreach ($property->parameters as $parameter) { //OCP\Util::writeLog('ldap_vcard_connector', __METHOD__.' parameter '.$parameter->value.' <> '.$v_param['type'], \OCP\Util::DEBUG); if (!strcmp($parameter->value, $v_param['type'])) { //OCP\Util::writeLog('ldap_vcard_connector', __METHOD__.' parameter '.$parameter->value.' found', \OCP\Util::DEBUG); if ($counter == $index) { return $property; } $counter++; } } } // Property not found, creating one //OCP\Util::writeLog('ldap_vcard_connector', __METHOD__.', create one '.$v_param['property'].';TYPE='.$v_param['type'], \OCP\Util::DEBUG); $line = count($vcard->children) - 1; $property = \Sabre\VObject\Property::create($v_param['property']); $vcard->add($property); if ($v_param['type'] != null) { //OCP\Util::writeLog('ldap_vcard_connector', __METHOD__.', creating one '.$v_param['property'].';TYPE='.$v_param['type'], \OCP\Util::DEBUG); //\OC_Log::write('ldapconnector', __METHOD__.', creating one '.$v_param['property'].';TYPE='.$v_param['type'], \OC_Log::DEBUG); $property->parameters[] = new \Sabre\VObject\Parameter('TYPE', '' . $v_param['type']); switch ($v_param['property']) { case "ADR": //OCP\Util::writeLog('ldap_vcard_connector', __METHOD__.', we have an address '.$v_param['property'].';TYPE='.$v_param['type'], \OCP\Util::DEBUG); $property->setValue(";;;;;;"); break; case "FN": $property->setValue(";;;;"); break; } } //OCP\Util::writeLog('ldap_vcard_connector', __METHOD__.' exiting '.$vcard->serialize(), \OCP\Util::DEBUG); return $property; }