<?php

// -----------------------------------------------------------------------
// This file is part of Igloo
// 
// Copyright (C) 2003, 2006 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// 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, 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 program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>


<form action="node_acs.php" method="post">
<input type="hidden" name="role_id" value="<?php if (isset($role['role_id'])) {echo $role['role_id'];}?>" />
<input type="hidden" name="resource_id" value="<?php if (isset($resource['resource_id'])) {echo $resource['resource_id'];}?>" />

<div class="col_left1">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_acs_permissions'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<table cellpadding="4" cellspacing="0" border="0" width="100%">
					<?php
					if (isset($resources[0])) {
					foreach($resources as $key1 => $res):
					?>
					<tr>
						<td colspan="2" valign="top">
							<b><?php echo $res['resource_name'];?></b><br />
						</td>
					</tr>
					<?php
					//get the privileges for each resource
					if (isset($res['privileges'])) {
					foreach($res['privileges'] as $key2 => $priv):
					?>
					<tr>
						<td valign="top" width="50%">
							<?php echo $priv['privilege_name'];?><br />
						</td>
						<td valign="top">
							<?php
							//create a table for each permission (one per role)
							if (isset($priv['permissions'])) {
							foreach($priv['permissions'] as $key3 => $perm):
							$checked = "";
							if ($perm == 1) {
								$checked = "checked";
							}
							?>
							<input type="checkbox" name="ids[<?php echo $res["resource_id"]."-".$priv["privilege_id"]."-".$key3;?>]" value="1" <?php echo $checked;?> /> <?php echo $roles[$key3]['role_name'];?><br />
							<?php
							endforeach;
							}
							?>
						</td>
					</tr>
					<?php
					endforeach;
					}
					?>
					
					
					<?php
					endforeach;
					}
					?>
					<tr>
						<td colspan="2" align="right">
							<input type="submit" name="update_permissions" value="<?php echo $lang['sub_update_permissions'];?>" class="button_urgent" / ><br />
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
</div>

<div class="col_right1">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_menu'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php echo $lang['txt_acs_permissions_help'];?><br />
				
				<?php
				if (isset($resources)) {
				foreach($resources as $key1 => $res):
				?>
				<p><b><?php echo $res['resource_name'];?></b><br />
				<?php echo $res['resource_desc'];?><br />
				</p>
				<?php
				endforeach;
				}
				?>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
</div>
</form>
