function block() { global $db, $messageStack; $return = array(); if (!strstr($_GET['main_page'], 'product_') && !strstr($_GET['main_page'], 'document_')) { return $return; } if (strstr($_GET['main_page'], 'reviews_info') || strstr($_GET['main_page'], 'reviews_write')) { return $return; } define('TEXT_OF_5_STARS', ''); $display_form = true; $display_list = true; if (!$_SESSION['customer_id'] || !empty($_SESSION['visitors_id'])) { $display_form = false; if (MODULE_EASY_REVIEWS_LIST_DISPLAY_FORCE_LOGIN == 'true') { $display_list = false; } } if (!zen_products_id_valid($_GET['products_id'])) { $display_form = false; $display_list = false; } if ($display_form) { $query = "\r\n SELECT customers_firstname, customers_lastname, customers_email_address\r\n FROM " . TABLE_CUSTOMERS . "\r\n WHERE customers_id = :customersID\r\n ;"; $query = $db->bindVars($query, ':customersID', $_SESSION['customer_id'], 'integer'); $customer = $db->Execute($query); } $reviews = array(); if ($display_list) { $query = "\r\n SELECT r.reviews_id, reviews_text, r.reviews_rating, r.date_added, r.customers_name\r\n FROM " . TABLE_REVIEWS . " r\r\n , " . TABLE_REVIEWS_DESCRIPTION . " rd\r\n WHERE r.products_id = :productsID\r\n AND r.reviews_id = rd.reviews_id\r\n AND rd.languages_id = :languagesID\r\n AND r.status = 1\r\n ORDER BY r.reviews_id desc\r\n LIMIT :limit\r\n ;"; $query = $db->bindVars($query, ':productsID', $_GET['products_id'], 'integer'); $query = $db->bindVars($query, ':languagesID', $_SESSION['languages_id'], 'integer'); $query = $db->bindVars($query, ':limit', MODULE_EASY_REVIEWS_MAX_DISPLAY_NEW_REVIEWS, 'integer'); $result = $db->Execute($query); while (!$result->EOF) { $reviews[] = array('id' => $result->fields['reviews_id'], 'customersName' => $result->fields['customers_name'], 'dateAdded' => $result->fields['date_added'], 'reviewsText' => $result->fields['reviews_text'], 'reviewsRating' => $result->fields['reviews_rating']); $result->MoveNext(); } } if ($display_form || $display_list) { $return['title'] = MODULE_EASY_REVIEWS_BLOCK_TITLE; $return['display_form'] = $display_form; $return['display_list'] = $display_list; $return['messageStack'] = $messageStack; $return['customer'] = $customer; $return['reviews'] = $reviews; } return $return; }
if (defined('QUICKUPDATES_NEW_COLUMN_1')) { echo zen_draw_hidden_field('export_products[' . $key . '][' . QUICKUPDATES_NEW_COLUMN_1 . ']', $value[QUICKUPDATES_NEW_COLUMN_1]) . "\n"; } } echo zen_image_submit('button_update.gif', 'Export products'); echo '</form>'; } ?> <!-- eof export viewed products paulm //--> </td> <td> <!-- // bof quick copy form --> <?php $quick_copy_from_array = array(); //export_products[$products->fields['products_id']]['products_model'] if (zen_products_id_valid(QUICKUPDATES_COPY_PRODUCT_ID_DEFAULT)) { $quick_copy_from_array[] = array('id' => QUICKUPDATES_COPY_PRODUCT_ID_DEFAULT, 'text' => 'id:' . QUICKUPDATES_COPY_PRODUCT_ID_DEFAULT . ' (' . TEXT_QUICK_COPY_PRODUCT_ID_DEFAULT . ')'); } foreach ((array) $export_products as $key => $value) { if (!empty($value['products_model'])) { $text = ' (' . $value['products_model'] . ')'; } $quick_copy_from_array[] = array('id' => $key, 'text' => 'id:' . $key . $text); } echo zen_draw_form('quickcopyfrom', FILENAME_QUICK_UPDATES); echo zen_draw_pull_down_menu('quick_copy_from_id', $quick_copy_from_array, $_SESSION['quick_updates']['quick_copy_from_id']); $array = array(); //$array[] = array('id' => $_SESSION['quick_updates']['quick_copy_number'],'text' => $_SESSION['quick_updates']['quick_copy_number'] . 'x'); $array[] = array('id' => 0, 'text' => '0x'); $array[] = array('id' => 1, 'text' => '1x'); $array[] = array('id' => 10, 'text' => '10x');
// | | // | Portions Copyright (c) 2003 osCommerce | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the GPL license, | // | that is bundled with this package in the file LICENSE, and is | // | available through the world-wide-web at the following url: | // | http://www.zen-cart.com/license/2_0.txt. | // | If you did not receive a copy of the zen-cart license and are unable | // | to obtain it through the world-wide-web, please send a note to | // | license@zen-cart.com so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // $Id: product_notifications.php 290 2004-09-15 19:48:26Z wilt $ // // test if box should show $show_product_notifications = false; if (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) { if ($_SESSION['customer_id']) { $check_query = "select count(*) as count\r\n from " . TABLE_CUSTOMERS_INFO . "\r\n where customers_info_id = '" . (int) $_SESSION['customer_id'] . "'\r\n and global_product_notifications = '1'"; $check = $db->Execute($check_query); if ($check->fields['count'] <= 0) { $show_product_notifications = true; } } else { $show_product_notifications = true; } } if ($show_product_notifications == true) { if (isset($_GET['products_id'])) { if ($_SESSION['customer_id']) { $check_query = "select count(*) as count\r\n from " . TABLE_PRODUCTS_NOTIFICATIONS . "\r\n where products_id = '" . (int) $_GET['products_id'] . "'\r\n and customers_id = '" . (int) $_SESSION['customer_id'] . "'"; $check = $db->Execute($check_query);
function quick_copy_product($products_id, $categories_id = '') { global $db; if (!(isset($products_id) && isset($categories_id))) { return FALSE; } // ?? $products_id = (int) $products_id; // copy from this product (to a new product) //$categories_id = zen_db_prepare_input($categories_id); // copy to this catagory //if(!($products_id > 0)) return false; if (!zen_products_id_valid($products_id)) { exit('Fatal error: attempt to copy invalid product by quick_copy (products_id = ' . $products_id . ')'); } // Copy attributes to duplicate product $products_id_from = $products_id; // bof duplicate $old_products_id = (int) $products_id; $product = $db->Execute("select products_type, products_quantity, products_model, products_image,\r\n products_price, products_virtual, products_date_available, products_weight,\r\n products_tax_class_id, manufacturers_id,\r\n products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute,\r\n product_is_free, product_is_call, products_quantity_mixed,\r\n product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order,\r\n products_price_sorter, master_categories_id\r\n from " . TABLE_PRODUCTS . "\r\n where products_id = '" . (int) $products_id . "'"); // bof replace product data by nimport product data (+ add purchase price) // eof replace product data by nimport product data $tmp_value = zen_db_input($product->fields['products_quantity']); $products_quantity = !zen_not_null($tmp_value) || $tmp_value == '' || $tmp_value == 0 ? 0 : $tmp_value; $tmp_value = zen_db_input($product->fields['products_price']); $products_price = !zen_not_null($tmp_value) || $tmp_value == '' || $tmp_value == 0 ? 0 : $tmp_value; $tmp_value = zen_db_input($product->fields['products_weight']); $products_weight = !zen_not_null($tmp_value) || $tmp_value == '' || $tmp_value == 0 ? 0 : $tmp_value; // check if categorie has products!? if (!$categories_id >= 0) { $categories_id = $product->fields['master_categories_id']; } $db->Execute("insert into " . TABLE_PRODUCTS . "\r\n (products_type, products_quantity, products_model, products_image,\r\n products_price, products_virtual, products_date_added, products_date_available,\r\n products_weight, products_status, products_tax_class_id,\r\n manufacturers_id,\r\n products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute,\r\n product_is_free, product_is_call, products_quantity_mixed,\r\n product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order,\r\n products_price_sorter, master_categories_id\r\n )\r\n values ('" . zen_db_input($product->fields['products_type']) . "',\r\n '" . $products_quantity . "',\r\n '" . zen_db_input($product->fields['products_model']) . "',\r\n '" . zen_db_input($product->fields['products_image']) . "',\r\n '" . $products_price . "',\r\n '" . zen_db_input($product->fields['products_virtual']) . "',\r\n now(),\r\n '" . zen_db_input($product->fields['products_date_available']) . "',\r\n '" . $products_weight . "', '0',\r\n '" . (int) $product->fields['products_tax_class_id'] . "',\r\n '" . (int) $product->fields['manufacturers_id'] . "',\r\n '" . zen_db_input($product->fields['products_quantity_order_min']) . "',\r\n '" . zen_db_input($product->fields['products_quantity_order_units']) . "',\r\n '" . zen_db_input($product->fields['products_priced_by_attribute']) . "',\r\n '" . (int) $product->fields['product_is_free'] . "',\r\n '" . (int) $product->fields['product_is_call'] . "',\r\n '" . (int) $product->fields['products_quantity_mixed'] . "',\r\n '" . zen_db_input($product->fields['product_is_always_free_shipping']) . "',\r\n '" . zen_db_input($product->fields['products_qty_box_status']) . "',\r\n '" . zen_db_input($product->fields['products_quantity_order_max']) . "',\r\n '" . zen_db_input($product->fields['products_sort_order']) . "',\r\n '" . zen_db_input($product->fields['products_price_sorter']) . "',\r\n '" . (int) $categories_id . "')"); $dup_products_id = $db->Insert_ID(); $description = $db->Execute("select language_id, products_name, products_description, products_url\r\n from " . TABLE_PRODUCTS_DESCRIPTION . "\r\n where products_id = '" . (int) $products_id . "'"); while (!$description->EOF) { $db->Execute("insert into " . TABLE_PRODUCTS_DESCRIPTION . "\r\n (products_id, language_id, products_name, products_description, products_url, products_viewed)\r\n values ('" . (int) $dup_products_id . "',\r\n '" . (int) $description->fields['language_id'] . "',\r\n '" . zen_db_input($description->fields['products_name']) . "',\r\n '" . zen_db_input($description->fields['products_description']) . "',\r\n '" . zen_db_input($description->fields['products_url']) . "', '0')"); $description->MoveNext(); } $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "\r\n (products_id, categories_id)\r\n values ('" . (int) $dup_products_id . "', '" . (int) $categories_id . "')"); $products_id = $dup_products_id; $description->MoveNext(); // FIX HERE ///////////////////////////////////////////////////////////////////////////////////////////// // Copy attributes to duplicate product $products_id_to = $dup_products_id; $products_id = $dup_products_id; /* if ( $_POST['copy_attributes']=='copy_attributes_yes' and $_POST['copy_as'] == 'duplicate' ) { // $products_id_to= $copy_to_products_id; // $copy_attributes_delete_first='1'; // $copy_attributes_duplicates_skipped='1'; // $copy_attributes_duplicates_overwrite='0'; if (DOWNLOAD_ENABLED == 'true') { $copy_attributes_include_downloads='1'; $copy_attributes_include_filename='1'; } else { $copy_attributes_include_downloads='0'; $copy_attributes_include_filename='0'; } zen_copy_products_attributes($products_id_from, $products_id_to); } */ // EOF: Attributes Copy on non-linked ///////////////////////////////////////////////////////////////////// // copy product discounts to duplicate zen_copy_discounts_to_product($old_products_id, (int) $dup_products_id); // eof duplicate // reset products_price_sorter for searches etc. zen_update_products_price_sorter($products_id); //zen_redirect(zen_href_link(FILENAME_QUICK_COPY, 'cPath=' . $categories_id . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''))); // succes $copy['products_id'] = (int) $dup_products_id; $copy['master_categories_id'] = (int) $categories_id; return $copy; }
unset($GLOBALS[$key]); } } else { unset($GLOBALS[$key]); } } } /** * sanitize $_SERVER vars */ $_SERVER['REMOTE_ADDR'] = preg_replace('~[^a-fA-F0-9.:%/]~', '', $_SERVER['REMOTE_ADDR']); /** * validate products_id for search engines and bookmarks, etc. */ if (isset($_GET['products_id']) && isset($_SESSION['check_valid']) && $_SESSION['check_valid'] != 'false') { $check_valid = zen_products_id_valid($_GET['products_id']); if (!$check_valid) { $_GET['main_page'] = zen_get_info_page($_GET['products_id']); /** * do not recheck redirect */ $_SESSION['check_valid'] = 'false'; zen_redirect(zen_href_link($_GET['main_page'], 'products_id=' . $_GET['products_id'])); } } else { $_SESSION['check_valid'] = 'true'; } /** * We do some checks here to ensure $_GET['main_page'] has a sane value */ if (!isset($_GET['main_page']) || !zen_not_null($_GET['main_page'])) {
function zen_copy_products_attributes($products_id_from, $products_id_to) { global $db; global $messageStack; global $copy_attributes_delete_first, $copy_attributes_duplicates_skipped, $copy_attributes_duplicates_overwrite, $copy_attributes_include_downloads, $copy_attributes_include_filename; // Check for errors in copy request if (!zen_has_product_attributes($products_id_from, 'false') or !zen_products_id_valid($products_id_to) or $products_id_to == $products_id_from) { if ($products_id_to == $products_id_from) { // same products_id $messageStack->add_session('<b>WARNING: Cannot copy from Product ID #' . $products_id_from . ' to Product ID # ' . $products_id_to . ' ... No copy was made' . '</b>', 'caution'); } else { if (!zen_has_product_attributes($products_id_from, 'false')) { // no attributes found to copy $messageStack->add_session('<b>WARNING: No Attributes to copy from Product ID #' . $products_id_from . ' for: ' . zen_get_products_name($products_id_from) . ' ... No copy was made' . '</b>', 'caution'); } else { // invalid products_id $messageStack->add_session('<b>WARNING: There is no Product ID #' . $products_id_to . ' ... No copy was made' . '</b>', 'caution'); } } } else { // FIX HERE - remove once working // check if product already has attributes $check_attributes = zen_has_product_attributes($products_id_to, 'false'); if ($copy_attributes_delete_first == '1' and $check_attributes == true) { // die('DELETE FIRST - Copying from ' . $products_id_from . ' to ' . $products_id_to . ' Do I delete first? ' . $copy_attributes_delete_first); // delete all attributes first from products_id_to zen_products_attributes_download_delete($products_id_to); $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int) $products_id_to . "'"); } // get attributes to copy from $products_copy_from = $db->Execute("select * from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int) $products_id_from . "'" . " order by products_attributes_id"); while (!$products_copy_from->EOF) { // This must match the structure of your products_attributes table $update_attribute = false; $add_attribute = true; $check_duplicate = $db->Execute("select * from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int) $products_id_to . "'" . " and options_id= '" . (int) $products_copy_from->fields['options_id'] . "' and options_values_id='" . (int) $products_copy_from->fields['options_values_id'] . "'"); if ($check_attributes == true) { if ($check_duplicate->RecordCount() == 0) { $update_attribute = false; $add_attribute = true; } else { if ($check_duplicate->RecordCount() == 0) { $update_attribute = false; $add_attribute = true; } else { $update_attribute = true; $add_attribute = false; } } } else { $update_attribute = false; $add_attribute = true; } // die('UPDATE/IGNORE - Checking Copying from ' . $products_id_from . ' to ' . $products_id_to . ' Do I delete first? ' . ($copy_attributes_delete_first == '1' ? TEXT_YES : TEXT_NO) . ' Do I add? ' . ($add_attribute == true ? TEXT_YES : TEXT_NO) . ' Do I Update? ' . ($update_attribute == true ? TEXT_YES : TEXT_NO) . ' Do I skip it? ' . ($copy_attributes_duplicates_skipped=='1' ? TEXT_YES : TEXT_NO) . ' Found attributes in From: ' . $check_duplicate->RecordCount()); if ($copy_attributes_duplicates_skipped == '1' and $check_duplicate->RecordCount() != 0) { // skip it $messageStack->add_session(TEXT_ATTRIBUTE_COPY_SKIPPING . $products_copy_from->fields['products_attributes_id'] . ' for Products ID#' . $products_id_to, 'caution'); } else { if ($add_attribute == true) { // New attribute - insert it $db->Execute("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_attributes_id, products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order, product_attribute_is_free, products_attributes_weight, products_attributes_weight_prefix, attributes_display_only, attributes_default, attributes_discounted, attributes_image, attributes_price_base_included, attributes_price_onetime, attributes_price_factor, attributes_price_factor_offset, attributes_price_factor_onetime, attributes_price_factor_onetime_offset, attributes_qty_prices, attributes_qty_prices_onetime, attributes_price_words, attributes_price_words_free, attributes_price_letters, attributes_price_letters_free, attributes_required) values (0, '" . (int) $products_id_to . "',\n '" . $products_copy_from->fields['options_id'] . "',\n '" . $products_copy_from->fields['options_values_id'] . "',\n '" . $products_copy_from->fields['options_values_price'] . "',\n '" . $products_copy_from->fields['price_prefix'] . "',\n '" . $products_copy_from->fields['products_options_sort_order'] . "',\n '" . $products_copy_from->fields['product_attribute_is_free'] . "',\n '" . $products_copy_from->fields['products_attributes_weight'] . "',\n '" . $products_copy_from->fields['products_attributes_weight_prefix'] . "',\n '" . $products_copy_from->fields['attributes_display_only'] . "',\n '" . $products_copy_from->fields['attributes_default'] . "',\n '" . $products_copy_from->fields['attributes_discounted'] . "',\n '" . $products_copy_from->fields['attributes_image'] . "',\n '" . $products_copy_from->fields['attributes_price_base_included'] . "',\n '" . $products_copy_from->fields['attributes_price_onetime'] . "',\n '" . $products_copy_from->fields['attributes_price_factor'] . "',\n '" . $products_copy_from->fields['attributes_price_factor_offset'] . "',\n '" . $products_copy_from->fields['attributes_price_factor_onetime'] . "',\n '" . $products_copy_from->fields['attributes_price_factor_onetime_offset'] . "',\n '" . $products_copy_from->fields['attributes_qty_prices'] . "',\n '" . $products_copy_from->fields['attributes_qty_prices_onetime'] . "',\n '" . $products_copy_from->fields['attributes_price_words'] . "',\n '" . $products_copy_from->fields['attributes_price_words_free'] . "',\n '" . $products_copy_from->fields['attributes_price_letters'] . "',\n '" . $products_copy_from->fields['attributes_price_letters_free'] . "',\n '" . $products_copy_from->fields['attributes_required'] . "')"); $messageStack->add_session(TEXT_ATTRIBUTE_COPY_INSERTING . $products_copy_from->fields['products_attributes_id'] . ' for Products ID#' . $products_id_to, 'caution'); } if ($update_attribute == true) { // Update attribute - Just attribute settings not ids $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set\n options_values_price='" . $products_copy_from->fields['options_values_price'] . "',\n price_prefix='" . $products_copy_from->fields['price_prefix'] . "',\n products_options_sort_order='" . $products_copy_from->fields['products_options_sort_order'] . "',\n product_attribute_is_free='" . $products_copy_from->fields['product_attribute_is_free'] . "',\n products_attributes_weight='" . $products_copy_from->fields['products_attributes_weight'] . "',\n products_attributes_weight_prefix='" . $products_copy_from->fields['products_attributes_weight_prefix'] . "',\n attributes_display_only='" . $products_copy_from->fields['attributes_display_only'] . "',\n attributes_default='" . $products_copy_from->fields['attributes_default'] . "',\n attributes_discounted='" . $products_copy_from->fields['attributes_discounted'] . "',\n attributes_image='" . $products_copy_from->fields['attributes_image'] . "',\n attributes_price_base_included='" . $products_copy_from->fields['attributes_price_base_included'] . "',\n attributes_price_onetime='" . $products_copy_from->fields['attributes_price_onetime'] . "',\n attributes_price_factor='" . $products_copy_from->fields['attributes_price_factor'] . "',\n attributes_price_factor_offset='" . $products_copy_from->fields['attributes_price_factor_offset'] . "',\n attributes_price_factor_onetime='" . $products_copy_from->fields['attributes_price_factor_onetime'] . "',\n attributes_price_factor_onetime_offset='" . $products_copy_from->fields['attributes_price_factor_onetime_offset'] . "',\n attributes_qty_prices='" . $products_copy_from->fields['attributes_qty_prices'] . "',\n attributes_qty_prices_onetime='" . $products_copy_from->fields['attributes_qty_prices_onetime'] . "',\n attributes_price_words='" . $products_copy_from->fields['attributes_price_words'] . "',\n attributes_price_words_free='" . $products_copy_from->fields['attributes_price_words_free'] . "',\n attributes_price_letters='" . $products_copy_from->fields['attributes_price_letters'] . "',\n attributes_price_letters_free='" . $products_copy_from->fields['attributes_price_letters_free'] . "',\n attributes_required='" . $products_copy_from->fields['attributes_required'] . "'" . " where products_id='" . (int) $products_id_to . "'" . " and options_id= '" . $products_copy_from->fields['options_id'] . "' and options_values_id='" . $products_copy_from->fields['options_values_id'] . "'"); // . " where products_id='" . $products_id_to . "'" . " and options_id= '" . $products_copy_from->fields['options_id'] . "' and options_values_id='" . $products_copy_from->fields['options_values_id'] . "' and attributes_image='" . $products_copy_from->fields['attributes_image'] . "' and attributes_price_base_included='" . $products_copy_from->fields['attributes_price_base_included'] . "'"); $messageStack->add_session(TEXT_ATTRIBUTE_COPY_UPDATING . $products_copy_from->fields['products_attributes_id'] . ' for Products ID#' . $products_id_to, 'caution'); } } $products_copy_from->MoveNext(); } // end of products attributes while loop // reset products_price_sorter for searches etc. zen_update_products_price_sorter($products_id_to); } // end of no attributes or other errors }
} else { $action = ''; } switch ($action) { case 'reset': $_SESSION['searchfilter'] = ""; break; case 'add': if (isset($_GET['products_id']) and is_numeric((int) $_GET['products_id'])) { $products_id = (int) $_GET['products_id']; } if (isset($_POST['products_id']) and is_numeric((int) $_POST['products_id'])) { $products_id = (int) $_POST['products_id']; } if (isset($products_id)) { if (zen_products_id_valid($products_id)) { $product_name = zen_get_products_name($products_id); $product_attributes = $stock->get_products_attributes($products_id, $language_id); $hidden_form .= zen_draw_hidden_field('products_id', $products_id) . "\n"; } else { zen_redirect(zen_href_link(FILENAME_ADDON_MODULES_ADMIN, zen_get_all_get_params(array('action')), 'NONSSL')); } } else { $query = 'SELECT DISTINCT attrib.products_id, description.products_name FROM ' . TABLE_PRODUCTS_ATTRIBUTES . ' attrib, ' . TABLE_PRODUCTS_DESCRIPTION . ' description WHERE attrib.products_id = description.products_id and description.language_id=' . (int) $language_id . ' order by description.products_name'; $products = $db->execute($query); while (!$products->EOF) {