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=''); }
|
else { $exists = $c->exists('subs',$cat_name,$cat_id=''); }
|
||||||
if ($exists == True) { $error[$errorcount++] = lang('That category name has been used already !'); }
|
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) {
|
if (! $error) {
|
||||||
$cat_name = addslashes($cat_name);
|
$cat_name = addslashes($cat_name);
|
||||||
$cat_description = addslashes($cat_description);
|
$cat_description = addslashes($cat_description);
|
||||||
|
@ -36,18 +36,25 @@
|
|||||||
|
|
||||||
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 (!$error) {
|
if (!$error) {
|
||||||
if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id); }
|
if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id); }
|
||||||
else { $exists = $c->exists('subs',$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 ($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_name = addslashes($cat_name);
|
||||||
$cat_description = addslashes($cat_description);
|
$cat_description = addslashes($cat_description);
|
||||||
$cat_access = 'public';
|
$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)); }
|
if ($errorcount) { $t->set_var('message',$phpgw->common->error_list($error)); }
|
||||||
|
@ -179,14 +179,14 @@
|
|||||||
|
|
||||||
if ($this->db->next_record())
|
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]['owner'] = $this->db->f('cat_owner');
|
||||||
$cats[0]['access'] = $this->db->f('cat_access');
|
$cats[0]['access'] = $this->db->f('cat_access');
|
||||||
$cats[0]['main'] = $this->db->f('cat_main');
|
$cats[0]['main'] = $this->db->f('cat_main');
|
||||||
$cats[0]['level'] = $this->db->f('cat_level');
|
$cats[0]['level'] = $this->db->f('cat_level');
|
||||||
$cats[0]['parent'] = $this->db->f('cat_parent');
|
$cats[0]['parent'] = $this->db->f('cat_parent');
|
||||||
$cats[0]['name'] = $this->db->f('cat_name');
|
$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');
|
$cats[0]['data'] = $this->db->f('cat_data');
|
||||||
}
|
}
|
||||||
return $cats;
|
return $cats;
|
||||||
@ -268,6 +268,11 @@
|
|||||||
function add($cat_name,$cat_parent,$cat_description = '', $cat_data = '',$cat_access = '',$cat_main)
|
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_main && ($cat_main > 0))
|
||||||
{
|
{
|
||||||
if (!$cat_parent)
|
if (!$cat_parent)
|
||||||
@ -324,6 +329,11 @@
|
|||||||
*/
|
*/
|
||||||
function edit($cat_id,$cat_parent,$cat_name,$cat_description = '',$cat_data = '',$cat_access = '',$cat_main)
|
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_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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
$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 (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id=''); }
|
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 ($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)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$cat_name = addslashes($cat_name);
|
$cat_name = addslashes($cat_name);
|
||||||
|
@ -42,12 +42,20 @@
|
|||||||
|
|
||||||
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 (!$error) {
|
if (!$error) {
|
||||||
if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id); }
|
if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id); }
|
||||||
else { $exists = $c->exists('subs',$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 ($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_name = addslashes($cat_name);
|
||||||
$cat_description = addslashes($cat_description);
|
$cat_description = addslashes($cat_description);
|
||||||
if ($access) { $cat_access = 'private'; }
|
if ($access) { $cat_access = 'private'; }
|
||||||
|
Loading…
Reference in New Issue
Block a user