[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/includes/modules/pages/account_notifications/ -> header_php.php (source)

   1  <?php
   2  /**

   3   * Header code file for the Account Notifications page

   4   *

   5   * @package page

   6   * @copyright Copyright 2003-2006 Zen Cart Development Team

   7   * @copyright Portions Copyright 2003 osCommerce

   8   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   9   * @version $Id: header_php.php 3007 2006-02-11 09:17:12Z drbyte $

  10   */
  11  // This should be first line of the script:

  12  $zco_notifier->notify('NOTIFY_HEADER_START_ACCOUNT_NOTIFICATION');
  13  
  14  if (!$_SESSION['customer_id']) {
  15    $_SESSION['navigation']->set_snapshot();
  16    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  17  }
  18  
  19  require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
  20  
  21  $global_query = "SELECT global_product_notifications
  22                   FROM   " . TABLE_CUSTOMERS_INFO . "
  23                   WHERE  customers_info_id = :customersID";
  24  
  25  $global_query = $db->bindVars($global_query, ':customersID',$_SESSION['customer_id'], 'integer');
  26  $global = $db->Execute($global_query);
  27  
  28  if (isset($_POST['action']) && ($_POST['action'] == 'process')) {
  29    if (isset($_POST['product_global']) && is_numeric($_POST['product_global'])) {
  30      $product_global = zen_db_prepare_input($_POST['product_global']);
  31    } else {
  32      $product_global = '0';
  33    }
  34  
  35    (array)$products = $_POST['notify'];
  36  
  37    if ($product_global != $global->fields['global_product_notifications']) {
  38      $product_global = (($global->fields['global_product_notifications'] == '1') ? '0' : '1');
  39  
  40      $sql = "UPDATE " . TABLE_CUSTOMERS_INFO . "
  41              SET    global_product_notifications = :globalProductNotifications
  42              WHERE  customers_info_id = :customersID";
  43  
  44      $sql = $db->bindVars($sql, ':globalProductNotifications',$product_global, 'integer');
  45      $sql = $db->bindVars($sql, ':customersID',$_SESSION['customer_id'], 'integer');
  46      $db->Execute($sql);
  47  
  48    } elseif (sizeof($products) > 0) {
  49      $products_parsed = array();
  50  
  51      foreach ($products as $parse_entry) {
  52        if (is_numeric($parse_entry)) {
  53          $products_parsed[] = $parse_entry;
  54        }
  55      }
  56  
  57      if (sizeof($products_parsed) > 0) {
  58        $check_query = "SELECT count(*) AS total
  59                        FROM   " . TABLE_PRODUCTS_NOTIFICATIONS . "
  60                        WHERE  customers_id = :customersID
  61                        AND    products_id NOT IN (:productsParsed)";
  62  
  63        $check_query = $db->bindVars($check_query, ':customersID',$_SESSION['customer_id'], 'integer');
  64        $check_query = $db->bindVars($check_query, ':productsParsed',implode(',', $products_parsed), 'csv');
  65        $check = $db->Execute($check_query);
  66  
  67        if ($check->fields['total'] > 0) {
  68          $sql = "DELETE FROM " . TABLE_PRODUCTS_NOTIFICATIONS . "
  69                  WHERE       customers_id = :customersID
  70                  AND         products_id NOT IN (:productsParsed)";
  71  
  72          $sql = $db->bindVars($sql, ':customersID',$_SESSION['customer_id'], 'integer');
  73          $sql = $db->bindVars($sql, ':productsParsed',implode(',', $products_parsed), 'csv');
  74          $db->Execute($sql);
  75        }
  76      }
  77    } else {
  78      $check_query = "SELECT count(*) AS total
  79                      FROM   " . TABLE_PRODUCTS_NOTIFICATIONS . "
  80                      WHERE  customers_id = :customersID";
  81  
  82      $check_query = $db->bindVars($check_query, ':customersID',$_SESSION['customer_id'], 'integer');
  83      $check = $db->Execute($check_query);
  84  
  85      if ($check->fields['total'] > 0) {
  86        $sql = "DELETE FROM " . TABLE_PRODUCTS_NOTIFICATIONS . "
  87                WHERE       customers_id = :customersID";
  88  
  89        $sql = $db->bindVars($sql, ':customersID',$_SESSION['customer_id'], 'integer');
  90        $db->Execute($sql);
  91      }
  92    }
  93  
  94    $messageStack->add_session('account', SUCCESS_NOTIFICATIONS_UPDATED, 'success');
  95  
  96    zen_redirect(zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));
  97  }
  98  
  99  /*

 100  $products_check_query = "SELECT count(*) AS total

 101                           FROM   " . TABLE_PRODUCTS_NOTIFICATIONS . "

 102                           WHERE  customers_id = :customersID";

 103  

 104  $products_check_query = $db->bindVars($products_check_query, ':customersID',$_SESSION['customer_id'], 'integer');

 105  $products_check = $db->Execute($products_check_query);

 106  if ($products_check->fields['total'] > 0) $flag_products_check = true;

 107  */
 108  
 109  $counter = 0;
 110  $notificationsArray = array();
 111  $products_query = "SELECT pd.products_id, pd.products_name
 112                     FROM   " . TABLE_PRODUCTS_DESCRIPTION . " pd,
 113                            " . TABLE_PRODUCTS_NOTIFICATIONS . " pn
 114                     WHERE  pn.customers_id = :customersID
 115                     AND    pn.products_id = pd.products_id
 116                     AND    pd.language_id = :languagesID
 117                     ORDER BY pd.products_name";
 118  
 119  $products_query = $db->bindVars($products_query, ':customersID',$_SESSION['customer_id'], 'integer');
 120  $products_query = $db->bindVars($products_query, ':languagesID',$_SESSION['languages_id'], 'integer');
 121  $products = $db->Execute($products_query);
 122  while (!$products->EOF) {
 123    $notificationsArray[] = array('counter'=>$counter,
 124                                  'products_id'=>$products->fields['products_id'],
 125                                  'products_name'=>$products->fields['products_name']);
 126    $counter++;
 127    $products->MoveNext();
 128  }
 129  $flag_products_check = sizeof($notificationsArray);
 130  
 131  
 132  $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));
 133  $breadcrumb->add(NAVBAR_TITLE_2);
 134  
 135  // This should be last line of the script:

 136  $zco_notifier->notify('NOTIFY_HEADER_END_ACCOUNT_NOTIFICATION');
 137  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics