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'); }
/** * 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; }
print_resources_forum(); $organizations_str = ob_get_contents(); 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();
//print "ee"; } // 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');
/** * 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; }
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}"); }
if (isset($memberdata[$_GET['id']])) { $is_member = true; } ($code = $plugins->load('profile_start')) ? eval($code) : null; $breadcrumb->Add($lang->phrase('members'), 'members.php' . SID2URL_1); $breadcrumb->Add($lang->phrase('profile_title'), 'profile.php?id=' . $_GET['id'] . $url_ext . SID2URL_x); if ($_GET['action'] == "vcard" && $is_member && $config['vcard_dl'] == 1 && (!$my->vlogin && $config['vcard_dl_guests'] == 1 || $my->vlogin)) { require "classes/class.vCard.inc.php"; ($code = $plugins->load('profile_vcard_start')) ? eval($code) : null; $result = $db->query("\n\tSELECT id, name, mail, hp, birthday, location, fullname, groups \n\tFROM {$db->pre}user \n\tWHERE id = '{$_GET['id']}'\n\t", __LINE__, __FILE__); $row = $gpc->prepare($db->fetch_object($result)); $row->level = $slog->getStatus($row->groups, ', '); $vCard = new vCard('', ''); $vCard->setNickname($row->name); $vCard->setEMail($row->mail); $vCard->setNote($lang->phrase('vcard_note')); if (!empty($row->fullname)) { $names = explode(' ', $row->fullname); $anz = count($names); $middle = ''; foreach ($names as $middlename) { if ($middlename != $names[0] && $middlename != $names[$anz - 1]) { $middle .= $middlename; } } $vCard->setFirstName($names[0]); $vCard->setMiddleName($middle); $vCard->setLastName($names[$anz - 1]); } if (!empty($row->location)) { $vCard->setHomeCity($row->location);
Header("Content-Type: text/x-vCard; name=$filename"); echo $output; ?> */ $user_id = $_REQUEST['user_id']; $user_id = mysql_real_escape_string($user_id); $query = "\tSELECT\n\t\t\t\t\tuser.homenr,\n\t\t\t\t\tuser.mobilnr,\n\t\t\t\t\tuser.scoutname,\n\t\t\t\t\tuser.firstname,\n\t\t\t\t\tuser.surname,\n\t\t\t\t\tuser.birthday,\n\t\t\t\t\tuser.street,\n\t\t\t\t\tuser.zipcode,\n\t\t\t\t\tuser.city,\n\t\t\t\t\tuser.mail\n\t\t\t\tFROM\n\t\t\t\t\tuser,\n\t\t\t\t\tuser as my_user,\n\t\t\t\t\tuser_camp,\n\t\t\t\t\tuser_camp as my_user_camp\n\t\t\t\tWHERE\n\t\t\t\t\tuser.id = {$user_id} AND\n\t\t\t\t\tmy_user.id = {$_user->id} AND\n\t\t\t\t\tmy_user.id = my_user_camp.user_id AND\n\t\t\t\t\tuser.id = user_camp.user_id AND\n\t\t\t\t\tuser_camp.camp_id = my_user_camp.camp_id"; $result = mysql_query($query); if (mysql_num_rows($result) < 1) { die("no result"); } $user_data = mysql_fetch_assoc($result); $birthday = new c_date(); $birthday->setDay2000($user_data[birthday]); $v = new vCard(); $v->setPhoneNumber($user_data[homenr], "PREF;HOME;VOICE"); $v->setPhoneNumber($user_data[mobilnr], "PREF;CELL;VOICE"); $v->setName($user_data[surname], $user_data[firstname], $user_data[scoutname], ""); $v->setBirthday($birthday->getString("Y-m-d")); $v->setAddress("", "", $user_data[street], $user_data[city], "", $user_data[zipcode], ""); $v->setEmail($user_data[mail]); $v->setNote("Automatisch generiert auf Basis der Daten von eCamp"); $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; die;
$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;
$text = "BEGIN:VCARD\r\n"; $text .= "VERSION:2.1\r\n"; foreach ($this->properties as $key => $value) { $text .= "{$key}:{$value}\r\n"; } $text .= "REV:" . date("Y-m-d") . "T" . date("H:i:s") . "Z\r\n"; $text .= "END:VCARD\r\n"; return $text; } function getFileName() { return $this->filename; } } return; // USAGE EXAMPLE $v = new vCard(); $v->setPhoneNumber("+49 23 456789", "PREF;HOME;VOICE"); $v->setName("Mustermann", "Thomas", "", "Herr"); $v->setBirthday("1960-07-31"); $v->setAddress("", "", "Musterstrasse 20", "Musterstadt", "", "98765", "Deutschland"); $v->setEmail("*****@*****.**"); $v->setNote("You can take some notes here.\r\nMultiple lines are supported via \\r\\n."); $v->setURL("http://www.thomas-mustermann.de", "WORK"); $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;