<?php
/*
* ITMS ValleyData source file version 1.0 May 11, 2001
*
* This edits existing users properties
*
*
* 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="User Management - Edit";
include("header.php");
include("adminonly.php");
db_open();
db_use();
$query = "SELECT name, email FROM users WHERE uid = '$edit_user'";
$result = db_query($query); // Get user's properties
$row = db_fetch_row($result);
$edit_user_name = $row["name"];
if(!isset($user_email))
$edit_user_email = $row["email"];
else
{
$user_email = trim($user_email);
$edit_user_email = $user_email;
}
if(isset($edit_user_submit)) // If the user hit the 'save changes'...
{
$newisadmin = ($newisadmin == "on" ? "1" : "0");
db_open();
db_use();
$query = "UPDATE users SET isadmin='$newisadmin', email='$user_email' WHERE uid = '$edit_user'";
db_query($query); // Update the user's email address and admin status
$query = "DELETE FROM user_groups WHERE uid = '$edit_user'";
if(db_query($query)) // Remove the user from all the groups
{
foreach($HTTP_POST_VARS as $comboname => $value) // For each group checked...
{
if(substr($comboname, 0, 2) == "cb")
{
$group_num = substr($comboname, 2);
$query = "INSERT into user_groups (gid, uid) VALUES ('$group_num', '$edit_user')";
db_query($query); // Add the user to checked group...
}
}
message_box("User Updated Successfully");
}
db_close();
}//end if(isset($edit_user_submit))
else if(isset($edit_pass_submit)) // If user hits 'Edit password' button
{
$newpassword = make_clean($newpassword);
$newconfirm_password = make_clean($newconfirm_password);
if($newpassword != $newconfirm_password) // If passwords don't match
{
message_box("Your two new passwords didn't match, try again...", "warning");
}
else
{
if($ENABLE_LDAP == "true")
ldap_update_password($edit_user_name, $newpassword);
else
db_update_password($edit_user_name, $newpassword);
}
}//end else if(isset($edit_pass_submit))
print("<IMG SRC=\"images/user_mgt.jpg\" WIDTH=\"400\" HEIGHT=\"41\" BORDER=\"0\" ALT=\"User Management\">");
?>
<H3><B>Edit <?php print($edit_user_name); ?>:</B></H3>
<FORM METHOD="POST" ACTION="user_edit.php">
<table>
<tr>
<td>User's Email Address:<INPUT size="35" TYPE="text" NAME="user_email" size="15" value="<?php print($edit_user_email); ?>"></td>
</tr>
<tr>
<td>User's Groups:</td>
</tr>
<tr>
<td>
<table>
<?php
$col_num = 0;
$all_groups = get_all_groups();
foreach($all_groups as $group) // Show all groups
{
$col_num++;
if($col_num == 1)
print("<tr>\n");
print("<td>\n");
if(is_user_in_group($edit_user,$group["gid"]))
$checked = "checked"; // Check the box if the user is currently in the group
else
$checked = "";
print("<INPUT TYPE=\"checkbox\" " . $checked ." NAME=\"cb" . $group["gid"] . "\"> " . $group["groupname"] . "\n");
print("</td>\n");
if($col_num == 2)
{
print("</tr>\n");
$col_num = 0;
}
}
?>
</table>
</td>
</tr>
<tr>
<td>
Administrator:<INPUT TYPE="checkbox"
<?php
if(is_admin($edit_user))
print(" checked NAME=\"newisadmin\"");
if($edit_user == $uid)
print(" disabled NAME=\"dummy\"");
else
print(" NAME=\"newisadmin\"");
?>
>
</td>
</tr>
<tr>
<td><?php
if($edit_user == $uid)
print("<INPUT TYPE=\"hidden\" NAME=\"newisadmin\" value=\"on\">");
?>
<INPUT TYPE="hidden" name="edit_user" value="<?php print($edit_user); ?>">
<INPUT TYPE="submit" name="edit_user_submit" value="Save Changes">
<INPUT TYPE="button" value="Cancel" onClick="location='user_mgt.php'">
</td>
</tr>
</table>
</FORM>
<FORM METHOD="POST" ACTION="user_edit.php">
<table>
<tr>
<td>Password:</td>
<td><INPUT TYPE="password" NAME="newpassword" size="10"></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><INPUT TYPE="password" NAME="newconfirm_password" size="10"></td>
</tr>
<tr>
<td>
<INPUT TYPE="hidden" name="edit_user" value="<?php print($edit_user); ?>">
<INPUT TYPE="submit" name="edit_pass_submit" value="Save Password">
</td>
<td>
<INPUT TYPE="button" value="Cancel" onClick="location='user_mgt.php'">
</td>
</tr>
</tr>
</table>
</form>
<?php
include("footer.php");
?>