* * ------------------------------------------------------------------------ * * 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$ */ class uiXport { var $template; var $public_functions = array( 'import' => True, 'export' => True ); var $bo; var $cat; var $start; var $limit; var $query; var $sort; var $order; var $filter; var $cat_id; function uiXport() { $this->template = $GLOBALS['phpgw']->template; $this->cat = CreateObject('phpgwapi.categories'); $this->bo = CreateObject('addressbook.boXport',True); $this->browser = CreateObject('phpgwapi.browser'); $this->_set_sessiondata(); } function _set_sessiondata() { $this->start = $this->bo->start; $this->limit = $this->bo->limit; $this->query = $this->bo->query; $this->sort = $this->bo->sort; $this->order = $this->bo->order; $this->filter = $this->bo->filter; $this->cat_id = $this->bo->cat_id; if($this->debug) { $this->_debug_sqsof(); } } /* Called only by index(), just prior to page footer. */ function save_sessiondata() { $data = array( 'start' => $this->start, 'limit' => $this->limit, 'query' => $this->query, 'sort' => $this->sort, 'order' => $this->order, 'filter' => $this->filter, 'cat_id' => $this->cat_id ); $this->bo->save_sessiondata($data); } /* Return a select form element with the categories option dialog in it */ function cat_option($cat_id='',$notall=False,$java=True,$multiple=False) { if($java) { $jselect = ' onChange="this.form.submit();"'; } /* Setup all and none first */ $cats_link = "\n" .''."\n"; return $cats_link; } function import() { $tsvfile = get_var('tsvfile','FILES'); $tsvfilename = get_var('tsvfilename','POST'); $convert = get_var('convert','POST'); $conv_type = get_var('conv_type','POST'); $cat_id = get_var('cat_id','POST'); $fcat_id = get_var('fcat_id','POST'); $private = get_var('private','POST'); if($convert) { if($conv_type == 'none') { $GLOBALS['phpgw_info']['flags']['noheader'] = False; $GLOBALS['phpgw_info']['flags']['noheader'] = True; $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); echo lang('No conversion type <none> could be located. Please choose a conversion type from the list'); echo ' ' . lang('OK') . ''; $GLOBALS['phpgw']->common->phpgw_footer(); $GLOBALS['phpgw']->common->phpgw_exit(); } $buffer = $this->bo->import($tsvfile['tmp_name'],$conv_type,$private,$fcat_id); if($download == '') { if($conv_type == 'Debug LDAP' || $conv_type == 'Debug SQL' ) { // filename, default application/octet-stream, length of file, default nocache True $GLOBALS['phpgw']->browser->content_header($tsvfilename,'',strlen($buffer)); echo $buffer; } else { $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); echo "
$buffer"; echo ''.lang('OK').''; $GLOBALS['phpgw']->common->phpgw_footer(); } } else { $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); echo "
$buffer"; echo ''.lang('OK').''; $GLOBALS['phpgw']->common->phpgw_footer(); } } else { $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); set_time_limit(0); $this->template->set_file(array('import' => 'import.tpl')); $dir_handle = opendir(PHPGW_APP_INC . SEP . 'import'); $i=0; $myfilearray = ''; while($file = readdir($dir_handle)) { if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file) ) { $myfilearray[$i] = $file; $i++; } } closedir($dir_handle); sort($myfilearray); for($i=0;$i
\n"; echo $buffer; echo "\n\n"; echo '' . lang('OK') . ''; $GLOBALS['phpgw']->common->phpgw_footer(); } } else { $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); set_time_limit(0); $this->template->set_file(array('export' => 'export.tpl')); $dir_handle = opendir(PHPGW_APP_INC. SEP . 'export'); $i=0; $myfilearray = ''; while($file = readdir($dir_handle)) { if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file) ) { $myfilearray[$i] = $file; $i++; } } closedir($dir_handle); sort($myfilearray); for($i=0;$i