Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/users/modifyuser.php
<?php
 /*     This file is used to display all cards that have been created
	It is expected that in production, this feature will be rather
	useless because of the number of accounts that will build up
	over time.  Some sort of method for clearing old accounts will
	need to be implemented.  For now, AllCards is the first step
	in building a reporting system.

	This file C. Carl H. Peterson 2004 and released under the GPL.
	If you didn't get a copy of the GPL with this, do a search for
	GPL and find it your self.  Remember, I copyrighted this so if
	you are using it you better have a license to use it.  GPl 
	works for me.
*/
if ($buttonID=="mod_user") {
$q1 = "select user_id,user_alias,user_firstname,user_lastname From user where user_status<='".$oreon->user->get_status()."'"; // get all the timed cards
echo "<p class=\"information\">Users list :</p>";
	$result1=$oreon->database->database->query($q1);  // <------ FIGURE OUT HOW MANY RESULTS WE ARE PULLING
	
	if (!$result1) {
		$_SESSION['error']='Invalid request : ' . "Query database error !";
		echo "<script Language=\"JavaScript\"> window.location.href='".$_SERVER['HTTP_REFERER']."';</script>";
		return;
	}
	
	$numrows=$oreon->database->database->result_num_rows($result1);
	
	if ($numrows == 0) 
	{
		$_SESSION['error']=" No user found, please create one or more !";
		echo "<script Language=\"JavaScript\"> window.location.href='".$_SERVER['HTTP_REFERER']."';</script>";
		return;
	}

	echo '<table border="2">';
	echo"<tr>";
	
	echo "<td class=\"bpcell\" width=180>";
	echo "<b>Alias</b>";
	echo "</td>";
	echo "<td class=\"bpcell\" width=180>";
	echo "<b>Fistname</b>";
	echo "</td>";
	echo "<td class=\"bpcell\" width=180>";
	echo "<b>Lastname</b>";
	echo "</td>";
	echo "</tr>";
	
	
	printf('<form  name="center"  action="phpmyprepaid.php" method="post">');
	
	while ($row = $oreon->database->database->fetch_object($result1)) {
		if(!isset($shade)) { $shade = 2;}
		$array[] = $row; 
		$Id= ($row->user_id);
		$alias= ($row->user_alias);
		$lastname=($row->user_lastname);
		$firstname=($row->user_firstname);
		echo("<tr>");
		
		if($shade == 1) { echo('<td STYLE="background-color: #F2F7FB">'); }
			else{ echo('<td STYLE="background-color: #cde5f4">'); }
    		 printf('<input type="radio" name="modUser" value="%s" %s/> %s<br />',
	                 $row->user_id,
		         (isset($_REQUEST['modUser']) and $_REQUEST['modUser'] == $row->user_alias) ? 'checked="checked" ' : '',
		         $alias);
		echo("</td>");
		if($shade == 1) { echo('<td STYLE="background-color: #F2F7FB">'); }
		else{ echo('<td STYLE="background-color: #cde5f4">'); }
		echo $lastname;
			echo("</td>");
		if($shade == 1) { echo('<td STYLE="background-color: #F2F7FB">'); }
		else{ echo('<td STYLE="background-color: #cde5f4">'); }
		echo $firstname;
			echo("</td></tr>");
		$count++ ; // <--- adds 0ne to the page number
		if($shade == 1) { $shade = 2;}else{ $shade = 1; }
               }

	echo "</table>";

	echo('<input type="hidden" name="buttonID" value="mod_user_form">');
	echo "<br>";
	echo ('<td align="right"><tr>');
	echo ("<input type=\"submit\" name=\"submit\" class=\"smallButton\" value=\"Modify user \"/>");
	echo ('</td></tr>');
        echo '</form>';
							  

	echo "<br>";
}
if ($buttonID=='mod_user_form') {
	if (!isset($_POST['modUser']))
	{
		 echo "<p class=\"information\"> You haven't choose any user for modification !!</p>";
	}
	else {
	$user=$oreon->database->getUser($_POST['modUser']);
	printf('<form  name="center"  action="phpmyprepaid.php" method="post">');
	echo '<input type="hidden" name="user[user_alias_old]" value="'.$user['user_alias'].'">';
	echo '<input type="hidden" name="user[user_id]" value="'.$user['user_id'].'">';
	echo '<hr>';
	echo "<p class=\"information\">Modify user information :</p>";
	echo '<hr><br>';

	echo '<table style="text-align: left;" border="0" cellpadding="2" cellspacing="2">
		<tbody>
		<tr>
		<td colspan="1" rowspan="2" style="width: 431px; height: 151px;">
		<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
		<tbody><tr>';

?>
<table border="4" align="center" cellpadding="0" cellspacing="0" width="400">
<tr>
									<td class="bpcell"><? echo $lang['u_name']; ?><font color='red'>*</font></td>
									<td> <input name="user[user_lastname]" type="text" value='<?echo $user['user_lastname']?>' size="30"></td>
								</tr>
								<tr>
									<td class="bpcell"><? echo $lang['u_lastname']; ?><font color='red'>*</font></td>
									<td><input name="user[user_firstname]" type="text" value='<?echo $user['user_firstname']?>' size="20"></td>
								</tr>
								<tr>
									<td class="bpcell"><? echo $lang['u_login']; ?><font color='red'>*</font></td>
									<td><input name="user[user_alias]" type="text" value='<?echo $user['user_alias']?>' size="20"></td>
								</tr>
								<tr>
									<td class="bpcell"><? echo $lang['u_email']; ?><font color='red'>*</font></td>
									<td><input name="user[user_mail]" type="text" value='<?echo $user['user_mail']?>' size="30"></td>
								</tr>
								<tr>
									<td class="bpcell"><? echo $lang['u_lang']; ?><font color='red'>*</font></td>
									<td>
									<select name="user[user_lang]">
									<?
									print "<option>" . $oreon->user->get_lang() . "</option>";
									$chemintotal = "./lang/";
									if ($handle  = opendir($chemintotal))	{
										while ($file = readdir($handle))	{
											if(!is_dir("$chemintotal/$file") && strcmp($file, "index.php")) {
												$tab = split('\.', $file);
												if (strcmp($oreon->user->get_lang(), $tab[0]))
													print "<option>" . $tab[0] . "</option>";
											}
										}
										closedir($handle);
									}
									?>
									</select>
									</td>
								</tr>
								<tr>
									<td class="bpcell"><? echo $lang['u_status']; ?><font color='red'>*</font></td>
									<td>
										<select name="user[user_status]">
<?
  if ($user['user_status']=='1') 
      echo "<option selected=\"selected\" value='1'>".$lang['u_user']."</option>";
  else
	  echo "<option value='1'>".$lang['u_user']."</option>";
if ($oreon->user->get_status()=='3' or $oreon->user->get_status()=='2' ) {
  if ($user['user_status']=='2') 
      echo "<option selected=\"selected\" value='2'>".$lang['u_administrator']."</option>";
  else
	  echo "<option value='2'>".$lang['u_administrator']."</option>";
}
if ($oreon->user->get_status()=='3') {
  if ($user['user_status']=='3') 
      echo "<option selected=\"selected\" value='3'>".$lang['u_sadministrator']."</option>";
  else
	  echo "<option value='3'>".$lang['u_sadministrator']."</option>";
}
?>
										</select>
									</td>
								</tr>
<?	  
$result = getLocationName($oreon->user);
$loc=getLocationUser($user['user_id']);
echo('<tr><td class="bpcell" >User default location :</td>');
echo('<td>');
echo('<select name="user[user_location]">');
while ($row = $oreon->database->database->fetch_object($result))
	if ($loc==$row->ID) 
		echo ("<option selected=\"selected\" value=\"".$row->ID."\">".$row->LocationName."</option>");
	else
	        echo ("<option value=\"".$row->ID."\">".$row->LocationName."</option>");

echo('</select></td></tr>');	
echo '</tbody>
	</table>
	</td>
	<td style="width: 286px; height: 168px;">
	<table style="text-align: left; width: 100%;" border="1"
	cellpadding="2" cellspacing="2">
	<tbody>
	<tr>
	<td colspan="2" rowspan="1" >User password<br></td> 
	</tr><tr>
	<td  class="bpcell">'.$lang['u_passwd'].'<font color=\'red\'>*</font></td>
	<td><input name="user[user_passwd]" type="password" size="12"></td>
	</tr>
	<tr>
	<td class="bpcell">'.$lang['u_ppasswd'].'<font color=\'red\'>*</font></td>
	<td><input name="user[user_ppasswd]" type="password"  size="12"></td>
	</td>
	</tr>
	<tr align="center">
	<td colspan="2" rowspan="1" style="width: 117px;">
	<input type="hidden" name="buttonID" value="ChangePasswd">
	<input type="hidden" name="user[user_id]" value="'.$user[user_id].'">
	<input type="submit" name="submit" class="smallButton" value="Change"></td>
	</form>
	</tbody>
	</table>
	</td>
	</tr>
	<tr>
	</tr>';
	
echo '<tr align="center"><td colspan="1" rowspan="1">
	<input type="hidden" name="buttonID" value="ChangeUsers">
	<input type="hidden" name="user[user_location_old]" value="'.$loc.'">
	<input type="submit" name="submit" class="smallButton" value="Modify user"></td>
	<td></td>
	</form>
	</tr>
 </tbody>
</table>
</td>';
}
}
?>
Return current item: phpMyPrepaid