Location: PHPKode > projects > OpenDataCenter Network Management System > include/administration_page/user.php
<?php
// ----------------------------------------------------------------------
// Copyright (C) 2007 by GREGORY LE BRAS
// ----------------------------------------------------------------------
// LICENSE
//
// This file is part of ODCNMS - Open DataCenter Network Management System
// 
// ODCNMS 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.
// 
// Foobar 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 Foobar; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
// ----------------------------------------------------------------------
// Original Author of file: GREGORY LE BRAS - http://www.odcnms.org/
// ----------------------------------------------------------------------
?>
<div class="title"><img src="images/user.gif" alt="User" align="bottom"> <?php echo TXT_USER; ?></div>

<?php
if (!isset($action))
{
?>
<table class="subtitle" width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<td width="90%"><h4><img src="images/user.gif" alt="User" align="top"> <?php echo TXT_ALL; ?> <?php echo TXT_USERS; ?></h4></td>
		<td width="10%" style="text-align:right">[ <a href="index.php?include=administration&page=user&action=add"><?php echo TXT_ADD; ?></a> ]</td>
	<tr>
</table>
<table class="sortable list" id="sortable" width="100%" cellspacing="2" cellpadding="3">
	<tr class="list_title">
		<td valign="top"><?php echo TXT_USERNAME; ?></td>
		<td valign="top"><?php echo TXT_STATUS; ?></td>
		<td width="12%" valign="top" class="unsortable"><?php echo TXT_ACTION; ?></td>
	</tr>
<?php
	$list1 = "list1"; 
	$list2 = "list2"; 
	$line_count = 0; 
	
	$request=mysql_query("SELECT * FROM $name_table_users ORDER BY username ASC") or die ("ERROR!");

	while($tmp_request=mysql_fetch_array($request))
	{
		$line_color = ($line_count % 2) ? $list1 : $list2;
	?>
		<tr class="<?php echo "$line_color"; ?>">
			<td valign="top"><?php print("<a href=\"index.php?include=administration&page=user&action=view&id=$tmp_request[id]\">$tmp_request[username]</a>"); ?></td>
			<td valign="top"><?php 
			switch ($tmp_request['administrator'])
			{
				case '0':
					echo "<font style='padding:2px;background:#0000ff;color:#fff'>".TXT_USER."</font>";					
				break;
				
				case '1':
					echo "<font style='padding:2px;background:#ff0000;color:#fff'>".TXT_ADMINISTRATOR."</font>";					
				break;
				
				case '2':
					echo "<font style='padding:2px;background:#00ff00;color:#fff'>".TXT_SUPER." ".TXT_ADMINISTRATOR."</font>";					
				break;				
			}

			?></td>
			<td width="12%" valign="top">[ <?php print("<a href=\"index.php?include=administration&page=user&action=edit&id=$tmp_request[id]\">".TXT_EDIT."</a>"); ?> ] [ <?php print("<a href=\"index.php?include=administration&page=user&action=delete&id=$tmp_request[id]\">".TXT_DELETE."</a>"); ?> ]</td>	
		</tr>
	<?php	
			$line_count++;
	}
?>	
</table>
<br><center><a href="javascript:history.go(-1);"><?php echo TXT_BACK; ?></a></center>
<?php
}
else
{
	$request=mysql_query("SELECT administrator FROM $name_table_users WHERE username=\"$login\"") or die ("ERROR!");

	while($tmp_request=mysql_fetch_array($request))
	{
		$user_privilege = $tmp_request['administrator'];
	}

	if ($user_privilege=="2")
	{
		if ($action == "add")
		{
			include("user/add.php");
		}
		else if ($action == "edit")
		{
			include("user/edit.php");
		}
		else if ($action == "delete")
		{
			include("user/delete.php");
		}
		else if ($action == "view")
		{
			include("user/view.php");
		}		
		else
		{
			include("pagenotfound.php");
		}
	}
	else
	{
		echo "<center><div id=\"status\" style=\"color:red\"><img src=\"images/forbidden.png\" alt=\"FORBIDDEN\"><br><br>";
		echo TXT_FORBIDDEN;
		echo "</div></center>";
	}
}
?>
Return current item: OpenDataCenter Network Management System