From 4b44ca9c95d4c8c937706ac8448b1efe5e873412 Mon Sep 17 00:00:00 2001 From: kkalev Date: Sat, 7 Sep 2002 14:52:33 +0000 Subject: [PATCH] * If we are editing a group show a comment that in the radiusd sql module the group tables are evaluated after the user tables. As a result user values should in general overwrite default values. * Add support for the default_user_profile of the sql module in lib/sql/defaults.php3 --- Changelog | 3 ++ conf/admin.conf | 5 ++ htdocs/user_edit.php3 | 8 ++++ lib/sql/defaults.php3 | 106 ++++++++++++++++++++++++++---------------- 4 files changed, 81 insertions(+), 41 deletions(-) diff --git a/Changelog b/Changelog index 1f74d85..8c24c9a 100644 --- a/Changelog +++ b/Changelog @@ -16,6 +16,9 @@ Ver 1.56: * In the user edit page print a message under the User Password field about if it exists or not. Update the user_info.php3 lib files to check for it. * In lib/ldap/defaults.php3 Dialup-Access should not be added in the default_vals. It is not inherited. +* If we are editing a group show a comment that in the radiusd sql module the group tables are evaluated + after the user tables. As a result user values should in general overwrite default values. +* Add support for the default_user_profile of the sql module in lib/sql/defaults.php3 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/conf/admin.conf b/conf/admin.conf index 363cd81..47393a8 100644 --- a/conf/admin.conf +++ b/conf/admin.conf @@ -105,6 +105,11 @@ sql_usergroup_table: usergroup sql_use_user_info_table: true sql_use_operators: true # +# Set this to the value of the default_user_profile in your +# sql.conf if that one is set. If it is not set leave blank +# or commented out +#sql_default_user_profile: DEFAULT +# # sql_password_attribute: User-Password sql_date_format: Y-m-d diff --git a/htdocs/user_edit.php3 b/htdocs/user_edit.php3 index 8779940..0103170 100644 --- a/htdocs/user_edit.php3 +++ b/htdocs/user_edit.php3 @@ -107,6 +107,14 @@ else if ($badusers == 1){ +are extracted after the attributes in the radcheck/radreply tables.
+Please take that into consideration when adding attributes in the group
+and selecting operators. +
+EOM; if ($user_type != 'group'){ echo << diff --git a/lib/sql/defaults.php3 b/lib/sql/defaults.php3 index 6c706a5..fbaa3ef 100644 --- a/lib/sql/defaults.php3 +++ b/lib/sql/defaults.php3 @@ -14,34 +14,26 @@ if ($login != ''){ $op = ""; $use_op = 0; } - unset($item_vals); - unset($tmp); - $link = @da_sql_pconnect($config); - if ($link){ - $res = @da_sql_query($link,$config, - "SELECT GroupName FROM $config[sql_usergroup_table] WHERE UserName = '$login';"); - if ($res){ - while(($row = @da_sql_fetch_array($res,$config))) - $member_groups[] = $row[GroupName]; - } - if (isset($member_groups)){ - foreach ($member_groups as $group){ - $res = @da_sql_query($link,$config, - "SELECT Attribute,Value $op FROM $config[sql_groupcheck_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]++; - } + $overwrite_defaults = 1; + $stop = 0; + $times = 0; + do{ + unset($item_vals); + unset($member_groups); + unset($tmp); + $times++; + $link = @da_sql_pconnect($config); + if ($link){ + $res = @da_sql_query($link,$config, + "SELECT GroupName FROM $config[sql_usergroup_table] WHERE UserName = '$login';"); + if ($res){ + while(($row = @da_sql_fetch_array($res,$config))) + $member_groups[] = $row[GroupName]; + } + if (isset($member_groups)){ + foreach ($member_groups as $group){ $res = @da_sql_query($link,$config, - "SELECT Attribute,Value $op FROM $config[sql_groupreply_table] + "SELECT Attribute,Value $op FROM $config[sql_groupcheck_table] WHERE GroupName = '$group';"); if ($res){ while(($row = @da_sql_fetch_array($res,$config))){ @@ -51,27 +43,59 @@ 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 partially: " . da_sql_error($link,$config) . "
\n"; - } - else - echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; - foreach($attrmap as $key => $val){ - if (isset($tmp[$val])){ - if ($use_op) - $default_vals["$key"][operator] = $tmp["$val"][operator]; - if ($tmp[$val][0] != '') - $default_vals["$key"] = $tmp["$val"]; + echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; + foreach($attrmap as $key => $val){ + if (isset($tmp[$val])){ + 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"]; + } + } } } } + if ($times == 1){ + if ($config[sql_default_user_profile] == '') + $stop = 1; + else{ + $saved_login = $login; + $saved_member_groups = $member_groups; + $login = $config[sql_default_user_profile]; + $overwrite_defaults = 0; + } + } + if ($times == 2){ + $login = $saved_login; + $member_groups = $saved_member_groups; + $stop = 1; + } } - } - else - echo "Could not connect to database
\n"; + else + echo "Could not connect to database
\n"; + }while($stop == 0); } ?> -- 2.39.5