From 212c43738ad59526b35ed69fd45f26f1f51ed333 Mon Sep 17 00:00:00 2001 From: ceb Date: Sat, 12 Oct 2002 00:50:37 +0000 Subject: [PATCH] update edit cats --- phpgwapi/inc/class.categories.inc.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/class.categories.inc.php b/phpgwapi/inc/class.categories.inc.php index 031ff1f5e3..4252aeb570 100644 --- a/phpgwapi/inc/class.categories.inc.php +++ b/phpgwapi/inc/class.categories.inc.php @@ -566,11 +566,22 @@ $cat_values['descr'] = $this->db->db_addslashes($cat_values['descr']); $cat_values['name'] = $this->db->db_addslashes($cat_values['name']); - $this->db->query("INSERT INTO phpgw_categories (cat_parent,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data," - . "cat_main,cat_level) VALUES ('" . $cat_values['parent'] . "','" . $this->account_id . "','" . $cat_values['access'] + if (isset($cat_values['id'])) + { + $id_col = 'cat_id,'; + $id_val = $cat_values['id'].','; + } + + $this->db->query("INSERT INTO phpgw_categories (${id_col}cat_parent,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data," + . "cat_main,cat_level) VALUES ($id_val'" . $cat_values['parent'] . "','" . $this->account_id . "','" . $cat_values['access'] . "','" . $this->app_name . "','" . $cat_values['name'] . "','" . $cat_values['descr'] . "','" . $cat_values['data'] . "','" . $cat_values['main'] . "','" . $cat_values['level'] . "')",__LINE__,__FILE__); + if (isset($cat_values['id'])) + { + $max = $cat_values['id']; + } + $max = $this->db->get_last_insert_id('phpgw_categories','cat_id'); if (!$cat_values['parent'] || $cat_values['parent'] == 0) @@ -649,7 +660,7 @@ */ function edit($cat_values) { - if (intval($cat_values['old_parent']) != $cat_values['parent']) + if (isset($cat_values['old_parent']) && intval($cat_values['old_parent']) != $cat_values['parent']) { $this->delete(array('cat_id' => $cat_values['id'],'drop_subs' => False,'modify_subs' => True)); return $this->add($cat_values);