<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 4/27/2015	ELL
// 
//
	include ("check_session.php");

?>
<!DOCTYPE html>
<html>
<head>
<title>Copy Public Users to Restricted Users | Breeze Website Builder</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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>
#copy_public_user_to_restricted_heading	{	width:400px;	}

#help_button	{	
	position:relative;
	display:block;
	top:-15px;
	left:350px;
	height:31px;
	width:31px;
	z-index:100;
}
</style>

<script src="js/json2.js"></script>
<script src="js/ajax.js"></script>
<script src="js/mouse_position.js"></script>
<script src="js/popup_msg.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/copy_public_user_to_restricted.js"></script>

<script>
<?php
	echo "	var theme = '$theme';\n\n";
	
	echo "	var MANAGE_PAGE_ACCESS_RESTRICT_PAGE_ACCESS = \"" . MANAGE_PAGE_ACCESS_RESTRICT_PAGE_ACCESS . "\";\n";
	echo "	var PAGE_1ST_CAP_WORD = \"" . PAGE_1ST_CAP_WORD . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_REQUIRE_LOGIN = \"" . MANAGE_PAGE_ACCESS_REQUIRE_LOGIN . "\";\n";
	echo "	var USER_TABLE_WORD = \"" . USER_TABLE_WORD . "\";\n";
	echo "	var ACCESS_LEVEL_WORD = \"" . ACCESS_LEVEL_WORD . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_LOGIN_PAGE = \"" . MANAGE_PAGE_ACCESS_LOGIN_PAGE . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_SHOW_LOGIN_LINKS_ALWAYS = \"" . MANAGE_PAGE_ACCESS_SHOW_LOGIN_LINKS_ALWAYS . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_DELETE_USER_CONFIRM_1_MSG = \"" . MANAGE_PAGE_ACCESS_DELETE_USER_CONFIRM_1_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_DELETE_USER_CONFIRM_2_MSG = \"" . MANAGE_PAGE_ACCESS_DELETE_USER_CONFIRM_2_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_USER_DELETED_1_MSG = \"" . MANAGE_PAGE_ACCESS_USER_DELETED_1_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_USER_DELETED_2_MSG = \"" . MANAGE_PAGE_ACCESS_USER_DELETED_2_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_DELETE_ACCESS_LEVEL_CONFIRM_1_MSG = \"" . MANAGE_PAGE_ACCESS_DELETE_ACCESS_LEVEL_CONFIRM_1_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_DELETE_ACCESS_LEVEL_CONFIRM_2_MSG = \"" . MANAGE_PAGE_ACCESS_DELETE_ACCESS_LEVEL_CONFIRM_2_MSG . "\";\n";
	echo "	var QUERY_READY_TO_SEND = \"" . QUERY_READY_TO_SEND . "\";\n";
	echo "	var QUERY_SENT = \"" . QUERY_SENT . "\";\n";
	echo "	var QUERY_COMPLETE = \"" . QUERY_COMPLETE . "\";\n";
	echo "	var QUERY_COMPLETE_NO_RECORD_FOUND = \"" . QUERY_COMPLETE_NO_RECORD_FOUND . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_LOCATING_PAGE_RESTRICTIONS_MSG = \"" . MANAGE_PAGE_ACCESS_LOCATING_PAGE_RESTRICTIONS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_COULD_NOT_UPDATE_PAGE_RESTRICTIONS_MSG = \"" . MANAGE_PAGE_ACCESS_COULD_NOT_UPDATE_PAGE_RESTRICTIONS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_PAGE_RESTRICTIONS_UPDATED_MSG = \"" . MANAGE_PAGE_ACCESS_PAGE_RESTRICTIONS_UPDATED_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_UPDATING_PAGE_RESTRICTIONS_MSG = \"" . MANAGE_PAGE_ACCESS_UPDATING_PAGE_RESTRICTIONS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_COULD_NOT_UPDATE_USER_STATUS_MSG = \"" . MANAGE_PAGE_ACCESS_COULD_NOT_UPDATE_USER_STATUS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_USER_STATUS_UPDATED_MSG = \"" . MANAGE_PAGE_ACCESS_USER_STATUS_UPDATED_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_UPDATING_USER_STATUS_MSG = \"" . MANAGE_PAGE_ACCESS_UPDATING_USER_STATUS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_COULD_NOT_MODIFY_TABLE_MSG = \"" . MANAGE_PAGE_ACCESS_COULD_NOT_MODIFY_TABLE_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_FIELDS_ADDED_TO_TABLE_MSG = \"" . MANAGE_PAGE_ACCESS_FIELDS_ADDED_TO_TABLE_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_ADDING_FIELDS_TO_TABLE_MSG = \"" . MANAGE_PAGE_ACCESS_ADDING_FIELDS_TO_TABLE_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_WELCOME_MESSAGE_PAGE_ADDED_TO_TABLE_MSG = \"" . MANAGE_PAGE_ACCESS_WELCOME_MESSAGE_PAGE_ADDED_TO_TABLE_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_ADDING_WELCOME_MESSAGE_PAGE_TO_TABLE_MSG = \"" . MANAGE_PAGE_ACCESS_ADDING_WELCOME_MESSAGE_PAGE_TO_TABLE_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_COULD_NOT_ADD_DELETE_ACCESS_LEVEL_MSG = \"" . MANAGE_PAGE_ACCESS_COULD_NOT_ADD_DELETE_ACCESS_LEVEL_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_ACESS_LEVEL_RECORDS_MODIFIED_MSG = \"" . MANAGE_PAGE_ACCESS_ACESS_LEVEL_RECORDS_MODIFIED_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_CHANGING_ACCESS_LEVELS_MSG = \"" . MANAGE_PAGE_ACCESS_CHANGING_ACCESS_LEVELS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_LOCATING_ACCESS_LEVELS_MSG = \"" . MANAGE_PAGE_ACCESS_LOCATING_ACCESS_LEVELS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_LOCATING_USERS_MSG = \"" . MANAGE_PAGE_ACCESS_LOCATING_USERS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_REQUIRED_FIELDS_MSG = \"" . MANAGE_PAGE_ACCESS_REQUIRED_FIELDS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_RETRIEVING_PAGE_RESTRICTIONS_MSG = \"" . MANAGE_PAGE_ACCESS_RETRIEVING_PAGE_RESTRICTIONS_MSG . "\";\n";
	echo "	var _NOT_SELECTED_ = \"" . _NOT_SELECTED_ . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_RETRIEVING_ACCESS_LEVELS_MSG = \"" . MANAGE_PAGE_ACCESS_RETRIEVING_ACCESS_LEVELS_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_RETRIEVING_USERS_MSG = \"" . MANAGE_PAGE_ACCESS_RETRIEVING_USERS_MSG . "\";\n";
	echo "	var USER_WORD = \"" . USER_WORD . "\";\n";
	echo "	var ACTIVE_WORD = \"" . ACTIVE_WORD . "\";\n";
	echo "	var EDITOR_STARTING_UPDATE_MSG = \"" . EDITOR_STARTING_UPDATE_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_ADDING_LOGIN_FIELDS_TO_TABLE_MSG = \"" . MANAGE_PAGE_ACCESS_ADDING_LOGIN_FIELDS_TO_TABLE_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_ASSIGNING_WELCOME_MESSAGE_PAGE_TO_TABLE_MSG = \"" . MANAGE_PAGE_ACCESS_ASSIGNING_WELCOME_MESSAGE_PAGE_TO_TABLE_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_ADDING_ACCESS_LEVEL_MSG = \"" . MANAGE_PAGE_ACCESS_ADDING_ACCESS_LEVEL_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_REMOVING_ACCESS_LEVEL_MSG = \"" . MANAGE_PAGE_ACCESS_REMOVING_ACCESS_LEVEL_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_NEW_USER_NOT_ADDED_ERR = \"" . MANAGE_PAGE_ACCESS_NEW_USER_NOT_ADDED_ERR . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_NEW_USER_CREATED_1_MSG = \"" . MANAGE_PAGE_ACCESS_NEW_USER_CREATED_1_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_NEW_USER_CREATED_2_MSG = \"" . MANAGE_PAGE_ACCESS_NEW_USER_CREATED_2_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_NEW_USER_CREATED_3_MSG = \"" . MANAGE_PAGE_ACCESS_NEW_USER_CREATED_3_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_NEW_USER_CREATED_4_MSG = \"" . MANAGE_PAGE_ACCESS_NEW_USER_CREATED_4_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_NEW_USER_CREATED_5_MSG = \"" . MANAGE_PAGE_ACCESS_NEW_USER_CREATED_5_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_PASSWORD_CHANGED_1_MSG = \"" . MANAGE_PAGE_ACCESS_PASSWORD_CHANGED_1_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_PASSWORD_CHANGED_2_MSG = \"" . MANAGE_PAGE_ACCESS_PASSWORD_CHANGED_2_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_USER_CHANGED_1_MSG = \"" . MANAGE_PAGE_ACCESS_USER_CHANGED_1_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_USER_CHANGED_2_MSG = \"" . MANAGE_PAGE_ACCESS_USER_CHANGED_2_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_USER_CHANGED_3_MSG = \"" . MANAGE_PAGE_ACCESS_USER_CHANGED_3_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_USER_CHANGED_4_MSG = \"" . MANAGE_PAGE_ACCESS_USER_CHANGED_4_MSG . "\";\n";
	echo "	var MANAGE_PAGE_ACCESS_NO_DATA_FOUND_FOR_USER_ERR = \"" . MANAGE_PAGE_ACCESS_NO_DATA_FOUND_FOR_USER_ERR . "\";\n";
	echo "	var TOP_1ST_CAP_WORD = \"" . TOP_1ST_CAP_WORD . "\";\n";
	echo "	var HEADER_1ST_CAP_WORD = \"" . HEADER_1ST_CAP_WORD . "\";\n";
	echo "	var YES_WORD = \"" . YES_WORD . "\";\n";
	echo "	var NO_WORD = \"" . NO_WORD . "\";\n";
