Пример #1
0
 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');
 }
Пример #2
0
<?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;