* Add a drop down menu with existing groups in group_new.php3
authorkkalev <kkalev>
Mon, 26 Jul 2004 21:13:06 +0000 (21:13 +0000)
committerkkalev <kkalev>
Mon, 26 Jul 2004 21:13:06 +0000 (21:13 +0000)
* Check for sql in show_groups.php3
* In lib/sql/group_info.php3 if $login is not set, find available groups and place them in
  $existing_groups along with a count of users per group. Use the functionality in group_new.php3
  and show_groups.php3
* Update TODO

dialup_admin/Changelog
dialup_admin/doc/TODO
dialup_admin/htdocs/group_new.php3
dialup_admin/htdocs/show_groups.php3
dialup_admin/lib/sql/group_info.php3

index 24bf5bd..123b745 100644 (file)
@@ -5,6 +5,12 @@ Ver 1.75:
 * Update FAQ about using php with no sql support.
 * Allow the user to select between viewing FAQ,HOWTO or README in the help page.
 * Use $_SERVER instead of $HTTP_SERVER_VARS
+* Add a drop down menu with existing groups in group_new.php3
+* Check for sql in show_groups.php3
+* In lib/sql/group_info.php3 if $login is not set, find available groups and place them in
+  $existing_groups along with a count of users per group. Use the functionality in group_new.php3
+  and show_groups.php3
+* Update TODO
 Ver 1.72:
 * Move the xlat function to a separate file in lib/xlat.php3
 * Add a lib/sql/nas_list.php3 to also get the nas list from sql (naslist.conf still works)
index 2d71d3f..2bea55f 100644 (file)
@@ -1,8 +1,6 @@
 * Minimize database (ldap,mysql) connections.
 * Clean up html code to make it smaller
 * More messages
-* Skins
-* Other languages in html
 * Multilanguage support for ldap attributes
 * Add language attributes in user_new.php3
 * Finger facility. Should find a way to make it work with all nases. That will
@@ -17,4 +15,6 @@
 * Parse the radius dictionary files so that we can show a pull down menu of possible values
   for various attributes.
 * Check the sql user code for sql injections
-* Also be able to keep username mappings in sql. Create and administration page
+* Also be able to keep username mappings in sql. Create an administration page
+* Get rid of register_globals. We only need a few user passed variables, we should get those
+  from the superglobals.
index fe0d6e1..f3a3673 100644 (file)
@@ -22,6 +22,7 @@ EOM;
 
 require('../lib/attrshow.php3');
 require('../lib/defaults.php3');
+require("../lib/$config[general_lib_type]/group_info.php3");
 
 if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
        $colspan=2;
@@ -87,6 +88,22 @@ EOM;
        echo <<<EOM
        <tr>
                <td align=right colspan=$colspan bgcolor="#d0ddb0">
+               Available Groups
+               </td><td>
+EOM;
+               if (!isset($existing_groups))
+                       echo "<b>No groups available</b>\n";
+               else{
+                       echo "<select name=\"existing_groups\">\n";     
+                       foreach ($existing_groups as $group)
+                               echo "<option value=\"$group\">$group\n";
+                       echo "</select>\n";
+               }
+       echo <<<EOM
+               </td>
+       </tr>
+       <tr>
+               <td align=right colspan=$colspan bgcolor="#d0ddb0">
                Group name
                </td><td>
                <input type=text name="login" value="$login" size=35>
index b652cab..e53711b 100644 (file)
@@ -20,6 +20,20 @@ else{
 EOM;
        exit();
 }
+if ($config[general_lib_type] != 'sql'){
+       echo <<<EOM
+<title>User Groups</title>
+<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
+<link rel="stylesheet" href="style.css">
+</head>
+<body>
+<center>
+<b>This page is only available if you are using sql as general library type</b>
+</body>
+</html>
+EOM;
+       exit();
+}
 ?>
 <head>
 <title>User Groups</title>
@@ -55,33 +69,23 @@ EOM;
        </tr>
 
 <?php
