diff --git a/addressbook/csv_import.php b/addressbook/csv_import.php index 7791792c12..accdb1772e 100644 --- a/addressbook/csv_import.php +++ b/addressbook/csv_import.php @@ -90,9 +90,7 @@ return ''; } - $cats = split('[,;]',$cats); - - while(list($k,$cat) = each($cats)) + foreach(split('[,;]',$cats) as $cat) { if(isset($cat2id[$cat])) { @@ -104,7 +102,11 @@ { $GLOBALS['phpgw']->categories = createobject('phpgwapi.categories'); } - if($id = $GLOBALS['phpgw']->categories->name2id(addslashes($cat))) + if (is_numeric($cat) && $GLOBALS['phpgw']->categories->id2name($cat) != '--') + { + $cat2id[$cat] = $ids[$cat] = $cat; + } + elseif ($id = $GLOBALS['phpgw']->categories->name2id(addslashes($cat))) { // cat exists $cat2id[$cat] = $ids[$cat] = $id; }