home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 90 / PIWD90.iso / pc / contents / ecommerce / software / osCommerce.exe / oscommerce-2.2ms2 / catalog / account_newsletters.php < prev    next >
PHP Script  |  2003-06-05  |  7KB  |  160 lines

  1. <?php
  2. /*
  3.   $Id: account_newsletters.php,v 1.3 2003/06/05 23:23:52 hpdl Exp $
  4.  
  5.   osCommerce, Open Source E-Commerce Solutions
  6.   http://www.oscommerce.com
  7.  
  8.   Copyright (c) 2003 osCommerce
  9.  
  10.   Released under the GNU General Public License
  11. */
  12.  
  13.   require('includes/application_top.php');
  14.  
  15.   if (!tep_session_is_registered('customer_id')) {
  16.     $navigation->set_snapshot();
  17.     tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  18.   }
  19.  
  20. // needs to be included earlier to set the success message in the messageStack
  21.   require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_NEWSLETTERS);
  22.  
  23.   $newsletter_query = tep_db_query("select customers_newsletter from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
  24.   $newsletter = tep_db_fetch_array($newsletter_query);
  25.  
  26.   if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) {
  27.     if (isset($HTTP_POST_VARS['newsletter_general']) && is_numeric($HTTP_POST_VARS['newsletter_general'])) {
  28.       $newsletter_general = tep_db_prepare_input($HTTP_POST_VARS['newsletter_general']);
  29.     } else {
  30.       $newsletter_general = '0';
  31.     }
  32.  
  33.     if ($newsletter_general != $newsletter['customers_newsletter']) {
  34.       $newsletter_general = (($newsletter['customers_newsletter'] == '1') ? '0' : '1');
  35.  
  36.       tep_db_query("update " . TABLE_CUSTOMERS . " set customers_newsletter = '" . (int)$newsletter_general . "' where customers_id = '" . (int)$customer_id . "'");
  37.     }
  38.  
  39.     $messageStack->add_session('account', SUCCESS_NEWSLETTER_UPDATED, 'success');
  40.  
  41.     tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
  42.   }
  43.  
  44.   $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
  45.   $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_NEWSLETTERS, '', 'SSL'));
  46. ?>
  47. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  48. <html <?php echo HTML_PARAMS; ?>>
  49. <head>
  50. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  51. <title><?php echo TITLE; ?></title>
  52. <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
  53. <link rel="stylesheet" type="text/css" href="stylesheet.css">
  54. <script language="javascript"><!--
  55. function rowOverEffect(object) {
  56.   if (object.className == 'moduleRow') object.className = 'moduleRowOver';
  57. }
  58.  
  59. function rowOutEffect(object) {
  60.   if (object.className == 'moduleRowOver') object.className = 'moduleRow';
  61. }
  62.  
  63. function checkBox(object) {
  64.   document.account_newsletter.elements[object].checked = !document.account_newsletter.elements[object].checked;
  65. }
  66. //--></script>
  67. </head>
  68. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
  69. <!-- header //-->
  70. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  71. <!-- header_eof //-->
  72.  
  73. <!-- body //-->
  74. <table border="0" width="100%" cellspacing="3" cellpadding="3">
  75.   <tr>
  76.     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
  77. <!-- left_navigation //-->
  78. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  79. <!-- left_navigation_eof //-->
  80.     </table></td>
  81. <!-- body_text //-->
  82.     <td width="100%" valign="top"><?php echo tep_draw_form('account_newsletter', tep_href_link(FILENAME_ACCOUNT_NEWSLETTERS, '', 'SSL')) . tep_draw_hidden_field('action', 'process'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
  83.       <tr>
  84.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  85.           <tr>
  86.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  87.             <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  88.           </tr>
  89.         </table></td>
  90.       </tr>
  91.       <tr>
  92.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  93.       </tr>
  94.       <tr>
  95.         <td class="main"><b><?php echo MY_NEWSLETTERS_TITLE; ?></b></td>
  96.       </tr>
  97.       <tr>
  98.         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  99.           <tr class="infoBoxContents">
  100.             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  101.               <tr>
  102.                 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  103.                 <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  104.                   <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="checkBox('newsletter_general')">
  105.                     <td class="main"><?php echo tep_draw_checkbox_field('newsletter_general', '1', (($newsletter['customers_newsletter'] == '1') ? true : false), 'onclick="checkBox(\'newsletter_general\')"'); ?></td>
  106.                     <td class="main"><b><?php echo MY_NEWSLETTERS_GENERAL_NEWSLETTER; ?></b></td>
  107.                   </tr>
  108.                   <tr>
  109.                     <td class="main"> </td>
  110.                     <td><table border="0" cellspacing="0" cellpadding="2">
  111.                       <tr>
  112.                         <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  113.                         <td class="main"><?php echo MY_NEWSLETTERS_GENERAL_NEWSLETTER_DESCRIPTION; ?></td>
  114.                         <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  115.                       </tr>
  116.                     </table></td>
  117.                   </tr>
  118.                 </table></td>
  119.                 <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  120.               </tr>
  121.             </table></td>
  122.           </tr>
  123.         </table></td>
  124.       </tr>
  125.       <tr>
  126.         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  127.       </tr>
  128.       <tr>
  129.         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  130.           <tr class="infoBoxContents">
  131.             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  132.               <tr>
  133.                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  134.                 <td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
  135.                 <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
  136.                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  137.               </tr>
  138.             </table></td>
  139.           </tr>
  140.         </table></td>
  141.       </tr>
  142.     </table></form></td>
  143. <!-- body_text_eof //-->
  144.     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
  145. <!-- right_navigation //-->
  146. <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
  147. <!-- right_navigation_eof //-->
  148.     </table></td>
  149.   </tr>
  150. </table>
  151. <!-- body_eof //-->
  152.  
  153. <!-- footer //-->
  154. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  155. <!-- footer_eof //-->
  156. <br>
  157. </body>
  158. </html>
  159. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  160.