forked from extern/egroupware
added function to check the valid main cat
This commit is contained in:
parent
8ad8e64091
commit
8dd7dad2ed
@ -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);
|
||||
|
@ -36,13 +36,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);
|
||||
$cat_access = 'public';
|
||||
|
@ -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)
|
||||
@ -325,6 +330,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))
|
||||
{
|
||||
if (!$cat_parent)
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -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);
|
||||
|
@ -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'; }
|
||||
|
Loading…
Reference in New Issue
Block a user