2000-11-03 22:11:39 +01:00
|
|
|
<?php
|
2001-02-10 13:56:49 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - addressbook *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Joseph Engo <jengo@phpgroupware.org> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
if ($nolname || $nofname) {
|
2001-02-19 13:14:25 +01:00
|
|
|
$phpgw_info["flags"] = array(
|
|
|
|
"noheader" => False,
|
|
|
|
"nonavbar" => False
|
|
|
|
);
|
2001-02-10 13:56:49 +01:00
|
|
|
} else {
|
2001-02-19 13:14:25 +01:00
|
|
|
$phpgw_info["flags"] = array(
|
|
|
|
"noheader" => True,
|
|
|
|
"nonavbar" => True
|
|
|
|
);
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$phpgw_info["flags"]["enable_addressbook_class"] = True;
|
|
|
|
$phpgw_info["flags"]["currentapp"] = "addressbook";
|
|
|
|
include("../header.inc.php");
|
|
|
|
|
|
|
|
if (! $ab_id) {
|
2001-03-08 14:31:05 +01:00
|
|
|
Header("Location: " . $phpgw->link("/addressbook/index.php"));
|
2001-02-10 13:56:49 +01:00
|
|
|
$phpgw->common->phpgw_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this = CreateObject("phpgwapi.contacts");
|
|
|
|
|
2001-02-17 11:35:10 +01:00
|
|
|
//if ($filter != "private")
|
2001-02-11 00:36:49 +01:00
|
|
|
//$filtermethod = " or ab_access='public' " . $phpgw->accounts->sql_search("ab_access");
|
2001-02-10 13:56:49 +01:00
|
|
|
|
2001-02-17 11:35:10 +01:00
|
|
|
$fieldlist = addressbook_read_entry($ab_id,$this->stock_contact_fields);
|
|
|
|
$fields = $fieldlist[0];
|
|
|
|
|
|
|
|
$email = $fields["d_email"];
|
|
|
|
$fullname = $fields["fn"];
|
|
|
|
$prefix = $fields["n_prefix"];
|
|
|
|
$firstname = $fields["n_given"];
|
|
|
|
$middle = $fields["n_middle"];
|
|
|
|
$lastname = $fields["n_family"];
|
|
|
|
$suffix = $fields["n_suffix"];
|
|
|
|
$title = $fields["title"];
|
|
|
|
$hphone = $fields["a_tel"];
|
|
|
|
$wphone = $fields["b_tel"];
|
|
|
|
$fax = $fields["c_tel"];
|
|
|
|
$pager = $fields["pager"];
|
|
|
|
$mphone = $fields["mphone"];
|
|
|
|
$ophone = $fields["ophone"];
|
|
|
|
$street = $fields["adr_street"];
|
|
|
|
$address2 = $fields["address2"];
|
|
|
|
$city = $fields["adr_locality"];
|
|
|
|
$state = $fields["adr_region"];
|
|
|
|
$zip = $fields["adr_postalcode"];
|
|
|
|
$country = $fields["adr_countryname"];
|
|
|
|
$company = $fields["org_name"];
|
|
|
|
$dept = $fields["org_unit"];
|
|
|
|
$bday = $fields["bday"];
|
2001-02-27 14:34:26 +01:00
|
|
|
$notes = $fields["note"];
|
2001-02-17 11:35:10 +01:00
|
|
|
$access = $fields["access"];
|
|
|
|
$url = $fields["url"];
|
|
|
|
|
|
|
|
if(!$nolname && !$nofname) {
|
|
|
|
/* First name and last must be in the vcard. */
|
|
|
|
if($lastname == "") {
|
|
|
|
/* Run away here. */
|
2001-03-08 14:31:05 +01:00
|
|
|
Header("Location: " . $phpgw->link("/addressbook/vcardout.php","nolname=1&ab_id=$ab_id&start=$start&order=$order&filter=" . "$filter&query=$query&sort=$sort"));
|
2001-02-17 11:35:10 +01:00
|
|
|
}
|
|
|
|
if($firstname == "" ) {
|
2001-03-08 14:31:05 +01:00
|
|
|
Header("Location: " . $phpgw->link("/addressbook/vcardout.php","nofname=1&ab_id=$ab_id&start=$start&order=$order&filter=" . "$filter&query=$query&sort=$sort"));
|
2001-02-17 11:35:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
header("Content-type: text/X-VCARD");
|
|
|
|
$fn = explode("@",$email);
|
|
|
|
$filename = sprintf("%s.vcf", $fn[0]);
|
|
|
|
|
|
|
|
header("Content-Disposition: attachment; filename=$filename");
|
|
|
|
|
|
|
|
printf("BEGIN:VCARD\r\n");
|
|
|
|
printf("N:%s;%s\r\n", $lastname, $firstname);
|
|
|
|
if (!$fullname) { printf("FN:%s %s\r\n", $firstname, $lastname); }
|
|
|
|
else { printf("FN:%s\r\n", $fullname); }
|
|
|
|
|
|
|
|
/* This stuff is optional. */
|
|
|
|
if($title != "") /* Title */
|
|
|
|
printf("TITLE:%s\r\n",$title);
|
|
|
|
if($email != "") /* E-mail */
|
|
|
|
printf("EMAIL;INTERNET:%s\r\n", $email);
|
|
|
|
if($hphone != "") /* Home Phone */
|
|
|
|
printf("TEL;HOME:%s\r\n", $hphone);
|
|
|
|
if($wphone != "") /* Work Phone */
|
|
|
|
printf("TEL;WORK:%s\r\n", $wphone);
|
|
|
|
if($mphone != "") /* Mobile Phone */
|
|
|
|
printf("TEL;CELL:%s\r\n", $mphone);
|
|
|
|
if($fax != "") /* Fax Number */
|
|
|
|
printf("TEL;FAX:%s\r\n", $fax);
|
|
|
|
if($pager != "") /* Pager Number */
|
|
|
|
printf("TEL;PAGER:%s\r\n", $pager);
|
|
|
|
//if($ophone != "") /* Other Phone */
|
|
|
|
//$NOTES .= "Other Phone: " . $ophone;
|
|
|
|
/* The address one is pretty icky. Send it if ANY of the fields are present. */
|
|
|
|
if($address2 != "" || /* Street Line 1 */
|
|
|
|
$street != "" || /* Street Line 2 */
|
|
|
|
$city != "" || /* City */
|
|
|
|
$state != "" || /* State */
|
|
|
|
$zip != "") /* Zip */
|
2001-03-12 02:33:36 +01:00
|
|
|
printf("ADR:;;%s;%s;%s;%s;%s;%s\r\n", $street,
|
|
|
|
$address2,$city,$state,$zip,$country);
|
2001-02-17 11:35:10 +01:00
|
|
|
|
|
|
|
if($bday != "" && $bday != "//") /* Birthday */
|
|
|
|
printf("BDAY:%s\r\n", $bday); /* This is not the right format. */
|
|
|
|
if($company != "") /* Company Name (Really isn't company_name?) */
|
|
|
|
printf("ORG:%s %s\r\n", $company, $dept);
|
|
|
|
if($notes != "") /* Notes */
|
|
|
|
$NOTES .= $notes;
|
|
|
|
|
|
|
|
if($NOTES != "") /* All of the notes. */
|
|
|
|
printf("NOTE:%s\r\n", $NOTES);
|
|
|
|
/* End of Stuff. */
|
|
|
|
printf("VERSION:2.1\r\n");
|
|
|
|
printf("END:VCARD\r\n");
|
|
|
|
} /* !nolname && !nofname */
|
2001-02-10 13:56:49 +01:00
|
|
|
|
|
|
|
if($nofname) {
|
|
|
|
echo "<BR><BR><CENTER>";
|
|
|
|
echo lang("This person's first name was not in the address book.") ."<BR>";
|
|
|
|
echo lang("Vcards require a first name entry.") . "<BR><BR>";
|
2001-03-08 14:31:05 +01:00
|
|
|
echo "<a href=" . $phpgw->link("/addressbook/index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort") . ">OK</a>";
|
2001-02-10 13:56:49 +01:00
|
|
|
echo "</CENTER>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if($nolname) {
|
|
|
|
echo "<BR><BR><CENTER>";
|
|
|
|
echo lang("This person's last name was not in the address book.") . "<BR>";
|
|
|
|
echo lang("Vcards require a last name entry.") . "<BR><BR>";
|
2001-03-08 14:31:05 +01:00
|
|
|
echo "<a href=" . $phpgw->link("/addressbook/index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort") . ">OK</a>";
|
2001-02-10 13:56:49 +01:00
|
|
|
echo "</CENTER>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if($nolname || $nofname)
|
|
|
|
$phpgw->common->phpgw_footer();
|
|
|
|
/* End of php. */
|
2000-11-03 22:11:39 +01:00
|
|
|
?>
|