added function to check the valid main cat

This commit is contained in:
bettina 2001-04-29 00:51:53 +00:00
parent 8ad8e64091
commit 8dd7dad2ed
5 changed files with 52 additions and 3 deletions

View File

@ -31,6 +31,12 @@
else { $exists = $c->exists('subs',$cat_name,$cat_id=''); }
if ($exists == True) { $error[$errorcount++] = lang('That category name has been used already !'); }
}
if ($cat_main && $cat_parent) {
$main = $c->return_main($cat_parent);
if ($main != $cat_main) { $error[$errorcount++] = lang('You selected an invalid main category !'); }
}
if (! $error) {
$cat_name = addslashes($cat_name);
$cat_description = addslashes($cat_description);

View File

@ -36,18 +36,25 @@
if ($submit) {
$errorcount = 0;
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 ($cat_main && $cat_parent) {
$main = $c->return_main($cat_parent);
if ($main != $cat_main) { $error[$errorcount++] = lang('You selected an invalid main category !'); }
}
$cat_name = addslashes($cat_name);
$cat_description = addslashes($cat_description);
$cat_access = 'public';
if (! $error) { $c->edit($cat_id,$cat_parent,$cat_name,$cat_description,$cat_data,$cat_access,$cat_main); }
if (! $error) { $c->edit($cat_id,$cat_parent,$cat_name,$cat_description,$cat_data,$cat_access,$cat_main); }
}
if ($errorcount) { $t->set_var('message',$phpgw->common->error_list($error)); }

View File

@ -179,14 +179,14 @@
if ($this->db->next_record())
{
$cats[0]['id'] = $this->db->f('cat_id');
$cats[0]['id'] = $this->db->f('cat_id');
$cats[0]['owner'] = $this->db->f('cat_owner');
$cats[0]['access'] = $this->db->f('cat_access');
$cats[0]['main'] = $this->db->f('cat_main');
$cats[0]['level'] = $this->db->f('cat_level');
$cats[0]['parent'] = $this->db->f('cat_parent');
$cats[0]['name'] = $this->db->f('cat_name');
$cats[0]['description'] = $this->db->f('cat_description');
$cats[0]['description'] = $this->db->f('cat_description');
$cats[0]['data'] = $this->db->f('cat_data');
}
return $cats;
@ -268,6 +268,11 @@
function add($cat_name,$cat_parent,$cat_description = '', $cat_data = '',$cat_access = '',$cat_main)
{
if ($cat_parent && (!$cat_main))
{
$cat_main = $cat_parent;
}
if ($cat_main && ($cat_main > 0))
{
if (!$cat_parent)
@ -324,6 +329,11 @@
*/
function edit($cat_id,$cat_parent,$cat_name,$cat_description = '',$cat_data = '',$cat_access = '',$cat_main)
{
if ($cat_parent && (!$cat_main))
{
$cat_main = $cat_parent;
}
if ($cat_main && ($cat_main > 0))
{
@ -427,5 +437,16 @@
}
}
function return_main($cat_id = '')
{
$this->db->query("select cat_main from phpgw_categories where cat_id='$cat_id'",__LINE__,__FILE__);
$this->db->next_record();
$cat_main = $this->db->f('cat_main');
return $cat_main;
}
}
?>

View File

@ -41,6 +41,7 @@
$errorcount = 0;
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=''); }
@ -48,6 +49,12 @@
if ($exists == True) { $error[$errorcount++] = lang('That category name has been used already !'); }
}
if ($cat_main && $cat_parent)
{
$main = $c->return_main($cat_parent);
if ($main != $cat_main) { $error[$errorcount++] = lang('You selected an invalid main category !'); }
}
if (!$error)
{
$cat_name = addslashes($cat_name);

View File

@ -42,12 +42,20 @@
if ($submit) {
$errorcount = 0;
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 ($cat_main && $cat_parent) {
$main = $c->return_main($cat_parent);
if ($main != $cat_main) { $error[$errorcount++] = lang('You selected an invalid main category !'); }
}
$cat_name = addslashes($cat_name);
$cat_description = addslashes($cat_description);
if ($access) { $cat_access = 'private'; }