/** * Generate the Vcard for the current Contact * *@return Nothing (display) **/ function generateVcard() { if (!$this->can($this->fields['id'], READ)) { return false; } // build the Vcard $vcard = new VObject\Component\VCard(['N' => [$this->fields["name"], $this->fields["firstname"]], 'EMAIL' => $this->fields["email"], 'NOTE' => $this->fields["comment"]]); $vcard->add('TEL', $this->fields["phone"], ['type' => 'PREF;WORK;VOICE']); $vcard->add('TEL', $this->fields["phone2"], ['type' => 'HOME;VOICE']); $vcard->add('TEL', $this->fields["mobile"], ['type' => 'WORK;CELL']); $vcard->add('URL', $this->GetWebsite(), ['type' => 'WORK']); $addr = $this->GetAddress(); if (is_array($addr)) { $addr_string = implode(";", array_filter($addr)); $vcard->add('ADR', $addr_string, ['type' => 'WORK;POSTAL']); } // send the VCard $output = $vcard->serialize(); $filename = $this->fields["name"] . "_" . $this->fields["firstname"] . ".vcf"; @Header("Content-Disposition: attachment; filename=\"{$filename}\""); @Header("Content-Length: " . Toolbox::strlen($output)); @Header("Connection: close"); @Header("content-type: text/x-vcard; charset=UTF-8"); echo $output; }
/** * Converts a ContactInformation object into a vcard * * @param \Prototype\ContactInformation $contact contact information to convert * @return \Sabre\VObject\Component\VCard created vcard */ public function convert(ContactInformation $contact) { $vcard = new VObject\Component\VCard(); if ($contact->hasAttribute('lastname') || $contact->hasAttribute('firstname') || $contact->hasAttribute('additionalNames') || $contact->hasAttribute('honorificPrefixes') || $contact->hasAttribute('honorificSuffixes')) { $N = [$contact->hasAttribute('lastname') ? $contact->getAttribute('lastname') : '', $contact->hasAttribute('firstname') ? $contact->getAttribute('firstname') : '', $contact->hasAttribute('additionalNames') ? $contact->getAttribute('additionalNames') : '', $contact->hasAttribute('honorificPrefixes') ? $contact->getAttribute('honorificPrefixes') : '', $contact->hasAttribute('honorificSuffixes') ? $contact->getAttribute('honorificSuffixes') : '']; $vcard->add('N', $N); } foreach (self::$attributeMap as $key => $value) { if ($contact->hasAttribute($key)) { $vcard->add($value, $contact->getAttribute($key)); } } return $vcard; }
/** * @param IUser $user * @return VCard */ public function createCardFromUser(IUser $user) { $uid = $user->getUID(); $displayName = $user->getDisplayName(); $displayName = empty($displayName) ? $uid : $displayName; $emailAddress = $user->getEMailAddress(); $cloudId = $user->getCloudId(); $image = $this->getAvatarImage($user); $groups = \OC::$server->getGroupManager()->getUserGroups($user); $vCard = new VCard(); $vCard->add(new Text($vCard, 'UID', $uid)); if (!empty($displayName)) { $vCard->add(new Text($vCard, 'FN', $displayName)); $vCard->add(new Text($vCard, 'N', $this->splitFullName($displayName))); } if (!empty($emailAddress)) { $vCard->add(new Text($vCard, 'EMAIL', $emailAddress, ['TYPE' => 'OTHER'])); } if (!empty($cloudId)) { $vCard->add(new Text($vCard, 'CLOUD', $cloudId)); } if ($image) { $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]); } if ($groups) { foreach ($groups as $groupName => $groupInfo) { $vCard->add(new Text($vCard, 'CATEGORIES', $groupName)); } } $vCard->validate(); return $vCard; }
public function NAttribute() { $vcard = new VObject\Component\VCard(); $vcard->add('N', ['Werner', 'Lukas', ['Roland', 'Thomas', 'Alfred', 'Joseph'], 'B.Sc.', 'Informatik']); $contact = new ContactInformation(); $contact->setLastname('Werner'); $contact->setFirstname('Lukas'); $contact->setAdditionalNames(['Roland', 'Thomas', 'Alfred', 'Joseph']); $contact->setHonorificPrefixes('B.Sc.'); $contact->setHonorificSuffixes('Informatik'); $this->assertEquals($vcard->serialize(), $this->object->convert($contact)->serialize()); }
/** * @param IUser $user * @return VCard */ public function createCardFromUser(IUser $user) { $uid = $user->getUID(); $displayName = $user->getDisplayName(); $displayName = empty($displayName) ? $uid : $displayName; $emailAddress = $user->getEMailAddress(); $cloudId = $user->getCloudId(); $image = $user->getAvatarImage(-1); $vCard = new VCard(); $vCard->add(new Text($vCard, 'UID', $uid)); if (!empty($displayName)) { $vCard->add(new Text($vCard, 'FN', $displayName)); $vCard->add(new Text($vCard, 'N', $this->splitFullName($displayName))); } if (!empty($emailAddress)) { $vCard->add(new Text($vCard, 'EMAIL', $emailAddress, ['TYPE' => 'OTHER'])); } if (!empty($cloudId)) { $vCard->add(new Text($vCard, 'CLOUD', $cloudId)); } if ($image) { $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]); } $vCard->validate(); return $vCard; }
public static function addingDummyContacts($iNum) { $active_addressbooks = array(); $active_addressbooks = Addressbook::active(\OCP\USER::getUser()); $contacts_addressbook = array(); $ids = array(); foreach ($active_addressbooks as $addressbook) { $ids[] = $addressbook['id']; } for ($i = 0; $i < $iNum; $i++) { //$dummyName=self::generateFnDummy(); $dummySure = self::generateFnDummy(10); $dummyLast = self::generateFnDummy(10); $uid = substr(md5(rand() . time()), 0, 10); $aid = $ids[0]; $vcard = new VObject\Component\VCard(array('N' => array($dummySure, $dummyLast, '', '', ''), 'UID' => $uid)); $vcard->FN = $dummySure . ' ' . $dummyLast; $vcard->CATEGORIES = 'familie'; $vcard->add('TEL', '+1 555 34567 456', array('type' => 'fax')); $vcard->add('TEL', '+1 555 34567 457', array('type' => 'voice', 'pref' => 1)); $vcard->add('EMAIL', '*****@*****.**', array('type' => 'work')); $vcard->add('EMAIL', '*****@*****.**', array('type' => 'private', 'pref' => 1)); $id = VCard::add($aid, $vcard, null, true); } }
/** * Generate vcard for the current user **/ function generateVcard() { // prepare properties for the Vcard if (!empty($this->fields["realname"]) || !empty($this->fields["firstname"])) { $name = [$this->fields["realname"], $this->fields["firstname"], "", "", ""]; } else { $name = [$this->fields["name"], "", "", "", ""]; } // create vcard $vcard = new VObject\Component\VCard(['N' => $name, 'EMAIL' => $this->getDefaultEmail(), 'NOTE' => $this->fields["comment"]]); $vcard->add('TEL', $this->fields["phone"], ['type' => 'PREF;WORK;VOICE']); $vcard->add('TEL', $this->fields["phone2"], ['type' => 'HOME;VOICE']); $vcard->add('TEL', $this->fields["mobile"], ['type' => 'WORK;CELL']); // send the VCard $output = $vcard->serialize(); $filename = implode("_", array_filter($name)) . ".vcf"; @Header("Content-Disposition: attachment; filename=\"{$filename}\""); @Header("Content-Length: " . Toolbox::strlen($output)); @Header("Connection: close"); @Header("content-type: text/x-vcard; charset=UTF-8"); echo $output; }
public function testValidateBroken() { $datetime = '123'; $vcard = new VObject\Component\VCard(); $prop = $vcard->add('BDAY', $datetime); $this->assertEquals(array(array('level' => 3, 'message' => 'The supplied value (123) is not a correct DATE-AND-OR-TIME property', 'node' => $prop)), $prop->validate()); }
function testValidateBadEncodingVCard21() { $document = new VCard(array('VERSION' => '2.1')); $property = $document->add('X-FOO', 'value'); $property['ENCODING'] = 'B'; $result = $property->validate(); $this->assertEquals('ENCODING=B is not valid for this document type.', $result[0]['message']); $this->assertEquals(1, $result[0]['level']); }
/** * create empty vcard * * @param string $uid * @return VCard */ protected function createEmptyVCard($uid) { $vCard = new VCard(); $vCard->add(new Text($vCard, 'UID', $uid)); return $vCard; }
/** * @expectedException \InvalidArgumentException */ function testMimeDir() { $vcard = new VObject\Component\VCard(); $vcard->add('PHOTO', ['a', 'b']); }
/** * @param CContact $oContact * @param \Sabre\VObject\Component\VCard $oVCard * @return void */ public static function UpdateVCardPhonesFromContact($oContact, &$oVCard) { $bFindHome = false; $bFindWork = false; $bFindCell = false; $bFindHomeFax = false; $bFindWorkFax = false; $oVCardCopy = clone $oVCard; if (empty($oContact->HomePhone)) { $bFindHome = true; } if (empty($oContact->BusinessPhone)) { $bFindWork = true; } if (empty($oContact->HomeMobile)) { $bFindCell = true; } if (empty($oContact->HomeFax)) { $bFindHomeFax = true; } if (empty($oContact->BusinessFax)) { $bFindWorkFax = true; } if (isset($oVCardCopy->TEL)) { unset($oVCard->TEL); foreach ($oVCardCopy->TEL as $oTel) { if ($oTypes = $oTel['TYPE']) { if ($oTypes->has('VOICE')) { if ($oTypes->has('HOME')) { if ($bFindHome) { unset($oTel); } else { $oTel->setValue($oContact->HomePhone); $bFindHome = true; } } if ($oTypes->has('WORK')) { if ($bFindWork) { unset($oTel); } else { $oTel->setValue($oContact->BusinessPhone); $bFindWork = true; } } if ($oTypes->has('CELL')) { if ($bFindCell) { unset($oTel); } else { $oTel->setValue($oContact->HomeMobile); $bFindCell = true; } } } else { if ($oTypes->has('FAX')) { if ($oTypes->has('HOME')) { if ($bFindHomeFax) { unset($oTel); } else { $oTel->setValue($oContact->HomeFax); $bFindHomeFax = true; } } if ($oTypes->has('WORK')) { if ($bFindWorkFax) { unset($oTel); } else { $oTel->setValue($oContact->BusinessFax); $bFindWorkFax = true; } } } } } if (isset($oTel)) { $oVCard->add($oTel); } } } if (!$bFindHome) { $oVCard->add('TEL', $oContact->HomePhone, array('TYPE' => array('VOICE', 'HOME'))); } if (!$bFindWork) { $oVCard->add('TEL', $oContact->BusinessPhone, array('TYPE' => array('VOICE', 'WORK'))); } if (!$bFindCell) { $oVCard->add('TEL', $oContact->HomeMobile, array('TYPE' => array('VOICE', 'CELL'))); } if (!$bFindHomeFax) { $oVCard->add('TEL', $oContact->HomeFax, array('TYPE' => array('FAX', 'HOME'))); } if (!$bFindWorkFax) { $oVCard->add('TEL', $oContact->BusinessFax, array('TYPE' => array('FAX', 'WORK'))); } }
function testAnotherSerializeOrderProp() { $prop4s = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10'); $comp = new VCard(array(), false); $comp->__set('SOMEPROP', 'FOO'); $comp->__set('ANOTHERPROP', 'FOO'); $comp->__set('THIRDPROP', 'FOO'); foreach ($prop4s as $prop4) { $comp->add('PROP4', 'FOO ' . $prop4); } $comp->__set('PROPNUMBERFIVE', 'FOO'); $comp->__set('PROPNUMBERSIX', 'FOO'); $comp->__set('PROPNUMBERSEVEN', 'FOO'); $comp->__set('PROPNUMBEREIGHT', 'FOO'); $comp->__set('PROPNUMBERNINE', 'FOO'); $comp->__set('PROPNUMBERTEN', 'FOO'); $comp->__set('VERSION', '2.0'); $comp->__set('UID', 'FOO'); $str = $comp->serialize(); $this->assertEquals("BEGIN:VCARD\r\nVERSION:2.0\r\nSOMEPROP:FOO\r\nANOTHERPROP:FOO\r\nTHIRDPROP:FOO\r\nPROP4:FOO 1\r\nPROP4:FOO 2\r\nPROP4:FOO 3\r\nPROP4:FOO 4\r\nPROP4:FOO 5\r\nPROP4:FOO 6\r\nPROP4:FOO 7\r\nPROP4:FOO 8\r\nPROP4:FOO 9\r\nPROP4:FOO 10\r\nPROPNUMBERFIVE:FOO\r\nPROPNUMBERSIX:FOO\r\nPROPNUMBERSEVEN:FOO\r\nPROPNUMBEREIGHT:FOO\r\nPROPNUMBERNINE:FOO\r\nPROPNUMBERTEN:FOO\r\nUID:FOO\r\nEND:VCARD\r\n", $str); }
/** * Creates a new or updates an existing vcard from save data. */ private function create_vcard_from_save_data($save_data, $vcf = null) { unset($save_data['vcard']); if (!$vcf) { // create fresh minimal vcard $vcf = new VObject\Component\VCard(array('UID' => $save_data['cuid'], 'REV' => date('c'))); } else { // update revision $vcf->REV = date("c"); } // N is mandatory if (array_key_exists('kind', $save_data) && $save_data['kind'] === 'group') { $vcf->N = $save_data['name']; } else { $vcf->N = array($save_data['surname'], $save_data['firstname'], $save_data['middlename'], $save_data['prefix'], $save_data['suffix']); } $new_org_value = array(); if (array_key_exists("organization", $save_data) && strlen($save_data['organization']) > 0) { $new_org_value[] = $save_data['organization']; } if (array_key_exists("department", $save_data)) { if (is_array($save_data['department'])) { foreach ($save_data['department'] as $key => $value) { $new_org_value[] = $value; } } else { if (strlen($save_data['department']) > 0) { $new_org_value[] = $save_data['department']; } } } if (count($new_org_value) > 0) { $vcf->ORG = $new_org_value; } else { unset($vcf->ORG); } // normalize date fields to RFC2425 YYYY-MM-DD date values foreach ($this->datefields as $key) { if (array_key_exists($key, $save_data) && strlen($save_data[$key]) > 0) { $val = rcube_strtotime($save_data[$key]); $save_data[$key] = date('Y-m-d', $val); } } // due to a bug in earlier versions of RCMCardDAV the PHOTO field was encoded base64 TWICE // This was recognized and fixed on 2013-01-09 and should be kept here until reasonable // certain that it's been fixed on users data, too. if (!array_key_exists('photo', $save_data) && strlen($vcf->PHOTO) > 0) { $save_data['photo'] = $vcf->PHOTO; } if (array_key_exists('photo', $save_data) && strlen($save_data['photo']) > 0 && base64_decode($save_data['photo'], true) !== FALSE) { self::$helper->debug("photo is base64 encoded. Decoding..."); $i = 0; while (base64_decode($save_data['photo'], true) !== FALSE && $i++ < 10) { self::$helper->debug("Decoding {$i}..."); $save_data['photo'] = base64_decode($save_data['photo'], true); } if ($i >= 10) { lef::$helper->warn("PHOTO of " . $save_data['uid'] . " does not decode after 10 attempts..."); } } // process all simple attributes foreach ($this->vcf2rc['simple'] as $vkey => $rckey) { if (array_key_exists($rckey, $save_data)) { if (strlen($save_data[$rckey]) > 0) { $vcf->{$vkey} = $save_data[$rckey]; } else { // delete the field unset($vcf->{$vkey}); } } } // Special handling for PHOTO if ($property = $vcf->PHOTO) { $property['ENCODING'] = 'B'; $property['VALUE'] = 'BINARY'; } // process all multi-value attributes foreach ($this->vcf2rc['multi'] as $vkey => $rckey) { // delete and fully recreate all entries // there is no easy way of mapping an address in the existing card // to an address in the save data, as subtypes may have changed unset($vcf->{$vkey}); $stmap = array($rckey => 'other'); foreach ($this->coltypes[$rckey]['subtypes'] as $subtype) { $stmap[$rckey . ':' . $subtype] = $subtype; } foreach ($stmap as $rcqkey => $subtype) { if (array_key_exists($rcqkey, $save_data)) { $avalues = is_array($save_data[$rcqkey]) ? $save_data[$rcqkey] : array($save_data[$rcqkey]); foreach ($avalues as $evalue) { if (strlen($evalue) > 0) { $prop = $vcf->add($vkey, $evalue); $this->set_attr_label($vcf, $prop, $rckey, $subtype); // set label } } } } } // process address entries unset($vcf->ADR); foreach ($this->coltypes['address']['subtypes'] as $subtype) { $rcqkey = 'address:' . $subtype; if (array_key_exists($rcqkey, $save_data)) { foreach ($save_data[$rcqkey] as $avalue) { if (strlen($avalue['street']) || strlen($avalue['locality']) || strlen($avalue['region']) || strlen($avalue['zipcode']) || strlen($avalue['country'])) { $prop = $vcf->add('ADR', array('', '', $avalue['street'], $avalue['locality'], $avalue['region'], $avalue['zipcode'], $avalue['country'])); $this->set_attr_label($vcf, $prop, 'address', $subtype); // set label } } } } return $vcf; }
public function testUpdateProperties() { $bookId = 42; $cardUri = 'card-uri'; $cardId = 2; $backend = $this->getMockBuilder('OCA\\DAV\\CardDAV\\CardDavBackend')->setConstructorArgs([$this->db, $this->principal, null])->setMethods(['getCardId'])->getMock(); $backend->expects($this->any())->method('getCardId')->willReturn($cardId); // add properties for new vCard $vCard = new VCard(); $vCard->add(new Text($vCard, 'UID', $cardUri)); $vCard->add(new Text($vCard, 'FN', 'John Doe')); $this->invokePrivate($backend, 'updateProperties', [$bookId, $cardUri, $vCard->serialize()]); $query = $this->db->getQueryBuilder(); $result = $query->select('*')->from('cards_properties')->execute()->fetchAll(); $this->assertSame(2, count($result)); $this->assertSame('UID', $result[0]['name']); $this->assertSame($cardUri, $result[0]['value']); $this->assertSame($bookId, (int) $result[0]['addressbookid']); $this->assertSame($cardId, (int) $result[0]['cardid']); $this->assertSame('FN', $result[1]['name']); $this->assertSame('John Doe', $result[1]['value']); $this->assertSame($bookId, (int) $result[1]['addressbookid']); $this->assertSame($cardId, (int) $result[1]['cardid']); // update properties for existing vCard $vCard = new VCard(); $vCard->add(new Text($vCard, 'FN', 'John Doe')); $this->invokePrivate($backend, 'updateProperties', [$bookId, $cardUri, $vCard->serialize()]); $query = $this->db->getQueryBuilder(); $result = $query->select('*')->from('cards_properties')->execute()->fetchAll(); $this->assertSame(1, count($result)); $this->assertSame('FN', $result[0]['name']); $this->assertSame('John Doe', $result[0]['value']); $this->assertSame($bookId, (int) $result[0]['addressbookid']); $this->assertSame($cardId, (int) $result[0]['cardid']); }
/** * Get this task as a VObject. This can be turned into a vcard file data. * * @return Sabre_VObject_Component */ public function toVObject() { $e = new Sabre\VObject\Component\VCard(); $e->prodid = '-//Intermesh//NONSGML Group-Office ' . \GO::config()->version . '//EN'; if (empty($this->uuid)) { $this->uuid = \GO\Base\Util\UUID::create('contact', $this->id); $this->save(true); } $e->uid = $this->uuid; $e->add('N', array($this->last_name, $this->first_name, $this->middle_name, $this->title, $this->suffix)); $e->add('FN', $this->name); if (!empty($this->email)) { // $p = new Sabre\VObject\Property('EMAIL',$this->email); // $p->add(new \GO\Base\VObject\Parameter('TYPE','INTERNET')); // $e->add($p); $e->add('email', $this->email, array('type' => array('INTERNET'))); } if (!empty($this->email2)) { // $p = new Sabre\VObject\Property('EMAIL',$this->email2); // $p->add(new \GO\Base\VObject\Parameter('TYPE','HOME,INTERNET')); // $e->add($p); $e->add('email', $this->email2, array('type' => array('HOME', 'INTERNET'))); } if (!empty($this->email3)) { // $p = new Sabre\VObject\Property('EMAIL',$this->email3); // $p->add(new \GO\Base\VObject\Parameter('TYPE','WORK,INTERNET')); // $e->add($p); $e->add('email', $this->email3, array('type' => array('WORK', 'INTERNET'))); } if (!empty($this->function)) { $e->add('TITLE', $this->function); } if (!empty($this->home_phone)) { // $p = new Sabre\VObject\Property('TEL',$this->home_phone); // $p->add(new \GO\Base\VObject\Parameter('TYPE','HOME,VOICE')); // $e->add($p); $e->add('TEL', $this->home_phone, array('type' => array('HOME', 'VOICE'))); } if (!empty($this->work_phone)) { // $p = new Sabre\VObject\Property('TEL',$this->work_phone); // $p->add(new \GO\Base\VObject\Parameter('TYPE','WORK,VOICE')); // $e->add($p); $e->add('TEL', $this->work_phone, array('type' => array('WORK', 'VOICE'))); } if (!empty($this->work_fax)) { // $p = new Sabre\VObject\Property('TEL',$this->work_fax); // $p->add(new \GO\Base\VObject\Parameter('TYPE','WORK,FAX')); // $e->add($p); $e->add('TEL', $this->work_fax, array('type' => array('WORK', 'FAX'))); } if (!empty($this->fax)) { // $p = new Sabre\VObject\Property('TEL',$this->fax); // $p->add(new \GO\Base\VObject\Parameter('TYPE','HOME,FAX')); // $e->add($p); $e->add('TEL', $this->fax, array('type' => array('HOME', 'FAX'))); } if (!empty($this->cellular)) { // $p = new Sabre\VObject\Property('TEL',$this->cellular); // $p->add(new \GO\Base\VObject\Parameter('TYPE','CELL,VOICE')); // $e->add($p); $e->add('TEL', $this->cellular, array('type' => array('CELL', 'VOICE'))); } if (!empty($this->cellular2)) { // $p = new Sabre\VObject\Property('TEL',$this->cellular2); // $p->add(new \GO\Base\VObject\Parameter('TYPE','CELL,VOICE')); // $e->add($p); $e->add('TEL', $this->cellular2, array('type' => array('CELL', 'VOICE'))); } if (!empty($this->birthday)) { $e->add('BDAY', $this->birthday); } if (!empty($this->homepage)) { $e->add('URL', $this->homepage); } if (!empty($this->company)) { // $e->add('ORG',$this->company->name,$this->department,$this->company->name2); // $p = new Sabre\VObject\Property('ADR',';;'.$this->company->address.' '.$this->company->address_no, // $this->company->city,$this->company->state,$this->company->zip,$this->company->country); // $p->add('TYPE','WORK'); // $e->add($p); $e->add('ORG', array($this->company->name, $this->department, $this->company->name2)); $e->add('ADR', array('', '', $this->company->address . ' ' . $this->company->address_no, $this->company->city, $this->company->state, $this->company->zip, $this->company->country), array('type' => 'WORK')); // $p = new Sabre\VObject\Property('ADR',';;'.$this->company->post_address.' '.$this->company->post_address_no, // $this->company->post_city,$this->company->post_state,$this->company->post_zip,$this->company->post_country); // $e->add($p); $e->add('ADR', array('', '', $this->company->post_address . ' ' . $this->company->post_address_no, $this->company->post_city, $this->company->post_state, $this->company->post_zip, $this->company->post_country), array('type' => 'WORK')); } // $p = new Sabre\VObject\Property('ADR',';;'.$this->address.' '.$this->address_no, // $this->city,$this->state,$this->zip,$this->country); // $p->add('TYPE','HOME'); // $e->add($p); // $e->add('ADR', array('', '', $this->address . ' ' . $this->address_no, $this->city, $this->state, $this->zip, $this->country), array('type' => 'HOME')); if (!empty($this->comment)) { $e->note = $this->comment; } // $mtimeDateTime = new \DateTime('@'.$this->mtime); // $rev = new Sabre_VObject_Element_DateTime('LAST-MODIFIED'); // $rev->setDateTime($mtimeDateTime, Sabre_VObject_Element_DateTime::UTC); // $e->add($rev); $e->rev = gmdate("Y-m-d\\TH:m:s\\Z", $this->mtime); if ($this->getPhotoFile()->exists()) { $e->add('photo', $this->getPhotoFile()->getContents(), array('type' => 'JPEG', 'encoding' => 'b')); } // $propModels = $this->vcardProperties->fetchAll(PDO::FETCH_ASSOC); // // foreach ($propModels as $propModel) { // $p = new Sabre\VObject\Property($propModel['name'],$propModel['value']); // if(!empty($propModel['parameters'])){ // $paramStrings = explode(';',$propModel['parameters']); // foreach ($paramStrings as $paramString) { // if(!empty($paramString)){ // $paramStringArr = explode('=',$paramString); // // $param = new \GO\Base\VObject\Parameter($paramStringArr[0]); // if (!empty($paramStringArr[1])) // $param->getValue() = $paramStringArr[1]; // $p->add($param); // } // } // } // $e->add($p); // } return $e; }
public function testCreateEmptyVCard() { $uid = 'uid'; $expectedVCard = new VCard(); $expectedVCard->add(new Text($expectedVCard, 'UID', $uid)); $expectedVCardSerialized = $expectedVCard->serialize(); $result = $this->invokePrivate($this->addressBookImpl, 'createEmptyVCard', [$uid]); $resultSerialized = $result->serialize(); $this->assertSame($expectedVCardSerialized, $resultSerialized); }