<?php
////////////////////////////////////////////////////////////////////////
// Restrict Page Access //
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 4/9/2010
// Revised: 2/9/2012	ELL
// Added table prefix handling.
	
	include ("check_session.php");
	
	$page_restrictions_saved = $_REQUEST['page_restrictions_saved'];
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Restrict Editing Access | Breeze Website Builder</title>
<link rel="stylesheet" href="theme/<?php echo $theme; ?>/manager.css" type="text/css">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">

<style type="text/css">
#restrict_page_access_heading	{	width:460px;	}
#button_help	{	left:410px;	}
#select_all_btn	{	width:110px;	}
#clear_all_btn	{	width:110px;	}
#save_restricted_pages_btn	{	width:110px;	}
</style>

<script language="javascript" type="text/javascript" src="js/browser_detect.js"></script>
<script language="javascript" type="text/javascript" src="js/mouse_position.js"></script>
<script language="javascript" type="text/javascript" src="js/popup_msg.js"></script>
<script language="javascript" type="text/javascript" src="js/restrict_editing_access.js"></script>
</head>

<body>

<div align="center">
<table width="80%" border="0"><tr><td>
<div id="restrict_page_access_heading" class="button_heading_sub_level_1"><div class="button_heading_text_sub_level_1"><?php echo RESTRICT_PAGE_EDITING_HEADING; ?></div><div id="button_help" class="button_heading_help" onclick="OpenHelpWindow();">&nbsp;</div></div>
</td></tr></table>

<form action="save_restrict_editing.php" method="post" enctype="multipart/form-data" name="frm_restrict_editing" id="frm_restrict_editing">
<table width="80%" border="0" class="layout_box_table">
<tr bgcolor='#CCCCCC'>
	<td><b><?php echo PAGE_1ST_CAP_WORD; ?></b></td><td><b><?php echo RESTRICTED_WORD; ?></b></td>
<?php
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "page_data ORDER BY page_name";
	$result = $bwb_dbh->query($query);
	while($row = $result->fetch(PDO::FETCH_ASSOC))
	{
		if ($bgclr == "#DDDDDD")
			$bgclr = "#EEEEEE";
		else
			$bgclr = "#DDDDDD";
			
		$page_name = $row["page_name"];
		$restricted = $row["restricted"];
		if ($restricted == 1)
			echo "<tr bgcolor='$bgclr'><td>$page_name</td><td><input name='$page_name' id='$page_name' type='checkbox' value='1' checked /></td></tr>\n";
		else
			echo "<tr bgcolor='$bgclr'><td>$page_name</td><td><input name='$page_name' id='$page_name' type='checkbox' value='1' /></td></tr>\n";
	}
?>
</tr>
</table>

<table width="80%" border="0" cellspacing="0" cellpadding="0">
 <tr>
   <td colspan="5">&nbsp;</td>
 </tr>
 <tr>
   <td align="center">
    <div class='button_console_add' id="select_all_btn" onClick="SelectAll();"><span class='button_console_text_w_icon'><?php echo SELECT_ALL; ?></span></div>
   </td>
   <td align="center">
    <div class='button_console_delete' id="clear_all_btn" onClick="ClearAll();"><span class='button_console_text_w_icon'><?php echo CLEAR_ALL; ?></span></div>
   </td>
   <td align="center">
    <div class='button_console_save' id="save_restricted_pages_btn" onClick="document.getElementById('frm_restrict_editing').submit();"><span class='button_console_text_w_icon'><?php echo EDITOR_SAVE; ?></span></div>
   </td>
 </tr>
</table>
</form> 
</div>

<?php include("lib/popup_msg.html"); ?>

<script language="JavaScript"  type="text/javascript">
	HidePopupMsg();
<?php	if ($page_restrictions_saved == 1)	{	?>
	popup_msg.top_offset = 100;
	popup_msg.left_offset = 320;
	popup_msg.popup_msg_type = 1;
	popup_msg.popup_timeout = 3000;
	popup_msg.status_msg = "<?php echo RESTRICT_PAGE_EDITING_RESTRICTIONS_SAVED_MSG; ?>";
	popup_msg.ShowPopupMsg();
<?php	}	?>
</script>

</body>
</html>