From e93eb90d38b7266a1f9ed79375803e01a1ff2723 Mon Sep 17 00:00:00 2001 From: bettina Date: Mon, 2 Jul 2001 02:25:26 +0000 Subject: [PATCH] update function id2name to return also main,app,owner --- phpgwapi/inc/class.categories.inc.php | 44 +++++++++++++++------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/phpgwapi/inc/class.categories.inc.php b/phpgwapi/inc/class.categories.inc.php index 9c9c330663..d9cd60e590 100644 --- a/phpgwapi/inc/class.categories.inc.php +++ b/phpgwapi/inc/class.categories.inc.php @@ -64,12 +64,12 @@ { switch($for) { - case 'app': $w = " where cat_appname='" . $this->app_name . "'"; break; + case 'app': $w = " where cat_appname='" . $this->app_name . "'"; break; case 'appandmains': $w = " where cat_appname='" . $this->app_name . "' and cat_parent ='0'"; case 'appandsubs': $w = " where cat_appname='" . $this->app_name . "' and cat_parent !='0'"; case 'subs': $w = " where cat_parent != '0'"; break; case 'mains': $w = " where cat_parent = '0'"; break; - default: return False; + default: return False; } $this->db->query("select count(*) from phpgw_categories $w",__LINE__,__FILE__); @@ -423,20 +423,37 @@ return $this->db->f('cat_id'); } - function id2name($cat_id) + function id2name($cat_id, $item = 'name') { - $this->db->query("select cat_name from phpgw_categories where cat_id='" - . "$cat_id'",__LINE__,__FILE__); + if ($item == 'main') + { + $value = 'cat_main'; + } + elseif ($item == 'owner') + { + $value = 'cat_owner'; + } + elseif ($item == 'app') + { + $value = 'cat_appname'; + } + else + { + $value = 'cat_name'; + } + + $this->db->query("select $value from phpgw_categories where cat_id='" + . "$cat_id'",__LINE__,__FILE__); $this->db->next_record(); - if ($this->db->f('cat_name')) + if ($this->db->f($value)) { - return $this->db->f('cat_name'); + return $this->db->f($value); } else { return '--'; - } + } } /*! @@ -490,16 +507,5 @@ return False; } } - - 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; - } } ?>