From 60d318bf861ed224b4256dc0d007c7796f0b4039 Mon Sep 17 00:00:00 2001 From: kkalev Date: Sun, 8 Sep 2002 13:24:19 +0000 Subject: [PATCH] In lib/sql/defaults.php3 instead of doing a select for each group the user belongs to, do one select with a where in () caluse. --- Changelog | 4 ++- lib/sql/defaults.php3 | 81 ++++++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/Changelog b/Changelog index 2802c9f..3457a9c 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,4 @@ -Ver 1.60: +Ver 1.59: * Small html fixes in user_edit.php3 and password.php3 * Show number of failed logins in the last 7 days in the user admin page * Show date in the user/server test page @@ -40,6 +40,8 @@ Ver 1.60: * Fix a few bugs * Remove the auto password generator from the user edit page. It has no meaning since the password is not shown +* In lib/sql/defaults.php3 instead of doing a select for each group the user belongs to, do one select with + a where in () caluse. Ver 1.55: * Update the FAQ about missing attributes from the user/group edit pages and add a few comments in the configuration files diff --git a/lib/sql/defaults.php3 b/lib/sql/defaults.php3 index 9b9a47d..c0a85e6 100644 --- a/lib/sql/defaults.php3 +++ b/lib/sql/defaults.php3 @@ -31,10 +31,28 @@ if ($login != ''){ $member_groups[] = $row[GroupName]; } if (isset($member_groups)){ - foreach ($member_groups as $group){ + $in = '('; + foreach ($member_groups as $group) + $in .= "'$group',"; + $in = substr($in,0,-1); + $in .= ')'; + $res = @da_sql_query($link,$config, + "SELECT Attribute,Value $op FROM $config[sql_groupcheck_table] + WHERE GroupName IN $in;"); + if ($res){ + while(($row = @da_sql_fetch_array($res,$config))){ + $attr = $row[Attribute]; + $val = $row[Value]; + if ($use_op){ + $oper = $row[op]; + $tmp["$attr"][operator][]="$oper"; + } + $tmp["$attr"][]="$val"; + $tmp["$attr"][count]++; + } $res = @da_sql_query($link,$config, - "SELECT Attribute,Value $op FROM $config[sql_groupcheck_table] - WHERE GroupName = '$group';"); + "SELECT Attribute,Value $op FROM $config[sql_groupreply_table] + WHERE GroupName IN $in;"); if ($res){ while(($row = @da_sql_fetch_array($res,$config))){ $attr = $row[Attribute]; @@ -43,46 +61,31 @@ if ($login != ''){ $oper = $row[op]; $tmp["$attr"][operator][]="$oper"; } - $tmp["$attr"][]="$val"; + $tmp["$attr"][] = "$val"; $tmp["$attr"][count]++; } - $res = @da_sql_query($link,$config, - "SELECT Attribute,Value $op FROM $config[sql_groupreply_table] - WHERE GroupName = '$group';"); - if ($res){ - while(($row = @da_sql_fetch_array($res,$config))){ - $attr = $row[Attribute]; - $val = $row[Value]; - if ($use_op){ - $oper = $row[op]; - $tmp["$attr"][operator][]="$oper"; - } - $tmp["$attr"][] = "$val"; - $tmp["$attr"][count]++; - } - } - else - echo "Database query failed partially: " . da_sql_error($link,$config) . "
\n"; } else - echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; - if (isset($tmp)){ - foreach(array_keys($tmp) as $val){ - if ($val == '') - continue; - $key = $rev_attrmap["$val"]; - if ($key == ''){ - $key = $val; - $attrmap["$key"] = $val; - $attr_type["$key"] = 'replyItem'; - $rev_attrmap["$val"] = $key; - } - if (!isset($default_vals["$key"]) || $overwrite_defaults){ - if ($use_op) - $default_vals["$key"][operator] = $tmp["$val"][operator]; - if ($tmp[$val][0] != '') - $default_vals["$key"] = $tmp["$val"]; - } + echo "Database query failed partially: " . da_sql_error($link,$config) . "
\n"; + } + else + echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; + if (isset($tmp)){ + foreach(array_keys($tmp) as $val){ + if ($val == '') + continue; + $key = $rev_attrmap["$val"]; + if ($key == ''){ + $key = $val; + $attrmap["$key"] = $val; + $attr_type["$key"] = 'replyItem'; + $rev_attrmap["$val"] = $key; + } + if (!isset($default_vals["$key"]) || $overwrite_defaults){ + if ($use_op) + $default_vals["$key"][operator] = $tmp["$val"][operator]; + if ($tmp[$val][0] != '') + $default_vals["$key"] = $tmp["$val"]; } } } -- 2.39.5