?>

var tables = new Array();
var bgclr = "#eeeeee";
var update_page_table_mode = 0;

<?php
	echo "var last_user_table = '$last_user_table';\n";
	echo "var last_user = '$last_user';\n";


	$query = "SHOW TABLES";
	$result = $bwb_dbh->query($query);
	$tmp_table = "";
	$j = 0;
	$tables = array();
	$rows = $result->fetchAll(PDO::FETCH_NUM);
	foreach ($rows as $row)
	{
	
		$tmp_table = $row[0];
		if ((substr($tmp_table, 0, strlen(BWB_TABLE_PREFIX)) != BWB_TABLE_PREFIX) || (BWB_TABLE_PREFIX == ""))
		{
			echo "tables[$j] = '" . $tmp_table . "';\n";
			$tables[$j] = $tmp_table;
			$j++;
		}
	}
	echo "var table_cnt = $j;\n\n";
	$table_cnt = $j;
	
?>
</script>

</head>

<body id="workspace_body">
<br>
<div align="center">
<table width="95%" border="0"><tr>
<td>
<div class="button_heading_sub_level_1" id="copy_public_user_to_restricted_heading"><div class="button_heading_text_sub_level_1"><?php //echo MANAGE_PAGE_ACCESS_HEADING; ?>Copy Public User to Breeze User as Restricted</div><div class="help_button" id="help_button" onClick="OpenHelpWindow();">&nbsp;</div></div>
</td>
</tr></table>

