Location: PHPKode > projects > Opensheet > opensheet/permissions.php
<?php



ini_set('display_errors','1');
error_reporting(E_ALL);
session_start();

require ('functions/base.functions.php');
include ('classes/global.class.php');


	set_lang($_SESSION['lang']);
	$login_type = new users();
		if ($_SESSION['permissions']['admin'] !== "1"){
		Header("Location: timesheet.php");
					exit();

		}
		
		#write permission to database
		if (!empty($_POST)){
	$permissions = $_POST;
		$users_blank = new Users;
		foreach ($users_blank->getUsersArray() as $key => $value){
			$users_blank_array[$key] = array(admin=>'0',pm=>'0',dm=>'0',fd=>'0',user=>'0');
			if ($permissions[$key]['admin'] == 'Y') { $users_blank_array[$key]['admin'] = '1';} 
			if ($permissions[$key]['dm'] == 'Y') { $users_blank_array[$key]['dm'] = '1';} 
			if ($permissions[$key]['pm'] == 'Y') { $users_blank_array[$key]['pm'] = '1';} 
			if ($permissions[$key]['fd'] == 'Y') { $users_blank_array[$key]['fd'] = '1';} 
			if ($permissions[$key]['user'] == 'Y') { $users_blank_array[$key]['user'] = '1';} 
		}
		
		$permission= new Users;
		$permission->setPermission($users_blank_array);
				Header("Location: permissions.php");
					exit();
	
	
}
		
		
		
		
		
		
		
?><!-- Headers -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/jqueryslidemenu.css" />
<link rel="stylesheet" href="js/addons/pager/jquery.tablesorter.pager.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="css/themes/blue/style.css" type="text/css" media="print, projection, screen" />

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="js/jqueryslidemenu.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.pager.js"></script>


<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/
</style>
<![endif]-->


<script type="text/javascript">
$(document).ready(function() { 
	    $(".tablesorter") 
	    .tablesorter({widthFixed: true, widgets: ['zebra']}) 
	   
	}); 

</script>


<title>Permission Setup</title>


</head>
<body>
<?php
include ('include/menu.settings.inc.html');

$users=new Users;		
		
		
?>
		<form action="" name="permissions" method="post">
		<div>
		<table class="tablesorter" cellspacing="1" style="width: 80%;">
			<thead>
		
		<tr>
		<th style="width: 25%;"><?php echo gettext('User name');?></th>
		<th style="width: 15%;"><?php echo gettext('Administrator');?></th>
		<th style="width: 15%;"><?php echo gettext('Project manager');?></th>
		<th style="width: 15%;"><?php echo gettext('Department manager');?></th>
		<th style="width: 15%;"><?php echo gettext('Financial manager');?></th>
		<th style="width: 15%;"><?php echo gettext('User');?></th>
		</tr>
			</thead>
			<tbody>



<?php 		
		
		
		




$users = new Users;
$permissions = new Users;

#print_r($users->getUsersArray());

foreach ($users->getUsersArray() as $key=>$value){
	if($value['status'] == 'Y'){
		$permission = $permissions->getUidPerm($key);
		
		echo "<tr><td>".$value['real_name']."</td>";
		echo "<td>";
		if ($permission['admin'] == '1') {
			echo '<input name="'.$key.'[admin]" type="checkbox" value="Y" checked style="background-color: #ffffff;" ></input>';
		}else {
			echo '<input name="'.$key.'[admin]" type="checkbox" value="Y" style="background-color: #ffffff;"></input>';
		}
		echo "</td>";
		echo "<td>";
		if ($permission['pm'] == '1') {
			echo '<input name="'.$key.'[pm]" type="checkbox" value="Y" checked></input>';
		}else {
			echo '<input name="'.$key.'[pm]" type="checkbox" value="Y" ></input>';
		}
		echo "</td>";
		echo "<td>";
		if ($permission['dm'] == '1') {
			echo '<input name="'.$key.'[dm]" type="checkbox" value="Y" checked></input>';
		}else {
			echo '<input name="'.$key.'[dm]" type="checkbox" value="Y" ></input>';
		}
		echo "</td>";
		echo "<td>";
		if ($permission['fd'] == '1') {
			echo '<input name="'.$key.'[fd]" type="checkbox" value="Y" checked></input>';
		}else {
			echo '<input name="'.$key.'[fd]" type="checkbox" value="Y" ></input>';
		}
		echo "</td>";
		echo "<td>";
		if ($permission['user'] == '1') {
			echo '<input name="'.$key.'[user]" type="checkbox" value="Y" checked></input>';
		}else {
			echo '<input name="'.$key.'[user]" type="checkbox" value="Y" ></input>';
		}
		echo "</td></tr>";
	
	
	}	
	
}

?>

</tbody>
</table>
</div>

<center><input type="submit"></input></center>
</form></body></html>
Return current item: Opensheet