From ed29d35d8b386971dd1a33144a0bf9f3d8cbf9af Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 4 Feb 2014 13:54:09 +0000 Subject: [PATCH] remove old csv import --- addressbook/csv_import.php | 526 ------------------------------------- 1 file changed, 526 deletions(-) delete mode 100644 addressbook/csv_import.php diff --git a/addressbook/csv_import.php b/addressbook/csv_import.php deleted file mode 100644 index 50f095d064..0000000000 --- a/addressbook/csv_import.php +++ /dev/null @@ -1,526 +0,0 @@ - - * @package addressbook - * @copyright (c) 2003-9 by Ralf Becker - * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License - * @version $Id$ - */ - -$GLOBALS['egw_info'] = array( - 'flags' => array( - 'currentapp' => 'addressbook', - 'noheader' => True, - ), -); -include('../header.inc.php'); - -if (isset($_FILES['csvfile']['tmp_name'])) -{ - $csvfile = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); - $GLOBALS['egw']->session->appsession('csvfile','',$csvfile); - $_POST['action'] = move_uploaded_file($_FILES['csvfile']['tmp_name'],$csvfile) ? - 'download' : ''; -} -else -{ - $csvfile = $GLOBALS['egw']->session->appsession('csvfile'); -} -if ($_POST['cancel']) -{ - @unlink($csvfile); - $GLOBALS['egw']->redirect_link('/addressbook/index.php'); -} -if (isset($_POST['charset'])) -{ - // we have to set the local, to fix eg. utf-8 imports, as fgetcsv requires it! - common::setlocale(LC_CTYPE,$_POST['charset']); -} -$GLOBALS['egw_info']['flags']['app_header'] = lang('Import CSV-File into Addressbook'); -$GLOBALS['egw']->common->egw_header(); - -$bocontacts = new addressbook_bo(); - -$template = CreateObject('phpgwapi.Template',common::get_tpl_dir('addressbook')); -//$template->set_unknowns('keep'); -$template->set_file(array('import' => 'csv_import.tpl')); -$template->set_block('import','filename','filenamehandle'); -$template->set_block('import','fheader','fheaderhandle'); -$template->set_block('import','fields','fieldshandle'); -$template->set_block('import','ffooter','ffooterhandle'); -$template->set_block('import','imported','importedhandle'); - -if(($_POST['action'] == 'download' || $_POST['action'] == 'continue') && (!$_POST['fieldsep'] || !$csvfile || !($fp=fopen($csvfile,'rb')))) -{ - $_POST['action'] = ''; -} -$template->set_var('action_url',$GLOBALS['egw']->link('/addressbook/csv_import.php')); - -$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in trans -$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment -$VPre = '|#'; // Value-Prefix, is expanded to \ for ereg_replace -$CPre = '|['; $CPreReg = '\|\['; // |{csv-fieldname} is expanded to the value of the csv-field -$CPos = ']'; $CPosReg = '\]'; // if used together with @ (replacement is eval-ed) value gets autom. quoted - -/** - * Find contact with at least n_family AND (n_given OR org_name) have to match - * - * @param string $n_family - * @param string $n_given - * @param string $org_name - * @return int|boolean contact id or false if no match - */ -function addr_id($n_family,$n_given,$org_name) -{ - global $bocontacts; - $addrs = $bocontacts->search(array('n_family'=>$n_family,'n_given'=>$n_given,'org_name'=>$org_name)); - if(!count($addrs)) - { - $addrs = $bocontacts->search(array('n_family'=>$n_family,'n_given'=>$n_given)); - } - if(!count($addrs)) - { - $addrs = $bocontacts->search(array('n_family'=>$n_family,'org_name'=>$org_name)); - } - if(count($addrs)) - { - return $addrs[0]['id']; - } - return False; -} - -function cat_id($cats) -{ - if(!$cats) - { - return ''; - } - $ids = array(); - foreach(preg_split('/ *[,;] */',$cats) as $cat) - { - if (is_numeric($cat) && $GLOBALS['egw']->categories->id2name($cat) != '--') - { - $id = (int) $cat; - } - elseif ($id = $GLOBALS['egw']->categories->name2id(addslashes($cat))) - { - // cat exists - } - else - { // create new cat - $id = $GLOBALS['egw']->categories->add(array('name' => $cat,'descr' => $cat)); - } - $ids[$id] = $id; // we use the $id as index to not ass a cat twice - } - return implode(',',$ids); -} - -if ($_POST['next']) $_POST['action'] = 'next'; -switch($_POST['action']) -{ - case '': // Start, ask Filename - $template->set_var('lang_csvfile',lang('CSV-Filename')); - $template->set_var('lang_fieldsep',lang('Fieldseparator')); - $template->set_var('lang_charset',lang('Charset of file')); - $template->set_var('select_charset', - html::select('charset','',translation::get_installed_charsets(),True)); - $template->set_var('fieldsep',$_POST['fieldsep'] ? $_POST['fieldsep'] : ';'); - $template->set_var('submit',lang('Import')); - $template->set_var('csvfile',$csvfile); - $template->set_var('enctype','ENCTYPE="multipart/form-data"'); - - $template->parse('filenamehandle','filename'); - break; - - case 'continue': - case 'download': - $defaults = $GLOBALS['egw_info']['user']['preferences']['addressbook']['cvs_import']; - if (!($unique_id = $GLOBALS['egw_info']['user']['preferences']['addressbook']['cvs_import_unique_id'])) $unique_id = 'id'; - if (!($unique_id2 = $GLOBALS['egw_info']['user']['preferences']['addressbook']['cvs_import_unique_id2'])) $unique_id2 = 'uid'; - if(!is_array($defaults)) - { - $defaults = array(); - } - $template->set_var('lang_csv_fieldname',lang('CSV-Fieldname')); - $template->set_var('lang_addr_fieldname',lang('Addressbook-Fieldname')); - $template->set_var('lang_translation',lang("Translation").' '.lang('help').''); - $template->set_var('submit', - html::submit_button('convert','Import') . ' '. - html::submit_button('cancel','Cancel')); - $template->set_var('lang_debug',lang('Test Import (show importable records only in browser)')); - $template->parse('fheaderhandle','fheader'); - - $addr_names = $bocontacts->contact_fields; - $addr_names['cat_id'] .= ': id or name, comma separated list'; - $addr_names['private'] .= ': 0 = public, 1 = private'; - $addr_names['owner'] .= ': id or account name of user or group, defaults to importing user'; - $addr_names['bday'] .= ': YYYY-mm-dd'; - $addr_names['uid'] = lang('Unique ID (UID)'); - $addr_names['account_id'] = lang('Account ID'); - unset($addr_names['jpegphoto']); // cant cvs import that - $cfs=array(); - foreach($bocontacts->customfields as $name => $data) - { - $cfs['#'.$name] = $addr_names['#'.$name] = $data['label']; - } - $addr_name_options = "