<?php
/*
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Implemented by Blake Schwendiman (blake@intechra.net)
  Updated 2002/3/30 -- Ross Lapkoff (rlapkoff@austin.rr.com)

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');
  require(DIR_WS_FUNCTIONS . 'misc_funcs.php');
  include (DIR_WS_LANGUAGES . $language . '/administrators.php');
	
?>
<html>
<head>
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="5" cellpadding="5">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
        </table></td>
      </tr>
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">&nbsp;Edit Administrator's Account&nbsp;</td>
          </tr>
        <tr><td>&nbsp;<?php echo tep_draw_separator('pixel_trans.gif', '1', '15'); ?>&nbsp;</td></tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td><?php echo tep_draw_separator(); ?></td>
          </tr>
          <tr><td>
                <table width="100%">
                    <tr><td width="10">&nbsp;</td>
                        <td colspan="2" class="infoBoxHeading"><b><font size="2">
				<?php echo TEXT_EDITING_ADMINISTRATORS;  ?></font></b></td>
                        <td class="infoBoxHeading"><b><font size="2"><?php print(TEXT_ADMIN_HAS_ACCESS_TO); ?></font></b></td>
                    </tr>
                    <?php
			    $edit_query = tep_db_query("select admin_name, allowed_pages from " . TABLE_ADMINISTRATORS . " where admin_id = '" . $HTTP_GET_VARS['aID'] . "'");
                      $aData = tep_db_fetch_array($edit_query);
                      	     $aUserID   = $aData['admin_name'];
                             $aAdminID  = $aData['admin_id'];
                             $aAccessTo = $aData['allowed_pages'];
                                
                                if (trim($aAccessTo) == '*') {
                                $aTextAccessTo = TEXT_FULL_ACCESS;
                                } else {
                                  $aTextAccessTo = '';
                                  $aAccessPages = explode('|', $aAccessTo);
                                    foreach($aAccessPages as $aPage) {
                                    $aTextAccessTo .= $aADMBoxes[$aPage] . ', ';
                                    }
                                    $aTextAccessTo = substr($aTextAccessTo, 0, strlen($aTextAccessTo) - 2);
                             } 
                                ?>
                                    <tr><td>&nbsp;</td>
						<td colspan="2" align="center" class="main"><b><?php echo '&nbsp;&nbsp;' . $aUserID; ?></b></td>
                                    <td class="main"><?php echo $aTextAccessTo; ?></td>
                                    </tr>
                </table>
            </td>
          </tr>
<?php if ($HTTP_GET_VARS['error'] == 'name') {
	echo  '<tr><td class="messageStackSuccess">&nbsp;&nbsp;  Name field is empty, please try again.</td></tr>';
	} elseif ($HTTP_GET_VARS['error'] == 'pass') {
	echo  '<tr><td class="messageStackSuccess">&nbsp;&nbsp;  Password field is empty or confirmed password does not match, please try again.</td></tr>';
	}
	?>
          <tr><td><?php echo tep_draw_separator(); ?></td>
          </tr>
          <tr><td>
             <table>
                <form method="post" action="administrators.php?action=update_admin_confirm&aID=<?php echo $aID; ?>">
                    <tr><td width="10">&nbsp;</td>
                        <td colspan="2" class="infoBoxHeading">&nbsp;</td>
                    </tr>
                    <tr><td width="10">&nbsp;</td>
                        <td class="infoBoxHeading" valign="top">
                            <table>
                                <tr><td class="main"><?php print(TEXT_ADMINISTRATOR_USERNAME); ?></td>
                                    <td><input type="text" name="username" maxlength="20"></td>
                                </tr>
                                <tr><td class="main"><?php print(TEXT_ADMINISTRATOR_PASSWORD); ?></td>
                                    <td><input type="password" name="password" maxlength="20"></td>
                                </tr>
                                <tr><td class="main"><?php print(TEXT_ADMINISTRATOR_CONFPWD); ?></td>
                                    <td><input type="password" name="confpwd" maxlength="20"><p></td>
                                </tr>
					 <tr><td colspan="2" class="messageStackError"><input type="checkbox" name="login_up" value="new">This is a new login for the current admin.</td>
                                </tr>
                                <tr><td colspan="2" class="smallText">Note: Unless this is checked, current login information for this administrator will remain the same, whether you type in the fields or not!<p></td>
                                </tr>
                            </table>
                        </td>
                        <td valign="top"><table width="100%">
                                <tr><td class="messageStackError"><input type="checkbox" name="adm_type" value="all"><?php print(TEXT_FULL_ACCESS); ?></td>
                                </tr>
					<tr><td colspan="2"><?php echo tep_draw_separator(); ?></td></tr>
                                <tr><td class="main"><?php print(TEXT_PARTIAL_ACCESS); ?>
                                    <select align="right" name="allowed_pages[]" size="<?php print( count( $aADMBoxes ) ); ?>" multiple>
                                        <?php 
                                            foreach($aADMBoxes as $aKey => $aValue) 
							 if ($aAccessTo == '*') {
						    print( "<option selected value=\"$aKey\">$aValue</option>" );
							  } else {																						
							   if (in_array($aKey,$aAccessPages)) {
						     print( "<option selected value=\"$aKey\">$aValue</option>" );
						   } else {
						   print( "<option value=\"$aKey\">$aValue</option>" );
                                              }
							} 
                                        ?>
                                        </select>
						<p>To add or delete areas accessible by this administrator, hold down CTRL and click each one.  If you want to give the
						   administrator full access to all files, check the box above instead.
                                    </td>
                                </tr>
                            </table> 
                        </td>
                    </tr>
                    <tr><td width="10">&nbsp;</td>
                        <td colspan="2" class="infoBoxHeading">
			<?php echo tep_image_submit('button_update.gif', 'Update') . ' <a href="' . tep_href_link(FILENAME_ADMINISTRATORS, tep_get_all_get_params(array('aID')) . 'aID=' . $HTTP_GET_VARS['aID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
                    </tr>
                   </form>
                </table>
            </td>
          </tr>
<!-- body_text_eof //-->
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>