From 3435ca7481cbc2eb2896059be478f9cf78052094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Thu, 21 Jun 2007 13:43:33 +0000 Subject: [PATCH] fixed category handling. allow to preserv cat if record is updated --- ...ass.import_export_helper_functions.inc.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/importexport/inc/class.import_export_helper_functions.inc.php b/importexport/inc/class.import_export_helper_functions.inc.php index 39cfdeda15..182c85557c 100755 --- a/importexport/inc/class.import_export_helper_functions.inc.php +++ b/importexport/inc/class.import_export_helper_functions.inc.php @@ -15,7 +15,7 @@ * use import_export_helper_functions::method */ class import_export_helper_functions { - + /** * nothing to construct here, only static functions! */ @@ -77,21 +77,22 @@ class import_export_helper_functions { * @return mixed comma seperated list or array with cat_ids */ public static function cat_name2id( $_cat_names ) { - $cats = &CreateObject( 'phpgwapi.categories' ); - $cats->app_name = 'phpgw'; + $cats = CreateObject( 'phpgwapi.categories' ); + $cats->app_name = $GLOBALS['egw_info']['flags']['currentapp']; $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names ); - foreach ( $cat_names as $cat_name ) { - if ( $cat_id = $cats->name2id( addslashes( $cat_name ))) { } - else $cat_id = $cats->add( array( - 'name' => $cat_name, - 'access' => 'public', - 'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')' - )); + + if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 ) { + $cat_id = $cats->add( array( + 'name' => $cat_name, + 'access' => 'public', + 'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')' + )); + } $cat_ids[] = $cat_id; } - return $_cat_names ? $cat_ids : implode( ',', $cat_ids ); + return is_array( $_cat_names ) ? $cat_ids : implode( ',', $cat_ids ); } // end of member function category_name2id