-$link = @da_sql_pconnect($config);
-if ($link){
-       $search = @da_sql_query($link,$config,
-       "SELECT COUNT(*) as counter,groupname FROM $config[sql_usergroup_table] GROUP BY groupname;");
-       if ($search){
-               if (@da_sql_num_rows($search,$config)){
-                       while( $row = @da_sql_fetch_array($search,$config) ){
-                               $num++;
-                               $group = $row[groupname];
-                               $num_members = $row[counter];
-                               echo <<<EOM
+unset($login);
+$num = 0;
+include_once('../lib/sql_group_info.php3');
+if (isset($existing_groups)){
+       foreach ($existing_groups as $num_members => $group){
+               $num++;
+               echo <<<EOM
                <tr align=center>
                        <td>$num</td>
                        <td><a href="group_admin.php3?login=$group" title="Edit group $group">$group</a></td>
                        <td>$num_members</td>
                </tr>
 EOM;
-                       }
-               }
-               else
-                       echo "<b>Could not find any groups</b><br>\n";
        }
-       else
-               echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
 }
 else
-       echo "<b>Could not connect to SQL database</b><br>\n";
+       echo "<b>Could not find any groups</b><br>\n";
 ?>
        </table>
 </table>
index fda77a6..0ad59b3 100644 (file)
@@ -17,25 +17,26 @@ $group_exists = 'no';
 unset($item_vals);
 unset($tmp);
 unset($group_members);
+unset($existing_groups);
 $link = @da_sql_pconnect($config);
 if ($link){
-       $res = @da_sql_query($link,$config,
-       "SELECT attribute,value $op FROM $config[sql_groupcheck_table] WHERE groupname = '$login';");
-       if ($res){
-               if (@da_sql_num_rows($res,$config))
-                       $group_exists = 'yes';
-               while(($row = @da_sql_fetch_array($res,$config))){
-                       $attr = $row[attribute];
-                       $val = $row[value];
-                       if ($use_op){
-                               $oper = $row[op];
-                               $tmp["$attr"][operator][]="$oper";
+       if ($login == ''){
+               $res = @da_sql_query($link,$config,
+               "SELECT COUNT(*) as counter,groupname FROM $config[sql_usergroup_table]
+               GROUP BY groupname;");
+               if ($res){
+                       while(($row = @da_sql_fetch_array($res,$config))){
+                               $name = $row[groupname];
+                               $existing_groups["$name"] = $row[counter];
                        }
-                       $tmp["$attr"][]="$val";
-                       $tmp["$attr"][count]++;
+                       ksort($existing_groups);
                }
+               else
+                       echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
+       }
+       else{
                $res = @da_sql_query($link,$config,
-               "SELECT attribute,value $op FROM $config[sql_groupreply_table] WHERE groupname = '$login';");
+               "SELECT attribute,value $op FROM $config[sql_groupcheck_table] WHERE groupname = '$login';");
                if ($res){
                        if (@da_sql_num_rows($res,$config))
                                $group_exists = 'yes';
@@ -46,45 +47,60 @@ if ($link){
                                        $oper = $row[op];
                                        $tmp["$attr"][operator][]="$oper";
                                }
-                               $tmp["$attr"][] = "$val";
+                               $tmp["$attr"][]="$val";
                                $tmp["$attr"][count]++;
                        }
-               }
-               else
-                       echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
-               $res = @da_sql_query($link,$config,
-               "SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;");
-               if ($res){
-                       if (@da_sql_num_rows($res,$config))
-                               $group_exists = 'yes';
-                       while(($row = @da_sql_fetch_array($res,$config))){
-                               $member = $row[username];
-                               $group_members[] = "$member";
+                       $res = @da_sql_query($link,$config,
+                       "SELECT attribute,value $op FROM $config[sql_groupreply_table] WHERE groupname = '$login';");
+                       if ($res){
+                               if (@da_sql_num_rows($res,$config))
+                                       $group_exists = 'yes';
+                               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: " . da_sql_error($link,$config) . "</b><br>\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;
+                       else
+                               echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
+                       $res = @da_sql_query($link,$config,
+                       "SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;");
+                       if ($res){
+                               if (@da_sql_num_rows($res,$config))
+                                       $group_exists = 'yes';
+                               while(($row = @da_sql_fetch_array($res,$config))){
+                                       $member = $row[username];
+                                       $group_members[] = "$member";
+                               }
+                       }       
+                       else
+                               echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\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;
+                                       }
+                                       $item_vals["$key"] = $tmp[$val];
+                                       $item_vals["$key"][count] = $tmp[$val][count];
+                                       if ($use_op)
+                                               $item_vals["$key"][operator] = $tmp[$val][operator];
                                }
-                               $item_vals["$key"] = $tmp[$val];
-                               $item_vals["$key"][count] = $tmp[$val][count];
-                               if ($use_op)
-                                       $item_vals["$key"][operator] = $tmp[$val][operator];
                        }
                }
-
+               else
+                       echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
        }
-       else
-               echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
 }
 else
        echo "<b>Could not connect to SQL database</b><br>\n";