function CarteIndividu($individu) { $v = new vCard(); $acl = Zend_Registry::get('acl'); $ind = Zend_Registry::get('user'); if ($acl->isAllowed($ind, $individu, 'fiche')) { $v->setName($individu->nom, $individu->prenom); if ($individu->naissance) { $v->setBirthday($individu->naissance); } $t0 = explode("\n", $individu->adresse); $t0 = array_pad($t0, 3, ''); list($adresse, $ville, $pays) = $t0; if (preg_match("`(\\d{5}) (.*)`", $ville, $res)) { $v->setAddress("", "", $adresse, $res[2], "", $res[1], $pays); } $v->setPhoneNumber($individu->fixe, "HOME"); $v->setPhoneNumber($individu->portable, "CELL"); if ($photo = $individu->getCheminImage()) { $v->setPhoto('jpeg', file_get_contents($photo)); } $v->setEmail($individu->adelec); $v->setURL($this->view->urlIndividu($individu, 'fiche', 'individus', true, true)); } else { $v->setName($individu->getName()); $v->setBirthday(substr($individu->naissance, 0, 4)); } array_push($this->view->vcards, $v); }
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 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; }
$company = new Societe($db); if ($contact->socid) { $result = $company->fetch($contact->socid); //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");
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}"); }
} // We create VCard $v = new vCard(); $v->setProdId('Dolibarr '.DOL_VERSION); $v->setUid('DOLIBARR-CONTACTID-'.$contact->id); $v->setName($contact->name, $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->ville, "", $contact->cp, ($contact->pays_code?$contact->pays:''), "WORK;POSTAL"); $v->setLabel("", "", $contact->address, $contact->ville, "", $contact->cp, ($contact->pays_code?$contact->pays:''), "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->tel, "WORK;VOICE"); if (! $contact->fax) $v->setPhoneNumber($company->fax, "WORK;FAX"); if (! $contact->cp) $v->setAddress("", "", $company->address, $company->ville, "", $company->cp, $company->pays_code, "WORK;POSTAL"); if ($company->email != $contact->email) $v->setEmail($company->email,'internet'); // Si contact lie a un tiers non de type "particulier"
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;