Check error after name check, skip exists call if cat_name=''

This commit is contained in:
Miles Lott 2001-04-21 15:51:39 +00:00
parent e1fcfb7fcf
commit 568fa2524c

View File

@ -35,23 +35,28 @@
$c = CreateObject('phpgwapi.categories'); $c = CreateObject('phpgwapi.categories');
$c->app_name = $cats_app; $c->app_name = $cats_app;
if ($submit) { if ($submit)
$errorcount = 0; {
$errorcount = 0;
if (!$cat_name) { $error[$errorcount++] = lang('Please enter a name for that category !'); } if (!$cat_name) { $error[$errorcount++] = lang('Please enter a name for that category !'); }
if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id=''); } if (!$error)
else { $exists = $c->exists('subs',$cat_name,$cat_id=''); } {
if ($exists == True) { $error[$errorcount++] = lang('That category name has been used already !'); } 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) { if (!$error)
$cat_name = addslashes($cat_name); {
$cat_description = addslashes($cat_description); $cat_name = addslashes($cat_name);
if ($access) { $cat_access = 'private'; } $cat_description = addslashes($cat_description);
else { $cat_access = 'public'; } 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 ($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)); } if (($submit) && (! $error) && (! $errorcount)) { $t->set_var('message',lang("Category x has been added !",$cat_name)); }