Location: PHPKode > projects > ACollab > group_admin/user_edit.php
<?php
/****************************************************************************************/
/* ACollab                                                                              */
/****************************************************************************************/
/* Copyright (c) 2002-2004  Adaptive Technology Resource Centre / University of Toronto */
/*                                                                                      */
/* http://atutor.ca/acollab                                                             */
/*                                                                                      */
/* This program is free software. You may 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 may access the GNU General Public License at:                                    */
/* http://www.opensource.org/licenses/gpl-license.php                                   */
/*                                                                                      */
/* You may contact the Adaptive Technology Resource Centre at                           */
/* Robarts Library, University of Toronto                                               */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
/* Further contact information is available at http://www.utoronto.ca/atrc/             */
/****************************************************************************************/
/* Programmer:                                                                          */
/* Joel Kronenberg - ATRC                                                               */
/****************************************************************************************/
// $Id: user_edit.php 236 2004-06-07 20:08:32Z boonhau $

exit('no longer used');

define('AC_INCLUDE_PATH', '../include/');

require(AC_INCLUDE_PATH.'vitals.inc.php');
authenticate(USER_GROUP_ADMIN);

$_SECTION[0][0] = _AC('home');
$_SECTION[0][1] = 'home.php';
$_SECTION[1][0] = _AC('administration');
$_SECTION[1][1] = 'group_admin/';
$_SECTION[2][0] = _AC('user_management');
$_SECTION[2][1] = 'group_admin/users.php';
$_SECTION[3][0] = _AC('edit_member_account');
$_SECTION[3][1] = 'group_admin/user_edit.php';

if ($_POST['cancel']) {
	header('Location: users.php');
	exit;
}

$id = intval($_REQUEST['id']);

if ($_POST['submit']) {
	$_POST['email'] = trim($_POST['email']);
	$_POST['fname']	= trim($_POST['fname']);
	$_POST['lname']	= trim($_POST['lname']);
	$_POST['title']	= trim($_POST['title']);
	$_POST['organization']	= trim($_POST['organization']);
	$_POST['branch']	= trim($_POST['branch']);
	$_POST['address']	= trim($_POST['address']);
	$_POST['city']	= trim($_POST['city']);

	$_POST['jurisdiction']	= intval($_POST['jurisdiction']);
	$_POST['department']	= intval($_POST['department']);
	$_POST['province']		= intval($_POST['province']);
	$_POST['status']		= intval($_POST['status']);

	if ($_POST['email'] == '') {
		$error[] = E_REG_MISSING_EMAIL;
	} else if (!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $_POST['email'])) {
		$error[] = E_REG_INVALID_EMAIL;
	}

	if (!isset($error)) {
		$_POST['email'] = $addslashes($_POST['email']);
		$_POST['fname'] = $addslashes($_POST['fname']);
		$_POST['lname'] = $addslashes($_POST['lname']);
		$_POST['title'] = $addslashes($_POST['title']);
		$_POST['organization'] = $addslashes($_POST['organization']);

		$sql = "UPDATE ".TABLE_PREFIX."members SET email='$_POST[email]', first_name='$_POST[fname]', last_name='$_POST[lname]', language='$_POST[ulang]', title='$_POST[title]', organization='$_POST[organization]', jurisdiction_id=$_POST[jurisdiction], department_id=$_POST[department], branch='$_POST[branch]', address='$_POST[address]', city='$_POST[city]', province_id=$_POST[province], postal_code='$_POST[postal_code]', phone='$_POST[phone]', fax='$_POST[fax]' WHERE member_id=$id";

		if (mysql_query($sql, $db)) {
			header('Location: users.php?f='.F_USER_EDITED);
			exit;
		} else {
			$error[] = E_USER_EDIT;
		}
	}
}

require(AC_INCLUDE_PATH.'header.inc.php');

