Merge branch 'release' of https://github.com/PrestaShop/PrestaShop into release

This commit is contained in:
Rémi Gaillard
2013-03-04 10:39:28 +01:00
2631 changed files with 24099 additions and 20926 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -124,8 +124,8 @@ class AddressCore extends ObjectModel
'postcode' => array('type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12),
'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64),
'other' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300),
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 16),
'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 16),
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16),
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -61,7 +61,6 @@ class AddressFormatCore extends ObjectModel
public static $forbiddenPropertyList = array(
'deleted',
'date_add',
'other',
'alias',
'secure_key',
'note',
@@ -74,6 +73,7 @@ class AddressFormatCore extends ObjectModel
'active',
'is_guest',
'date_upd',
'country',
'years',
'days',
'months',
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+6 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -129,7 +129,10 @@ class Autoload
// Write classes index on disc to cache it
$filename = $this->root_dir.Autoload::INDEX_FILE;
if ((file_exists($filename) && !is_writable($filename)) || !is_writable(dirname($filename)))
throw new PrestaShopException($filename.' is not writable, please give write permissions (chmod 666) on this file.');
{
header('HTTP/1.1 503 temporarily overloaded');
die('/cache/class_index.php is not writable, please give write permissions (chmod 666) on this file.');
}
else
{
// Let's write index content in cache file
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+20 -20
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -482,7 +482,8 @@ class CarrierCore extends ObjectModel
$countries[$country['id_country']] = $country;
foreach ($states as &$state)
if (isset($countries[$state['id_country']])) /* Does not keep the state if its country has been disabled and not selected */
$countries[$state['id_country']]['states'][] = $state;
if ($state['active'] == 1)
$countries[$state['id_country']]['states'][] = $state;
return $countries;
}
@@ -564,8 +565,8 @@ class CarrierCore extends ObjectModel
}
$row['name'] = (strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME'));
$row['price'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier']));
$row['price_tax_exc'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier'], false));
$row['price'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier'], true, null, null, $id_zone));
$row['price_tax_exc'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier'], false, null, null, $id_zone));
$row['img'] = file_exists(_PS_SHIP_IMG_DIR_.(int)$row['id_carrier']).'.jpg' ? _THEME_SHIP_DIR_.(int)$row['id_carrier'].'.jpg' : '';
// If price is false, then the carrier is unavailable (carrier module)
@@ -1161,23 +1162,18 @@ class CarrierCore extends ObjectModel
$query->where('pc.id_product = '.(int)$product->id);
$query->where('pc.id_shop = '.(int)$id_shop);
$carriers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
if (!empty($carriers))
{
$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
$carrier_list = array();
if (!empty($carriers_for_product))
{
//the product is linked with carriers
$carrier_list = array();
foreach ($carriers as $carrier) //check if the linked carriers are available in current zone
foreach ($carriers_for_product as $carrier) //check if the linked carriers are available in current zone
if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone))
$carrier_list[] = $carrier['id_carrier'];
if (!empty($carrier_list))
return $carrier_list;
else
if (empty($carrier_list))
return array();//no linked carrier are available for this zone
}
$carrier_list = array();
// The product is not dirrectly linked with a carrier
// Get all the carriers linked to a warehouse
if ($id_warehouse)
@@ -1189,13 +1185,17 @@ class CarrierCore extends ObjectModel
$available_carrier_list = array();
$customer = new Customer($cart->id_customer);
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart);
foreach ($carriers as $carrier)
$available_carrier_list[] = $carrier['id_carrier'];
if (empty($warehouse_carrier_list))
$carrier_list = $available_carrier_list;
if ($carrier_list)
$carrier_list = array_intersect($available_carrier_list, $carrier_list);
else
$carrier_list = array_intersect($warehouse_carrier_list, $available_carrier_list);
$carrier_list = $available_carrier_list;
if (isset($warehouse_carrier_list))
$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);
if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0)
{
+76 -59
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -51,7 +51,7 @@ class CartCore extends ObjectModel
public $id_lang;
/** @var boolean True if the customer wants a recycled package */
public $recyclable = 1;
public $recyclable = 0;
/** @var boolean True if the customer wants a gift wrapping */
public $gift = 0;
@@ -59,6 +59,9 @@ class CartCore extends ObjectModel
/** @var string Gift message if specified */
public $gift_message;
/** @var boolean Mobile Theme */
public $mobile_theme;
/** @var string Object creation date */
public $date_add;
@@ -109,6 +112,7 @@ class CartCore extends ObjectModel
'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'gift_message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage'),
'mobile_theme' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'delivery_option' => array('type' => self::TYPE_STRING),
'secure_key' => array('type' => self::TYPE_STRING, 'size' => 32),
'allow_seperated_package' =>array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
@@ -119,12 +123,12 @@ class CartCore extends ObjectModel
protected $webserviceParameters = array(
'fields' => array(
'id_address_delivery' => array('xlink_resource' => 'addresses'),
'id_address_invoice' => array('xlink_resource' => 'addresses'),
'id_currency' => array('xlink_resource' => 'currencies'),
'id_customer' => array('xlink_resource' => 'customers'),
'id_guest' => array('xlink_resource' => 'guests'),
'id_lang' => array('xlink_resource' => 'languages'),
'id_address_delivery' => array('xlink_resource' => 'addresses'),
'id_address_invoice' => array('xlink_resource' => 'addresses'),
'id_currency' => array('xlink_resource' => 'currencies'),
'id_customer' => array('xlink_resource' => 'customers'),
'id_guest' => array('xlink_resource' => 'guests'),
'id_lang' => array('xlink_resource' => 'languages'),
),
'associations' => array(
'cart_rows' => array('resource' => 'cart_row', 'virtual_entity' => true, 'fields' => array(
@@ -423,8 +427,8 @@ class CartCore extends ObjectModel
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`, product_shop.`available_for_order`, product_shop.`price`, p.`weight`,
stock.`quantity` quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, product_shop.`active`, p.`date_add`,
p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
CONCAT(cp.`id_product`, cp.`id_product_attribute`, cp.`id_address_delivery`) AS unique_id, cp.id_address_delivery,
product_shop.`wholesale_price`, product_shop.advanced_stock_management');
CONCAT(cp.`id_product`, IFNULL(cp.`id_product_attribute`, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
product_shop.`wholesale_price`, product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference');
// Build FROM
$sql->from('cart_product', 'cp');
@@ -436,13 +440,14 @@ class CartCore extends ObjectModel
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$this->id_lang.Shop::addSqlRestrictionOnLang('pl', 'cp.id_shop')
);
$sql->leftJoin('category_lang', 'cl', '
product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = '.(int)$this->id_lang.Shop::addSqlRestrictionOnLang('cl', 'cp.id_shop')
);
$sql->leftJoin('product_supplier', 'ps', 'ps.id_product=cp.id_product AND ps.id_product_attribute=cp.id_product_attribute AND ps.id_supplier=p.id_supplier');
// @todo test if everything is ok, then refactorise call of this method
$sql->join(Product::sqlStock('cp', 'cp'));
@@ -472,7 +477,6 @@ class CartCore extends ObjectModel
$sql->select('
product_attribute_shop.`price` AS price_attribute, product_attribute_shop.`ecotax` AS ecotax_attr,
IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
IF (IFNULL(pa.`supplier_reference`, \'\') = \'\', p.`supplier_reference`, pa.`supplier_reference`) AS supplier_reference,
(p.`weight`+ pa.`weight`) weight_attribute,
IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13,
IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
@@ -487,7 +491,7 @@ class CartCore extends ObjectModel
}
else
$sql->select(
'p.`reference` AS reference, p.`supplier_reference` AS supplier_reference, p.`ean13`,
'p.`reference` AS reference, p.`ean13`,
p.`upc` AS upc, product_shop.`minimal_quantity` AS minimal_quantity'
);
$result = Db::getInstance()->executeS($sql);
@@ -1191,6 +1195,7 @@ class CartCore extends ObjectModel
// refresh cache of self::_products
$this->_products = $this->getProducts(true);
CartRule::autoRemoveFromCart();
CartRule::autoAddToCart();
return $return;
}
@@ -1331,6 +1336,9 @@ class CartCore extends ObjectModel
else
$shipping_fees = 0;
if ($type == Cart::ONLY_SHIPPING)
return $shipping_fees;
if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING)
$type = Cart::ONLY_PRODUCTS;
@@ -1455,12 +1463,14 @@ class CartCore extends ObjectModel
$wrapping_fees = 0;
if ($this->gift)
$wrapping_fees = Tools::convertPrice(Tools::ps_round($this->getGiftWrappingPrice($with_taxes), 2), Currency::getCurrencyInstance((int)$this->id_currency));
if ($type == Cart::ONLY_WRAPPING)
return $wrapping_fees;
$order_total_discount = 0;
if (!in_array($type, array(Cart::ONLY_SHIPPING, Cart::ONLY_PRODUCTS)) && CartRule::isFeatureActive())
{
// First, retrieve the cart rules associated to this "getOrderTotal"
if ($with_shipping)
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS)
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_ALL);
else
{
@@ -1486,7 +1496,7 @@ class CartCore extends ObjectModel
foreach ($cart_rules as $cart_rule)
{
// If the cart rule offers free shipping, add the shipping cost
if ($with_shipping && $cart_rule['obj']->free_shipping)
if (($with_shipping || $type == Cart::ONLY_DISCOUNTS) && $cart_rule['obj']->free_shipping)
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_SHIPPING, ($param_product ? $package : null), $use_cache), 2);
// If the cart rule is a free gift, then add the free gift value only if the gift is in this package
@@ -1507,19 +1517,11 @@ class CartCore extends ObjectModel
// If the cart rule offers a reduction, the amount is prorated (with the products in the package)
if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0)
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), 2);
}
$order_total_discount = min(Tools::ps_round($order_total_discount, 2), $wrapping_fees + $order_total_products + $shipping_fees);
$order_total -= $order_total_discount;
}
if ($type == Cart::ONLY_SHIPPING)
return $shipping_fees;
if ($type == Cart::ONLY_WRAPPING)
return $wrapping_fees;
if ($type == Cart::BOTH)
$order_total += $shipping_fees + $wrapping_fees;
@@ -1687,7 +1689,7 @@ class CartCore extends ObjectModel
{
$product['carrier_list'] = array_merge($product['carrier_list'], Carrier::getAvailableCarrierList(new Product($product['id_product']), $id_war, $product['id_address_delivery'], null, $this));
if (in_array((int)$id_war, $product['warehouse_list']) && $id_warehouse == 0)
$id_warehouse = $id_war;
$id_warehouse = (int)$id_war;
}
if (!isset($grouped_by_warehouse[$product['id_address_delivery']]['in_stock'][$id_warehouse]))
@@ -2324,11 +2326,12 @@ class CartCore extends ObjectModel
* Get the delivery option seleted, or if no delivery option was selected, the cheapest option for each address
* @return array delivery option
*/
public function getDeliveryOption($default_country = null, $dontAutoSeletectOptions = false, $use_cache = true)
public function getDeliveryOption($default_country = null, $dontAutoSelectOptions = false, $use_cache = true)
{
static $cache = array(0 => false, 1 => false);
if ($cache[(int)$dontAutoSeletectOptions] !== false && $use_cache)
return $cache[(int)$dontAutoSeletectOptions];
static $cache = array();
$cache_id = (int)(is_object($default_country) ? $default_country->id : 0).'-'.(int)$dontAutoSelectOptions;
if (isset($cache[$cache_id]) && $use_cache)
return $cache[$cache_id];
$delivery_option_list = $this->getDeliveryOptionList($default_country);
@@ -2346,12 +2349,12 @@ class CartCore extends ObjectModel
if ($validated)
{
$cache[(int)$dontAutoSeletectOptions] = $delivery_option;
$cache[$cache_id] = $delivery_option;
return $delivery_option;
}
}
if ($dontAutoSeletectOptions)
if ($dontAutoSelectOptions)
return false;
// No delivery option selected or delivery option selected is not valid, get the better for all options
@@ -2380,7 +2383,7 @@ class CartCore extends ObjectModel
$delivery_option[$id_address] = key($options);
}
$cache[(int)$dontAutoSeletectOptions] = $delivery_option;
$cache[$cache_id] = $delivery_option;
return $delivery_option;
}
@@ -2395,11 +2398,13 @@ class CartCore extends ObjectModel
*/
public function getTotalShippingCost($delivery_option = null, $use_tax = true, Country $default_country = null)
{
if(isset(Context::getContext()->cookie->id_country))
$default_country = new Country(Context::getContext()->cookie->id_country);
if (is_null($delivery_option))
$delivery_option = $this->getDeliveryOption($default_country, false, false);
$total_shipping = 0;
$delivery_option_list = $this->getDeliveryOptionList();
$delivery_option_list = $this->getDeliveryOptionList($default_country);
foreach ($delivery_option as $id_address => $key)
{
if (!isset($delivery_option_list[$id_address]) || !isset($delivery_option_list[$id_address][$key]))
@@ -2467,7 +2472,7 @@ class CartCore extends ObjectModel
*
* @return float Shipping total
*/
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null)
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null)
{
if ($this->isVirtualCart())
return 0;
@@ -2513,19 +2518,22 @@ class CartCore extends ObjectModel
return $shipping_cost;
}
// Get id zone
if (!$this->isMultiAddressDelivery()
&& isset($this->id_address_delivery) // Be carefull, id_address_delivery is not usefull one 1.5
&& $this->id_address_delivery
&& Customer::customerHasAddress($this->id_customer, $this->id_address_delivery
))
$id_zone = Address::getZoneById((int)$this->id_address_delivery);
else
if(!isset($id_zone))
{
if (!Validate::isLoadedObject($default_country))
$default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
$id_zone = (int)$default_country->id_zone;
// Get id zone
if (!$this->isMultiAddressDelivery()
&& isset($this->id_address_delivery) // Be carefull, id_address_delivery is not usefull one 1.5
&& $this->id_address_delivery
&& Customer::customerHasAddress($this->id_customer, $this->id_address_delivery
))
$id_zone = Address::getZoneById((int)$this->id_address_delivery);
else
{
if (!Validate::isLoadedObject($default_country))
$default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
$id_zone = (int)$default_country->id_zone;
}
}
if ($id_carrier && !$this->isCarrierInRange((int)$id_carrier, (int)$id_zone))
@@ -2604,8 +2612,12 @@ class CartCore extends ObjectModel
$carrier = self::$_carriers[$id_carrier];
// No valid Carrier or $id_carrier <= 0 ?
if (!Validate::isLoadedObject($carrier))
die(Tools::displayError('Fatal error: "no default carrier"'));
{
Cache::store($cache_id, 0);
return 0;
}
if (!$carrier->active)
{
@@ -2656,13 +2668,16 @@ class CartCore extends ObjectModel
// Get shipping cost using correct method
if ($carrier->range_behavior)
{
// Get id zone
if (isset($this->id_address_delivery)
&& $this->id_address_delivery
&& Customer::customerHasAddress($this->id_customer, $this->id_address_delivery))
$id_zone = Address::getZoneById((int)$this->id_address_delivery);
else
$id_zone = (int)$default_country->id_zone;
if(!isset($id_zone))
{
// Get id zone
if (isset($this->id_address_delivery)
&& $this->id_address_delivery
&& Customer::customerHasAddress($this->id_customer, $this->id_address_delivery))
$id_zone = Address::getZoneById((int)$this->id_address_delivery);
else
$id_zone = (int)$default_country->id_zone;
}
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int)$carrier->id, $this->getTotalWeight(), (int)$id_zone);
@@ -2827,8 +2842,8 @@ class CartCore extends ObjectModel
$invoice = new Address((int)$this->id_address_invoice);
// New layout system with personalization fields
$formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
$formatted_addresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice);
$formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
$total_tax = $this->getOrderTotal() - $this->getOrderTotal(false);
@@ -2851,10 +2866,12 @@ class CartCore extends ObjectModel
foreach ($cart_rules as &$cart_rule)
{
// If the cart rule is automatic (wihtout any code) and include free shipping, it should not be displayed as a cart rule but only set the shipping cost to 0
if ($cart_rule['free_shipping'] && empty($cart_rule['code']))
if ($cart_rule['free_shipping'] && (empty($cart_rule['code']) || preg_match('/^'.CartRule::BO_ORDER_CODE_PREFIX.'[0-9]+/', $cart_rule['code'])))
{
$cart_rule['value_real'] -= $total_shipping;
$cart_rule['value_tax_exc'] = $total_shipping_tax_exc;
$cart_rule['value_tax_exc'] -= $total_shipping_tax_exc;
$total_discounts -= $total_shipping;
$total_discounts_tax_exc -= $total_shipping_tax_exc;
// Update total shipping
$total_shipping = 0;
@@ -2952,7 +2969,7 @@ class CartCore extends ObjectModel
{
$sql = 'SELECT c.`id_cart`
FROM '._DB_PREFIX_.'cart c
WHERE c.`id_cart` NOT IN (SELECT o.`id_cart` FROM '._DB_PREFIX_.'orders o)
WHERE c.`id_cart` NOT IN (SELECT o.`id_cart` FROM '._DB_PREFIX_.'orders o WHERE o.`id_customer` = '.(int)$id_customer.')
AND c.`id_customer` = '.(int)$id_customer.'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'c').'
ORDER BY c.`date_upd` DESC';
@@ -2960,7 +2977,7 @@ class CartCore extends ObjectModel
if (!$id_cart = Db::getInstance()->getValue($sql))
return false;
return $id_cart;
return (int)$id_cart;
}
/**
+47 -25
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -31,6 +31,9 @@ class CartRuleCore extends ObjectModel
const FILTER_ACTION_SHIPPING = 2;
const FILTER_ACTION_REDUCTION = 3;
const FILTER_ACTION_GIFT = 4;
const FILTER_ACTION_ALL_NOCAP = 5;
const BO_ORDER_CODE_PREFIX = 'BO_ORDER_';
/* This variable controls that a free gift is offered only once, even when multi-shippping is activated and the same product is delivered in both addresses */
protected static $only_one_gift = array();
@@ -117,14 +120,20 @@ class CartRuleCore extends ObjectModel
/**
* @see ObjectModel::add()
*/
public function add($autodate = true, $nullValues = false)
public function add($autodate = true, $null_values = false)
{
if (!parent::add($autodate, $nullValues))
if (!parent::add($autodate, $null_values))
return false;
Configuration::updateGlobalValue('PS_CART_RULE_FEATURE_ACTIVE', '1');
return true;
}
public function update($null_values = false)
{
Cache::clean('getContextualValue_'.$this->id.'_*');
return parent::update($null_values);
}
/**
* @see ObjectModel::delete()
@@ -214,28 +223,26 @@ class CartRuleCore extends ObjectModel
FROM `'._DB_PREFIX_.'cart_rule` cr
LEFT JOIN `'._DB_PREFIX_.'cart_rule_lang` crl ON (cr.`id_cart_rule` = crl.`id_cart_rule` AND crl.`id_lang` = '.(int)$id_lang.')
WHERE (
cr.`id_customer` = '.(int)$id_customer.'
cr.`id_customer` = '.(int)$id_customer.' OR cr.group_restriction = 1
'.($includeGeneric ? 'OR cr.`id_customer` = 0' : '').'
)
AND highlight = 1
AND cr.date_from < "'.date('Y-m-d H:i:s').'"
AND cr.date_to > "'.date('Y-m-d H:i:s').'"
'.($active ? 'AND cr.`active` = 1' : '').'
'.($inStock ? 'AND cr.`quantity` > 0' : ''));
// Remove cart rule that does not match the customer groups
if ($includeGeneric)
{
$customerGroups = Customer::getGroupsStatic($id_customer);
foreach ($result as $key => $cart_rule)
if ($cart_rule['group_restriction'])
{
$cartRuleGroups = Db::getInstance()->getValue('SELECT id_group FROM '._DB_PREFIX_.'cart_rule_group WHERE id_cart_rule = '.(int)$cart_rule['id_cart_rule']);
foreach ($cartRuleGroups as $cartRuleGroup)
if (in_array($cartRuleGroups['id_group'], $customerGroups))
continue 2;
$customerGroups = Customer::getGroupsStatic($id_customer);
foreach ($result as $key => $cart_rule)
if ($cart_rule['group_restriction'])
{
$cartRuleGroups = Db::getInstance()->executeS('SELECT id_group FROM '._DB_PREFIX_.'cart_rule_group WHERE id_cart_rule = '.(int)$cart_rule['id_cart_rule']);
foreach ($cartRuleGroups as $cartRuleGroup)
if (in_array($cartRuleGroup['id_group'], $customerGroups))
continue 2;
unset($result[$key]);
}
}
unset($result[$key]);
}
foreach ($result as &$cart_rule)
if ($cart_rule['quantity_per_user'])
@@ -417,8 +424,10 @@ class CartRuleCore extends ObjectModel
}
// Check if the customer delivery address is usable with the cart rule
if ($this->country_restriction && $context->cart->id_address_delivery)
if ($this->country_restriction)
{
if (!$context->cart->id_address_delivery)
return (!$display_error) ? false : Tools::displayError('You must choose a delivery address before applying this voucher to your order');
$id_cart_rule = (int)Db::getInstance()->getValue('
SELECT crc.id_cart_rule
FROM '._DB_PREFIX_.'cart_rule_country crc
@@ -429,8 +438,10 @@ class CartRuleCore extends ObjectModel
}
// Check if the carrier chosen by the customer is usable with the cart rule
if ($this->carrier_restriction && $context->cart->id_carrier)
if ($this->carrier_restriction)
{
if (!$context->cart->id_carrier)
return (!$display_error) ? false : Tools::displayError('You must choose a carrier before applying this voucher to your order');
$id_cart_rule = (int)Db::getInstance()->getValue('
SELECT crc.id_cart_rule
FROM '._DB_PREFIX_.'cart_rule_carrier crc
@@ -744,7 +755,7 @@ class CartRuleCore extends ObjectModel
return Cache::retrieve($cache_id);
// Free shipping on selected carriers
if ($this->free_shipping && ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_SHIPPING))
if ($this->free_shipping && in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_SHIPPING)))
{
if (!$this->carrier_restriction)
$reduction_value += $context->cart->getOrderTotal($use_tax, Cart::ONLY_SHIPPING, is_null($package) ? null : $package['products'], is_null($package) ? null : $package['id_carrier']);
@@ -762,7 +773,7 @@ class CartRuleCore extends ObjectModel
}
}
if ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_REDUCTION)
if (in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_REDUCTION)))
{
// Discount (%) on the whole order
if ($this->reduction_percent && $this->reduction_product == 0)
@@ -853,7 +864,15 @@ class CartRuleCore extends ObjectModel
// If it has the same tax application that you need, then it's the right value, whatever the product!
if ($this->reduction_tax == $use_tax)
{
// The reduction cannot exceed the products total, except when we do not want it to be limited (for the partial use calculation)
if ($filter != CartRule::FILTER_ACTION_ALL_NOCAP)
{
$cart_amount = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS);
$reduction_amount = min($reduction_amount, $cart_amount);
}
$reduction_value += $prorata * $reduction_amount;
}
else
{
if ($this->reduction_product > 0)
@@ -879,9 +898,12 @@ class CartRuleCore extends ObjectModel
// Discount (¤) on the whole order
elseif ($this->reduction_product == 0)
{
// TODO : this should not use the prorata
$cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
$cart_amount_te = $context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
// The reduction cannot exceed the products total, except when we do not want it to be limited (for the partial use calculation)
if ($filter != CartRule::FILTER_ACTION_ALL_NOCAP)
$reduction_amount = min($reduction_amount, $this->reduction_tax ? $cart_amount_ti : $cart_amount_te);
$cart_vat_amount = $cart_amount_ti - $cart_amount_te;
@@ -906,7 +928,7 @@ class CartRuleCore extends ObjectModel
}
// Free gift
if ((int)$this->gift_product && ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_GIFT))
if ((int)$this->gift_product && in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_GIFT)))
{
$id_address = (is_null($package) ? 0 : $package['id_address']);
foreach ($package_products as $product)
+4 -7
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -240,9 +240,6 @@ class CategoryCore extends ObjectModel
{
$id_lang = is_null($id_lang) ? Context::getContext()->language->id : (int)$id_lang;
if (!(int)$id_lang)
$id_lang = _USER_ID_LANG_;
$children = array();
$subcats = $this->getSubCategories($id_lang, true);
if (($max_depth == 0 || $current_depth < $max_depth) && $subcats && count($subcats))
@@ -1051,7 +1048,7 @@ class CategoryCore extends ObjectModel
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT ctg.`id_group`
FROM '._DB_PREFIX_.'category_group ctg
WHERE ctg.`id_category` = '.(int)$this->id.' AND ctg.`id_group` = 1
WHERE ctg.`id_category` = '.(int)$this->id.' AND ctg.`id_group` = '.(int)Group::getCurrent()->id.'
');
} else {
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
@@ -1351,7 +1348,7 @@ class CategoryCore extends ObjectModel
SELECT c.`id_category`
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` IN ('.implode(', ', Shop::getContextListShopID()).') )
WHERE cs.`id_shop` = '.(int)$id_shop.'
AND c.`id_parent` = '.(int)$this->id_parent);
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -287,7 +287,7 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
*/
public function sqlGroupBy($sql)
{
$this->query->orderBy($this->parseFields($sql));
$this->query->groupBy($this->parseFields($sql));
return $this;
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+5 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -145,6 +145,9 @@ class ConfigurationCore extends ObjectModel
*/
public static function get($key, $id_lang = null, $id_shop_group = null, $id_shop = null)
{
if (defined('_PS_DO_NOT_LOAD_CONFIGURATION_') && _PS_DO_NOT_LOAD_CONFIGURATION_)
return false;
// If conf if not initialized, try manual query
if (!self::$_CONF)
{
+8 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -76,6 +76,7 @@ class ConfigurationTestCore
'register_globals' => false,
'gz' => false,
'mcrypt' => false,
'mbstring' => false,
'magicquotes' => false,
'dom' => false,
'pdo_mysql' => false,
@@ -294,6 +295,11 @@ class ConfigurationTestCore
return ConfigurationTest::test_dir($dir);
}
public static function test_mbstring()
{
return function_exists('mb_strtolower');
}
public static function test_mcrypt()
{
return function_exists('mcrypt_encrypt');
+3 -5
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -70,8 +70,6 @@ class ConnectionCore extends ObjectModel
*/
public function getFields()
{
if (!$this->id_shop)
$this->id_shop = Context::getContext()->shop->id;
if (!$this->id_shop_group)
$this->id_shop_group = Context::getContext()->shop->id_shop_group;
@@ -147,7 +145,7 @@ class ConnectionCore extends ObjectModel
$connection->id_shop_group = Context::getContext()->shop->id_shop_group;
$connection->date_add = $cookie->date_add;
if (Validate::isAbsoluteUrl($referer))
$connection->http_referer = $referer;
$connection->http_referer = substr($referer, 0, 254);
$connection->add();
$cookie->id_connections = $connection->id;
return $connection->id_page;
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -69,7 +69,7 @@ class ConnectionsSourceCore extends ObjectModel
{
$parsed = parse_url($_SERVER['HTTP_REFERER']);
$parsed_host = parse_url(Tools::getProtocol().Tools::getHttpHost(false, false).__PS_BASE_URI__);
if ((preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)))
if ((!isset($parsed['path']) ||!isset($parsed_host['path'])) || (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)))
&& !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__)))
return false;
if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER'])))
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+20 -4
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -111,7 +111,7 @@ class ContextCore
$this->mobile_device = false;
if ($this->checkMobileContext())
{
if(isset(Context::getContext()->cookie->no_mobile) && Context::getContext()->cookie->no_mobile == false AND (int)Configuration::get('PS_ALLOW_MOBILE_DEVICE') != 0)
if (isset(Context::getContext()->cookie->no_mobile) && Context::getContext()->cookie->no_mobile == false AND (int)Configuration::get('PS_ALLOW_MOBILE_DEVICE') != 0)
$this->mobile_device = true;
else
{
@@ -143,9 +143,25 @@ class ContextCore
{
// Check mobile context
if (Tools::isSubmit('no_mobile_theme'))
{
Context::getContext()->cookie->no_mobile = true;
else if (Tools::isSubmit('mobile_theme_ok'))
if (Context::getContext()->cookie->id_guest)
{
$guest = new Guest(Context::getContext()->cookie->id_guest);
$guest->mobile_theme = false;
$guest->update();
}
}
elseif (Tools::isSubmit('mobile_theme_ok'))
{
Context::getContext()->cookie->no_mobile = false;
if (Context::getContext()->cookie->id_guest)
{
$guest = new Guest(Context::getContext()->cookie->id_guest);
$guest->mobile_theme = true;
$guest->update();
}
}
return isset($_SERVER['HTTP_USER_AGENT'])
&& isset(Context::getContext()->cookie)
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -107,7 +107,7 @@ class CookieCore
{
if ($shared_url != $out[4])
continue;
if (preg_match('/^(?:.*\.)?([^.]*(?:.{2,3})?\..{2,3})$/Ui', $shared_url, $res))
if (preg_match('/^(?:.*\.)?([^.]*(?:.{2,4})?\..{2,3})$/Ui', $shared_url, $res))
{
$domain = '.'.$res[1];
break;
+5 -4
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -82,7 +82,7 @@ class CountryCore extends ObjectModel
'zip_code_format' => array('type' => self::TYPE_STRING, 'validate' => 'isZipCodeFormat'),
'display_tax_label' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
// Lang fields
/* Lang fields */
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64),
),
'associations' => array(
@@ -132,7 +132,8 @@ class CountryCore extends ObjectModel
if ($list_states)
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'state` ORDER BY `name` ASC') as $state)
if (isset($countries[$state['id_country']])) /* Does not keep the state if its country has been disabled and not selected */
$countries[$state['id_country']]['states'][] = $state;
if ($state['active'] == 1)
$countries[$state['id_country']]['states'][] = $state;
return $countries;
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+30 -13
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -42,7 +42,10 @@ class CustomerCore extends ObjectModel
public $id_gender = 0;
/** @var integer Default group ID */
public $id_default_group = _PS_DEFAULT_CUSTOMER_GROUP_;
public $id_default_group;
/** @var integer Current language used by the customer */
public $id_lang;
/** @var string Lastname */
public $lastname;
@@ -135,6 +138,7 @@ class CustomerCore extends ObjectModel
protected $webserviceParameters = array(
'fields' => array(
'id_default_group' => array('xlink_resource' => 'groups'),
'id_lang' => array('xlink_resource' => 'languages'),
'newsletter_date_add' => array(),
'ip_registration_newsletter' => array(),
'last_passwd_gen' => array('setter' => null),
@@ -181,6 +185,7 @@ class CustomerCore extends ObjectModel
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'id_default_group' => array('type' => self::TYPE_INT, 'copy_post' => false),
'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
),
@@ -189,11 +194,18 @@ class CustomerCore extends ObjectModel
protected static $_defaultGroupId = array();
protected static $_customerHasAddress = array();
protected static $_customer_groups = array();
public function __construct($id = null)
{
$this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');
parent::__construct($id);
}
public function add($autodate = true, $null_values = true)
{
$this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->id;
$this->id_shop_group = ($this->id_shop_group) ? $this->id_shop_group : Context::getContext()->shop->id_shop_group;
$this->id_lang = ($this->id_lang) ? $this->id_lang : Context::getContext()->language->id;
$this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days);
$this->secure_key = md5(uniqid(rand(), true));
$this->last_passwd_gen = date('Y-m-d H:i:s', strtotime('-'.Configuration::get('PS_PASSWD_TIME_FRONT').'minutes'));
@@ -201,11 +213,11 @@ class CustomerCore extends ObjectModel
if ($this->newsletter && !Validate::isDate($this->newsletter_date_add))
$this->newsletter_date_add = date('Y-m-d H:i:s');
if ($this->id_default_group == _PS_DEFAULT_CUSTOMER_GROUP_)
if ($this->id_default_group == Configuration::get('PS_CUSTOMER_GROUP'))
if ($this->is_guest)
$this->id_default_group = Configuration::get('PS_GUEST_GROUP');
$this->id_default_group = (int)Configuration::get('PS_GUEST_GROUP');
else
$this->id_default_group = Configuration::get('PS_CUSTOMER_GROUP');
$this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');
/* Can't create a guest customer, if this feature is disabled */
if ($this->is_guest && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
@@ -221,7 +233,7 @@ class CustomerCore extends ObjectModel
if ($this->newsletter && !Validate::isDate($this->newsletter_date_add))
$this->newsletter_date_add = date('Y-m-d H:i:s');
if (Context::getContext()->controller->controller_type == 'admin')
if (isset(Context::getContext()->controller) && Context::getContext()->controller->controller_type == 'admin')
$this->updateGroup($this->groupBox);
if ($this->deleted)
@@ -400,16 +412,17 @@ class CustomerCore extends ObjectModel
*/
public static function customerHasAddress($id_customer, $id_address)
{
if (!array_key_exists($id_customer, self::$_customerHasAddress))
$key = (int)$id_customer.'-'.(int)$id_address;
if (!array_key_exists($id_address, self::$_customerHasAddress))
{
self::$_customerHasAddress[$id_customer] = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
self::$_customerHasAddress[$key] = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_address`
FROM `'._DB_PREFIX_.'address`
WHERE `id_customer` = '.(int)$id_customer.'
AND `id_address` = '.(int)$id_address.'
AND `deleted` = 0');
}
return self::$_customerHasAddress[$id_customer];
return self::$_customerHasAddress[$key];
}
public static function resetAddressCache($id_customer)
@@ -426,13 +439,14 @@ class CustomerCore extends ObjectModel
*/
public function getAddresses($id_lang)
{
$sql = 'SELECT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
$sql = 'SELECT DISTINCT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
FROM `'._DB_PREFIX_.'address` a
LEFT JOIN `'._DB_PREFIX_.'country` c ON (a.`id_country` = c.`id_country`)
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = a.`id_state`)
'.(Context::getContext()->shop->getGroup()->share_order ? '' : Shop::addSqlAssociation('country', 'c')).'
WHERE `id_lang` = '.(int)$id_lang.' AND `id_customer` = '.(int)$this->id.' AND a.`deleted` = 0';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
@@ -598,9 +612,12 @@ class CustomerCore extends ObjectModel
public static function getGroupsStatic($id_customer)
{
if (!Group::isFeatureActive() || $id_customer == 0)
if (!Group::isFeatureActive())
return array(Configuration::get('PS_CUSTOMER_GROUP'));
if ($id_customer == 0)
self::$_customer_groups[$id_customer] = array((int)Configuration::get('PS_UNIDENTIFIED_GROUP'));
if (!isset(self::$_customer_groups[$id_customer]))
{
self::$_customer_groups[$id_customer] = array();
+13 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -55,6 +55,17 @@ class CustomerMessageCore extends ObjectModel
'read' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool')
),
);
protected $webserviceParameters = array(
'fields' => array(
'id_employee' => array(
'xlink_resource' => 'employees'
),
'id_customer_thread' => array(
'xlink_resource' => 'customer_threads'
),
),
);
public static function getMessagesByOrderId($id_order, $private = true)
{
+37 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -59,6 +59,39 @@ class CustomerThreadCore extends ObjectModel
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
),
);
protected $webserviceParameters = array(
'fields' => array(
'id_lang' => array(
'xlink_resource' => 'languages'
),
'id_shop' => array(
'xlink_resource' => 'shops'
),
'id_customer' => array(
'xlink_resource' => 'customers'
),
'id_order' => array(
'xlink_resource' => 'orders'
),
'id_product' => array(
'xlink_resource' => 'products'
),
),
'associations' => array(
'customer_messages' => array(
'resource' => 'customer_message',
'id' => array('required' => true)),
)
);
public function getWsCustomerMessages()
{
return Db::getInstance()->executeS('
SELECT `id_customer_message` id
FROM `'._DB_PREFIX_.'customer_message`
WHERE `id_customer_thread` = '.(int)$this->id);
}
public function delete()
{
@@ -102,6 +135,7 @@ class CustomerThreadCore extends ObjectModel
SELECT id_customer_thread
FROM '._DB_PREFIX_.'customer_thread ct2
WHERE status = "open" AND ct.id_contact = ct2.id_contact
'.Shop::addSqlRestriction().'
ORDER BY date_upd ASC
LIMIT 1
) as id_customer_thread
@@ -111,6 +145,7 @@ class CustomerThreadCore extends ObjectModel
WHERE ct.status = "open"
AND ct.id_contact IS NOT NULL
AND cl.id_contact IS NOT NULL
'.Shop::addSqlRestriction().'
GROUP BY ct.id_contact HAVING COUNT(*) > 0
');
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+22 -21
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -395,7 +395,19 @@ class DispatcherCore
$this->default_routes[$route] = array();
$this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details);
}
// Set default routes
foreach (Language::getLanguages() as $lang)
foreach ($this->default_routes as $id => $route)
$this->addRoute(
$id,
$route['rule'],
$route['controller'],
$lang['id_lang'],
$route['keywords'],
isset($route['params']) ? $route['params'] : array()
);
// Load the custom routes prior the defaults to avoid infinite loops
if ($this->use_routes)
{
@@ -438,18 +450,6 @@ class DispatcherCore
isset($route_data['params']) ? $route_data['params'] : array()
);
}
// Set default routes
foreach (Language::getLanguages() as $lang)
foreach ($this->default_routes as $id => $route)
$this->addRoute(
$id,
$route['rule'],
$route['controller'],
$lang['id_lang'],
$route['keywords'],
isset($route['params']) ? $route['params'] : array()
);
}
/**
@@ -468,7 +468,7 @@ class DispatcherCore
if ($keywords)
{
$transform_keywords = array();
preg_match_all('#\\\{(([^{}]+)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]+))?\\\}#', $regexp, $m);
preg_match_all('#\\\{(([^{}]*)\\\:)?('.implode('|', array_keys($keywords)).')(\\\:([^{}]*))?\\\}#', $regexp, $m);
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
{
$prepend = $m[2][$i];
@@ -537,7 +537,7 @@ class DispatcherCore
if (!isset($this->routes[$id_lang]) && !isset($this->routes[$id_lang][$route_id]))
return false;
return preg_match('#\{([^{}]+:)?'.preg_quote($keyword, '#').'(:[^{}])?\}#', $this->routes[$id_lang][$route_id]['rule']);
return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_lang][$route_id]['rule']);
}
/**
@@ -554,7 +554,7 @@ class DispatcherCore
return false;
foreach ($this->default_routes[$route_id]['keywords'] as $keyword => $data)
if (isset($data['param']) && !preg_match('#\{([^{}]+:)?'.$keyword.'(:[^{}])?\}#', $rule))
if (isset($data['param']) && !preg_match('#\{([^{}]*:)?'.$keyword.'(:[^{}]*)?\}#', $rule))
$errors[] = $keyword;
return (count($errors)) ? false : true;
@@ -581,7 +581,6 @@ class DispatcherCore
return ($route_id == 'index') ? $index_link.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '').$anchor;
}
$route = $this->routes[$id_lang][$route_id];
// Check required fields
$query_params = isset($route['params']) ? $route['params'] : array();
foreach ($route['keywords'] as $key => $data)
@@ -598,8 +597,10 @@ class DispatcherCore
// Build an url which match a route
if ($this->use_routes || $force_routes)
{
$url = $route['rule'];
$add_param = array();
foreach ($params as $key => $value)
{
if (!isset($route['keywords'][$key]))
@@ -613,10 +614,10 @@ class DispatcherCore
$replace = $route['keywords'][$key]['prepend'].$params[$key].$route['keywords'][$key]['append'];
else
$replace = '';
$url = preg_replace('#\{([^{}]+:)?'.$key.'(:[^{}])?\}#', $replace, $url);
$url = preg_replace('#\{([^{}]*:)?'.$key.'(:[^{}]*)?\}#', $replace, $url);
}
}
$url = preg_replace('#\{([^{}]+:)?[a-z0-9_]+?(:[^{}])?\}#', '', $url);
$url = preg_replace('#\{([^{}]*:)?[a-z0-9_]+?(:[^{}]*)?\}#', '', $url);
if (count($add_param))
$url .= '?'.http_build_query($add_param, '', '&');
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+17 -11
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -84,7 +84,7 @@ class GroupCore extends ObjectModel
ORDER BY g.`id_group` ASC');
}
public function getCustomers($count = false, $start = 0, $limit = 0)
public function getCustomers($count = false, $start = 0, $limit = 0, $shop_filtering = false)
{
if ($count)
return Db::getInstance()->getValue('
@@ -92,6 +92,7 @@ class GroupCore extends ObjectModel
FROM `'._DB_PREFIX_.'customer_group` cg
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (cg.`id_customer` = c.`id_customer`)
WHERE cg.`id_group` = '.(int)$this->id.'
'.($shop_filtering ? Shop::addSqlRestriction(Shop::SHARE_CUSTOMER) : '').'
AND c.`deleted` != 1');
return Db::getInstance()->executeS('
SELECT cg.`id_customer`, c.*
@@ -99,6 +100,7 @@ class GroupCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (cg.`id_customer` = c.`id_customer`)
WHERE cg.`id_group` = '.(int)$this->id.'
AND c.`deleted` != 1
'.($shop_filtering ? Shop::addSqlRestriction(Shop::SHARE_CUSTOMER) : '').'
ORDER BY cg.`id_customer` ASC
'.($limit > 0 ? 'LIMIT '.(int)$start.', '.(int)$limit : ''));
}
@@ -106,10 +108,10 @@ class GroupCore extends ObjectModel
public static function getReduction($id_customer = null)
{
if (!isset(self::$cache_reduction['customer'][(int)$id_customer]))
{
$id_group = $id_customer ? Customer::getDefaultGroupId((int)$id_customer) : (int)Configuration::get('PS_CUSTOMER_GROUP');
self::$cache_reduction['customer'][(int)$id_customer] = Group::getReductionByIdGroup($id_group);
}
{
$id_group = $id_customer ? Customer::getDefaultGroupId((int)$id_customer) : (int)Group::getCurrent()->id;
self::$cache_reduction['customer'][(int)$id_customer] = Group::getReductionByIdGroup($id_group);
}
return self::$cache_reduction['customer'][(int)$id_customer];
}
@@ -157,7 +159,7 @@ class GroupCore extends ObjectModel
public function delete()
{
if ($this->id == _PS_DEFAULT_CUSTOMER_GROUP_)
if ($this->id == (int)Configuration::get('PS_CUSTOMER_GROUP'))
return false;
if (parent::delete())
{
@@ -295,13 +297,17 @@ class GroupCore extends ObjectModel
*/
public static function getCurrent()
{
static $groups = array();
$customer = Context::getContext()->customer;
$id_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
if (Validate::isLoadedObject($customer))
$id_group = (int)$customer->id_default_group;
else
$id_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
if (!isset($groups[$id_group]))
$groups[$id_group] = new Group($id_group);
return new self($id_group);
return $groups[$id_group];
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+7 -10
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -40,6 +40,7 @@ class GuestCore extends ObjectModel
public $real_player;
public $windows_media;
public $accept_language;
public $mobile_theme;
/**
* @see ObjectModel::$definition
@@ -62,6 +63,7 @@ class GuestCore extends ObjectModel
'real_player' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'windows_media' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'accept_language' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 8),
'mobile_theme' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
),
);
@@ -77,7 +79,7 @@ class GuestCore extends ObjectModel
$acceptLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$this->id_operating_system = $this->getOs($userAgent);
$this->id_web_browser = $this->getBrowser($userAgent);
$this->accept_language = $this->getLanguage($acceptLanguage);
$this->mobile_theme = Context::getContext()->getMobileDevice();
}
protected function getLanguage($acceptLanguage)
@@ -183,12 +185,7 @@ class GuestCore extends ObjectModel
{
$guest = new Guest(isset($cookie->id_customer) ? Guest::getFromCustomer((int)($cookie->id_customer)) : null);
$guest->userAgent();
if ($guest->id_operating_system || $guest->id_web_browser)
{
$guest->save();
$cookie->id_guest = (int)($guest->id);
}
$guest->save();
$cookie->id_guest = (int)($guest->id);
}
}
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -79,7 +79,7 @@ class HelpAccessCore
$tooltip = '';
$ctx = @stream_context_create(array('http' => array('timeout' => 10)));
$res = @file_get_contents($url, 0, $ctx);
$res = Tools::file_get_contents($url, false, $ctx);
$infos = preg_split('/\|/', $res);
if (count($infos) > 0)
+4 -10
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -98,7 +98,7 @@ class HookCore extends ObjectModel
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT * FROM `'._DB_PREFIX_.'hook` h
'.($position ? 'WHERE h.`position` = 1' : '').'
ORDER BY `title`'
ORDER BY `name`'
);
}
@@ -286,6 +286,7 @@ class HookCore extends ObjectModel
{
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
$sql->where('mg.`id_group` IN ('.implode(', ', $groups).')');
$sql->where(Module::getPaypalIgnore());
$sql->groupBy('hm.id_hook, hm.id_module');
}
@@ -298,16 +299,9 @@ class HookCore extends ObjectModel
// Get all available payment module
$payment_modules = array();
if (isset($context->shop->id))
foreach (Module::getPaymentModules() as $module)
$payment_modules[] = $module['name'];
if ($results)
foreach ($results as $row)
{
if ($row['hook'] == 'displayPayment' && !in_array($row['module'], $payment_modules))
continue;
$row['hook'] = strtolower($row['hook']);
if (!isset($list[$row['hook']]))
$list[$row['hook']] = array();
+14 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -367,6 +367,18 @@ class ImageCore extends ObjectModel
');
return self::$_cacheGetSize[$type];
}
public static function getWidth($params, &$smarty)
{
$result = self::getSize($params['type']);
return $result['width'];
}
public static function getHeight($params, &$smarty)
{
$result = self::getSize($params['type']);
return $result['height'];
}
/**
* Clear all images in tmp dir
+11 -7
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -119,6 +119,11 @@ class ImageManagerCore
*/
public static function resize($src_file, $dst_file, $dst_width = null, $dst_height = null, $file_type = 'jpg', $force_type = false)
{
if (PHP_VERSION_ID < 50300)
clearstatcache();
else
clearstatcache(true, $src_file);
if (!file_exists($src_file) || !filesize($src_file))
return false;
list($src_width, $src_height, $type) = getimagesize($src_file);
@@ -163,6 +168,9 @@ class ImageManagerCore
}
}
if (!ImageManager::checkImageMemoryLimit($src_file))
return false;
$dest_image = imagecreatetruecolor($dst_width, $dst_height);
// If image is a PNG and the output is PNG, fill with transparency. Else fill with white background.
@@ -262,11 +270,7 @@ class ImageManagerCore
public static function validateUpload($file, $max_file_size = 0)
{
if ((int)$max_file_size > 0 && $file['size'] > (int)$max_file_size)
return sprintf(
Tools::displayError('Image is too large (%1$d kB). Maximum allowed: %2$d kB'),
$file['size'] / 1000,
$max_file_size / 1000
);
return sprintf(Tools::displayError('Image is too large (%1$d kB). Maximum allowed: %2$d kB'), $file['size'] / 1024, $max_file_size / 1024);
if (!ImageManager::isRealImage($file['tmp_name'], $file['type']) || !ImageManager::isCorrectImageFileExt($file['name']))
return Tools::displayError('Image format not recognized, allowed formats are: .gif, .jpg, .png');
if ($file['error'])
+8 -5
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -62,7 +62,7 @@ class ImageTypeCore extends ObjectModel
'table' => 'image_type',
'primary' => 'id_image_type',
'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isImageTypeName', 'required' => true, 'size' => 16),
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isImageTypeName', 'required' => true, 'size' => 64),
'width' => array('type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true),
'height' => array('type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true),
'categories' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
@@ -143,13 +143,16 @@ class ImageTypeCore extends ObjectModel
{
$theme_name = Context::getContext()->shop->theme_name;
$name_without_theme_name = str_replace(array('_'.$theme_name, $theme_name.'_'), '', $name);
//check if the theme name is already in $name if yes only return $name
if (strstr($name, $theme_name) && self::getByNameNType($name))
return $name;
else if (self::getByNameNType($name_without_theme_name.'_'.$theme_name))
return $name_without_theme_name.'_'.$theme_name;
else
else if (self::getByNameNType($theme_name.'_'.$name_without_theme_name))
return $theme_name.'_'.$name_without_theme_name;
else
return $name_without_theme_name.'_default';
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+14 -4
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -35,6 +35,8 @@ class LinkCore
public $protocol_content;
protected $ssl_enable;
protected static $category_disable_rewrite = null;
/**
* Constructor (initialization only)
@@ -50,6 +52,9 @@ class LinkCore
define('_PS_BASE_URL_', Tools::getShopDomain(true));
if (!defined('_PS_BASE_URL_SSL_'))
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
if (Link::$category_disable_rewrite === null)
Link::$category_disable_rewrite = array(Configuration::get('PS_HOME_CATEGORY'), Configuration::get('PS_ROOT_CATEGORY'));
$this->ssl_enable = Configuration::get('PS_SSL_ENABLED');
}
@@ -134,7 +139,7 @@ class LinkCore
$params['category'] = (!$category) ? $product->category : $category;
$cats = array();
foreach ($product->getParentCategories() as $cat)
if (!in_array($cat['id_category'], array(1, 2)))//remove root and home category from the URL
if (!in_array($cat['id_category'], Link::$category_disable_rewrite))//remove root and home category from the URL
$cats[] = $cat['link_rewrite'];
$params['categories'] = implode('/', $cats);
}
@@ -194,6 +199,7 @@ class LinkCore
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if (!is_object($category))
@@ -535,7 +541,11 @@ class LinkCore
}
if (!$array)
return $url.(($this->allow == 1 || $url == $this->url) ? '?' : '&').http_build_query($vars, '', '&');
if (count($vars))
return $url.(($this->allow == 1 || $url == $this->url) ? '?' : '&').http_build_query($vars, '', '&');
else
return $url;
$vars['requestUrl'] = $url;
if ($type && $id_object)
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -432,7 +432,7 @@ class LocalizationPackCore
$attributes = $xml->group_default->attributes();
if (isset($attributes['price_display_method']) && in_array((int)$attributes['price_display_method'], array(0, 1)))
{
$group = new Group((int)_PS_DEFAULT_CUSTOMER_GROUP_);
$group = new Group((int)Configuration::get('PS_CUSTOMER_GROUP'));
$group->price_display_method = (int)$attributes['price_display_method'];
if (!$group->save())
$this->_errors[] = Tools::displayError('An error occurred during the default group update');
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+19 -15
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -54,18 +54,6 @@ class MailCore
public static function Send($id_lang, $template, $subject, $template_vars, $to,
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null)
{
$theme_path = _PS_THEME_DIR_;
// Get the path of theme by id_shop if exist
if (is_numeric($id_shop) && $id_shop)
{
$shop = new Shop((int)$id_shop);
$theme_name = $shop->getTheme();
if (_THEME_NAME_ != $theme_name)
$theme_path = _PS_ROOT_DIR_.'/themes/'.$theme_name.'/';
}
$configuration = Configuration::getMultiple(array(
'PS_SHOP_EMAIL',
'PS_MAIL_METHOD',
@@ -78,6 +66,22 @@ class MailCore
'PS_MAIL_METHOD',
'PS_MAIL_TYPE'
));
// Returns immediatly if emails are deactivated
if ($configuration['PS_MAIL_METHOD'] == 3)
return true;
$theme_path = _PS_THEME_DIR_;
// Get the path of theme by id_shop if exist
if (is_numeric($id_shop) && $id_shop)
{
$shop = new Shop((int)$id_shop);
$theme_name = $shop->getTheme();
if (_THEME_NAME_ != $theme_name)
$theme_path = _PS_ROOT_DIR_.'/themes/'.$theme_name.'/';
}
if (!isset($configuration['PS_MAIL_SMTP_ENCRYPTION']))
$configuration['PS_MAIL_SMTP_ENCRYPTION'] = 'off';
@@ -204,7 +208,7 @@ class MailCore
$template_path = $theme_path.'mails/';
$override_mail = true;
}
else if (!file_exists($template_path.$template.'.txt') && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT))
if (!file_exists($template_path.$template.'.txt') && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT))
{
Tools::dieOrLog(Tools::displayError('Error - The following e-mail template is missing:').' '.$template_path.$template.'.txt', $die);
return false;
+9 -4
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -110,7 +110,7 @@ class ManufacturerCore extends ObjectModel
{
$address = new Address($this->id_address);
if (!$address->delete())
if (Validate::isLoadedObject($address) AND !$address->delete())
return false;
if (parent::delete())
@@ -316,6 +316,11 @@ class ManufacturerCore extends ObjectModel
$alias = 'product_shop.';
elseif ($order_by == 'name')
$alias = 'pl.';
elseif ($order_by == 'manufacturer_name')
{
$order_by = 'name';
$alias = 'm.';
}
elseif ($order_by == 'quantity')
$alias = 'stock.';
else
@@ -358,7 +363,7 @@ class ManufacturerCore extends ObjectModel
WHERE cg.`id_group` '.$sql_groups.'
)
AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))
ORDER BY '.$alias.pSQL($order_by).' '.pSQL($order_way).'
ORDER BY '.$alias.'`'.bqSQL($order_by).'` '.pSQL($order_way).'
LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+33 -12
View File
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -32,7 +32,7 @@ class MediaCore
'ui.mouse' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => false),
'ui.position' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array(), 'theme' => false),
'ui.draggable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => false),
'ui.droppable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('uicore', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false),
'ui.droppable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false),
'ui.resizable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.selectable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.sortable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
@@ -68,11 +68,13 @@ class MediaCore
$html_content = preg_replace_callback(
'/(<[a-zA-Z0-9]+)((\s?[a-zA-Z0-9]+=[\"\\\'][^\"\\\']*[\"\\\']\s?)*)>/',
array('Media', 'minifyHTMLpregCallback'),
$html_content);
$html_content,
Media::getBackTrackLimit());
require_once(_PS_TOOL_DIR_.'minify_html/minify_html.class.php');
$html_content = str_replace(chr(194).chr(160), '&nbsp;', $html_content);
$html_content = Minify_HTML::minify($html_content, array('xhtml', 'cssMinifier', 'jsMinifier'));
if (trim($minified_content = Minify_HTML::minify($html_content, array('xhtml', 'cssMinifier', 'jsMinifier'))) != '')
$html_content = $minified_content;
return $html_content;
}
@@ -101,7 +103,8 @@ class MediaCore
$html_content = preg_replace_callback(
'/\\s*(<script\\b[^>]*?>)([\\s\\S]*?)(<\\/script>)\\s*/i',
array('Media', 'packJSinHTMLpregCallback'),
$html_content);
$html_content,
Media::getBackTrackLimit());
// If the string is too big preg_replace return an error
// In this case, we don't compress the content
@@ -128,12 +131,18 @@ class MediaCore
public static function packJS($js_content)
{
if (strlen($js_content) > 0)
if (!empty($js_content))
{
require_once(_PS_TOOL_DIR_.'js_minify/jsmin.php');
return JSMin::minify($js_content);
try {
$js_content = JSMin::minify($js_content);
} catch (Exception $e) {
if (_PS_MODE_DEV_)
echo $e->getMessage();
return $js_content;
}
}
return false;
return $js_content;
}
public static function minifyCSS($css_content, $fileuri = false, &$import_url = array())
@@ -143,10 +152,10 @@ class MediaCore
$current_css_file = $fileuri;
if (strlen($css_content) > 0)
{
$css_content = preg_replace('#/\*.*?\*/#s', '', $css_content);
$css_content = preg_replace_callback('#url\((?:\'|")?([^\)\'"]*)(?:\'|")?\)#s', array('Tools', 'replaceByAbsoluteURL'), $css_content);
$css_content = preg_replace('#/\*.*?\*/#s', '', $css_content, Media::getBackTrackLimit());
$css_content = preg_replace_callback('#url\((?!data:)(?:\'|")?([^\)\'"]*)(?:\'|")?\)#s', array('Tools', 'replaceByAbsoluteURL'), $css_content, Media::getBackTrackLimit());
$css_content = preg_replace('#\s+#', ' ', $css_content);
$css_content = preg_replace('#\s+#', ' ', $css_content, Media::getBackTrackLimit());
$css_content = str_replace("\t", '', $css_content);
$css_content = str_replace("\n", '', $css_content);
//$css_content = str_replace('}', "}\n", $css_content);
@@ -465,6 +474,18 @@ class MediaCore
return $css_files;
}
public static function getBackTrackLimit()
{
static $limit = null;
if ($limit === null)
{
$limit = @ini_get('pcre.backtrack_limit');
if (!$limit)
$limit = -1;
}
return $limit;
}
/**
* Combine Compress and Cache (ccc) JS calls
@@ -539,4 +560,4 @@ class MediaCore
return array_merge(array($protocol_link.Tools::getMediaServer($url).$url), $js_external_files);
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+16 -7
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -65,11 +65,20 @@ class MetaCore extends ObjectModel
);
foreach ($files as $file)
if ($file != 'index.php' && preg_match('/^[a-z0-9_.-]*\.php$/i', $file) && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages))
$selected_pages[strtolower(str_replace('Controller.php', '', $file))] = strtolower(str_replace('Controller.php', '', $file));
else if ($file != 'index.php' && preg_match('/^([a-z0-9_.-]*\/)?[a-z0-9_.-]*\.php$/i', $file) && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages))
$selected_pages[strtolower(sprintf(Tools::displayError('%2$s (in %1$s)'), dirname($file), str_replace('Controller.php', '', basename($file))))] = strtolower(str_replace('Controller.php', '', basename($file)));
{
if ($file != 'index.php' && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages))
{
$reflection = new ReflectionClass(str_replace('.php', '', $file));
$properties = $reflection->getDefaultProperties();
if (isset($properties['php_self']))
$selected_pages[$properties['php_self']] = $properties['php_self'];
else if (preg_match('/^[a-z0-9_.-]*\.php$/i', $file))
$selected_pages[strtolower(str_replace('Controller.php', '', $file))] = strtolower(str_replace('Controller.php', '', $file));
else if (preg_match('/^([a-z0-9_.-]*\/)?[a-z0-9_.-]*\.php$/i', $file))
$selected_pages[strtolower(sprintf(Tools::displayError('%2$s (in %1$s)'), dirname($file), str_replace('Controller.php', '', basename($file))))] = strtolower(str_replace('Controller.php', '', basename($file)));
}
}
// Add modules controllers to list (this function is cool !)
foreach (glob(_PS_MODULE_DIR_.'*/controllers/front/*.php') as $file)
{
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+59 -49
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -169,8 +169,8 @@ abstract class ObjectModelCore
{
if (!ObjectModel::$db)
ObjectModel::$db = Db::getInstance();
$this->def = self::getDefinition($this);
$this->def = ObjectModel::getDefinition($this);
$this->setDefinitionRetrocompatibility();
if ($id_lang !== null)
@@ -191,7 +191,7 @@ abstract class ObjectModelCore
if ($id)
{
// Load object from database if object id is present
$cache_id = 'objectmodel_'.$this->def['table'].'_'.(int)$id.'_'.(int)$id_shop.'_'.(int)$id_lang;
$cache_id = 'objectmodel_'.$this->def['classname'].'_'.(int)$id.'_'.(int)$id_shop.'_'.(int)$id_lang;
if (!Cache::isStored($cache_id))
{
$sql = new DbQuery();
@@ -209,36 +209,37 @@ abstract class ObjectModelCore
// Get shop informations
if (Shop::isTableAssociated($this->def['table']))
$sql->leftJoin($this->def['table'].'_shop', 'c', 'a.'.$this->def['primary'].' = c.'.$this->def['primary'].' AND c.id_shop = '.(int)$this->id_shop);
if ($row = ObjectModel::$db->getRow($sql))
Cache::store($cache_id, $row);
if ($object_datas = ObjectModel::$db->getRow($sql))
{
if (!$id_lang && isset($this->def['multilang']) && $this->def['multilang'])
{
$sql = 'SELECT * FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_lang`
WHERE `'.$this->def['primary'].'` = '.(int)$id
.(($this->id_shop && $this->isLangMultishop()) ? ' AND `id_shop` = '.$this->id_shop : '');
if ($object_datas_lang = ObjectModel::$db->executeS($sql))
foreach ($object_datas_lang as $row)
foreach ($row as $key => $value)
{
if (array_key_exists($key, $this) && $key != $this->def['primary'])
{
if (!isset($object_datas[$key]) || !is_array($object_datas[$key]))
$object_datas[$key] = array();
$object_datas[$key][$row['id_lang']] = $value;
}
}
}
Cache::store($cache_id, $object_datas);
}
}
else
$object_datas = Cache::retrieve($cache_id);
$result = Cache::retrieve($cache_id);
if ($result)
if ($object_datas)
{
$this->id = (int)$id;
foreach ($result as $key => $value)
foreach ($object_datas as $key => $value)
if (array_key_exists($key, $this))
$this->{$key} = $value;
if (!$id_lang && isset($this->def['multilang']) && $this->def['multilang'])
{
$sql = 'SELECT * FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_lang`
WHERE `'.$this->def['primary'].'` = '.(int)$id
.(($this->id_shop && $this->isLangMultishop()) ? ' AND `id_shop` = '.$this->id_shop : '');
$result = ObjectModel::$db->executeS($sql);
if ($result)
foreach ($result as $row)
foreach ($row as $key => $value)
{
if (array_key_exists($key, $this) && $key != $this->def['primary'])
{
if (!is_array($this->{$key}))
$this->{$key} = array();
$this->{$key}[$row['id_lang']] = $value;
}
}
}
$this->{$key} = $value;
}
}
@@ -388,7 +389,7 @@ abstract class ObjectModelCore
return (int)$value;
case self::TYPE_FLOAT :
return (float)$value;
return (float)str_replace(',', '.', $value);
case self::TYPE_DATE :
if (!$value)
@@ -614,7 +615,6 @@ abstract class ObjectModelCore
else
$all_fields = $fields;
foreach ($id_shop_list as $id_shop)
{
$fields['id_shop'] = (int)$id_shop;
@@ -1158,9 +1158,9 @@ abstract class ObjectModelCore
public function clearCache($all = false)
{
if ($all)
Cache::clean('objectmodel_'.$this->def['table'].'_*');
else if ($this->id)
Cache::clean('objectmodel_'.$this->def['table'].'_'.(int)$this->id.'_*');
Cache::clean('objectmodel_'.$this->def['classname'].'_*');
elseif ($this->id)
Cache::clean('objectmodel_'.$this->def['classname'].'_'.(int)$this->id.'_*');
}
/**
@@ -1459,24 +1459,34 @@ abstract class ObjectModelCore
*/
public static function getDefinition($class, $field = null)
{
$reflection = new ReflectionClass($class);
$definition = $reflection->getStaticPropertyValue('definition');
if (is_object($class))
$definition['classname'] = get_class($class);
else
$class = get_class($class);
if ($field === null)
$cache_id = 'objectmodel_def_'.$class;
if ($field !== null || !Cache::isStored($cache_id))
{
$reflection = new ReflectionClass($class);
$definition = $reflection->getStaticPropertyValue('definition');
$definition['classname'] = $class;
if (!empty($definition['multilang']))
$definition['associations'][Collection::LANG_ALIAS] = array(
'type' => self::HAS_MANY,
'field' => $definition['primary'],
'foreign_field' => $definition['primary'],
);
if (!empty($definition['multilang']))
$definition['associations'][Collection::LANG_ALIAS] = array(
'type' => self::HAS_MANY,
'field' => $definition['primary'],
'foreign_field' => $definition['primary'],
);
if ($field)
return isset($definition['fields'][$field]) ? $definition['fields'][$field] : null;
if ($field)
return isset($definition['fields'][$field]) ? $definition['fields'][$field] : null;
return $definition;
Cache::store($cache_id, $definition);
return $definition;
}
return Cache::retrieve($cache_id);
}
/**
+8 -9
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -113,8 +113,7 @@ class PackCore extends Product
foreach ($items as $item)
{
// Updated for 1.5.0
if (Product::getQuantity($item->id) < $item->pack_quantity
|| (Product::getQuantity($item->id) < $item->pack_quantity && !$item->isAvailableWhenOutOfStock((int)$item->out_of_stock)))
if (Product::getQuantity($item->id) < $item->pack_quantity && !$item->isAvailableWhenOutOfStock((int)$item->out_of_stock))
return false;
}
return true;
@@ -143,16 +142,16 @@ class PackCore extends Product
AND a.`id_product_pack` = '.(int)$id_product;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as &$row)
$row = Product::getTaxesInformations($row);
foreach ($result as &$line)
$line = Product::getTaxesInformations($line);
if (!$full)
return $result;
$array_result = array();
foreach ($result as $row)
if (!Pack::isPack($row['id_product']))
$array_result[] = Product::getProductProperties($id_lang, $row);
foreach ($result as $prow)
if (!Pack::isPack($prow['id_product']))
$array_result[] = Product::getProductProperties($id_lang, $prow);
return $array_result;
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -11
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -53,15 +53,6 @@ class PaymentCCCore extends OrderPayment
'primary' => 'id_payment_cc',
);
/**
* @deprecated 1.5.0.2
* @see OrderPaymentCore
*/
public function getFields()
{
Tools::displayAsDeprecated();
return parent::getFields();
}
/**
* @deprecated 1.5.0.2
+16 -20
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -174,13 +174,6 @@ abstract class PaymentModuleCore extends Module
$order_creation_failed = false;
$cart_total_paid = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
if ($this->context->cart->orderExists())
{
$error = Tools::displayError('An order has already been placed using this cart.');
Logger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id));
die($error);
}
foreach ($cart_delivery_option as $id_address => $key_carriers)
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
foreach ($data['package_list'] as $id_package)
@@ -234,6 +227,7 @@ abstract class PaymentModuleCore extends Module
$order->recyclable = $this->context->cart->recyclable;
$order->gift = (int)$this->context->cart->gift;
$order->gift_message = $this->context->cart->gift_message;
$order->mobile_theme = $this->context->cart->mobile_theme;
$order->conversion_rate = $this->context->currency->conversion_rate;
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float)$amount_paid, 2) : $amount_paid;
$order->total_paid_real = 0;
@@ -327,7 +321,7 @@ abstract class PaymentModuleCore extends Module
foreach ($order_detail_list as $key => $order_detail)
{
$order = $order_list[$key];
if (!$order_creation_failed & isset($order->id))
if (!$order_creation_failed && isset($order->id))
{
if (!$secure_key)
$message .= '<br />'.Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
@@ -358,10 +352,11 @@ abstract class PaymentModuleCore extends Module
$price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$customization_quantity = 0;
$customized_datas = Product::getAllCustomizedDatas((int)$order->id_cart);
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']]))
{
$customization_text = '';
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']] as $customization)
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization)
{
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text)
@@ -369,13 +364,11 @@ abstract class PaymentModuleCore extends Module
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])).'<br />';
$customization_text .= '---<br />';
}
$customization_text = rtrim($customization_text, '---<br />');
$customization_quantity = (int)$product['customizationQuantityTotal'];
$customization_quantity = (int)$product['customization_quantity'];
$products_list .=
'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
@@ -407,16 +400,14 @@ abstract class PaymentModuleCore extends Module
{
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
$values = array(
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL, $package),
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL, $package)
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
);
// If the reduction is not applicable to this order, then continue with the next one
if (!$values['tax_excl'])
continue;
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values);
/* IF
** - This is not multi-shipping
** - The value of the voucher is greater than the total of the order
@@ -467,8 +458,13 @@ abstract class PaymentModuleCore extends Module
null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop
);
}
$values['tax_incl'] -= $values['tax_incl'] - $order->total_products_wt;
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
}
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used))
{
$cart_rule_used[] = $cart_rule['obj']->id;
@@ -509,7 +505,7 @@ abstract class PaymentModuleCore extends Module
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->message = htmlentities($update_message->message, ENT_COMPAT, 'UTF-8');
$customer_message->message = $update_message->message;
$customer_message->private = 0;
if (!$customer_message->add())
@@ -614,7 +610,7 @@ abstract class PaymentModuleCore extends Module
{
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang).sprintf('%06d', $order->invoice_number).'.pdf';
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
$file_attachement['mime'] = 'application/pdf';
}
else
+139 -37
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -244,7 +244,7 @@ class ProductCore extends ObjectModel
'multilang' => true,
'multilang_shop' => true,
'fields' => array(
/* Classic fields */
// Classic fields
'id_shop_default' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
@@ -362,6 +362,10 @@ class ProductCore extends ObjectModel
'getter' => false,
'setter' => false
),
'type' => array(
'getter' => 'getWsType',
'setter' => false,
),
),
'associations' => array(
'categories' => array(
@@ -414,7 +418,14 @@ class ProductCore extends ObjectModel
'required' => true,
'xlink_resource' => 'product'),
)
),
),
'product_bundle' => array(
'resource' => 'products',
'fields' => array(
'id' => array('required' => true),
'quantity' => array(),
),
),
),
);
@@ -589,9 +600,16 @@ class ProductCore extends ObjectModel
*/
public static function getDefaultAttribute($id_product, $minimum_quantity = 0)
{
static $combinations = array();
if (!Combination::isFeatureActive())
return 0;
if (!isset($combinations[$id_product]))
$combinations[$id_product] = array();
if (isset($combinations[$id_product][$minimum_quantity]))
return $combinations[$id_product][$minimum_quantity];
$sql = 'SELECT pa.id_product_attribute
FROM '._DB_PREFIX_.'product_attribute pa
'.Shop::addSqlAssociation('product_attribute', 'pa').'
@@ -630,14 +648,19 @@ class ProductCore extends ObjectModel
WHERE pa.id_product = '.(int)$id_product;
$result = Db::getInstance()->getValue($sql);
}
$combinations[$id_product][$minimum_quantity] = $result;
return $result;
}
public static function updateDefaultAttribute($id_product)
public function setAvailableDate($available_date = '0000-00-00')
{
Db::getInstance()->update('product_shop', array(
'cache_default_attribute' => (int)Product::getDefaultAttribute($id_product),
), 'id_product = '.(int)$id_product);
if (Validate::isDateFormat($available_date) && $this->available_date != $available_date)
{
$this->available_date = $available_date;
return $this->update();
}
return false;
}
public static function updateIsVirtual($id_product)
@@ -660,6 +683,15 @@ class ProductCore extends ObjectModel
return parent::validateFieldsLang($die, $error_return);
}
/**
* @see ObjectModel::validateField()
*/
public function validateField($field, $value, $id_lang = null)
{
$value = ($field == 'description_short' ? strip_tags($value) : $value);
return parent::validateField($field, $value, $id_lang);
}
public function toggleStatus()
{
//test if the product is active and if redirect_type is empty string and set default value to id_product_redirected & redirect_type
@@ -884,7 +916,7 @@ class ProductCore extends ObjectModel
);
$return = Db::getInstance()->delete('category_product', 'id_product = '.(int)$this->id);
if ($clean_positions === true)
if ($clean_positions === true && is_array($result))
foreach ($result as $row)
$return &= $this->cleanPositions((int)$row['id_category']);
@@ -1223,7 +1255,19 @@ class ProductCore extends ObjectModel
$result &= ObjectModel::updateMultishopTable('product', array(
'cache_default_attribute' => (int)$id_product_attribute,
), 'a.`id_product` = '.(int)$this->id);
$this->cache_default_attribute = (int)$id_product_attribute;
return $result;
}
public static function updateDefaultAttribute($id_product)
{
$id_default_attribute = (int)Product::getDefaultAttribute($id_product);
$result = Db::getInstance()->update('product_shop', array(
'cache_default_attribute' => $id_default_attribute,
), 'id_product = '.(int)$id_product);
$result &= Db::getInstance()->update('product', array(
'cache_default_attribute' => $id_default_attribute,
), 'id_product = '.(int)$id_product);
return $result;
}
@@ -2399,7 +2443,7 @@ class ProductCore extends ObjectModel
if (!Validate::isBool($usetax) || !Validate::isUnsignedId($id_product))
die(Tools::displayError());
// Initializations
$id_group = (isset($context->customer) ? $context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_);
$id_group = (isset($context->customer) ? $context->customer->id_default_group : (int)Configuration::get('PS_CUSTOMER_GROUP'));
// If there is cart in context or if the specified id_cart is different from the context cart id
if (!is_object($cur_cart) || (Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart))
@@ -2421,12 +2465,13 @@ class ProductCore extends ObjectModel
if ((int)$id_cart)
{
$condition = '';
$cache_name = (int)$id_cart.'_'.(int)$id_product;
$cache_name = (int)$id_cart.'_'.(int)$id_product.'_'.(int)$id_product_attribute;
if (!isset(self::$_cart_quantity[$cache_name]) || self::$_cart_quantity[$cache_name] != (int)$quantity)
self::$_cart_quantity[$cache_name] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(`quantity`)
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_product` = '.(int)$id_product.'
AND `id_product_attribute` = '.(int)$id_product_attribute.'
AND `id_cart` = '.(int)$id_cart);
$cart_quantity = self::$_cart_quantity[$cache_name];
}
@@ -2533,10 +2578,13 @@ class ProductCore extends ObjectModel
if (!$use_customer_price)
$id_customer = 0;
if ($id_product_attribute === null)
$id_product_attribute = Product::getDefaultAttribute($id_product);
$cache_id = $id_product.'-'.$id_shop.'-'.$id_currency.'-'.$id_country.'-'.$id_state.'-'.$zipcode.'-'.$id_group.
'-'.$quantity.'-'.(int)$id_product_attribute.'-'.($use_tax?'1':'0').'-'.$decimals.'-'.($only_reduc?'1':'0').
'-'.($use_reduc?'1':'0').'-'.$with_ecotax.'-'.$id_customer;
'-'.$quantity.'-'.$id_product_attribute.'-'.($use_tax?'1':'0').'-'.$decimals.'-'.($only_reduc?'1':'0').
'-'.($use_reduc?'1':'0').'-'.$with_ecotax.'-'.$id_customer.'-'.(int)$use_group_reduction.'-'.(int)$id_cart.'-'.(int)$real_quantity;
// reference parameter is filled before any returns
$specific_price = SpecificPrice::getSpecificPrice(
(int)$id_product,
@@ -2620,7 +2668,6 @@ class ProductCore extends ObjectModel
// Add Tax
if ($use_tax)
$price = $product_tax_calculator->addTaxes($price);
$price = Tools::ps_round($price, $decimals);
// Reduction
$reduc = 0;
@@ -2632,14 +2679,14 @@ class ProductCore extends ObjectModel
if (!$specific_price['id_currency'])
$reduction_amount = Tools::convertPrice($reduction_amount, $id_currency);
$reduc = Tools::ps_round(!$use_tax ? $product_tax_calculator->removeTaxes($reduction_amount) : $reduction_amount, $decimals);
$reduc = !$use_tax ? $product_tax_calculator->removeTaxes($reduction_amount) : $reduction_amount;
}
else
$reduc = Tools::ps_round($price * $specific_price['reduction'], $decimals);
$reduc = $price * $specific_price['reduction'];
}
if ($only_reduc)
return $reduc;
return Tools::ps_round($reduc, $decimals);
if ($use_reduc)
$price -= $reduc;
@@ -2652,7 +2699,6 @@ class ProductCore extends ObjectModel
$price *= ((100 - Group::getReductionByIdGroup($id_group)) / 100);
}
$price = Tools::ps_round($price, $decimals);
// Eco Tax
if (($result['ecotax'] || isset($result['attribute_ecotax'])) && $with_ecotax)
{
@@ -2929,7 +2975,7 @@ class ProductCore extends ObjectModel
}
/**
* Check if there is not a default attribute and create it not
* Check if there is no default attribute and create it if not
*/
public function checkDefaultAttributes()
{
@@ -3388,18 +3434,27 @@ class ProductCore extends ObjectModel
return true;
$data = array();
$res = true;
foreach ($results as $row)
{
$new_filename = ProductDownload::getNewFilename();
copy(_PS_DOWNLOAD_DIR_.$row['filename'], _PS_DOWNLOAD_DIR_.$new_filename);
$data[] = array(
'id_product' => (int)$id_product_new,
'display_filename' => pSQL($row['display_filename']),
'filename' => pSQL($row['filename']),
'filename' => pSQL($new_filename),
'date_expiration' => pSQL($row['date_expiration']),
'nb_days_accessible' => (int)$row['nb_days_accessible'],
'nb_downloadable' => (int)$row['nb_downloadable'],
'active' => (int)$row['active'],
'is_shareable' => (int)$row['is_shareable']
'is_shareable' => (int)$row['is_shareable'],
'date_add' => date('Y-m-d H:i:s')
);
return Db::getInstance()->insert('product_download', $data);
$res &= Db::getInstance()->insert('product_download', $data);
}
return $res;
}
public static function duplicateAttachments($id_product_old, $id_product_new)
@@ -3546,17 +3601,19 @@ class ProductCore extends ObjectModel
if (isset($customizations['labels']))
{
$query = 'INSERT INTO `'._DB_PREFIX_.'` (`id_customization_field`, `id_lang`, `name`) VALUES ';
$query = 'INSERT INTO `'._DB_PREFIX_.'customization_field_lang` (`id_customization_field`, `id_lang`, `name`) VALUES ';
$data = array();
foreach ($customizations['labels'][$old_customization_field_id] as $customization_label)
{
$data = array(
'id_customization_field' => (int)$customization_field_id,
'id_lang' => (int)$customization_label['id_lang'],
'name' => pSQL($customization_label['name']),
);
if (!Db::getInstance()->insert('customization_field_lang', $data))
return false;
if (!Db::getInstance()->insert('customization_field_lang', $data))
return false;
}
}
}
return true;
@@ -3699,14 +3756,21 @@ class ProductCore extends ObjectModel
$row['specific_prices'] = $specific_prices;
$row['quantity'] = Product::getQuantity(
(int)$row['id_product'],
0,
isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null
);
if ($row['id_product_attribute'])
$row['quantity_all_versions'] = Product::getQuantity(
{
$row['quantity_all_versions'] = $row['quantity'];
$row['quantity'] = Product::getQuantity(
(int)$row['id_product'],
0,
isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null
$row['id_product_attribute'],
isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null
);
else
$row['quantity'] = Product::getQuantity((int)$row['id_product']);
}
$row['id_image'] = Product::defineProductImage($row, $id_lang);
$row['features'] = Product::getFrontFeaturesStatic((int)$id_lang, $row['id_product']);
@@ -4170,7 +4234,7 @@ class ProductCore extends ObjectModel
SELECT ctg.`id_group`
FROM `'._DB_PREFIX_.'category_product` cp
INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
WHERE cp.`id_product` = '.(int)$this->id.' AND ctg.`id_group` = 1');
WHERE cp.`id_product` = '.(int)$this->id.' AND ctg.`id_group` ='.(int)Group::getCurrent()->id);
else
return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT cg.`id_group`
@@ -4672,7 +4736,7 @@ class ProductCore extends ObjectModel
'.Shop::addSqlAssociation('product_attribute', 'pa').'
LEFT JOIN `'._DB_PREFIX_.'layered_indexable_attribute_lang_value` la
ON (la.`id_attribute` = a.`id_attribute` AND la.`id_lang` = '.(int)Context::getContext()->language->id.')
WHERE la.`url_name` IS NOT NULL
WHERE la.`url_name` IS NOT NULL AND la.`url_name` != \'\'
AND pa.`id_product` = '.(int)$id_product);
if (!empty($nb_custom_values))
@@ -4689,7 +4753,7 @@ class ProductCore extends ObjectModel
ON (a.`id_attribute_group` = g.`id_attribute_group`)
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
AND g.`url_name` IS NOT NULL');
AND g.`url_name` IS NOT NULL AND g.`url_name` != \'\'');
if (empty($group))
{
$group = Db::getInstance()->executeS('
@@ -4778,7 +4842,7 @@ class ProductCore extends ObjectModel
'.Shop::addSqlAssociation('product_attribute', 'pa').'
LEFT JOIN `'._DB_PREFIX_.'layered_indexable_attribute_lang_value` la
ON (la.`id_attribute` = a.`id_attribute` AND la.`id_lang` = '.(int)Context::getContext()->language->id.')
WHERE la.`url_name` IS NOT NULL
WHERE la.`url_name` IS NOT NULL AND la.`url_name` != \'\'
AND pa.`id_product` = '.(int)$id_product);
if (!empty($nb_custom_values))
@@ -4795,7 +4859,7 @@ class ProductCore extends ObjectModel
ON (a.`id_attribute_group` = g.`id_attribute_group`)
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
AND g.`url_name` IS NOT NULL');
AND g.`url_name` IS NOT NULL AND g.`url_name` != \'\'');
if (empty($group))
{
$group = Db::getInstance()->executeS('
@@ -4912,7 +4976,7 @@ class ProductCore extends ObjectModel
{
$query->from('product_attribute', 'pa');
$query->join(Shop::addSqlAssociation('product_attribute', 'pa'));
$query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = '.(int)$id_lang);
$query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl'));
$query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute');
$query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
$query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = '.(int)$id_lang);
@@ -4923,6 +4987,7 @@ class ProductCore extends ObjectModel
{
$query->from('product_lang', 'pl');
$query->where('pl.id_product = '.(int)$id_product);
$query->where('pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl'));
}
return Db::getInstance()->getValue($query);
@@ -5147,5 +5212,42 @@ class ProductCore extends ObjectModel
WHERE pa.`id_product` = '.(int)$this->id
);
}
/**
* For a given ean13 reference, returns the corresponding id
*
* @param string $ean13
* @return int id
*/
public static function getIdByEan13($ean13)
{
if (empty($ean13))
return 0;
if(!Validate::isEan13($ean13))
return 0;
$query = new DbQuery();
$query->select('p.id_product');
$query->from('product', 'p');
$query->where('p.ean13 = \''.pSQL($ean13).'\'');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
}
public function getWsType()
{
$type_information = array(
Product::PTYPE_SIMPLE => 'simple',
Product::PTYPE_PACK => 'pack',
Product::PTYPE_VIRTUAL => 'virtual',
);
return $type_information[$this->getType()];
}
public function getWsProductBundle()
{
return Db::getInstance()->executeS('SELECT id_product_item as id, quantity FROM '._DB_PREFIX_.'pack where id_product_pack = '.(int)$this->id);
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+5 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -68,7 +68,7 @@ class ProductSaleCore
$final_order_by = $order_by;
if (empty($order_by) || $order_by == 'position' || $order_by = 'price') $order_by = 'sales';
if (empty($order_way)) $order_way = 'DESC';
if (empty($order_way) || $order_by == 'sales') $order_way = 'DESC';
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
@@ -98,6 +98,7 @@ class ProductSaleCore
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
'.Product::sqlStock('p').'
WHERE product_shop.`active` = 1
AND p.`visibility` != \'none\'
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `'._DB_PREFIX_.'category_group` cg
@@ -150,6 +151,7 @@ class ProductSaleCore
ON cl.`id_category` = product_shop.`id_category_default`
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
WHERE product_shop.`active` = 1
AND p.`visibility` != \'none\'
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `'._DB_PREFIX_.'category_group` cg
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+4 -4
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -247,7 +247,7 @@ class RequestSqlCore extends ObjectModel
*/
public function cutAttribute($attr, $from)
{
if (preg_match('#^((`(\()?([a-z_])+`(\))?)|((\()?([a-z_])+(\))?))\.((`(\()?([a-z_])+`(\))?)|((\()?([a-z_])+(\))?))$#i', $attr))
if (preg_match('#^((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))\.((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))$#i', $attr))
{
$tab = explode('.', str_replace(array('`', '(', ')'), '', $attr));
if (!$table = $this->returnNameTable($tab[0], $from))
@@ -258,7 +258,7 @@ class RequestSqlCore extends ObjectModel
'attribut' => $tab[1],
'string' => $attr);
}
else if (preg_match('#^((`(\()?([a-z_])+`(\))?)|((\()?([a-z_])+(\))?))$#i', $attr))
elseif (preg_match('#^((`(\()?([a-z0-9_])+`(\))?)|((\()?([a-z0-9_])+(\))?))$#i', $attr))
{
$attribut = str_replace(array('`', '(', ')'), '', $attr);
if (!$table = $this->returnNameTable(false, $from))
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -111,7 +111,7 @@ class SearchCore
$string = preg_replace('/[^\s]-+/', '', $string);
}
$blacklist = Configuration::get('PS_SEARCH_BLACKLIST', $id_lang);
$blacklist = Tools::strtolower(Configuration::get('PS_SEARCH_BLACKLIST', $id_lang));
if (!empty($blacklist))
{
$string = preg_replace('/(?<=\s)('.$blacklist.')(?=\s)/Su', '', $string);
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+5 -5
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -345,7 +345,7 @@ class SpecificPriceCore extends ObjectModel
if (!SpecificPrice::isFeatureActive())
return array();
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT `id_product`, `id_product_attribute`
FROM `'._DB_PREFIX_.'specific_price`
WHERE `id_shop` IN(0, '.(int)$id_shop.') AND
@@ -361,9 +361,9 @@ class SpecificPriceCore extends ObjectModel
)
AND
`reduction` > 0
');
', false);
$ids_product = array();
foreach ($results as $row)
while ($row = Db::getInstance()->nextRow($result))
$ids_product[] = $with_combination_id ? array('id_product' => (int)$row['id_product'], 'id_product_attribute' => (int)$row['id_product_attribute']) : (int)$row['id_product'];
return $ids_product;
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+8 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -243,6 +243,12 @@ class SupplierCore extends ObjectModel
$alias = 'product_shop.';
elseif ($order_by == 'id_product')
$alias = 'p.';
elseif ($order_by == 'manufacturer_name')
{
$order_by = 'name';
$alias = 'm.';
}
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock,
IFNULL(stock.quantity, 0) as quantity,
pl.`description`,
+49 -3
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -42,6 +42,8 @@ class TabCore extends ObjectModel
/** @var integer active */
public $active = true;
const TAB_MODULE_LIST_URL = 'api.prestashop.com/xml/tab_modules_list.xml';
/**
* @see ObjectModel::$definition
@@ -503,4 +505,48 @@ class TabCore extends ObjectModel
{
return Db::getInstance()->getValue('SELECT class_name FROM '._DB_PREFIX_.'tab WHERE id_tab = '.(int)$id_tab);
}
}
public static function getTabModulesList($id_tab)
{
$modules_list = array('default_list' => array(), 'slider_list' => array());
$xml_tab_modules_list = false;
$db_tab_module_list = Db::getInstance()->executeS('
SELECT module
FROM '._DB_PREFIX_.'tab_module_preference
WHERE `id_tab` = '.(int)$id_tab.'
AND `id_employee` = '.(int)Context::getContext()->employee->id
);
if (file_exists(_PS_ROOT_DIR_.Module::CACHE_FILE_TAB_MODULES_LIST))
$xml_tab_modules_list = @simplexml_load_file(_PS_ROOT_DIR_.Module::CACHE_FILE_TAB_MODULES_LIST);
$class_name = null;
$display_type = 'default_list';
if ($xml_tab_modules_list)
foreach($xml_tab_modules_list->tab as $tab)
{
foreach($tab->attributes() as $key => $value)
if ($key == 'class_name')
$class_name = (string)$value;
if (Tab::getIdFromClassName((string)$class_name) == $id_tab)
{
foreach($tab->attributes() as $key => $value)
if ($key == 'display_type')
$display_type = (string)$value;
foreach ($tab->children() as $module)
foreach ($module->attributes() as $k => $v)
if ($k == 'name')
$modules_list[$display_type][] = (string)$v;
}
}
//merge tab modules preferences from db with xml
foreach($db_tab_module_list as $m)
if (!in_array($m, $modules_list))
$modules_list['slider_list'][] = $m['module'];
return $modules_list;
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+63 -29
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -110,7 +110,7 @@ class ToolsCore
}
/**
* Redirect url wich allready PS_BASE_URI
* Redirect URLs already containing PS_BASE_URI
*
* @param string $url Desired URL
*/
@@ -644,14 +644,14 @@ class ToolsCore
{
if (is_array($string))
return array_map(array('Tools', 'htmlentitiesUTF8'), $string);
return htmlentities($string, $type, 'utf-8');
return htmlentities((string)$string, $type, 'utf-8');
}
public static function htmlentitiesDecodeUTF8($string)
{
if (is_array($string))
return array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $string);
return html_entity_decode($string, ENT_QUOTES, 'utf-8');
return html_entity_decode((string)$string, ENT_QUOTES, 'utf-8');
}
public static function safePostVars()
@@ -730,11 +730,16 @@ class ToolsCore
*
* @param object $object Object to display
*/
public static function fd($object)
public static function fd($object, $type = 'log')
{
$types = array('log', 'debug', 'info', 'warn', 'error', 'assert');
if(!in_array($type, $types))
$type = 'log';
echo '
<script type="text/javascript">
console.log('.json_encode($object).');
console.'.$type.'('.json_encode($object).');
</script>
';
}
@@ -968,19 +973,24 @@ class ToolsCore
*/
public static function str2url($str)
{
if (function_exists('mb_strtolower'))
$str = mb_strtolower($str, 'utf-8');
static $allow_accented_chars = null;
if ($allow_accented_chars === null)
$allow_accented_chars = Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
$str = trim($str);
if (!function_exists('mb_strtolower') || !Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
if (function_exists('mb_strtolower'))
$str = mb_strtolower($str, 'utf-8');
elseif (!$allow_accented_chars)
$str = Tools::replaceAccentedChars($str);
// Remove all non-whitelist chars.
if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
if ($allow_accented_chars)
$str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-\pL]/u', '', $str);
else
$str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-]/','', $str);
$str = preg_replace('/[\s\'\:\/\[\]-]+/', ' ', $str);
$str = str_replace(array(' ', '/'), '-', $str);
@@ -1267,18 +1277,28 @@ class ToolsCore
public static function file_get_contents($url, $use_include_path = false, $stream_context = null, $curl_timeout = 5)
{
if ($stream_context == null)
$stream_context = @stream_context_create(array('http' => array('timeout' => 5)));
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
if ($stream_context == null && preg_match('/^https?:\/\//', $url))
$stream_context = @stream_context_create(array('http' => array('timeout' => $curl_timeout)));
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $url))
return @file_get_contents($url, $use_include_path, $stream_context);
elseif (function_exists('curl_init'))
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $curl_timeout);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, $curl_timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$opts = stream_context_get_options($stream_context);
if (isset($opts['http']['method']) && Tools::strtolower($opts['http']['method']) == 'post')
{
curl_setopt($curl, CURLOPT_POST, true);
if (isset($opts['http']['content']))
{
parse_str($opts['http']['content'], $datas);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
}
}
$content = curl_exec($curl);
curl_close($curl);
return $content;
@@ -1289,10 +1309,7 @@ class ToolsCore
public static function simplexml_load_file($url, $class_name = null)
{
if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1')))
return @simplexml_load_string(Tools::file_get_contents($url), $class_name);
else
return false;
return @simplexml_load_string(Tools::file_get_contents($url), $class_name);
}
@@ -1476,7 +1493,7 @@ class ToolsCore
return Tools::getHttpHost();
}
public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false)
public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null)
{
if (defined('PS_INSTALLATION_IN_PROGRESS'))
return true;
@@ -1489,6 +1506,9 @@ class ToolsCore
if (is_null($disable_multiviews))
$disable_multiviews = (int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
if ($disable_modsec === null)
$disable_modsec = (int)Configuration::get('PS_HTACCESS_DISABLE_MODSEC');
// Check current content of .htaccess and save all code outside of prestashop comments
$specific_before = $specific_after = '';
if (file_exists($path))
@@ -1525,6 +1545,18 @@ class ToolsCore
'virtual' => $shop_url->virtual_uri,
'id_shop' => $shop_url->id_shop
);
if ($shop_url->domain == $shop_url->domain_ssl)
continue;
if (!isset($domains[$shop_url->domain_ssl]))
$domains[$shop_url->domain_ssl] = array();
$domains[$shop_url->domain_ssl][] = array(
'physical' => $shop_url->physical_uri,
'virtual' => $shop_url->virtual_uri,
'id_shop' => $shop_url->id_shop
);
}
// Write data in .htaccess file
@@ -1539,6 +1571,9 @@ class ToolsCore
if ($disable_multiviews)
fwrite($write_fd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
if ($disable_modsec)
fwrite($write_fd, "<IfModule mod_security.c>\nSecFilterEngine Off\nSecFilterScanPOST Off\n</IfModule>");
fwrite($write_fd, "RewriteEngine on\n");
if (!$medias)
@@ -1657,11 +1692,9 @@ class ToolsCore
FileETag INode MTime Size
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript
</IfModule>
</IfModule>\n\n";
fwrite($write_fd, $cache_control);
}
@@ -1830,6 +1863,7 @@ exit;
self::$_caching = (int)$smarty->caching;
$smarty->force_compile = 0;
$smarty->caching = (int)$level;
$smarty->cache_lifetime = 31536000; // 1 Year
}
public static function restoreCacheSettings(Context $context = null)
@@ -2198,7 +2232,7 @@ exit;
$filtered_files = array();
$real_ext = '';
$real_ext = false;
if (!empty($ext))
$real_ext = '.'.$ext;
$real_ext_length = strlen($real_ext);
@@ -2206,7 +2240,7 @@ exit;
$subdir = ($dir) ? $dir.'/' : '';
foreach ($files as $file)
{
if (strpos($file, $real_ext) && strpos($file, $real_ext) == (strlen($file) - $real_ext_length))
if (!$real_ext || (strpos($file, $real_ext) && strpos($file, $real_ext) == (strlen($file) - $real_ext_length)))
$filtered_files[] = $subdir.$file;
if ($recursive && $file[0] != '.' && is_dir($real_path.$file))
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
+36 -25
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -46,26 +46,33 @@ class CacheMemcacheCore extends Cache
// Get keys (this code comes from Doctrine 2 project)
$this->keys = array();
$all_slabs = $this->memcache->getExtendedStats('slabs');
foreach ($all_slabs as $server => $slabs)
{
if (is_array($slabs))
{
foreach (array_keys($slabs) as $slab_id)
{
$dump = $this->memcache->getExtendedStats('cachedump', (int)$slab_id);
if ($dump)
{
foreach ($dump as $entries)
{
if ($entries)
$this->keys = array_merge($this->keys, array_keys($entries));
}
}
}
}
}
$servers = self::getMemcachedServers();
if(is_array($servers) && count($servers) > 0 && method_exists('Memcache', 'getStats'))
$all_slabs = $this->memcache->getStats('slabs');
if(isset($all_slabs) && is_array($all_slabs))
foreach ($all_slabs as $server => $slabs)
{
if (is_array($slabs))
{
foreach (array_keys($slabs) as $slab_id)
{
if(is_int($slab_id))
{
$dump = $this->memcache->getStats('cachedump', (int)$slab_id);
if ($dump)
{
foreach ($dump as $entries)
{
if ($entries)
$this->keys = array_merge($this->keys, array_keys($entries));
}
}
}
}
}
}
}
public function __destruct()
@@ -78,12 +85,16 @@ class CacheMemcacheCore extends Cache
*/
public function connect()
{
$this->memcache = new Memcache();
$servers = CacheMemcache::getMemcachedServers();
if (class_exists('Memcache') && extension_loaded('memcache'))
$this->memcache = new Memcache();
else
return false;
$servers = self::getMemcachedServers();
if (!$servers)
return false;
foreach ($servers as $server)
$this->memcache->addServer($server['ip'], $server['port'], $server['weight']);
$this->memcache->addServer($server['ip'], $server['port'], true, (int) $server['weight']);
$this->is_connected = true;
}
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

Some files were not shown because too many files have changed in this diff Show More