From 47a938e92aebe15253ce23d944d5acaf7ca4f872 Mon Sep 17 00:00:00 2001 From: skeeter Date: Fri, 19 Jan 2001 13:16:00 +0000 Subject: [PATCH] small performance fixes --- phpgwapi/inc/class.accounts_ldap.inc.php | 27 ++++++++++++++++++------ phpgwapi/inc/class.accounts_sql.inc.php | 20 +++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/phpgwapi/inc/class.accounts_ldap.inc.php b/phpgwapi/inc/class.accounts_ldap.inc.php index 1459231620..434ca63a15 100644 --- a/phpgwapi/inc/class.accounts_ldap.inc.php +++ b/phpgwapi/inc/class.accounts_ldap.inc.php @@ -133,13 +133,28 @@ } function read_groups($lid) { - global $phpgw_info, $phpgw; + global $phpgw_info, $phpgw; + + $db2 = $phpgw->db; + + if (gettype($lid) == "integer") { + if ($phpgw_info["user"]["account_id"] != $lid) { + $db2->query("select account_groups from accounts where account_id=$lid",__LINE__,__FILE__); + $db2->next_record(); + $gl = explode(",",$db2->f("account_groups")); + } else { + $gl = $phpgw_info["user"]["groups"]; + } + } else { + if ($phpgw_info["user"]["userid"] != $lid) { + $db2->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__); + $db2->next_record(); + $gl = explode(",",$db2->f("account_groups")); + } else { + $gl = $phpgw_info["user"]["groups"]; + } + } - $db = $phpgw->db; - $db->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__); - $db->next_record(); - - $gl = explode(",",$db->f("account_groups")); for ($i=1; $i<(count($gl)-1); $i++) { $ga = explode(":",$gl[$i]); $groups[$ga[0]] = $ga[1]; diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php index ad449ed365..5b4416254d 100644 --- a/phpgwapi/inc/class.accounts_sql.inc.php +++ b/phpgwapi/inc/class.accounts_sql.inc.php @@ -85,12 +85,22 @@ $db2 = $phpgw->db; - if ($phpgw_info["user"]["userid"] != $lid) { - $db2->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__); - $db2->next_record(); - $gl = explode(",",$db2->f("account_groups")); - } else { + if (gettype($lid) == "integer") { + if ($phpgw_info["user"]["account_id"] != $lid) { + $db2->query("select account_groups from accounts where account_id=$lid",__LINE__,__FILE__); + $db2->next_record(); + $gl = explode(",",$db2->f("account_groups")); + } else { $gl = $phpgw_info["user"]["groups"]; + } + } else { + if ($phpgw_info["user"]["userid"] != $lid) { + $db2->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__); + $db2->next_record(); + $gl = explode(",",$db2->f("account_groups")); + } else { + $gl = $phpgw_info["user"]["groups"]; + } } for ($i=1; $i<(count($gl)-1); $i++) {