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

/*
 * ITMS ValleyData source file version 1.0 May 11, 2001
 *
 * Confirm and perform user deletion if that user has no pending tasks,
 * also delete that user's private tasks and processes
 *
 *
 *
 * 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 - Delete";

include("header.php");

include("adminonly.php");

db_open();
db_use();
$name_query = "SELECT name FROM users WHERE uid = '$delete_user'";
$result = db_query($name_query); // Get user's name
$row = db_fetch_row($result);
$delete_user_name = $row["name"];

$user_array = get_all_other_users($delete_user);
if($user_array)
foreach ($user_array as $user) // For each user other than yourself, add the user to the list
{
	$user_options .= "<option value=\"" . $user["uid"] . "\">" . $user["name"] . "</option>\n";
}

$confirm_html = <<<CONFIRM
<table>
<tr>
	<tr>
		<td>
            <FORM METHOD=POST ACTION="user_delete.php">
            Tasks assigned by $delete_user_name will now be assigned by:
			<SELECT NAME="user_to_reassign">
			$user_options
			</SELECT>
			<INPUT TYPE="hidden" name="delete_now" value="$delete_user_name">
            <INPUT TYPE="hidden" name="delete_user" value="$delete_user">
			<INPUT TYPE="submit" value="Delete User">
            <INPUT TYPE="button" value="Cancel" onClick="location='user_mgt.php'">
            </FORM>
		</td>
	</tr>
</table>
CONFIRM;

if(isset($delete_now)) // If user hits 'ok' button
{
    db_open();
    db_use();
    $query_reassign_tasks = "UPDATE pending_tasks SET assigner='$user_to_reassign' WHERE assigner='$delete_user'";
    db_query($query_reassign_tasks);
    if($ENABLE_LDAP == "true")
	    ldap_delete_user($delete_user_name);
    else
        db_delete_user($delete_user_name);
    print("<form>\n");
    print("<INPUT TYPE=\"button\" value=\"Ok\" onClick=\"location='user_mgt.php'\">");
    print("</form>\n");
}
else if(!isset($cancel) && !isset($delete_now)) // Show confirmation
{
    message_box("Are You sure you want to delete " . $delete_user_name . " from ITMS?", "warning");
	message_box("All $delete_user_name's pending tasks and private task templates will be deleted.", "warning");
    print($confirm_html);
}

include("footer.php");

?>

Return current item: Internet Task Management System