diff --git a/admin/deletecategory.php b/admin/deletecategory.php index ce04ec2b0a..43f470ae95 100644 --- a/admin/deletecategory.php +++ b/admin/deletecategory.php @@ -32,7 +32,7 @@ { if ($subs) { - $c->delete($cat_id,'True'); + $c->delete($cat_id,True); } else { @@ -60,7 +60,7 @@ $apps_cats = $c->exists('subs',$cat_name='',$cat_id); - if ($apps_cats==True) + if ($apps_cats) { $t->set_var('messages',lang('This category is currently being used by applications as a parent category') . '
' . lang('You will need to remove the subcategories before you can delete the parent category')); @@ -82,7 +82,7 @@ $exists = $c->exists('subs',$cat_name='',$cat_id); - if ($exists==True) + if ($exists) { $t->set_var('lang_subs',lang('Do you also want to delete all global subcategories ?')); $t->set_var('subs',''); diff --git a/phpgwapi/inc/class.categories.inc.php b/phpgwapi/inc/class.categories.inc.php index 5572cf4fe6..0f8e8016b7 100644 --- a/phpgwapi/inc/class.categories.inc.php +++ b/phpgwapi/inc/class.categories.inc.php @@ -183,7 +183,6 @@ */ function return_single($id = '') { - $this->db->query("select * from phpgw_categories where cat_id='$id'",__LINE__,__FILE__); if ($this->db->next_record()) @@ -361,11 +360,11 @@ @abstract delete category @param $cat_id int - category id */ - function delete($cat_id,$subs = 'False') + function delete($cat_id,$subs = False) { - if ($subs == 'True') + if ($subs) { - $subdelete = " OR cat_parent='$cat_id'"; + $subdelete = " OR cat_parent='$cat_id' OR cat_main='$cat_id' "; } $this->db->query("delete from phpgw_categories where cat_id='$cat_id' $subdelete and cat_appname='" diff --git a/preferences/deletecategory.php b/preferences/deletecategory.php index 74ee946e4a..7071944244 100644 --- a/preferences/deletecategory.php +++ b/preferences/deletecategory.php @@ -36,12 +36,13 @@ { if ($subs) { - $c->delete($cat_id,'True'); + $c->delete($cat_id,True); } else { $c->delete($cat_id); } + Header('Location: ' . $phpgw->link('/preferences/categories.php','cats_app=' . $cats_app . '&extra=' . $extra . '&cats_level=' . $cats_level . '&global_cats=' . $global_cats)); } @@ -65,7 +66,8 @@ $t->set_var('hidden_vars',$hidden_vars); $exists = $c->exists('subs',$cat_name='',$cat_id); - if ($exists==True) + + if ($exists) { $t->set_var('lang_subs',lang('Do you also want to delete all subcategories ?')); $t->set_var('subs','');