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(
|
2001-04-07 16:39:08 +02:00
|
|
|
"noheader" => False,
|
|
|
|
"nonavbar" => False,
|
|
|
|
"noappheader" => False,
|
|
|
|
"noappfooter" => False
|
2001-02-19 13:14:25 +01:00
|
|
|
);
|
2001-02-10 13:56:49 +01:00
|
|
|
} else {
|
2001-02-19 13:14:25 +01:00
|
|
|
$phpgw_info["flags"] = array(
|
2001-04-07 16:39:08 +02:00
|
|
|
"noheader" => True,
|
|
|
|
"nonavbar" => True,
|
|
|
|
"noappheader" => True,
|
|
|
|
"noappfooter" => True
|
2001-02-19 13:14:25 +01:00
|
|
|
);
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
|
2001-03-17 16:07:01 +01:00
|
|
|
$phpgw_info["flags"]["enable_contacts_class"] = True;
|
2001-04-07 16:39:08 +02:00
|
|
|
$phpgw_info["flags"]["enable_browser_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-21 21:20:30 +01:00
|
|
|
$extrafields = array("address2" => "address2");
|
2001-03-16 02:31:25 +01:00
|
|
|
$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-04-04 03:59:50 +02:00
|
|
|
$email = $fields["email"];
|
2001-03-21 21:20:30 +01:00
|
|
|
$emailtype = $fields["email_type"]; if (!$emailtype) { $fields["email_type"] = 'INTERNET'; }
|
2001-04-04 03:59:50 +02:00
|
|
|
$hemail = $fields["email_home"];
|
2001-03-21 21:20:30 +01:00
|
|
|
$hemailtype = $fields["email_home_type"]; if (!$hemailtype) { $fields["email_home_type"] = 'INTERNET'; }
|
2001-02-17 11:35:10 +01:00
|
|
|
$firstname = $fields["n_given"];
|
|
|
|
$lastname = $fields["n_family"];
|
|
|
|
|
|
|
|
if(!$nolname && !$nofname) {
|
|
|
|
/* First name and last must be in the vcard. */
|
|
|
|
if($lastname == "") {
|
|
|
|
/* Run away here. */
|
2001-03-29 17:39:10 +02:00
|
|
|
Header("Location: " . $phpgw->link("/addressbook/vcardout.php",
|
|
|
|
"nolname=1&ab_id=$ab_id&start=$start&order=$order&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id"));
|
2001-02-17 11:35:10 +01:00
|
|
|
}
|
|
|
|
if($firstname == "" ) {
|
2001-03-29 17:39:10 +02:00
|
|
|
Header("Location: " . $phpgw->link("/addressbook/vcardout.php",
|
|
|
|
"nofname=1&ab_id=$ab_id&start=$start&order=$order&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id"));
|
2001-02-17 11:35:10 +01:00
|
|
|
}
|
|
|
|
|
2001-04-04 03:59:50 +02:00
|
|
|
if ($email)
|
|
|
|
{
|
|
|
|
$fn = explode("@",$email);
|
|
|
|
$filename = sprintf("%s.vcf", $fn[0]);
|
|
|
|
}
|
|
|
|
elseif ($hemail)
|
|
|
|
{
|
|
|
|
$fn = explode("@",$hemail);
|
|
|
|
$filename = sprintf("%s.vcf", $fn[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$fn = strtolower($firstname);
|
|
|
|
$filename = sprintf("%s.vcf", $fn);
|
|
|
|
}
|
2001-02-17 11:35:10 +01:00
|
|
|
|
2001-03-21 21:20:30 +01:00
|
|
|
// create vcard object
|
|
|
|
$vcard = CreateObject("phpgwapi.vcard");
|
|
|
|
// set translation variable
|
|
|
|
$myexport = $vcard->export;
|
|
|
|
// check that each $fields exists in the export array and
|
|
|
|
// set a new array to equal the translation and original value
|
|
|
|
while( list($name,$value) = each($fields) ) {
|
|
|
|
if ($myexport[$name] && ($value != "") ) {
|
|
|
|
//echo '<br>'.$name."=".$fields[$name]."\n";
|
|
|
|
$buffer[$myexport[$name]] = $value;
|
2001-03-16 02:31:25 +01:00
|
|
|
}
|
|
|
|
}
|
2001-04-14 04:42:50 +02:00
|
|
|
|
2001-03-21 21:20:30 +01:00
|
|
|
// create a vcard from this translated array
|
|
|
|
$entry = $vcard->out($buffer);
|
2001-04-14 04:42:50 +02:00
|
|
|
// print it using browser class for headers
|
|
|
|
// filename, mimetype, no length, default nocache True
|
|
|
|
$phpgw->browser->content_header($filename,'text/x-vcard');
|
2001-03-21 21:20:30 +01:00
|
|
|
echo $entry;
|
|
|
|
$phpgw->common->exit;
|
2001-02-17 11:35:10 +01:00
|
|
|
} /* !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-29 17:39:10 +02:00
|
|
|
echo "<a href=" . $phpgw->link("/addressbook/index.php",
|
|
|
|
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . ">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-29 17:39:10 +02:00
|
|
|
echo "<a href=" . $phpgw->link("/addressbook/index.php",
|
|
|
|
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . ">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
|
|
|
?>
|