]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
* Allow the administrator to specify a group in the New User page. Update lib/sql...
authorkkalev <kkalev>
Tue, 13 Aug 2002 10:18:30 +0000 (10:18 +0000)
committerkkalev <kkalev>
Tue, 13 Aug 2002 10:18:30 +0000 (10:18 +0000)
  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

Changelog
htdocs/group_admin.php3
htdocs/user_new.php3
lib/sql/create_user.php3
lib/sql/defaults.php3

index ce6578143668e4d8a6b8f89ff04fc37ef27b270b..19e3c558fa387f1d4681243890657ed8543a810d 100644 (file)
--- 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
index 6201b234a94135a355d39ba85b45d7e4663edb40..acf89dbfabb734ecc67487613ea37ce616831997 100644 (file)
@@ -1,4 +1,8 @@
 <?php
+if ($show == 1 && isset($del_members)){
+        header("Location: user_admin.php3?login=$del_members[0]");
+        exit;
+}
 require('../conf/config.php3');
 if ($config[general_lib_type] != 'sql'){
        echo <<<EOM
@@ -83,6 +87,7 @@ if ($do_changes == 1){
    <form method=post>
       <input type=hidden name=login value=<?php echo $login ?>>
       <input type=hidden name=do_changes value=0>
+      <input type=hidden name=show value=0>
        <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
 <tr>
 <td align=right bgcolor="#d0ddb0">
@@ -109,6 +114,8 @@ New Group Member(s)<br>Separate group members<br> by whitespace or newline
        </table>
 <br>
 <input type=submit class=button value="Commit Changes" OnClick="this.form.do_changes.value=1">
+<br><br>
+<input type=submit class=button value="Administer selected user" OnClick="this.form.show.value=1">
 </form>
 </td></tr>
 </table>
index 5936537bffe5a3e3ac765042bee6207bd0953ebb..e239e1f7bba7dba25fbe0783a338aa157c461043 100644 (file)
@@ -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;
                <input type=text name="passwd" size=35>
                </td>
        </tr>
+EOM;
+       if ($config[general_lib_type] == 'sql'){
+               if (isset($member_groups))
+                       $group = $member_groups[0];
+               echo <<<EOM
+       <tr>
+               <td align=right colspan=$colspan bgcolor="#d0ddb0">
+               Group
+               </td><td>
+               <input type=text name="Fgroup" value="$group" size=35>
+               </td>
+       </tr>
+EOM;
+       }
+       echo <<<EOM
        <tr>
                <td align=right colspan=$colspan bgcolor="#d0ddb0">
                Name (First Name Surname)
index 39f5a2e903dc9a4fe716d40a81f405ca23e04c4d..b4392d6484731e587637abd1a2823e2ea454ed0a 100644 (file)
@@ -39,6 +39,26 @@ if ($link){
                                else
                                        echo "<b>User already exists in user info table.</b><br>\n";
                        }
+                       else
+                               echo "<b>Could not add user information in user info table</b><br>\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 "<b>Could not add user to group $Fgroup. SQL Error</b><br>\n";
+                               }
+                               else
+                                       echo "<b>User already is a member of group $Fgroup</b><br>\n";
+                       }
+                       else
+                               echo "<b>Could not add user to group $Fgroup. SQL Error</b><br>\n";
                }
                if (!$da_abort){
                        foreach($show_attrs as $key => $attr){
index 06bec34aa8a7476a2f05c59018b326d01a0c0128..a997b36d3aa3de029a0df5b7a3df50358284b09b 100644 (file)
@@ -1,45 +1,34 @@
 <?php
-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 "<b>Could not include SQL library</b><br>\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 "<b>Could not include SQL library</b><br>\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 "<b>Database query failed partially</b><br>\n";
                                }
                                else
-                                       echo "<b>Database query failed partially</b><br>\n";
-                       }
-                       else
-                               echo "<b>Database query failed</b><br>\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 "<b>Database query failed</b><br>\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 "<b>Could not connect to database</b><br>\n";
 }
-else
-       echo "<b>Could not connect to database</b><br>\n";
 ?>