Exemple #1
0
 /**
  * Heart of the vCard data assignment process.
  *
  * The runner gets all the metadata for the contact and calls the writeVcard method to output the vCard
  * to the user.
  */
 public function run()
 {
     $this->preProcess();
     $params = array();
     $defaults = array();
     $ids = array();
     $params['id'] = $params['contact_id'] = $this->_contactId;
     $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids);
     // now that we have the contact's data - let's build the vCard
     // TODO: non-US-ASCII support (requires changes to the Contact_Vcard_Build class)
     $vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'vcard_name'));
     $vcard = new Contact_Vcard_Build('2.1');
     if ($defaults['contact_type'] == 'Individual') {
         $vcard->setName(CRM_Utils_Array::value('last_name', $defaults), CRM_Utils_Array::value('first_name', $defaults), CRM_Utils_Array::value('middle_name', $defaults), CRM_Utils_Array::value('prefix', $defaults), CRM_Utils_Array::value('suffix', $defaults));
         $organizationName = CRM_Utils_Array::value('organization_name', $defaults);
         if ($organizationName !== NULL) {
             $vcard->addOrganization($organizationName);
         }
     } elseif ($defaults['contact_type'] == 'Organization') {
         $vcard->setName($defaults['organization_name'], '', '', '', '');
     } elseif ($defaults['contact_type'] == 'Household') {
         $vcard->setName($defaults['household_name'], '', '', '', '');
     }
     $vcard->setFormattedName($defaults['display_name']);
     $vcard->setSortString($defaults['sort_name']);
     if (!empty($defaults['nick_name'])) {
         $vcard->addNickname($defaults['nick_name']);
     }
     if (!empty($defaults['job_title'])) {
         $vcard->setTitle($defaults['job_title']);
     }
     if (!empty($defaults['birth_date_display'])) {
         $vcard->setBirthday(CRM_Utils_Array::value('birth_date_display', $defaults));
     }
     if (!empty($defaults['home_URL'])) {
         $vcard->setURL($defaults['home_URL']);
     }
     // TODO: $vcard->setGeo($lat, $lon);
     if (!empty($defaults['address'])) {
         $stateProvices = CRM_Core_PseudoConstant::stateProvince();
         $countries = CRM_Core_PseudoConstant::country();
         foreach ($defaults['address'] as $location) {
             // we don't keep PO boxes in separate fields
             $pob = '';
             $extend = CRM_Utils_Array::value('supplemental_address_1', $location);
             if (!empty($location['supplemental_address_2'])) {
                 $extend .= ', ' . $location['supplemental_address_2'];
             }
             $street = CRM_Utils_Array::value('street_address', $location);
             $locality = CRM_Utils_Array::value('city', $location);
             $region = NULL;
             if (!empty($location['state_province_id'])) {
                 $region = $stateProvices[CRM_Utils_Array::value('state_province_id', $location)];
             }
             $country = NULL;
             if (!empty($location['country_id'])) {
                 $country = $countries[CRM_Utils_Array::value('country_id', $location)];
             }
             $postcode = CRM_Utils_Array::value('postal_code', $location);
             if (!empty($location['postal_code_suffix'])) {
                 $postcode .= '-' . $location['postal_code_suffix'];
             }
             $vcard->addAddress($pob, $extend, $street, $locality, $region, $postcode, $country);
             $vcardName = $vcardNames[$location['location_type_id']];
             if ($vcardName) {
                 $vcard->addParam('TYPE', $vcardName);
             }
             if (!empty($location['is_primary'])) {
                 $vcard->addParam('TYPE', 'PREF');
             }
         }
     }
     if (!empty($defaults['phone'])) {
         foreach ($defaults['phone'] as $phone) {
             $vcard->addTelephone($phone['phone']);
             $vcardName = $vcardNames[$phone['location_type_id']];
             if ($vcardName) {
                 $vcard->addParam('TYPE', $vcardName);
             }
             if ($phone['is_primary']) {
                 $vcard->addParam('TYPE', 'PREF');
             }
         }
     }
     if (!empty($defaults['email'])) {
         foreach ($defaults['email'] as $email) {
             $vcard->addEmail($email['email']);
             $vcardName = $vcardNames[$email['location_type_id']];
             if ($vcardName) {
                 $vcard->addParam('TYPE', $vcardName);
             }
             if ($email['is_primary']) {
                 $vcard->addParam('TYPE', 'PREF');
             }
         }
     }
     // all that's left is sending the vCard to the browser
     $filename = CRM_Utils_String::munge($defaults['display_name']);
     $vcard->send($filename . '.vcf', 'attachment', 'utf-8');
     CRM_Utils_System::civiExit();
 }
