From: kkalev Date: Tue, 13 Aug 2002 10:18:30 +0000 (+0000) Subject: * Allow the administrator to specify a group in the New User page. Update lib/sql... X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=c164096258b83aa6f430a503b870bfb3f04d5753;p=freeradius-dialup-admin.git * Allow the administrator to specify a group in the New User page. Update lib/sql/create_user.php3 to add the user to the specified group * Call user_info.php3 and defaults.php3 in user_new.php3 after creating a user * Only run if $login is not NULL in lib/sql/defaults.php3 * In group admin add a button to administer the selected user which will redirect the administrator to the corresponding user_admin page --- diff --git a/Changelog b/Changelog index ce65781..19e3c55 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,11 @@ Ver 1.52: * Add Reply-Message in conf/user_edit.attrs so that it appears in the user/group edit pages +* Allow the administrator to specify a group in the New User page. Update lib/sql/create_user.php3 to add + the user to the specified group +* Call user_info.php3 and defaults.php3 in user_new.php3 after creating a user +* Only run if $login is not NULL in lib/sql/defaults.php3 +* In group admin add a button to administer the selected user which will redirect the administrator to the + corresponding user_admin page Ver 1.51: * Only call user_info.php3 in user_new.php3 when we are creating a user * Fix a bug with personal information attributes in user_new.php3 diff --git a/htdocs/group_admin.php3 b/htdocs/group_admin.php3 index 6201b23..acf89db 100644 --- a/htdocs/group_admin.php3 +++ b/htdocs/group_admin.php3 @@ -1,4 +1,8 @@ > +
@@ -109,6 +114,8 @@ New Group Member(s)
Separate group members
by whitespace or newline

+

+ diff --git a/htdocs/user_new.php3 b/htdocs/user_new.php3 index 5936537..e239e1f 100644 --- a/htdocs/user_new.php3 +++ b/htdocs/user_new.php3 @@ -62,6 +62,9 @@ EOM; else{ if (is_file("../lib/$config[general_lib_type]/create_user.php3")) include("../lib/$config[general_lib_type]/create_user.php3"); + require("../lib/defaults.php3"); + if (is_file("../lib/$config[general_lib_type]/user_info.php3")) + include("../lib/$config[general_lib_type]/user_info.php3"); } } ?> @@ -85,6 +88,21 @@ EOM; +EOM; + if ($config[general_lib_type] == 'sql'){ + if (isset($member_groups)) + $group = $member_groups[0]; + echo << + + Group + + + + +EOM; + } + echo << Name (First Name Surname) diff --git a/lib/sql/create_user.php3 b/lib/sql/create_user.php3 index 39f5a2e..b4392d6 100644 --- a/lib/sql/create_user.php3 +++ b/lib/sql/create_user.php3 @@ -39,6 +39,26 @@ if ($link){ else echo "User already exists in user info table.
\n"; } + else + echo "Could not add user information in user info table
\n"; + } + if ($Fgroup != ''){ + $res = @da_sql_query($link,$config, + "SELECT UserName FROM $config[sql_usergroup_table] + WHERE UserName = '$login' AND GroupName = '$Fgroup';"); + if ($res){ + if (!@da_sql_num_rows($res,$config)){ + $res = @da_sql_query($link,$config, + "INSERT INTO $config[sql_usergroup_table] + (UserName,GroupName) VALUES ('$login','$Fgroup');"); + if (!$res || !@da_sql_affected_rows($link,$res,$config)) + echo "Could not add user to group $Fgroup. SQL Error
\n"; + } + else + echo "User already is a member of group $Fgroup
\n"; + } + else + echo "Could not add user to group $Fgroup. SQL Error
\n"; } if (!$da_abort){ foreach($show_attrs as $key => $attr){ diff --git a/lib/sql/defaults.php3 b/lib/sql/defaults.php3 index 06bec34..a997b36 100644 --- a/lib/sql/defaults.php3 +++ b/lib/sql/defaults.php3 @@ -1,45 +1,34 @@ Could not include SQL library
\n"; - exit(); -} -if ($config[sql_use_operators] == 'true'){ - $op = ',op'; - $use_op = 1; -}else{ - $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 ($login != ''){ + require('../lib/sql/attrmap.php3'); + if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3")) + include_once("../lib/sql/drivers/$config[sql_type]/functions.php3"); + else{ + echo "Could not include SQL library
\n"; + exit(); } - 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]++; - } + if ($config[sql_use_operators] == 'true'){ + $op = ',op'; + $use_op = 1; + }else{ + $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_groupreply_table] WHERE GroupName = '$group';"); + "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]; @@ -48,27 +37,42 @@ if ($link){ $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
\n"; } else - echo "Database query failed partially
\n"; - } - else - echo "Database query failed
\n"; - foreach($attrmap as $key => $val){ - if (isset($tmp[$val])){ - if ($tmp[$val][0] != '') - $default_vals["$key"] = $tmp[$val][0]; - if ($use_op) - if ($tmp[$val][operator][0] != '') - $default_vals["$key"][operator] = $tmp[$val][operator][0]; + echo "Database query failed
\n"; + foreach($attrmap as $key => $val){ + if (isset($tmp[$val])){ + if ($tmp[$val][0] != '') + $default_vals["$key"] = $tmp[$val][0]; + if ($use_op) + if ($tmp[$val][operator][0] != '') + $default_vals["$key"][operator] = $tmp[$val][operator][0]; + } } } } } + else + echo "Could not connect to database
\n"; } -else - echo "Could not connect to database
\n"; ?>