[ 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/product_music/ -> 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      // First we delete related records from related product-type tables:

  42      //echo 'SQL=' . "select media_id from " . TABLE_MEDIA_TO_PRODUCTS . " where product_id = '" . (int)$product_id . "'<br />";

  43  
  44      $product_media = $db->Execute("select media_id from " . TABLE_MEDIA_TO_PRODUCTS . "
  45                                     where product_id = '" . (int)$product_id . "'");
  46      //echo 'media count =' . $product_media->RecordCount() . '<br />';

  47      while (!$product_media->EOF) {
  48        //echo 'media delete=' . $product_media->fields['media_id'] . '<br />';

  49        $db->Execute("delete from " . TABLE_MEDIA_TO_PRODUCTS . "
  50                      where media_id='" . (int)zen_db_input($product_media->fields['media_id']) . "'
  51                      and product_id = '" . (int)$product_id . "'");
  52        $product_media->MoveNext();
  53      }
  54  
  55      //echo 'SQL=' . "select artists_id, record_company_id, music_genre_id from " . TABLE_PRODUCT_MUSIC_EXTRA . "                                 where products_id = '" . (int)$product_id . "'<br />";

  56      $music_extra = $db->Execute("select artists_id, record_company_id, music_genre_id from " . TABLE_PRODUCT_MUSIC_EXTRA . "
  57                                       where products_id = '" . (int)$product_id . "'");
  58      //echo 'media count =' . $music_extra->RecordCount() . '<br />';

  59      if ($music_extra->RecordCount()>0) {
  60        //echo 'artists_id delete=' . $music_extra->fields['artists_id'] . '<br />';

  61        //echo 'record_company_id delete=' . $music_extra->fields['record_company_id'] . '<br />';

  62        //echo 'music_genre_id delete=' . $music_extra->fields['music_genre_id'] . '<br />';

  63        $db->Execute("delete from " . TABLE_PRODUCT_MUSIC_EXTRA . "
  64                      where products_id = '" . (int)$product_id . "'
  65                      and artists_id = '" . zen_db_input($music_extra->fields['artists_id']) . "'
  66                      and record_company_id = '" . zen_db_input($music_extra->fields['record_company_id']) . "'
  67                      and music_genre_id = '" . zen_db_input($music_extra->fields['music_genre_id']) . "'");
  68      }
  69  
  70      //--------------PRODUCT_TYPE_SPECIFIC_INSTRUCTIONS_GO__ABOVE__HERE--------------------------------------------------------

  71  
  72  
  73      // now do regular non-type-specific delete:

  74  
  75      // remove product from all its categories:

  76      for ($k=0, $m=sizeof($product_categories); $k<$m; $k++) {
  77        $db->Execute("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . "
  78                      where products_id = '" . (int)$product_id . "'
  79                      and categories_id = '" . (int)$product_categories[$k] . "'");
  80      }
  81  
  82      // confirm that product is no longer linked to any categories

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

  87  
  88      // if not linked to any categories, do delete:

  89      if ($count_categories->fields['total'] == '0') {
  90        zen_remove_product($product_id, $delete_linked);
  91      }
  92  
  93    } // endif $do_delete_flag

  94  
  95    // if this is a single-product delete, redirect to categories page

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

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


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