Exemple #2
0
    die('You should not access this file directly.');
}
// get GETPARAMETER for contact_id
$contact_id = (int) w2PgetParam($_GET, 'contact_id', 0);
$canRead = $perms->checkModule('contacts', 'view');
if (!$canRead) {
    $AppUI->redirect('m=public&a=access_denied');
}
if ($contact_id) {
    $contact = new CContact();
    $contact->loadFull($AppUI, $contact_id);
    // include PEAR vCard class
    require_once $AppUI->getLibraryClass('PEAR/Contact_Vcard_Build');
    // instantiate a builder object
    // (defaults to version 3.0)
    $vcard = new Contact_Vcard_Build();
    // set a formatted name
    $vcard->setFormattedName($contact->contact_first_name . ' ' . $contact->contact_last_name);
    // set the structured name parts
    $vcard->setName($contact->contact_last_name, $contact->contact_first_name, $contact->contact_type, $contact->contact_title, '');
    // set the source of the vCard
    $vcard->setSource($w2Pconfig['company_name'] . ' ' . $w2Pconfig['page_title'] . ': ' . $w2Pconfig['site_domain']);
    // set the birthday of the contact
    $vcard->setBirthday($contact->contact_birthday);
    // set a note of the contact
    $contact->contact_notes = mb_str_replace("\r", ' ', $contact->contact_notes);
    $vcard->setNote($contact->contact_notes);
    // add an organization
    $vcard->addOrganization($contact->company_name);
    // add dp company id
    $vcard->setUniqueID($contact->contact_company);
 /**
  * export the member informations as a vcard (*.vcf)
  *
  * @param integer $id
  * @return void
  */
 function _exportVCard($id)
 {
     global $objDatabase;
     //error_reporting(E_ALL);ini_set('display_errors',1);
     $query = "  SELECT `pic1`, `pic2`, `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `13`, `14`, `15`, `16`, `17`, `18`\n                    FROM `" . DBPREFIX . "module_memberdir_values`\n                    WHERE `id` = " . $id;
     if (($objRS = $objDatabase->SelectLimit($query, 1)) !== false) {
         \Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/PEAR/Contact_Vcard_Build.php');
         $vcard = new \Contact_Vcard_Build();
         $lastname = $objRS->fields['1'];
         $firstname = $objRS->fields['2'];
         $company = $objRS->fields['3'];
         $phone = $objRS->fields['4'];
         $mobile = $objRS->fields['5'];
         $address = $objRS->fields['6'];
         $zip = $objRS->fields['7'];
         $city = $objRS->fields['8'];
         $email = $objRS->fields['9'];
         $fax = $objRS->fields['10'];
         $homepage = $objRS->fields['11'];
         $birthday = $objRS->fields['12'];
         $special1 = $objRS->fields['13'];
         $special2 = $objRS->fields['14'];
         $special3 = $objRS->fields['15'];
         $special4 = $objRS->fields['16'];
         $special5 = $objRS->fields['17'];
         $special6 = $objRS->fields['18'];
         $vcard->setFormattedName("{$lastname} {$firstname}");
         $vcard->setName($lastname, $firstname, '', '', '');
         $vcard->addEmail($email);
         $vcard->addParam('TYPE', 'HOME');
         $vcard->addAddress($address, '', '', '', '', '', '');
         $vcard->addOrganization($company);
         $vcard->addTelephone($phone);
         $vcard->addParam('TYPE', 'HOME');
         $vcard->addTelephone($mobile);
         $vcard->addParam('TYPE', 'CELL');
         $vcard->setURL($homepage);
         $vcard->setBirthday($birthday);
         header('Content-Disposition: attachment; filename="' . $lastname . '_' . $firstname . '.vcf"');
         header('Content-Type: text/x-vcard');
         echo $vcard->fetch();
         die;
     } else {
         die('DB Error: ' . $objDatabase->ErrorMsg());
     }
 }
}
if (isset($_GET['contact_id']) && !($_GET['contact_id'] == '')) {
    //pull data for this contact
    $q = new DBQuery();
    $q->addTable('contacts');
    $q->addQuery('*');
    $q->addWhere("contact_id = {$contact_id}");
    $contacts = $q->loadList();
    //foreach ($contacts as $row) {
    //echo $row['contact_id'];
    //}
    // include PEAR vCard class
    require_once $AppUI->getLibraryClass('PEAR/Contact_Vcard_Build');
    // instantiate a builder object
    // (defaults to version 3.0)
    $vcard = new Contact_Vcard_Build();
    // set a formatted name
    $vcard->setFormattedName($contacts[0]['contact_first_name'] . ' ' . $contacts[0]['contact_last_name']);
    // set the structured name parts
    $vcard->setName($contacts[0]['contact_last_name'], $contacts[0]['contact_first_name'], $contacts[0]['contact_type'], $contacts[0]['contact_title'], '');
    // set the source of the vCard
    $vcard->setSource($dPconfig['company_name'] . ' ' . $dPconfig['page_title'] . ': ' . $dPconfig['site_domain']);
    // set the birthday of the contact
    $vcard->setBirthday($contacts[0]['contact_birthday']);
    // set a note of the contact
    $contacts[0]['contact_notes'] = str_replace("\r", " ", $contacts[0]['contact_notes']);
    $vcard->setNote($contacts[0]['contact_notes']);
    // add an organization
    $vcard->addOrganization($contacts[0]['contact_company']);
    // add a phone number
    $vcard->addTelephone($contacts[0]['contact_phone']);
 public static function vcard($mailvars)
 {
     if (!is_array($mailvars)) {
         return false;
     }
     $default = array('firstname' => '', 'middlename' => '', 'lastname' => '', 'nickname' => '', 'title' => '', 'work_title' => '', 'email' => '', 'pobox' => '', 'extendedaddress' => '', 'street' => '', 'zipcode' => '', 'city' => '', 'state' => '', 'country' => '', 'work_pobox' => '', 'work_office' => '', 'work_street' => '', 'work_zipcode' => '', 'work_city' => '', 'work_state' => '', 'work_country' => '', 'birthday' => '', 'work_email' => '', 'work_telephone' => '', 'website' => '', 'telephone' => '', 'work_role' => '', 'note' => '', 'work_organization' => '');
     $vars = array_merge($default, $mailvars);
     $vcard = new Contact_Vcard_Build();
     // General informations
     $vcard->setFormattedName($vars['nom'] . ' ' . $vars['lastname']);
     $vcard->setName($vars['lastname'], $vars['firstname'], $vars['middlename'], $vars['title'], '');
     $vcard->setBirthday($vars['birthday']);
     $vcard->addNickname($vars['nickname']);
     $vcard->setNote($vars['note']);
     // Home informations
     $vcard->addEmail($vars['email']);
     $vcard->addParam('TYPE', 'HOME');
     $vcard->addTelephone($vars['telephone']);
     $vcard->addParam('TYPE', 'HOME');
     $vcard->addAddress($vars['pobox'], $vars['street'], $vars['extendedaddress'], $vars['city'], $vars['state'], $vars['zipcode'], $vars['country']);
     $vcard->addParam('TYPE', 'HOME');
     $vcard->setURL($vars['website']);
     $vcard->addParam('TYPE', 'HOME');
     // Business informations
     $vcard->addEmail($vars['work_email']);
     $vcard->addParam('TYPE', 'WORK');
     $vcard->addTelephone($vars['work_telephone']);
     $vcard->addParam('TYPE', 'WORK');
     $vcard->addAddress($vars['work_pobox'], $vars['work_office'], $vars['work_street'], $vars['work_city'], $vars['work_state'], $vars['work_zipcode'], $vars['work_country']);
     $vcard->addParam('TYPE', 'WORK');
     $vcard->addOrganization($vars['work_organization']);
     $vcard->setRole($vars['work_role']);
     $vcard->setTitle($vars['work_title']);
     return $vcard->fetch();
 }
Exemple #6
0
 function vcard($data)
 {
     $vcard = new Contact_Vcard_Build();
     $vcard->setFormattedName($data["first_name"] . " " . $data["last_name"]);
     $vcard->setName($data["last_name"], $data["first_name"], NULL, NULL, NULL);
     if ($data["email"]) {
         $vcard->addEmail($data['email']);
     }
     $address = explode("\n", $data["address"]);
     $cityregionpost = explode(",", $address[1]);
     $regionpost = explode(" ", $cityregionpost[1]);
     $vcard->addAddress(NULL, NULL, $address[0], $cityregionpost[0], $regionpost[0], $regionpost[1], NULL);
     $vcard->addParam("TYPE", "HOME");
     if ($data["work_phone"]) {
         $vcard->addTelephone($data["work_phone"]);
         $vcard->addParam("TYPE", "WORK");
     }
     if ($data["home_phone"]) {
         $vcard->addTelephone($data["home_phone"]);
         $vcard->addParam("TYPE", "HOME");
     }
     $vcard->setURL($this->config["base_uri"] . "actors/" . $data["mbrid"]);
     $vcard->setUniqueID($data["barcode_nmbr"]);
     return $vcard->fetch();
 }
 /**
  * Gibt vCard Daten zurück. Statisch weil es auch von der Trl_Component
  * aufgerufen wird.
  */
 protected function _getVcardContent($dataRow, $imageData)
 {
     $defaults = $this->_getDefaultValues();
     require_once Kwf_Config::getValue('externLibraryPath.pearContactVcardBuild') . '/Contact/Vcard/Build.php';
     $vcard = new Contact_Vcard_Build('2.1');
     $vcard->setName(utf8_decode($dataRow->lastname), utf8_decode($dataRow->firstname), '', utf8_decode($dataRow->title), '');
     $vcard->addParam('CHARSET', 'ISO-8859-1');
     $vcard->setFormattedName(utf8_decode($dataRow->firstname) . ' ' . utf8_decode($dataRow->lastname));
     $vcard->addParam('CHARSET', 'ISO-8859-1');
     if (isset($defaults['ORG'])) {
         $vcard->addOrganization(utf8_decode($defaults['ORG']));
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     if (!empty($dataRow->working_position)) {
         $vcard->setRole(utf8_decode($dataRow->working_position));
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     if (!empty($dataRow->phone)) {
         $vcard->addTelephone(utf8_decode($dataRow->phone));
         $vcard->addParam('TYPE', 'WORK');
         $vcard->addParam('TYPE', 'PREF');
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     if (!empty($dataRow->mobile)) {
         $vcard->addTelephone(utf8_decode($dataRow->mobile), 'mobile');
         $vcard->addParam('TYPE', 'WORK');
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     $fax = null;
     if (!empty($dataRow->fax)) {
         $fax = $dataRow->fax;
     } else {
         if (isset($defaults['TEL;WORK;FAX'])) {
             $fax = $defaults['TEL;WORK;FAX'];
         }
     }
     if ($fax) {
         $vcard->addTelephone(utf8_decode($fax), 'fax');
         $vcard->addParam('TYPE', 'WORK');
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     if (!empty($dataRow->email)) {
         $vcard->addEmail(utf8_decode($dataRow->email));
         $vcard->addParam('TYPE', 'WORK');
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     if (isset($defaults['URL;WORK'])) {
         $vcard->setURL(utf8_decode($defaults['URL;WORK']));
         $vcard->addParam('TYPE', 'WORK');
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     if (isset($defaults['NOTE'])) {
         $vcard->setNote(utf8_decode($defaults['NOTE']));
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     if (isset($defaults['ADR;WORK']) || !empty($dataRow->street) || !empty($dataRow->city) || !empty($dataRow->zip) || !empty($dataRow->country)) {
         /**
          * muss ein array mit folgenden werten liefern:
          * 0 => ''
          * 1 => ''
          * 2 => street
          * 3 => city
          * 4 => province
          * 5 => zip
          * 6 => country
          */
         $values = array();
         if (!empty($defaults['ADR;WORK'])) {
             $values = explode(';', utf8_decode($defaults['ADR;WORK']));
         }
         for ($i = 0; $i <= 6; $i++) {
             if (!isset($values[$i])) {
                 $values[$i] = '';
             }
         }
         if (!empty($dataRow->street)) {
             $values[2] = utf8_decode($dataRow->street);
         }
         if (!empty($dataRow->city)) {
             $values[3] = utf8_decode($dataRow->city);
         }
         if (!empty($dataRow->country)) {
             $values[4] = utf8_decode($dataRow->country);
         }
         if (!empty($dataRow->zip)) {
             $values[5] = utf8_decode($dataRow->zip);
         }
         if (!empty($dataRow->country)) {
             $values[6] = utf8_decode($dataRow->country);
         }
         $vcard->addAddress($values[0], $values[1], $values[2], $values[3], $values[4], $values[5], $values[6]);
         $vcard->addParam('TYPE', 'WORK');
         $vcard->addParam('CHARSET', 'ISO-8859-1');
     }
     if ($imageData && $imageData->hasContent()) {
         $data = call_user_func_array(array($imageData->componentClass, 'getMediaOutput'), array($imageData->componentId, 'default', $imageData->componentClass));
         $type = explode('/', $data['mimeType']);
         $type[1] = strtoupper($type[1]);
         if ($type[1] == 'PJPEG') {
             $type[1] = 'JPEG';
         }
         if ($type[1] == 'JPEG') {
             $vcard->setPhoto(base64_encode($data['contents']));
             $vcard->addParam('TYPE', $type[1]);
             $vcard->addParam('ENCODING', 'BASE64');
         }
     }
     $vcard->setRevision(date('Y-m-d') . 'T' . date('H:i:s') . 'Z');
     return $vcard->fetch();
 }
Exemple #8
0
$sBirthDate = FormatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, "-", $per_Flags);
// Assign the values locally, after selecting whether to display the family or person information
SelectWhichAddress($sAddress1, $sAddress2, $per_Address1, $per_Address2, $fam_Address1, $fam_Address2, False);
$sCity = SelectWhichInfo($per_City, $fam_City, False);
$sState = SelectWhichInfo($per_State, $fam_State, False);
$sZip = SelectWhichInfo($per_Zip, $fam_Zip, False);
$sCountry = SelectWhichInfo($per_Country, $fam_Country, False);
$sHomePhone = SelectWhichInfo(ExpandPhoneNumber($per_HomePhone, $sCountry, $dummy), ExpandPhoneNumber($fam_HomePhone, $fam_Country, $dummy), False);
$sWorkPhone = SelectWhichInfo(ExpandPhoneNumber($per_WorkPhone, $sCountry, $dummy), ExpandPhoneNumber($fam_WorkPhone, $fam_Country, $dummy), False);
$sCellPhone = SelectWhichInfo(ExpandPhoneNumber($per_CellPhone, $sCountry, $dummy), ExpandPhoneNumber($fam_CellPhone, $fam_Country, $dummy), False);
$sEmail = SelectWhichInfo($per_Email, $fam_Email, False);
// Instantiate the vCard class and then build the card.
if ($bOldVCardVersion) {
    $vcard = new Contact_Vcard_Build(2.1);
} else {
    $vcard = new Contact_Vcard_Build();
}
// set a formatted name
$vcard->setFormattedName(iconv("UTF-8", "ISO-8859-1", FormatFullName($per_Title, $per_FirstName, $per_MiddleName, $per_LastName, $per_Suffix, 0)));
// set the structured name parts
$vcard->setName(iconv("UTF-8", "ISO-8859-1", $per_LastName), iconv("UTF-8", "ISO-8859-1", $per_FirstName), iconv("UTF-8", "ISO-8859-1", $per_MiddleName), iconv("UTF-8", "ISO-8859-1", $per_Title), iconv("UTF-8", "ISO-8859-1", $per_Suffix));
$vcard->addEmail(iconv("UTF-8", "ISO-8859-1", $sEmail));
$vcard->addParam('TYPE', 'HOME');
$vcard->addParam('TYPE', 'PREF');
$vcard->addEmail(iconv("UTF-8", "ISO-8859-1", $per_WorkEmail));
$vcard->addParam('TYPE', 'WORK');
if ($bPalmVCard) {
    $vcard->addAddress(';', iconv("UTF-8", "ISO-8859-1", $sAddress1), iconv("UTF-8", "ISO-8859-1", $sAddress2), iconv("UTF-8", "ISO-8859-1", $sCity), iconv("UTF-8", "ISO-8859-1", $sState), iconv("UTF-8", "ISO-8859-1", $sZip), iconv("UTF-8", "ISO-8859-1", $sCountry));
} else {
    $vcard->addAddress('', iconv("UTF-8", "ISO-8859-1", $sAddress1), iconv("UTF-8", "ISO-8859-1", $sAddress2), iconv("UTF-8", "ISO-8859-1", $sCity), iconv("UTF-8", "ISO-8859-1", $sState), iconv("UTF-8", "ISO-8859-1", $sZip), iconv("UTF-8", "ISO-8859-1", $sCountry));
}
Exemple #9
0
function doVcards($single, $extension, $targetcode, $zip)
{
    $sql = "select * from tempcsvdata where uid = '" . $_SESSION["loginCRM"] . "' order by id";
    $csvdata = $_SESSION['db']->getAll($sql);
    if ($csvdata) {
        $pfad = $_SESSION["login"] . "/vcard";
        chkdir($pfad, '.');
        $pfad = "../dokumente/" . $_SESSION["dbname"] . "/" . $pfad . "/";
        $felder = explode(":", $csvdata[0]["csvdaten"]);
        $personen = False;
        if (in_array("TITEL", $felder)) {
            $personen = True;
        }
        $i = 0;
        foreach ($felder as $feld) {
            $felder[$feld] = $i++;
        }
        array_shift($csvdata);
        if ($single) {
            if ($personen) {
                $filename = "Pvcard." . $extension;
            } else {
                $filename = "Fvcard." . $extension;
            }
            $f = fopen($pfad . $filename, "w");
        }
        $srvcode = strtoupper($_SESSION["charset"]);
        $cnt = 0;
        foreach ($csvdata as $row) {
            $vcard = new Contact_Vcard_Build();
            if ($targetcode != $srvcode) {
                $row["csvdaten"] = iconv($srvcode, $targetcode, $row["csvdaten"]);
            }
            $data = explode(":", $row["csvdaten"]);
            $vcard->setFormattedName($data[$felder["NAME1"]]);
            if ($data[$felder["NAME2"]]) {
                if ($personen) {
                    $vcard->setName($data[$felder["NAME2"]], $data[$felder["NAME1"]], "", $data[$felder["ANREDE"]], $data[$felder["TITEL"]]);
                } else {
                    $vcard->setName($data[$felder["NAME1"]], $data[$felder["NAME2"]], "", "", "");
                }
            } else {
                if ($personen) {
                    $vcard->setName($data[$felder["NAME1"]], "", "", $data[$felder["ANREDE"]], $data[$felder["TITEL"]]);
                } else {
                    $vcard->setName($data[$felder["NAME1"]], "", "", "", "");
                }
            }
            $vcard->addAddress('', '', $data[$felder["STRASSE"]], $data[$felder["ORT"]], '', $data[$felder["PLZ"]], $data[$felder["LAND"]]);
            $vcard->addParam('TYPE', 'WORK');
            if ($personen) {
                $vcard->addOrganization($data[$felder["FIRMA"]]);
            } else {
                $vcard->addOrganization($data[$felder["NAME1"]]);
                $vcard->addOrganization($data[$felder["NAME2"]]);
            }
            if ($data["email"]) {
                $vcard->addEmail($data[$felder["EMAIL"]]);
                $vcard->addParam('TYPE', 'WORK');
            }
            if ($data["phone"]) {
                $vcard->addTelephone($data[$felder["TEL"]]);
                $vcard->addParam('TYPE', 'WORK');
            }
            if ($data["fax"]) {
                $vcard->addTelephone($data[$felder["FAX"]]);
                $vcard->addParam('TYPE', 'FAX');
            }
            // get back the vCard and print it
            $text = $vcard->fetch();
            if (!$single) {
                if ($personen) {
                    $f = fopen($pfad . "/" . $data[$felder["ID"]] . $data[$felder["NAME1"]] . "_vcard." . $extension, "w");
                } else {
                    $f = fopen($pfad . "/" . $data[$felder["KDNR"]] . "_vcard." . $extension, "w");
                }
                fputs($f, $text);
                fclose($f);
            } else {
                fputs($f, $text);
            }
            unset($vcard);
            unset($text);
            $cnt++;
        }
        if ($single) {
            fclose($f);
        }
        if ($zip) {
            require 'pclzip.lib.php';
            require 'zip.lib.php';
            if (!$single) {
                $oldpath = getCWD();
                chdir($pfad);
                $archiveFiles = glob("*_vcard." . $extension);
                chdir($oldpath);
            } else {
                //$archiveFiles[] = "vcard.".$_POST["extension"];
                $archiveFiles[] = $filename;
            }
            $filename = "vcard." . $extension . ".zip";
            $archive = new PclZip($pfad . $filename);
            $v_list = $archive->create($pfad . $_SESSION["login"], '', $pfad . $_SESSION["login"], '', "vcardPreAdd");
            $zip = new zipfile();
            for ($i = 0; $i < count($archiveFiles); $i++) {
                $file = $archiveFiles[$i];
                // zip.lib dirty hack
                $fp = fopen($pfad . $file, "r");
                $content = @fread($fp, filesize($pfad . $file));
                fclose($fp);
                $zip->addFile($content, $file);
                unlink($pfad . $file);
            }
            $fp = fopen($pfad . $filename, "w+");
            fputs($fp, $zip->file());
            fclose($fp);
        }
        if ($single || $zip) {
            echo "[<a href='" . $pfad . $filename . "'>download</a>]<br />";
        } else {
        }
    }
    echo "{$cnt} Adressen bearbeitet.";
}
Exemple #10
0
$sBirthDate = FormatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay);
// Assign the values locally, after selecting whether to display the family or person information
SelectWhichAddress($sAddress1, $sAddress2, $per_Address1, $per_Address2, $fam_Address1, $fam_Address2, False);
$sCity = SelectWhichInfo($per_City, $fam_City, False);
$sState = SelectWhichInfo($per_State, $fam_State, False);
$sZip = SelectWhichInfo($per_Zip, $fam_Zip, False);
$sCountry = SelectWhichInfo($per_Country, $fam_Country, False);
$sHomePhone = SelectWhichInfo(ExpandPhoneNumber($per_HomePhone, $sCountry, $dummy), ExpandPhoneNumber($fam_HomePhone, $fam_Country, $dummy), False);
$sWorkPhone = SelectWhichInfo(ExpandPhoneNumber($per_WorkPhone, $sCountry, $dummy), ExpandPhoneNumber($fam_WorkPhone, $fam_Country, $dummy), False);
$sCellPhone = SelectWhichInfo(ExpandPhoneNumber($per_CellPhone, $sCountry, $dummy), ExpandPhoneNumber($fam_CellPhone, $fam_Country, $dummy), False);
$sEmail = SelectWhichInfo($per_Email, $fam_Email, False);
// Instantiate the vCard class and then build the card.
if ($bOldVCardVersion) {
    $vcard = new Contact_Vcard_Build(2.1);
} else {
    $vcard = new Contact_Vcard_Build();
}
// set a formatted name
$vcard->setFormattedName(FormatFullName($per_Title, $per_FirstName, $per_MiddleName, $per_LastName, $per_Suffix, 0));
// set the structured name parts
$vcard->setName($per_LastName, $per_FirstName, $per_MiddleName, $per_Title, $per_Suffix);
$vcard->addEmail($sEmail);
$vcard->addParam('TYPE', 'HOME');
$vcard->addParam('TYPE', 'PREF');
$vcard->addEmail($per_WorkEmail);
$vcard->addParam('TYPE', 'WORK');
if ($bPalmVCard) {
    $vcard->addAddress(';', $sAddress1, $sAddress2, $sCity, $sState, $sZip, $sCountry);
} else {
    $vcard->addAddress('', $sAddress1, $sAddress2, $sCity, $sState, $sZip, $sCountry);
}
 /**
  *
  * Create a vcard from user
  *
  * @access private
  *
  * @param int $authorid  The UserID to build the vcard
  *
  * @return bool
  *
  */
 function createVCard($authorid)
 {
     global $serendipity;
     include 'Contact_Vcard_Build.php';
     if (!class_exists('Contact_Vcard_Build')) {
         return false;
     }
     $authorres = $this->getConfigVars($authorid);
     $name = explode(" ", $serendipity['POST']['profilerealname']);
     $city = explode(" ", $serendipity['POST']['profilecity']);
     $vcard = new Contact_Vcard_Build();
     $vcard->setFormattedName($serendipity['POST']['profilerealname']);
     $vcard->setName($name[1], $name[0], "", "", "");
     $vcard->addEmail($serendipity['POST']['profileemail']);
     $vcard->addParam('TYPE', 'WORK');
     $vcard->addParam('TYPE', 'PREF');
     $vcard->addAddress("", "", $serendipity['POST']['profilestreet'], $city[1], "", $city[0], $serendipity['POST']['profilecountry']);
     $vcard->addParam('TYPE', 'WORK');
     $vcard->setURL($serendipity['POST']['profileurl']);
     $card = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . serendipity_makeFilename($serendipity['POST']['profilerealname']) . ".vcf";
     if (!($fp = @fopen($card, "w"))) {
         return false;
     }
     fwrite($fp, $vcard->fetch());
     fclose($fp);
     $q = 'SELECT id
             FROM ' . $serendipity['dbPrefix'] . 'images
            WHERE name = \'' . serendipity_makeFilename($serendipity['POST']['profilerealname']) . '\'
              AND extension = \'vcf\'';
     $res = serendipity_db_query($q, true, 'assoc');
     if (!is_array($res)) {
         serendipity_insertImageInDatabase(basename($card), '');
     }
     return true;
 }
Exemple #12
0
<?php

// report all errors
error_reporting(E_ALL);
// include the class file
require_once 'Contact_Vcard_Build.php';
// instantiate a builder object
// (defaults to version 3.0)
$vcard = new Contact_Vcard_Build();
// set a formatted name
$vcard->setFormattedName('Bolivar Shagnasty');
// set the structured name parts
$vcard->setName('Shagnasty', 'Bolivar', 'Odysseus', 'Mr.', 'III');
// add a work email.  note that we add the value
// first and the param after -- Contact_Vcard_Build
// is smart enough to add the param in the correct
// place.
$vcard->addEmail('*****@*****.**');
$vcard->addParam('TYPE', 'WORK');
// add a home/preferred email
$vcard->addEmail('*****@*****.**');
$vcard->addParam('TYPE', 'HOME');
$vcard->addParam('TYPE', 'PREF');
// add a work address
$vcard->addAddress('POB 101', 'Suite 202', '123 Main', 'Beverly Hills', 'CA', '90210', 'US');
$vcard->addParam('TYPE', 'WORK');
// send the vcard
$vcard->send('boshag.txt', 'inline');
 function executeExportvcard()
 {
     global $controller, $GenderOption;
     require_once 'Contact_Vcard_Build.php';
     $vcard = new Contact_Vcard_Build();
     $apf_contact = DB_DataObject::factory('ApfContact');
     $apf_contact->get($apf_contact->escape($controller->getID()));
     // set a formatted name
     $vcard->setFormattedName($apf_contact->getName());
     // set the structured name parts
     $vcard->setName($apf_contact->getName(), '', '', $GenderOption[$apf_contact->getGender()], '');
     // add a work email.  note that we add the value
     // first and the param after -- Contact_Vcard_Build
     // is smart enough to add the param in the correct
     // place.
     $vcard->addEmail($apf_contact->getEmail());
     $vcard->addParam('TYPE', 'WORK');
     // add a home/preferred email
     $vcard->addEmail($apf_contact->getEmail());
     $vcard->addParam('TYPE', 'HOME');
     $vcard->addParam('TYPE', 'PREF');
     // add a home/preferred Telephone
     $vcard->addTelephone($apf_contact->getPhone());
     $vcard->addParam('TYPE', 'HOME');
     $vcard->addParam('TYPE', 'PREF');
     // add a home/preferred Telephone
     $vcard->addTelephone($apf_contact->getMobile());
     $vcard->addParam('TYPE', 'CELL');
     $vcard->addParam('TYPE', 'VOICE');
     // add a work address
     $vcard->addAddress('', '', $apf_contact->getAddrees(), '', '', '', 'CN');
     $vcard->addParam('TYPE', 'WORK');
     $vcard->addParam('TYPE', 'HOME');
     // set the title (checks for colon-escaping)
     //	    $vcard->setTitle('The Title: The Subtitle');
     $vcard->send($apf_contact->getName() . ".vcf");
     exit;
 }
Exemple #14
0
<?php

require_once 'Contact_Vcard_Build.php';
require_once "inc/stdLib.php";
include "inc/FirmenLib.php";
$Q = $_GET["Q"] ? $_GET["Q"] : $_POST["Q"];
// instantiate a builder object (defaults to version 3.0)
$vcard = new Contact_Vcard_Build();
if ($_GET["pid"]) {
    include "inc/persLib.php";
    $data = getKontaktStamm($_GET["pid"]);
    //UID
    $UID = 'P' . $_GET["pid"] . '@' . $_SESSION['mandant'];
    $vcard->setKey($_GET["pid"]);
    $vcard->setUniqueID($UID);
    $vcard->setRevision(date('c'));
    // set a formatted name
    $vcard->setFormattedName($data["cp_givenname"] . " " . $data["cp_name"]);
    // set the structured name parts
    $prefix = $data["cp_greeting"] ? $data["cp_greeting"] . " " . $data["cp_title"] : $data["cp_title"];
    $vcard->setName($data["cp_name"], $data["cp_givenname"], "", $prefix, "");
    // add a work email.  note that we add the value
    // first and the param after -- Contact_Vcard_Build
    // is smart enough to add the param in the correct place.
    if ($data["cp_email"]) {
        $vcard->addEmail($data["cp_email"]);
        $vcard->addParam('TYPE', 'WORK');
        $vcard->addParam('TYPE', 'PREF');
    }
    // add a work address
    $vcard->addAddress('', '', $data["cp_street"], $data["cp_city"], '', $data["cp_zipcode"], $data["cp_country"]);