[ 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]

/admin/includes/modules/ -> delete_product_confirm.php (source)

   1  <?php
   2  /**

   3   * @package admin

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

   5   * @copyright Portions Copyright 2003 osCommerce

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

   7   * @version $Id: delete_product_confirm.php 3345 2006-04-02 05:57:34Z drbyte $

   8   */
   9  
  10    if (!defined('IS_ADMIN_FLAG')) {
  11      die('Illegal Access');
  12    }
  13    // NOTE: Debug code left in to help with creating additional product type delete-scripts

  14  
  15    // test if demo mode active

  16    if (zen_admin_demo()) {
  17      $_GET['action']= '';
  18      $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  19      zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  20    }
  21  
  22    $do_delete_flag = false;
  23    //echo 'products_id=' . $_POST['products_id'] . '<br />';

  24    if (isset($_POST['products_id']) && isset($_POST['product_categories']) && is_array($_POST['product_categories'])) {
  25      $product_id = zen_db_prepare_input($_POST['products_id']);
  26      $product_categories = $_POST['product_categories'];
  27      $do_delete_flag = true;
  28      if (!isset($delete_linked)) $delete_linked = 'true';
  29    }
  30  
  31    if (zen_not_null($cascaded_prod_id_for_delete) && zen_not_null($cascaded_prod_cat_for_delete) ) {
  32      $product_id = $cascaded_prod_id_for_delete;
  33      $product_categories = $cascaded_prod_cat_for_delete;
  34      $do_delete_flag = true;
  35      // no check for $delete_linked here, because it should already be passed from categories.php

  36    }
  37  
  38    if ($do_delete_flag) {
  39      //--------------PRODUCT_TYPE_SPECIFIC_INSTRUCTIONS_GO__BELOW_HERE--------------------------------------------------------

  40  
  41  
  42      //--------------PRODUCT_TYPE_SPECIFIC_INSTRUCTIONS_GO__ABOVE__HERE--------------------------------------------------------

  43  
  44  
  45      // now do regular non-type-specific delete:

  46  
  47      // remove product from all its categories:

  48      for ($k=0, $m=sizeof($product_categories); $k<$m; $k++) {
  49        $db->Execute("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . "
  50                      where products_id = '" . (int)$product_id . "'
  51                      and categories_id = '" . (int)$product_categories[$k] . "'");
  52      }
  53      // confirm that product is no longer linked to any categories

  54      $count_categories = $db->Execute("select count(categories_id) as total
  55                                        from " . TABLE_PRODUCTS_TO_CATEGORIES . "
  56                                        where products_id = '" . (int)$product_id . "'");
  57      // echo 'count of category links for this product=' . $count_categories->fields['total'] . '<br />';

  58  
  59      // if not linked to any categories, do delete:

  60      if ($count_categories->fields['total'] == '0') {
  61        zen_remove_product($product_id, $delete_linked);
  62      }
  63  
  64    } // endif $do_delete_flag

  65  
  66    // if this is a single-product delete, redirect to categories page

  67    // if not, then this file was called by the cascading delete initiated by the category-delete process

  68    if ($action == 'delete_product_confirm') zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
  69  ?>


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