$sql	= "SELECT M.* FROM ".TABLE_PREFIX."members M, ".TABLE_PREFIX."groups_members H WHERE M.member_id=$id AND H.member_id=$id AND H.group_id=$_SESSION[group_id]";
$result	= mysql_query($sql, $db);
if (!$row = mysql_fetch_assoc($result)) {
	$error = E_USER_NOT_FOUND;
	print_errors($error);
	require(AC_INCLUDE_PATH.'footer.inc.php');	
	exit;
}

	if ($_POST['submit']) {
		$row = $_POST;
		$row['login']	= $_POST['login'];
		$row['first_name']	= $_POST['fname'];
		$row['last_name']	= $_POST['lname'];
		$row['password']	= $_POST['password'];
		$row['email']		= $_POST['email'];
		$row['language']	= $_POST['ulang'];
		$row['status']		= $_POST['status'];
		$row['priv_email']	= $_POST['priv'];
		$row['province_id']	= $_POST['province'];
		$row['jurisdiction_id']	= $_POST['jurisdiction'];
		$row['department_id']	= $_POST['department'];
	}

	if ($_POST['submit']) {
		$my_groups = $_POST['groups'];
	} else {
		$sql	= "SELECT group_id FROM ".TABLE_PREFIX."groups_members WHERE member_id=$id";
		$result	= mysql_query($sql, $db);
		$my_groups = array();
		while ($temp_row = mysql_fetch_assoc($result)) {
			$my_groups[] = $temp_row['group_id'];
		}
	}

	if (isset($error)) {
		print_errors($error);
	}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
	<input type="hidden" name="id" value="<?php echo $row['member_id']; ?>" />
	<table border="0" cellspacing="0" cellpadding="2" align="center" class="box2">
	<tr>
		<th colspan="5" class="box"><h3><?php echo _AC('edit_member_account'); ?></h3></th>
	</tr>
	<tr>
		<td class="row1">&nbsp;</td>
		<td colspan="3" class="row1"><img src="images/clr.gif" height="1" width="1" alt="" /><br /><?php
			echo _AC('denotes_required', '<img src="images/required.gif" height="14" width="14" alt="'._AC('required_field').'" />');
		?><br /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right" valign="top"><label for="username"><b><?php echo _AC('username'); ?>:</b></label></td>
		<td class="row1" valign="top">&nbsp;</td>
		<td class="row1"><?php echo $row['login']; ?></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right" valign="top"><label for="email"><b><?php echo _AC('email'); ?>:</b></label></td>
		<td class="row1" valign="top"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" class="img" /></td>
		<td class="row1"><input type="text" name="email" class="input" size="30" id="email" value="<?php echo $row['email']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="fname"><b><?php echo _AC('first_name'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="text" name="fname" class="input" size="20" id="fname" value="<?php echo $row['first_name']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="lname"><b><?php echo _AC('last_name'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="text" name="lname" class="input" size="20" id="lname" value="<?php echo $row['last_name']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="title"><b><?php echo _AC('title'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="text" name="title" class="input" size="20" id="title" value="<?php echo $row['title']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="org"><b><?php echo _AC('organization'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="text" name="organization" class="input" size="20" id="org" value="<?php echo $row['organization']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="jur"><b><?php echo _AC('jurisdiction'); ?>:</b></label></td>
		<td class="row1" valign="top"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" class="img" /></td>
		<td class="row1"><?php
						$jurisdictions = get_jurisdictions('title', 'ASC');
						if ($jurisdictions) {
							$num_jurisdictions = min(count($jurisdictions), 4);
							echo '<select name="jurisdiction" id="jur" class="input" onfocus="this.className=\'input highlight\'" onblur="this.className=\'input\'">';
							foreach ($jurisdictions as $jurisdiction) {
								echo '<option value="'.$jurisdiction['jurisdiction_id'].'"';
								if ($jurisdiction['jurisdiction_id'] == $row['jurisdiction_id']) {
									echo ' selected="selected"';
								}
								echo '>'.$jurisdiction['title'].'</option>';		
							}
							echo '</select>';
						} else {
							echo _AC('no_jurisdictions_found');
						}
						?></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="dept"><b><?php echo _AC('department_ministry'); ?>:</b></label></td>
		<td class="row1" valign="top"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" class="img" /></td>
		<td class="row1"><?php
						$departments = get_departments('title', 'ASC');
						if ($departments) {
							$num_departments = min(count($departments), 4);
							echo '<select name="department" id="dept" class="input" onfocus="this.className=\'input highlight\'" onblur="this.className=\'input\'">';
							foreach ($departments as $department) {
								echo '<option value="'.$department['department_id'].'"';
								if ($department['department_id'] == $row['department_id']) {
									echo ' selected="selected"';
								}
								echo '>'.$department['title'].'</option>';		
							}
							echo '</select>';
						} else {
							echo _AC('no_departments_found');
						}
						?></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="branch"><b><?php echo _AC('branch_directorate_section'); ?>:</b></label></td>
		<td class="row1" valign="top">&nbsp;</td>
		<td class="row1"><input type="text" name="branch" class="input" size="40" id="branch" value="<?php echo $row['branch']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr>
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right" valign="top"><label for="address"><b><?php echo _AC('address'); ?>:</b></label></td>
		<td class="row1" valign="top">&nbsp;</td>
		<td class="row1"><textarea name="address" id="address" cols="40" rows="3" class="input" onfocus="this.className='input highlight'" onblur="this.className='input'"><?php echo $row['address']; ?></textarea></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="city"><b><?php echo _AC('city'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="text" name="city" class="input" size="20" id="city" value="<?php echo $row['city']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="prov"><b><?php echo _AC('province_territory'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><?php
						$provinces = get_provinces('title', 'ASC');
						if ($provinces) {
							$num_provinces = min(count($provinces), 4);
							echo '<select name="province" id="prov" class="input" onfocus="this.className=\'input highlight\'" onblur="this.className=\'input\'">';
							foreach ($provinces as $province) {
								echo '<option value="'.$province['province_id'].'"';
								if ($province['province_id'] == $row['province_id']) {
									echo ' selected="selected"';
								}
								echo '>'.$province['title'].'</option>';		
							}
							echo '</select>';
						} /* else {
							echo _AC('no_provinces_found');
						} */
						?></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="postal_code"><b><?php echo _AC('postal_code'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="text" name="postal_code" class="input" size="8" id="postal_code" value="<?php echo $row['postal_code']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="phone"><b><?php echo _AC('phone'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="text" name="phone" class="input" size="20" id="phone" value="<?php echo $row['phone']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="fax"><b><?php echo _AC('fax'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="text" name="fax" class="input" size="20" id="fax" value="<?php echo $row['fax']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" align="right"><label for="lang"><b><?php echo _AC('language'); ?>:</b></label></td>
		<td class="row1">&nbsp;</td>
		<td class="row1"><input type="radio" name="ulang" id="lang1" value="en"  <?php if ($row['language'] == 'en') { echo 'checked="checked"'; } ?> onfocus="this.className='highlight'" onblur="this.className=''" /><label for="lang1"><?php echo _AC('en'); ?></label>, <input type="radio" name="ulang" id="lang0" value="fr"  <?php if ($row['language'] == 'fr') { echo 'checked="checked"'; } ?> onfocus="this.className='highlight'" onblur="this.className=''" /><label for="lang0"><?php echo _AC('fr'); ?></label></td>
		<td class="row1">&nbsp;</td>
	</tr>
	<tr bgcolor="white">
		<td class="row1">&nbsp;</td>
		<td class="row1" colspan="3" align="right"><br /><input type="submit" name="submit" value=" <?php echo _AC('edit'); ?> " class="submitY" onfocus="this.className='submitY highlight'" onblur="this.className='submitY'" /> &nbsp; <input type="submit" name="cancel" value="<?php echo _AC('cancel'); ?>" class="submitN" onfocus="this.className='submitN highlight'" onblur="this.className='submitN'" /><br /><br /></td>
		<td class="row1">&nbsp;</td>
	</tr>
	</table>
</form>

<?php
require(AC_INCLUDE_PATH.'footer.inc.php');
?>
Return current item: ACollab