Ejemplo n.º 1
0
    function export($user)
    {
        global $db, $loader;
        $row = $db->fetch('
			select
				*
			from
				sitellite_user
			where
				username = ?', $user);
        if (!$row) {
            $this->error = $db->error;
            return false;
        }
        // build vcard
        $loader->import('saf.Date.vCalendar');
        $card = new vCal();
        $card->tag = 'VCARD';
        $card->addProperty('VERSION', '3.0');
        $card->addProperty('PRODID', '-//Simian Systems\\, Inc//NONSGML Sitellite CMS ' . SITELLITE_VERSION . '//EN');
        if (empty($row->firstname) && empty($row->lastname)) {
            // skip name
            $card->addProperty('N', $row->username);
        } else {
            $card->addProperty('N', array($row->firstname, $row->lastname));
            $card->addProperty('FN', $row->firstname . ' ' . $row->lastname);
        }
        if (!empty($row->company)) {
            $card->addProperty('ORG', $row->company);
        }
        if (!empty($row->position)) {
            $title =& $card->addProperty('TITLE', $row->position);
            $title->addParameter('LANGUAGE', $row->lang);
        }
        if (!empty($row->email)) {
            $card->addProperty('EMAIL', $row->email, array('type' => 'WORK'));
        }
        if (!empty($row->phone)) {
            $card->addProperty('TEL', $row->phone, array('type' => 'WORK'));
        }
        if (!empty($row->cell)) {
            $card->addProperty('TEL', $row->cell, array('type' => 'CELL'));
        }
        if (!empty($row->fax)) {
            $card->addProperty('TEL', $row->fax, array('type' => 'FAX'));
        }
        if (!empty($row->home)) {
            $card->addProperty('TEL', $row->home, array('type' => 'HOME'));
        }
        if (!empty($row->address1)) {
            $card->addProperty('ADR', array('', '', $row->address1, $row->city, $row->province, $row->postal_code, $row->country), array('type' => 'HOME'));
        }
        if (!empty($row->website)) {
            $card->addProperty('URL', $row->website);
        }
        // write the vcard
        return $card->unfold($card->write());
    }
Ejemplo n.º 2
0
$card->tag = 'VCARD';
$card->addProperty('VERSION', '3.0');
$card->addProperty('FN', $user->firstname . ' ' . $user->lastname);
$card->addProperty('N', array($user->lastname, $user->firstname));
if (!empty($user->company)) {
    $card->addProperty('ORG', $user->company);
}
if (!empty($user->website)) {
    $card->addProperty('URL', $user->website, array('TYPE' => 'WORK'));
}
if (!empty($user->email)) {
    $card->addProperty('EMAIL', $user->email, array('PREF' => 'INTERNET'));
}
if (!empty($user->phone)) {
    $card->addProperty('TEL', $user->phone, array('TYPE' => 'WORK'));
}
if (!empty($user->cell)) {
    $card->addProperty('TEL', $user->cell, array('TYPE' => 'CELL'));
}
if (!empty($user->home)) {
    $card->addProperty('TEL', $user->home, array('TYPE' => 'HOME'));
}
if (!empty($user->address1)) {
    $card->addProperty('item1.ADR', array($user->address1, $user->address2, $user->city, $user->province, $user->postal_code, $user->country), array('TYPE' => 'WORK'));
}
$card->addProperty('X-SITELLITE', $user->username, array('TYPE' => 'WORK'));
// phone & address info...
header('Content-Type: text/x-vcard');
header('Content-Disposition: attachment; filename="' . $user->firstname . ' ' . $user->lastname . '.vcf');
echo $card->unfold($card->write());
exit;