From 568fa2524cc8d377af4cc31558ad2f7a614b9930 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sat, 21 Apr 2001 15:51:39 +0000 Subject: [PATCH] Check error after name check, skip exists call if cat_name='' --- preferences/addcategory.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/preferences/addcategory.php b/preferences/addcategory.php index 4b7c86604c..c360de1aef 100644 --- a/preferences/addcategory.php +++ b/preferences/addcategory.php @@ -35,23 +35,28 @@ $c = CreateObject('phpgwapi.categories'); $c->app_name = $cats_app; - if ($submit) { - $errorcount = 0; + if ($submit) + { + $errorcount = 0; - if (!$cat_name) { $error[$errorcount++] = lang('Please enter a name for that category !'); } - if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id=''); } - else { $exists = $c->exists('subs',$cat_name,$cat_id=''); } - if ($exists == True) { $error[$errorcount++] = lang('That category name has been used already !'); } + if (!$cat_name) { $error[$errorcount++] = lang('Please enter a name for that category !'); } + if (!$error) + { + if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id=''); } + else { $exists = $c->exists('subs',$cat_name,$cat_id=''); } + if ($exists == True) { $error[$errorcount++] = lang('That category name has been used already !'); } + } - if (! $error) { - $cat_name = addslashes($cat_name); - $cat_description = addslashes($cat_description); - if ($access) { $cat_access = 'private'; } - else { $cat_access = 'public'; } + if (!$error) + { + $cat_name = addslashes($cat_name); + $cat_description = addslashes($cat_description); + if ($access) { $cat_access = 'private'; } + else { $cat_access = 'public'; } - $c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access); + $c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access); + } } - } if ($errorcount) { $t->set_var('message',$phpgw->common->error_list($error)); } if (($submit) && (! $error) && (! $errorcount)) { $t->set_var('message',lang("Category x has been added !",$cat_name)); }