Пример #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
ob_end_clean();
// end of modified by Cindy Qi Li on Jan 12, 2010
/* append the Organizations and Resources to the imsmanifest */
$imsmanifest_xml .= str_replace(array('{ORGANIZATIONS}', '{GLOSSARY}', '{RESOURCES}', '{TEST_ITEMS}', '{COURSE_TITLE}'), array($organizations_str, $glossary_manifest_xml, $resources, $test_xml_items, $ims_course_title), $ims_template_xml['final']);
// generate the vcard for the instructor/author
$usersDAO = new UsersDAO();
$row = $usersDAO->getUserByID($instructor_id);
//$sql = "SELECT first_name, last_name, email, website, login, phone FROM ".TABLE_PREFIX."members WHERE member_id=$instructor_id";
//$result = mysql_query($sql, $db);
$vcard = new vCard();
if (isset($row)) {
    $vcard->setName($row['last_name'], $row['first_name'], $row['login']);
    $vcard->setEmail($row['email']);
    $vcard->setNote('Originated from an AContent at ' . TR_BASE_HREF . '. See ATutor.ca for additional information.');
    $vcard->setURL($row['website']);
    $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml);
} else {
    $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml);
}
/* save the imsmanifest.xml file */
$zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml');
/* Commented by Cindy Qi Li on Jan 12, 2010
// AContent does not have glossary and forums (discussion tools)
if ($glossary_xml) {
	$zipfile->create_dir('resources/GlossaryItem/');
	$zipfile->add_file($glossary_xml,  'resources/GlossaryItem/glossary.xml');
}
*/
$zipfile->close();
// this is optional, since send_file() closes it anyway
$ims_course_title = str_replace(array(' ', ':'), '_', $ims_course_title);
Пример #3
0
 /**
  * Generate vcard for the current user
  **/
 function generateVcard()
 {
     include_once GLPI_ROOT . "/lib/vcardclass/classes-vcard.php";
     // build the Vcard
     $vcard = new vCard();
     if (!empty($this->fields["realname"]) || !empty($this->fields["firstname"])) {
         $vcard->setName($this->fields["realname"], $this->fields["firstname"], "", "");
     } else {
         $vcard->setName($this->fields["name"], "", "", "");
     }
     $vcard->setPhoneNumber($this->fields["phone"], "PREF;WORK;VOICE");
     $vcard->setPhoneNumber($this->fields["phone2"], "HOME;VOICE");
     $vcard->setPhoneNumber($this->fields["mobile"], "WORK;CELL");
     $vcard->setEmail($this->getDefaultEmail());
     $vcard->setNote($this->fields["comment"]);
     // send the  VCard
     $output = $vcard->getVCard();
     $filename = $vcard->getFileName();
     // "xxx xxx.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;
 }
Пример #4
0
 /**
  * Generate the Vcard for the current Contact
  *
  *@return Nothing (display)
  **/
 function generateVcard()
 {
     include GLPI_ROOT . "/lib/vcardclass/classes-vcard.php";
     if (!$this->can($this->fields['id'], READ)) {
         return false;
     }
     // build the Vcard
     $vcard = new vCard();
     $vcard->setName($this->fields["name"], $this->fields["firstname"], "", "");
     $vcard->setPhoneNumber($this->fields["phone"], "PREF;WORK;VOICE");
     $vcard->setPhoneNumber($this->fields["phone2"], "HOME;VOICE");
     $vcard->setPhoneNumber($this->fields["mobile"], "WORK;CELL");
     $addr = $this->GetAddress();
     if (is_array($addr)) {
         $vcard->setAddress($addr["name"], "", $addr["address"], $addr["town"], $addr["state"], $addr["postcode"], $addr["country"], "WORK;POSTAL");
     }
     $vcard->setEmail($this->fields["email"]);
     $vcard->setNote($this->fields["comment"]);
     $vcard->setURL($this->GetWebsite(), "WORK");
     // send the  VCard
     $output = $vcard->getVCard();
     $filename = $vcard->getFileName();
     // "xxx xxx.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;
 }
Пример #5
0
    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');
    }
    // Si contact lie a un tiers non de type "particulier"
    if ($contact->typent_code != 'TE_PRIVATE') {
        $v->setOrg($company->nom);
    }
}
// Personal informations
$v->setPhoneNumber($contact->phone_perso, "HOME;VOICE");
if ($contact->birthday) {
    $v->setBirthday($contact->birthday);
}
$db->close();
// Renvoi la VCard au navigateur
$output = $v->getVCard();
$filename = trim(urldecode($v->getFileName()));
// "Nom prenom.vcf"
$filenameurlencoded = dol_sanitizeFileName(urlencode($filename));
//$filename = dol_sanitizeFileName($filename);
header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
header("Content-Length: " . dol_strlen($output));
header("Connection: close");
header("Content-Type: text/x-vcard; name=\"" . $filename . "\"");
print $output;
Пример #6
0
 function create_vcard($user)
 {
     global $config, $conn;
     require_once $config['basepath'] . '/include/misc.inc.php';
     $misc = new misc();
     require_once $config['basepath'] . '/include/class/vcard/vcard.inc.php';
     $v = new vCard();
     $first = $this->get_user_first_name($user);
     $last = $this->get_user_last_name($user);
     $v->setName($last, $first);
     $sql = 'SELECT userdb_emailaddress FROM ' . $config['lang_table_prefix'] . 'userdb WHERE userdb_id=' . $user;
     $recordSet = $conn->Execute($sql);
     if ($recordSet === false) {
         $misc->log_error($sql);
     }
     $email = $recordSet->fields['userdb_emailaddress'];
     $v->setEmail($email);
     $sql = $sql = "SELECT userdbelements_field_name,userdbelements_field_value FROM " . $config['lang_table_prefix'] . "userdbelements WHERE userdb_id=" . $user;
     $recordSet = $conn->Execute($sql);
     if ($recordSet === false) {
         $misc->log_error($sql);
     }
     while (!$recordSet->EOF) {
         if ($recordSet->fields['userdbelements_field_name'] == $config['vcard_phone']) {
             $phone = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setPhoneNumber($phone, "HOME;VOICE");
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_fax']) {
             $fax = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setPhoneNumber($fax, "HOME;FAX");
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_mobile']) {
             $mobile = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setPhoneNumber($mobile, "HOME;CELL");
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_notes']) {
             $notes = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setNote($notes);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_url']) {
             $url = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
             $v->setURL($url, "HOME");
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_address']) {
             $address = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_city']) {
             $city = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_state']) {
             $state = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_zip']) {
             $zip = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         } elseif ($recordSet->fields['userdbelements_field_name'] == $config['vcard_country']) {
             $country = $misc->make_db_unsafe($recordSet->fields['userdbelements_field_value']);
         }
         $v->setAddress("", "", $address, $city, $state, $zip, $country, "HOME;POSTAL");
         $recordSet->MoveNext();
     }
     $output = $v->getVCard();
     echo $output;
     $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}");
 }