function testVCard2() { $vCard = new vCard(); $vCard->setOrganization('Testing, Inc.'); $vCard->setName('Smith', 'John', 'J.', 'Mr.', 'Jr.'); $vCard->setEmail('*****@*****.**'); $vCard->setPhoneNumber('612-555-3000', 'CELL'); $vCard->setTitle('Senior Tester'); $vCard->setAddress('555 Testing Dr', 'Suite 100', 'Testertown', 'TN', '12345', '', 'USA', '', 'HOME'); $vCard->setNote('Test note.'); $vCard->setURL('http://www.slashdot.org'); $output = trim($vCard->getVCard()); $outputLines = explode("\n", $output); $outputLines = array_map('trim', $outputLines); $this->assertIdentical($outputLines[0], 'BEGIN:VCARD'); $this->assertIdentical($outputLines[1], 'VERSION:2.1'); $this->assertIdentical($outputLines[2], 'ORG;ENCODING=QUOTED-PRINTABLE:Testing, Inc.'); $this->assertIdentical($outputLines[3], 'N:Smith;John;J.;Mr.;Jr.'); $this->assertIdentical($outputLines[4], 'FN:Mr. John J. Smith Jr.'); $this->assertIdentical($outputLines[5], 'EMAIL;INTERNET:test@testerson.org'); $this->assertIdentical($outputLines[6], 'TEL;CELL:612-555-3000'); $this->assertIdentical($outputLines[7], 'TITLE;ENCODING=QUOTED-PRINTABLE:Senior Tester'); $this->assertIdentical($outputLines[8], 'ADR;HOME;ENCODING=QUOTED-PRINTABLE:;Suite 100;555 Testing Dr;Testertown;TN;12345;USA'); $this->assertIdentical($outputLines[9], 'ORG;ENCODING=QUOTED-PRINTABLE:Test note.'); $this->assertIdentical($outputLines[10], 'URL:http://www.slashdot.org'); /* Test revision timestamp. */ $this->assertPatternIn('/^REV:\\d{8}T\\d{6}$/', $outputLines[11]); $currentREVNumeric = date('YmdHis'); $vCardREVNumeric = preg_replace('/REV:|T/', '', $outputLines[11]); $this->assertTrue($vCardREVNumeric >= $currentREVNumeric - 5 && $vCardREVNumeric <= $currentREVNumeric + 5, 'REV is within +/-5 seconds of current timestamp'); $this->assertIdentical($outputLines[12], 'MAILER:CATS'); $this->assertIdentical($outputLines[13], 'END:VCARD'); $this->assertIdentical($vCard->getFilename(), 'John Smith.vcf'); }
public function testSetTitle() { $vcard = new vCard(); $vcard->setTitle('cat'); $this->assertEquals('cat', $vcard->getProperty('TITLE')); }
<?php #Application name: PhpCollab #Status page: 0 #Path by root: ../users/exportuser.php $export = "true"; $checkSession = "false"; include_once '../includes/library.php'; include "../includes/vcard.class.php"; $tmpquery = "WHERE mem.id = '{$id}'"; $userDetail = new request(); $userDetail->openMembers($tmpquery); $v = new vCard(); $v->setPhoneNumber($userDetail->mem_phone_work[0]); $v->setName($userDetail->mem_name[0]); $v->setTitle($userDetail->mem_title[0]); $v->setOrganization($userDetail->mem_org_name[0]); $v->setEmail($userDetail->mem_email_work[0]); $v->setPhoneNumber($userDetail->mem_phone_work[0], "WORK;VOICE"); $v->setPhoneNumber($userDetail->mem_phone_home[0], "HOME;VOICE"); $v->setPhoneNumber($userDetail->mem_mobile[0], "CELL;VOICE"); $v->setPhoneNumber($userDetail->mem_fax[0], "WORK;FAX"); $output = $v->getVCard(); $filename = $v->getFileName(); Header("Content-Disposition: attachment; filename={$filename}"); Header("Content-Length: " . strlen($output)); Header("Connection: close"); Header("Content-Type: text/x-vCard; name={$filename}"); echo $output;
} // We create VCard $v = new vCard(); $v->setProdId('Dolibarr ' . DOL_VERSION); $v->setUid('DOLIBARR-CONTACTID-' . $contact->id); $v->setName($contact->lastname, $contact->firstname, "", "", ""); $v->setFormattedName($contact->getFullName($langs)); // By default, all informations are for work (except phone_perso and phone_mobile) $v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); $v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE"); $v->setPhoneNumber($contact->fax, "WORK;FAX"); $v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, $contact->country_code ? $contact->country_id : '', "WORK;POSTAL"); $v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, $contact->country_code ? $contact->country_id : '', "WORK"); $v->setEmail($contact->email, 'internet,pref'); $v->setNote($contact->note); $v->setTitle($contact->poste); // Data from linked company if ($company->id) { $v->setURL($company->url, "WORK"); if (!$contact->phone_pro) { $v->setPhoneNumber($company->phone, "WORK;VOICE"); } if (!$contact->fax) { $v->setPhoneNumber($company->fax, "WORK;FAX"); } if (!$contact->zip) { $v->setAddress("", "", $company->address, $company->town, "", $company->zip, $company->country_code, "WORK;POSTAL"); } if ($company->email != $contact->email) { $v->setEmail($company->email, 'internet'); }
$sql2 = "SELECT * FROM contacts_titlelist WHERE title_id = '{$contact_title}' LIMIT 1"; $result2 = mysql_query($sql2, $conn) or die(mysql_error()); $array2 = mysql_fetch_array($result2); $title_name = $array2['title_name']; // WRAP UP OTHER INFORMATION INTO A NOTE if ($contact_reference != "") { $contact_reference = "Notes:\n" . $contact_reference; } $contact_reference = $contact_reference . "\nContact Added to Database:\n" . $contact_added; // USAGE EXAMPLE $v = new vCard(); $v->setPhoneNumber($output_telephone, "TEL;PREF;WORK;VOICE"); $v->setPhoneNumber($contact_telephone_home, "TEL;HOME;VOICE"); $v->setPhoneNumber($output_fax, "TEL;WORK;FAX"); $v->setPhoneNumber($contact_mobile, "TEL;CELL;VOICE"); $v->setName($contact_namesecond, $contact_namefirst, "", ""); $v->setTitle($title_name); $v->setBirthday(""); $v->setCompany($company_name); $v->setLabel("", "", $contact_address, $contact_city, "", $contact_postcode); $v->setAddress("", "", $company_address, $company_city, "", $company_postcode); $v->setEmail($contact_email); $v->setNote($contact_reference); $v->setURL($company_web); $output = $v->getVCard(); $filename = $v->getFileName(); //Header("Content-Disposition: attachment; filename=$filename"); //Header("Content-Length: ".strlen($output)); //Header("Connection: close"); //Header("Content-Type: text/x-vCard; name=$filename"); echo $output;