Location: PHPKode > projects > Internet Task Management System > itms_mysql_build_0111/group_edit.php
<?php

/*
 * ITMS ValleyData source file version 1.0 May 11, 2001
 *
 * Enables an ITMS administrator to edit a group
 *
 *
 * Internet Task Management System: An online system used for recording information about and assigning tasks and processes.
 * Copyright (C) 2001  ValleyData Programming Group
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * See file named "gpl.txt" included with source code or
 * visit http://www.gnu.org/copyleft/gpl.txt on the internet.
 */
$title="Group Management - Edit";

include("header.php");

include("adminonly.php");

db_open();
db_use();
$query = "SELECT groupname FROM groups WHERE gid = '$edit_group'";
$result = db_query($query); //get group's info
$row = db_fetch_row($result);
$edit_group_name = $row["groupname"];

if(isset($edit_group_submit)) //if they are edditing the group now
{
    db_open();
    db_use();

    $query = "DELETE FROM user_groups WHERE gid = '$edit_group'";
    if(db_query($query)) //remove all users from the group
    {
        foreach($HTTP_POST_VARS as $comboname => $value)
        {
            if(substr($comboname, 0, 2) == "cb")
            {
                $user_num = substr($comboname, 2);
                $query = "INSERT into user_groups (uid, gid) VALUES ('$user_num', '$edit_group')";
                db_query($query); //add each user that was checked to the group
            }
        }
        message_box("Group Updated Successfully");
    }
    db_close();
}

print("<IMG SRC=\"images/group_mgt.jpg\" WIDTH=\"400\" HEIGHT=\"41\" BORDER=\"0\" ALT=\"Group Management\">");
?>

<FORM METHOD="POST" ACTION="group_edit.php">

<H3><B>Edit <?php print($edit_group_name); ?>:</B></H3>
<table>
	<tr>
    <td>Group's Users:</td>
	</tr>
	<tr>
    <td>
        <table>
    <?php
        $col_num = 0;
        $all_users = get_all_users();
		foreach($all_users as $user)
		{
            $col_num++;
			if($col_num == 1)
				print("<tr>\n");
            print("<td>\n");
			if(is_user_in_group($user["uid"], $edit_group))
				$checked = "checked";
			else
				$checked = "";
			print("<INPUT TYPE=\"checkbox\" " . $checked ." NAME=\"cb" . $user["uid"] . "\">&nbsp;" . $user["name"] . "\n");
            print("</td>\n");
			if($col_num == 4)
			{
				print("</tr>\n");
				$col_num = 0;
			}
		}
    ?>
        </table>
	</td>
    </tr>
	<tr>
		<td>
			<INPUT TYPE="hidden" name="edit_group" value="<?php print($edit_group); ?>">
			<INPUT TYPE="submit" name="edit_group_submit" value="Save Changes">
			<INPUT TYPE="button" value="Cancel" onClick="location='group_mgt.php'">
		</td>
	</tr>
</table>

</FORM>
<?php
include("footer.php"); 
?>
Return current item: Internet Task Management System