From 52796590bf84b5ab2c075d01490ef3cf663da431 Mon Sep 17 00:00:00 2001 From: seek3r Date: Tue, 30 Jan 2001 10:46:09 +0000 Subject: [PATCH] trying to get code ready for admin pages --- phpgwapi/inc/class.accounts_ldap.inc.php | 32 ++++++++++++++++-------- phpgwapi/inc/class.accounts_sql.inc.php | 18 ++++++++++--- phpgwapi/inc/class.acl.inc.php | 21 ++++++++++++++++ 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/phpgwapi/inc/class.accounts_ldap.inc.php b/phpgwapi/inc/class.accounts_ldap.inc.php index 70e567ce58..e5ec939c08 100644 --- a/phpgwapi/inc/class.accounts_ldap.inc.php +++ b/phpgwapi/inc/class.accounts_ldap.inc.php @@ -174,30 +174,40 @@ return $group_names; } - function listusers($groups="") + function listusers($group="") { global $phpgw; - $db = $phpgw->db; + $db2 = $phpgw->db; - if ($groups) { - $db->query("select account_lid,account_firstname,account_lastname from accounts where account_groups" - . "like '%,$groups,%'",__LINE__,__FILE__); + if ($group) { + $users = $phpgw->acl->get_ids_for_location($group, 1, "phpgw_group", "u"); + reset ($users); + $sql = "select account_lid,account_firstname,account_lastname from accounts where account_id in ("; + for ($idx=0; $idxquery($sql,__LINE__,__FILE__); } else { - $db->query("select account_lid,account_firstname,account_lastname from accounts",__LINE__,__FILE__); + $db2->query("select account_lid,account_firstname,account_lastname from accounts",__LINE__,__FILE__); } $i = 0; - while ($db->next_record()) { - $accounts["account_lid"][$i] = $db->f("account_lid"); - $accounts["account_firstname"][$i] = $db->f("account_firstname"); - $accounts["account_lastname"][$i] = $db->f("account_lastname"); + while ($db2->next_record()) { + $accounts["account_lid"][$i] = $db2->f("account_lid"); + $accounts["account_firstname"][$i] = $db2->f("account_firstname"); + $accounts["account_lastname"][$i] = $db2->f("account_lastname"); $i++; } return $accounts; } - function username2userid($user_name) + function username2userid($user_name) { global $phpgw, $phpgw_info; $db2 = $phpgw->db; diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php index 67a64bb5f1..5a1daaa0cd 100644 --- a/phpgwapi/inc/class.accounts_sql.inc.php +++ b/phpgwapi/inc/class.accounts_sql.inc.php @@ -131,15 +131,25 @@ return $group_names; } - function listusers($groups="") + function listusers($group="") { global $phpgw; $db2 = $phpgw->db; - if ($groups) { - $db2->query("select account_lid,account_firstname,account_lastname from accounts where account_groups" - . "like '%,$groups,%'",__LINE__,__FILE__); + if ($group) { + $users = $phpgw->acl->get_ids_for_location($group, 1, "phpgw_group", "u"); + reset ($users); + $sql = "select account_lid,account_firstname,account_lastname from accounts where account_id in ("; + for ($idx=0; $idxquery($sql,__LINE__,__FILE__); } else { $db2->query("select account_lid,account_firstname,account_lastname from accounts",__LINE__,__FILE__); } diff --git a/phpgwapi/inc/class.acl.inc.php b/phpgwapi/inc/class.acl.inc.php index 3712a9ccdd..812bcf4096 100644 --- a/phpgwapi/inc/class.acl.inc.php +++ b/phpgwapi/inc/class.acl.inc.php @@ -206,5 +206,26 @@ return $locations; } + function get_ids_for_location($location, $required, $app = False, $id_type = "u"){ + global $phpgw, $phpgw_info; + if ($app == False){ + $app = $phpgw_info["flags"]["currentapp"]; + } + $sql = "select acl_account from phpgw_acl where acl_appname = '$app' and "; + $sql .= "acl_account_type = '".$id_type."' and acl_location = ".$location; + $this->db->query($sql ,__LINE__,__FILE__); + $rights = 0; + if ($this->db->num_rows() == 0 ){ return False; } + while ($this->db->next_record()) { + if ($this->db->f("acl_rights") == 0){ return False; } + $rights |= $this->db->f("acl_rights"); + if (!!($rights & $required) == True){ + $accounts[] = $this->db->f("acl_account"); + }else{ + return False; + } + } + return $accounts; + } } //end of acl class ?>