2001-03-17 22:32:35 +01:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* 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$ */
|
|
|
|
|
2001-03-18 07:31:24 +01:00
|
|
|
if ($download =='on') {
|
|
|
|
$phpgw_info["flags"] = array(
|
|
|
|
"noheader" => True,
|
|
|
|
"nonavbar" => True
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$phpgw_info["flags"] = array(
|
|
|
|
"noheader" => False,
|
|
|
|
"nonavbar" => False
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2001-03-17 22:32:35 +01:00
|
|
|
$phpgw_info["flags"]["currentapp"] = "addressbook";
|
|
|
|
$phpgw_info["flags"]["enable_contacts_class"] = True;
|
2001-04-07 16:39:08 +02:00
|
|
|
$phpgw_info["flags"]["enable_browser_class"] = True;
|
2001-03-17 22:32:35 +01:00
|
|
|
include("../header.inc.php");
|
|
|
|
|
|
|
|
$sep = SEP;
|
|
|
|
|
|
|
|
if (!$convert) {
|
|
|
|
$t = new Template($phpgw_info["server"]["app_tpl"]);
|
|
|
|
$t->set_file(array("export" => "export.tpl"));
|
|
|
|
|
|
|
|
$dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."export");
|
|
|
|
$i=0; $myfilearray="";
|
|
|
|
while ($file = readdir($dir_handle)) {
|
|
|
|
#echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."conv".$sep.$file)." -->";
|
|
|
|
if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."export".$sep.$file) ) {
|
|
|
|
$myfilearray[$i] = $file;
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($dir_handle);
|
|
|
|
sort($myfilearray);
|
|
|
|
for ($i=0;$i<count($myfilearray);$i++) {
|
|
|
|
$fname = ereg_replace('_',' ',$myfilearray[$i]);
|
2001-03-28 03:54:00 +02:00
|
|
|
$conv .= ' <OPTION VALUE="'.$myfilearray[$i].'">'.$fname.'</OPTION>'."\n";
|
2001-03-17 22:32:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$t->set_var("lang_cancel",lang("Cancel"));
|
2001-03-28 03:54:00 +02:00
|
|
|
$t->set_var("lang_cat",lang("Select Category"));
|
2001-03-30 05:51:10 +02:00
|
|
|
$t->set_var("cat_link",cat_option($cat_id,False,False));
|
2001-03-29 13:02:14 +02:00
|
|
|
$t->set_var("cancel_url",$phpgw->link("/addressbook/index.php"));
|
2001-03-17 22:32:35 +01:00
|
|
|
$t->set_var("navbar_bg",$phpgw_info["theme"]["navbar_bg"]);
|
|
|
|
$t->set_var("navbar_text",$phpgw_info["theme"]["navbar_text"]);
|
2001-03-18 08:20:32 +01:00
|
|
|
$t->set_var("export_text",lang("Export from Addressbook"));
|
2001-03-29 13:02:14 +02:00
|
|
|
$t->set_var("action_url",$phpgw->link("/addressbook/export.php"));
|
2001-03-17 22:32:35 +01:00
|
|
|
$t->set_var("filename",lang("Export file name"));
|
|
|
|
$t->set_var("conv",$conv);
|
|
|
|
$t->set_var("debug",lang(""));
|
|
|
|
$t->set_var("download",lang("Submit"));
|
2001-03-29 13:02:14 +02:00
|
|
|
$t->set_var("start",$start);
|
|
|
|
$t->set_var("sort",$sort);
|
|
|
|
$t->set_var("order",$order);
|
|
|
|
$t->set_var("filter",$filter);
|
|
|
|
$t->set_var("query",$query);
|
|
|
|
$t->set_var("cat_id",$cat_id);
|
2001-03-17 22:32:35 +01:00
|
|
|
$t->pparse("out","export");
|
|
|
|
|
|
|
|
$phpgw->common->phpgw_footer();
|
|
|
|
} else {
|
|
|
|
include ($phpgw_info["server"]["app_root"].$sep."export".$sep.$conv_type);
|
|
|
|
$buffer=array();
|
|
|
|
$this = new export_conv;
|
|
|
|
|
|
|
|
// Read in user custom fields, if any
|
|
|
|
$phpgw->preferences->read_repository();
|
|
|
|
$customfields = array();
|
2001-03-19 18:18:28 +01:00
|
|
|
while (list($col,$descr) = @each($phpgw_info["user"]["preferences"]["addressbook"])) {
|
2001-03-17 22:32:35 +01:00
|
|
|
if ( substr($col,0,6) == 'extra_' ) {
|
|
|
|
$field = ereg_replace('extra_','',$col);
|
|
|
|
$field = ereg_replace(' ','_',$field);
|
|
|
|
$customfields[$field] = ucfirst($field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$extrafields = array(
|
|
|
|
"ophone" => "ophone",
|
|
|
|
"address2" => "address2",
|
|
|
|
"address3" => "address3"
|
|
|
|
);
|
2001-03-21 23:51:37 +01:00
|
|
|
if ($this->type != 'vcard') {
|
|
|
|
$this->qfields = $this->stock_contact_fields;# + $extrafields;# + $customfields;
|
|
|
|
}
|
2001-03-17 22:32:35 +01:00
|
|
|
|
2001-03-30 06:02:38 +02:00
|
|
|
if (!empty($cat_id))
|
|
|
|
{
|
|
|
|
$buffer = $this->export_start_file($buffer,$cat_id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$buffer = $this->export_start_file($buffer);
|
|
|
|
}
|
2001-03-17 22:32:35 +01:00
|
|
|
|
|
|
|
for ($i=0;$i<count($this->ids);$i++) {
|
|
|
|
$buffer = $this->export_start_record($buffer);
|
|
|
|
while( list($name,$value) = each($this->currentrecord) ) {
|
|
|
|
$buffer = $this->export_new_attrib($buffer,$name,$value);
|
|
|
|
}
|
|
|
|
$buffer = $this->export_end_record($buffer);
|
|
|
|
}
|
|
|
|
|
2001-03-18 07:31:24 +01:00
|
|
|
// Here, buffer becomes a string suitable for printing
|
2001-03-17 22:32:35 +01:00
|
|
|
$buffer = $this->export_end_file($buffer);
|
|
|
|
|
|
|
|
$tsvfilename = $phpgw_info['server']['temp_dir'].$sep.$tsvfilename;
|
|
|
|
|
2001-03-20 19:02:48 +01:00
|
|
|
if ( ($download == "on") || ($o->type == 'pdb') ) {
|
2001-04-14 04:42:50 +02:00
|
|
|
// filename, default application/octet-stream, length of file, default nocache True
|
|
|
|
$phpgw->browser->content_header($tsvfilename,'',strlen($buffer));
|
2001-03-18 07:31:24 +01:00
|
|
|
echo $buffer;
|
2001-03-17 22:32:35 +01:00
|
|
|
} else {
|
|
|
|
echo "<pre>\n";
|
2001-03-18 07:31:24 +01:00
|
|
|
echo $buffer;
|
2001-03-17 22:32:35 +01:00
|
|
|
echo "\n</pre>\n";
|
2001-03-28 03:59:08 +02:00
|
|
|
echo '<a href="'.$phpgw->link("/addressbook/index.php",
|
2001-03-29 17:39:10 +02:00
|
|
|
"sort=$sort&order=$order&filter=$filter&start=$start&query=$query&cat_id=$cat_id")
|
2001-03-28 03:59:08 +02:00
|
|
|
. '">'.lang("OK").'</a>';
|
2001-03-17 22:32:35 +01:00
|
|
|
$phpgw->common->phpgw_footer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|