Пример #1
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;
 }
Пример #2
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;
 }
Пример #3
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;
Пример #4
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}");
 }
Пример #5
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;
Пример #6
0
	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"
	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;

?>