<table width="95%" border="1" cellspacing="0" cellpadding="5"><tr><td>
<table width="100%" border="0" class="layout_box_table">
  <tr>
    <td class="sub_title"><?php echo MANAGE_PAGE_ACCESS_APPROVE_ACCESSTO_USERS; ?></td>
     <td align="right" class='header_row'><b><?php echo TABLE_WORD; ?>:</b>&nbsp;</td>
    <td>
    <select name="user_table_for_users_table" id="user_table_for_users_table" onChange="RetrieveUserLists(this.value, true);">
    	<option><?php echo _NOT_SELECTED_; ?></option>
<?php
	for ($i = 0; $i < $table_cnt; $i++)
	{
		if ($tables[$i] == $last_user_table)
			echo "<option value='" . $tables[$i] . "' selected='selected'>" . $tables[$i] . "</option>";
		else
			echo "<option value='" . $tables[$i] . "'>" . $tables[$i] . "</option>";
	}
?>
    </select>
    </td>
  </tr>
  
  <tr>
    <td colspan="3">  
     <table border="0" width="95%" align="center">
      <tr id="user_nav_row_top">
        <td width="25%" align="center">
         <img src="./theme/<?php echo $theme; ?>/images/First.gif" id="first_top" border="0" onClick="moveFirst();" style="cursor:default;" onMouseOver="this.style.cursor='pointer';" />
        </td>
        <td width="25%" align="center">
          <img src="./theme/<?php echo $theme; ?>/images/Previous.gif" id="prev_top" border="0" onClick="movePrev();" style="cursor:default;" onMouseOver="this.style.cursor='pointer';" />
        </td>
        <td width="25%" align="center">
          <img src="./theme/<?php echo $theme; ?>/images/Next.gif" id="next_top" border="0" onClick="moveNext();" style="cursor:default;" onMouseOver="this.style.cursor='pointer';" />
        </td>
        <td width="25%" align="center">
          <img src="./theme/<?php echo $theme; ?>/images/Last.gif" id="last_top" border="0" onClick="moveLast();" style="cursor:default;" onMouseOver="this.style.cursor='pointer';" />
        </td>
      </tr>
    </table>
    </td>
  </tr>
  
  <tr>
  	<td colspan="3"><div id="UsersTable">&nbsp;</div></td>
  </tr>
  
  <tr>
    <td colspan="3">  
     <table border="0" width="95%" align="center">
      <tr id="user_nav_row_bot">
        <td width="25%" align="center">
         <img src="./theme/<?php echo $theme; ?>/images/First.gif" id="first_bot" border="0" onClick="moveFirst();" style="cursor:default;" onMouseOver="this.style.cursor='pointer';" />
        </td>
        <td width="25%" align="center">
          <img src="./theme/<?php echo $theme; ?>/images/Previous.gif" id="prev_bot" border="0" onClick="movePrev();" style="cursor:default;" onMouseOver="this.style.cursor='pointer';" />
        </td>
        <td width="25%" align="center">
          <img src="./theme/<?php echo $theme; ?>/images/Next.gif" id="next_bot" border="0" onClick="moveNext();" style="cursor:default;" onMouseOver="this.style.cursor='pointer';" />
        </td>
        <td width="25%" align="center">
          <img src="./theme/<?php echo $theme; ?>/images/Last.gif" id="last_bot" border="0" onClick="moveLast();" style="cursor:default;" onMouseOver="this.style.cursor='pointer';" />
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>

</td>
</tr>  
</table>
</div>

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

<script language='javascript' type='text/javascript'>
   if (last_user_table != "")
   	RetrieveUserLists(last_user_table);
   else
   	ShowHidePageBtns();
	
	HidePopupMsg();
</script>
</body>
</html>