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
|
|
|
}
|
|
|
|
|
2001-03-17 16:07:01 +01:00
|
|
|
$phpgw_info["flags"]["enable_contacts_class"] = True;
|
2001-02-10 13:56:49 +01:00
|
|
|
$phpgw_info["flags"]["currentapp"] = "addressbook";
|
|
|
|
include("../header.inc.php");
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
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-03-16 02:31:25 +01:00
|
|
|
$extrafields = array(
|
|
|
|
"ophone" => "ophone",
|
|
|
|
"address2" => "address2",
|
|
|
|
"address3" => "address3"
|
|
|
|
);
|
|
|
|
$qfields = $this->stock_contact_fields + $extrafields;
|
|
|
|
|
|
|
|
$fieldlist = addressbook_read_entry($ab_id,$qfields);
|
2001-02-17 11:35:10 +01:00
|
|
|
$fields = $fieldlist[0];
|
|
|
|
|
2001-03-16 02:31:25 +01:00
|
|
|
$email = $fields["email"];
|
|
|
|
$emailtype = $fields["email_type"]; if (!$emailtype) { $emailtype = 'INTERNET'; }
|
|
|
|
$hemail = $fields["email_home"]; if (!$hemail) { $hemail = 'none'; }
|
|
|
|
$hemailtype = $fields["email_home_type"]; if (!$hemailtype) { $hemailtype = 'INTERNET'; }
|
2001-02-17 11:35:10 +01:00
|
|
|
$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"];
|
2001-03-16 02:31:25 +01:00
|
|
|
$aphone = $fields["tel_work"];
|
|
|
|
$bphone = $fields["tel_home"];
|
|
|
|
$afax = $fields["tel_fax"];
|
|
|
|
$apager = $fields["tel_pager"];
|
|
|
|
$amphone = $fields["tel_cell"];
|
|
|
|
$aisdnphone = $fields["tel_isdn"];
|
|
|
|
$acarphone = $fields["tel_car"];
|
|
|
|
$avidphone = $fields["tel_video"];
|
|
|
|
$amsgphone = $fields["tel_msg"];
|
|
|
|
$abbsphone = $fields["tel_bbs"];
|
|
|
|
$amodem = $fields["tel_modem"];
|
|
|
|
$preferred = $fields["tel_prefer"];
|
|
|
|
$aophone = $fields["ophone"];
|
|
|
|
|
|
|
|
// Setup array for display of preferred phone number below
|
|
|
|
while (list($name,$val) = each($this->tel_types)) {
|
|
|
|
if ($name == $preferred) {
|
|
|
|
$pref[$name] .= ';PREF';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$aophone = $fields["ophone"];
|
|
|
|
$astreet = $fields["adr_one_street"];
|
2001-02-17 11:35:10 +01:00
|
|
|
$address2 = $fields["address2"];
|
2001-03-16 02:31:25 +01:00
|
|
|
$acity = $fields["adr_one_locality"];
|
|
|
|
$astate = $fields["adr_one_region"];
|
|
|
|
$azip = $fields["adr_one_postalcode"];
|
|
|
|
$acountry = $fields["adr_one_countryname"];
|
2001-03-20 17:34:03 +01:00
|
|
|
$atype = strtoupper($fields["adr_one_type"]); if (!empty($atype)) { $atype = ';'.$atype; }
|
2001-03-16 02:31:25 +01:00
|
|
|
$label = $fields["label"];
|
|
|
|
|
|
|
|
$bstreet = $fields["adr_two_street"];
|
|
|
|
$bcity = $fields["adr_two_locality"];
|
|
|
|
$bstate = $fields["adr_two_region"];
|
|
|
|
$bzip = $fields["adr_two_postalcode"];
|
|
|
|
$bcountry = $fields["adr_two_countryname"];
|
2001-03-20 17:34:03 +01:00
|
|
|
$btype = strtoupper($fields["adr_two_type"]); if (!empty($btype)) { $btype = ';'.$btype; }
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-02-17 11:35:10 +01:00
|
|
|
$company = $fields["org_name"];
|
|
|
|
$dept = $fields["org_unit"];
|
2001-03-21 01:25:50 +01:00
|
|
|
|
2001-02-17 11:35:10 +01:00
|
|
|
$bday = $fields["bday"];
|
2001-03-21 01:25:50 +01:00
|
|
|
$tmp = split("/",$bday); # 12/31/1969 -> 1969-12-31
|
|
|
|
if ($tmp[0]) {
|
2001-03-21 06:14:07 +01:00
|
|
|
$bday = $tmp[2]."-".$tmp[0]."-".$tmp[1];
|
2001-03-21 01:25:50 +01:00
|
|
|
}
|
|
|
|
|
2001-03-18 00:52:36 +01:00
|
|
|
$notes = ereg_replace("\r\n","=0A",$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
|
|
|
}
|
|
|
|
|
2001-03-16 02:31:25 +01:00
|
|
|
header("Content-type: text/x-vcard");
|
2001-02-17 11:35:10 +01:00
|
|
|
$fn = explode("@",$email);
|
|
|
|
$filename = sprintf("%s.vcf", $fn[0]);
|
|
|
|
|
|
|
|
header("Content-Disposition: attachment; filename=$filename");
|
|
|
|
|
|
|
|
printf("BEGIN:VCARD\r\n");
|
2001-03-17 16:07:01 +01:00
|
|
|
printf("X-PHPGROUPWARE-FILE-AS:phpGroupWare.org\r\n");
|
2001-02-17 11:35:10 +01:00
|
|
|
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); }
|
|
|
|
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-02-17 11:35:10 +01:00
|
|
|
if($title != "") /* Title */
|
|
|
|
printf("TITLE:%s\r\n",$title);
|
2001-03-16 02:31:25 +01:00
|
|
|
|
|
|
|
// 'A' grouping - work stuff
|
2001-02-17 11:35:10 +01:00
|
|
|
if($email != "") /* E-mail */
|
2001-03-16 02:31:25 +01:00
|
|
|
printf("A.EMAIL;%s:%s\r\n", $emailtype,$email);
|
|
|
|
|
|
|
|
if($aphone != "") printf("A.TEL%s;WORK:%s\r\n", $pref['work'], $aphone);
|
|
|
|
if($amphone != "") printf("A.TEL%s;CELL:%s\r\n", $pref['cell'], $amphone);
|
|
|
|
if($afax != "") printf("A.TEL%s;FAX:%s\r\n", $pref['fax'], $afax);
|
|
|
|
if($apager != "") printf("A.TEL%s;PAGER:%s\r\n", $pref['pager'], $apager);
|
|
|
|
if($amsgphone != "") printf("A.TEL%s;MSG:%s\r\n", $pref['msg'], $amsgphone);
|
|
|
|
if($acarphone != "") printf("A.TEL%s;CAR:%s\r\n", $pref['car'], $acarphone);
|
|
|
|
if($abbs != "") printf("A.TEL%s;BBS:%s\r\n", $pref['fax'], $afax);
|
|
|
|
if($amodem != "") printf("A.TEL%s;MODEM:%s\r\n", $pref['modem'], $amodem);
|
|
|
|
if($aisdnphone != "") printf("A.TEL%s;ISDN:%s\r\n", $pref['isdn'], $aisdnphone);
|
|
|
|
if($avidphone != "") printf("A.TEL%s;VIDEO:%s\r\n", $pref['video'], $avidphone);
|
|
|
|
|
|
|
|
if($ophone != "") $NOTES .= "Other Phone: " . $ophone . "\r\n";
|
|
|
|
|
|
|
|
if($astreet != "" || /* Business Street Line 1 */
|
|
|
|
$address2 != "" || /* Business Street Line 2 */
|
|
|
|
$acity != "" || /* Business City */
|
|
|
|
$astate != "" || /* Business State */
|
|
|
|
$azip != "") { /* Business Zip */
|
|
|
|
printf("A.ADR%s;WORK:;%s;%s;%s;%s;%s;%s\r\n", $atype,$address2,
|
|
|
|
$astreet,$acity,$astate,$azip,$acountry);
|
|
|
|
}
|
|
|
|
if ($label) {
|
2001-03-21 06:14:07 +01:00
|
|
|
$label = ereg_replace("\r\n","=0D=0A",$label);
|
2001-03-21 01:25:50 +01:00
|
|
|
$label = ereg_replace("\n","=0D=0A",$label);
|
|
|
|
printf("LABEL;WORK;QUOTED-PRINTABLE:%s\n",$label);
|
2001-03-16 02:31:25 +01:00
|
|
|
} else {
|
|
|
|
if ($address2 && $astreet && $acity && $astate && $azip && $acountry) {
|
2001-03-21 06:14:07 +01:00
|
|
|
printf("LABEL;WORK;QUOTED-PRINTABLE:%s=0D=0A%s=0D=0A%s,%s %s=0D=0A%s\r\n",$address2,$astreet,$acity,$astate,$azip,$acountry);
|
2001-03-16 02:31:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// end 'A' grouping
|
|
|
|
|
|
|
|
// 'B' Grouping - home stuff
|
|
|
|
if($hemail != "") /* Home E-mail */
|
|
|
|
printf("B.EMAIL;%s:%s\r\n", $hemailtype,$hemail);
|
|
|
|
if($bphone != "") /* Home Phone */
|
|
|
|
printf("B.TEL%s;HOME:%s\r\n", $pref['home'],$bphone);
|
|
|
|
|
|
|
|
if( $bstreet != "" || /* Home Street */
|
|
|
|
$bcity != "" || /* Home City */
|
|
|
|
$bstate != "" || /* Home State */
|
|
|
|
$bzip != "") { /* Home Zip */
|
|
|
|
printf("B.ADR%s;HOME:;;%s;%s;%s;%s;%s\r\n", $btype,$bstreet,
|
|
|
|
$bcity,$bstate,$bzip,$bcountry);
|
|
|
|
}
|
2001-03-17 16:07:01 +01:00
|
|
|
if ($bstreet && $bcity && $bstate && $bzip && $bcountry) {
|
2001-03-21 06:14:07 +01:00
|
|
|
printf("LABEL;HOME;QUOTED-PRINTABLE:%s=0D=0A%s=0D=0A%s=0D=0A%s=0D=0A%s\n",$bstreet,$bcity,$bstate,$bzip,$bcountry);
|
2001-03-17 16:07:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($url) {
|
|
|
|
printf("URL:%s\r\n",$url);
|
|
|
|
}
|
2001-03-16 02:31:25 +01:00
|
|
|
// end 'B' grouping
|
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 */
|
2001-03-21 06:14:07 +01:00
|
|
|
$notes = ereg_replace("\n","=0D=0A",$notes);
|
2001-02-17 11:35:10 +01:00
|
|
|
$NOTES .= $notes;
|
|
|
|
|
|
|
|
if($NOTES != "") /* All of the notes. */
|
2001-03-21 06:14:07 +01:00
|
|
|
printf("NOTE;QUOTED-PRINTABLE:%s\n", $NOTES);
|
2001-02-17 11:35:10 +01:00
|
|
|
/* 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
|
|
|
?>
|