Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap
Conflicts: admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl admin-dev/themes/default/template/controllers/modules_positions/form.tpl admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl admin-dev/themes/default/template/controllers/products/input_text_lang.tpl admin-dev/themes/default/template/controllers/products/shipping.tpl admin-dev/themes/default/template/controllers/shipping/content.tpl admin-dev/themes/default/template/helpers/form/form.tpl admin-dev/themes/default/template/helpers/list/list_header.tpl admin-dev/themes/default/template/toolbar.tpl classes/helper/HelperList.php controllers/admin/AdminCategoriesController.php controllers/admin/AdminManufacturersController.php controllers/admin/AdminModulesPositionsController.php controllers/admin/AdminPerformanceController.php controllers/admin/AdminStockInstantStateController.php css/admin.css js/admin-products.js js/admin.js
This commit is contained in:
+4
-5
@@ -313,11 +313,10 @@ class AddressCore extends ObjectModel
|
||||
{
|
||||
$key = 'address_exists_'.(int)$id_address;
|
||||
if (!Cache::isStored($key))
|
||||
Cache::store(
|
||||
$key, Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT `id_address`
|
||||
FROM '._DB_PREFIX_.'address a
|
||||
WHERE a.`id_address` = '.(int)$id_address));
|
||||
{
|
||||
$id_address = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT `id_address` FROM '._DB_PREFIX_.'address a WHERE a.`id_address` = '.(int)$id_address);
|
||||
Cache::store($key, (bool)$id_address);
|
||||
}
|
||||
return Cache::retrieve($key);
|
||||
}
|
||||
|
||||
|
||||
+61
-13
@@ -165,6 +165,14 @@ class CarrierCore extends ObjectModel
|
||||
public function __construct($id = null, $id_lang = null)
|
||||
{
|
||||
parent::__construct($id, $id_lang);
|
||||
|
||||
/**
|
||||
* keep retrocompatibility SHIPPING_METHOD_DEFAULT
|
||||
* @deprecated 1.5.5
|
||||
*/
|
||||
if ($this->shipping_method == Carrier::SHIPPING_METHOD_DEFAULT)
|
||||
$this->shipping_method = ((int)Configuration::get('PS_SHIPPING_METHOD') ? Carrier::SHIPPING_METHOD_WEIGHT : Carrier::SHIPPING_METHOD_PRICE);
|
||||
|
||||
/**
|
||||
* keep retrocompatibility id_tax_rules_group
|
||||
* @deprecated 1.5.0
|
||||
@@ -370,13 +378,12 @@ class CarrierCore extends ObjectModel
|
||||
*/
|
||||
public static function getDeliveryPriceByRanges($range_table, $id_carrier)
|
||||
{
|
||||
$range_table = pSQL($range_table);
|
||||
$sql = 'SELECT d.id_'.$range_table.', d.id_carrier, d.id_zone, d.price
|
||||
$sql = 'SELECT d.`id_'.bqSQL($range_table).'`, d.id_carrier, d.id_zone, d.price
|
||||
FROM '._DB_PREFIX_.'delivery d
|
||||
LEFT JOIN '._DB_PREFIX_.$range_table.' r ON r.id_'.$range_table.' = d.id_'.$range_table.'
|
||||
LEFT JOIN `'._DB_PREFIX_.bqSQL($range_table).'` r ON r.`id_'.bqSQL($range_table).'` = d.`id_'.bqSQL($range_table).'`
|
||||
WHERE d.id_carrier = '.(int)$id_carrier.'
|
||||
AND d.id_'.$range_table.' IS NOT NULL
|
||||
AND d.id_'.$range_table.' != 0
|
||||
AND d.`id_'.bqSQL($range_table).'` IS NOT NULL
|
||||
AND d.`id_'.bqSQL($range_table).'` != 0
|
||||
'.Carrier::sqlDeliveryRangeShop($range_table).'
|
||||
ORDER BY r.delimiter1';
|
||||
return Db::getInstance()->executeS($sql);
|
||||
@@ -456,6 +463,22 @@ class CarrierCore extends ObjectModel
|
||||
return $carriers;
|
||||
}
|
||||
|
||||
public static function getIdTaxRulesGroupMostUsed()
|
||||
{
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT id_tax_rules_group
|
||||
FROM (
|
||||
SELECT COUNT(*) n, c.id_tax_rules_group
|
||||
FROM '._DB_PREFIX_.'carrier c
|
||||
JOIN '._DB_PREFIX_.'tax_rules_group trg ON (c.id_tax_rules_group = trg.id_tax_rules_group)
|
||||
WHERE trg.active = 1
|
||||
GROUP BY c.id_tax_rules_group
|
||||
ORDER BY n DESC
|
||||
LIMIT 1
|
||||
) most_used'
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDeliveredCountries($id_lang, $active_countries = false, $active_carriers = false, $contain_states = null)
|
||||
{
|
||||
if (!Validate::isBool($active_countries) || !Validate::isBool($active_carriers))
|
||||
@@ -712,7 +735,7 @@ class CarrierCore extends ObjectModel
|
||||
*/
|
||||
public function deleteDeliveryPrice($range_table)
|
||||
{
|
||||
$where = '`id_carrier` = '.(int)$this->id.' AND (`id_'.$range_table.'` IS NOT NULL OR `id_'.$range_table.'` = 0) ';
|
||||
$where = '`id_carrier` = '.(int)$this->id.' AND (`id_'.bqSQL($range_table).'` IS NOT NULL OR `id_'.bqSQL($range_table).'` = 0) ';
|
||||
|
||||
if (Shop::getContext() == Shop::CONTEXT_ALL)
|
||||
$where .= 'AND id_shop IS NULL AND id_shop_group IS NULL';
|
||||
@@ -730,7 +753,7 @@ class CarrierCore extends ObjectModel
|
||||
* @param array $priceList Prices list in multiple arrays (changed to array since 1.5.0)
|
||||
* @return boolean Insertion result
|
||||
*/
|
||||
public function addDeliveryPrice($price_list)
|
||||
public function addDeliveryPrice($price_list, $delete = false)
|
||||
{
|
||||
if (!$price_list)
|
||||
return false;
|
||||
@@ -749,6 +772,17 @@ class CarrierCore extends ObjectModel
|
||||
if (!isset($values['id_shop_group']))
|
||||
$values['id_shop_group'] = (Shop::getContext() != Shop::CONTEXT_ALL) ? Shop::getContextShopGroupID() : null;
|
||||
|
||||
if ($delete)
|
||||
Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'delivery`
|
||||
WHERE id_shop = '.(int)$values['id_shop'].'
|
||||
AND id_shop_group='.(int)$values['id_shop_group'].'
|
||||
AND id_carrier='.(int)$values['id_carrier'].
|
||||
($values['id_range_price'] !== null ? ' AND id_range_price='.(int)$values['id_range_price'] : '').
|
||||
($values['id_range_weight'] !== null ? ' AND id_range_weight='.(int)$values['id_range_weight'] : '').'
|
||||
AND id_zone='.(int)$values['id_zone']
|
||||
);
|
||||
|
||||
$sql .= '(';
|
||||
foreach ($values as $v)
|
||||
{
|
||||
@@ -912,9 +946,11 @@ class CarrierCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getRangeObject()
|
||||
public function getRangeObject($shipping_method = false)
|
||||
{
|
||||
$shipping_method = $this->getShippingMethod();
|
||||
if (!$shipping_method)
|
||||
$shipping_method = $this->getShippingMethod();
|
||||
|
||||
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT)
|
||||
return new RangeWeight();
|
||||
elseif ($shipping_method == Carrier::SHIPPING_METHOD_PRICE)
|
||||
@@ -1032,9 +1068,9 @@ class CarrierCore extends ObjectModel
|
||||
$sql = 'AND '.$alias.'.id_delivery = (
|
||||
SELECT d2.id_delivery
|
||||
FROM '._DB_PREFIX_.'delivery d2
|
||||
WHERE d2.id_carrier = '.$alias.'.id_carrier
|
||||
AND d2.id_zone = '.$alias.'.id_zone
|
||||
AND d2.id_'.$range_table.' = '.$alias.'.id_'.$range_table.'
|
||||
WHERE d2.id_carrier = `'.bqSQL($alias).'`.id_carrier
|
||||
AND d2.id_zone = `'.bqSQL($alias).'`.id_zone
|
||||
AND d2.`id_'.bqSQL($range_table).'` = `'.bqSQL($alias).'`.`id_'.bqSQL($range_table).'`
|
||||
'.$where.'
|
||||
ORDER BY d2.id_shop DESC, d2.id_shop_group DESC
|
||||
LIMIT 1
|
||||
@@ -1250,5 +1286,17 @@ class CarrierCore extends ObjectModel
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function setGroups($groups, $delete = true)
|
||||
{
|
||||
if ($delete)
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier = '.(int)$this->id);
|
||||
if (!count($groups))
|
||||
return true;
|
||||
$sql = 'INSERT INTO '._DB_PREFIX_.'carrier_group (id_carrier, id_group) VALUES ';
|
||||
foreach ($groups as $id_group)
|
||||
$sql .= '('.(int)$this->id.', '.(int)$id_group.'),';
|
||||
|
||||
return Db::getInstance()->execute(rtrim($sql, ','));
|
||||
}
|
||||
}
|
||||
|
||||
+16
-11
@@ -134,6 +134,7 @@ class CartCore extends ObjectModel
|
||||
'cart_rows' => array('resource' => 'cart_row', 'virtual_entity' => true, 'fields' => array(
|
||||
'id_product' => array('required' => true, 'xlink_resource' => 'products'),
|
||||
'id_product_attribute' => array('required' => true, 'xlink_resource' => 'combinations'),
|
||||
'id_address_delivery' => array('required' => true, 'xlink_resource' => 'addresses'),
|
||||
'quantity' => array('required' => true),
|
||||
)
|
||||
),
|
||||
@@ -209,7 +210,7 @@ class CartCore extends ObjectModel
|
||||
if (!isset($this->id_address_invoice) || $this->id_address_invoice == $id_address)
|
||||
{
|
||||
$to_update = true;
|
||||
$this->context->cart->id_address_invoice = $id_address_new;
|
||||
$this->id_address_invoice = $id_address_new;
|
||||
}
|
||||
if (!isset($this->id_address_delivery) || $this->id_address_delivery == $id_address)
|
||||
{
|
||||
@@ -764,6 +765,9 @@ class CartCore extends ObjectModel
|
||||
if (!Validate::isLoadedObject($cartRule))
|
||||
return false;
|
||||
|
||||
if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$this->id))
|
||||
return false;
|
||||
|
||||
// Add the cart rule to the cart
|
||||
if (!Db::getInstance()->insert('cart_cart_rule', array(
|
||||
'id_cart_rule' => (int)$id_cart_rule,
|
||||
@@ -3030,8 +3034,10 @@ class CartCore extends ObjectModel
|
||||
public function addTextFieldToProduct($id_product, $index, $type, $text_value)
|
||||
{
|
||||
$text_value = str_replace(array("\n", "\r"), '', nl2br($text_value));
|
||||
$text_value = str_replace('\\', '\\\\', $text_value);
|
||||
$text_value = str_replace('\'', '\\\'', $text_value);
|
||||
if (!_PS_MAGIC_QUOTES_GPC_){
|
||||
$text_value = str_replace('\\', '\\\\', $text_value);
|
||||
$text_value = str_replace('\'', '\\\'', $text_value);
|
||||
}
|
||||
return $this->_addCustomization($id_product, 0, $index, $type, $text_value, 0);
|
||||
}
|
||||
|
||||
@@ -3207,25 +3213,24 @@ class CartCore extends ObjectModel
|
||||
|
||||
public function getWsCartRows()
|
||||
{
|
||||
$query = '
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT id_product, id_product_attribute, quantity
|
||||
FROM `'._DB_PREFIX_.'cart_product`
|
||||
WHERE id_cart = '.(int)$this->id.'
|
||||
AND id_shop = '.(int)Context::getContext()->shop->id;
|
||||
|
||||
$result = Db::getInstance()->executeS($query);
|
||||
return $result;
|
||||
WHERE id_cart = '.(int)$this->id.' AND id_shop = '.(int)Context::getContext()->shop->id
|
||||
);
|
||||
}
|
||||
|
||||
public function setWsCartRows($values)
|
||||
{
|
||||
if ($this->deleteAssociations())
|
||||
{
|
||||
$query = 'INSERT INTO `'._DB_PREFIX_.'cart_product`(`id_cart`, `id_product`, `id_product_attribute`, `quantity`, `date_add`, `id_shop`) VALUES ';
|
||||
$query = 'INSERT INTO `'._DB_PREFIX_.'cart_product`(`id_cart`, `id_product`, `id_product_attribute`, `id_address_delivery`, `quantity`, `date_add`, `id_shop`) VALUES ';
|
||||
|
||||
foreach ($values as $value)
|
||||
$query .= '('.(int)$this->id.', '.(int)$value['id_product'].', '.
|
||||
(isset($value['id_product_attribute']) ? (int)$value['id_product_attribute'] : 'NULL').', '.(int)$value['quantity'].', NOW(), '.(int)Context::getContext()->shop->id.'),';
|
||||
(isset($value['id_product_attribute']) ? (int)$value['id_product_attribute'] : 'NULL').', '.
|
||||
(isset($value['id_address_delivery']) ? (int)$value['id_address_delivery'] : 0).', '.
|
||||
(int)$value['quantity'].', NOW(), '.(int)Context::getContext()->shop->id.'),';
|
||||
|
||||
Db::getInstance()->execute(rtrim($query, ','));
|
||||
}
|
||||
|
||||
+9
-31
@@ -10,7 +10,7 @@
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy 502immediately.
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
@@ -495,36 +495,14 @@ class CartRuleCore extends ObjectModel
|
||||
$cartTotal = $context->cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_PRODUCTS);
|
||||
if ($this->minimum_amount_shipping)
|
||||
$cartTotal += $context->cart->getOrderTotal($this->minimum_amount_tax, Cart::ONLY_SHIPPING);
|
||||
$products = $context->cart->getProducts();
|
||||
$cart_rules = $context->cart->getCartRules();
|
||||
|
||||
// If a product is given for free in this rule and already in the cart, the price is subtracted
|
||||
if ($this->gift_product && $alreadyInCart)
|
||||
{
|
||||
$query = new DbQuery();
|
||||
|
||||
$query->select('id_product');
|
||||
$query->from('cart_product');
|
||||
$query->where('id_product = '.(int)$this->gift_product);
|
||||
$query->where('id_cart = '.(int)$context->cart->id);
|
||||
|
||||
if ((int)$this->gift_product_attribute)
|
||||
$query->where('id_product_attribute = '.(int)$this->gift_product_attribute);
|
||||
|
||||
if (Db::getInstance()->getValue($query))
|
||||
{
|
||||
$ref = false;
|
||||
$product_price = Product::getPriceStatic(
|
||||
$this->gift_product,
|
||||
$this->minimum_amount_tax,
|
||||
$this->gift_product_attribute,
|
||||
null, null, false, true, 1, null,
|
||||
$context->cart->id_customer ? $context->cart->id_customer : null,
|
||||
$context->cart->id,
|
||||
(int)$context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} ? (int)$context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} : null,
|
||||
$ref, true, true, $context, true
|
||||
);
|
||||
$cartTotal -= $product_price;
|
||||
}
|
||||
}
|
||||
foreach ($cart_rules as &$cart_rule)
|
||||
if ($cart_rule['gift_product'])
|
||||
foreach ($products as $key => &$product)
|
||||
if (empty($product['gift']) && $product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute'])
|
||||
$cartTotal = Tools::ps_round($cartTotal - $product[$this->minimum_amount_tax ? 'price_wt' : 'price'], (int)$context->currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
|
||||
|
||||
if ($cartTotal < $minimum_amount)
|
||||
return (!$display_error) ? false : Tools::displayError('You have not reached the minimum amount required to use this voucher');
|
||||
@@ -1130,7 +1108,7 @@ class CartRuleCore extends ObjectModel
|
||||
WHERE `id_cart` = '.(int)$context->cart->id.'
|
||||
)
|
||||
)
|
||||
AND cr.id_cart_rule NOT IN (SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$context->cart->id.')
|
||||
AND cr.id_cart_rule NOT IN (SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$context->cart->id.')
|
||||
ORDER BY priority';
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
if ($result)
|
||||
|
||||
@@ -74,6 +74,16 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
|
||||
* @var int Total of elements for iteration
|
||||
*/
|
||||
protected $total;
|
||||
|
||||
/**
|
||||
* @var int Page number
|
||||
*/
|
||||
protected $page_number = 0;
|
||||
|
||||
/**
|
||||
* @var int Size of a page
|
||||
*/
|
||||
protected $page_size = 0;
|
||||
|
||||
protected $fields = array();
|
||||
protected $alias = array();
|
||||
@@ -334,6 +344,11 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// All limit clause
|
||||
if ($this->page_size)
|
||||
$this->query->limit($this->page_size, $this->page_number * $this->page_size);
|
||||
|
||||
|
||||
// Shall we display query for debug ?
|
||||
if ($display_query)
|
||||
@@ -659,6 +674,34 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
|
||||
}
|
||||
return $this->fields[$field];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the page number
|
||||
*
|
||||
* @param int $page_number
|
||||
* @return Collection
|
||||
*/
|
||||
public function setPageNumber($page_number)
|
||||
{
|
||||
$page_number = (int)$page_number;
|
||||
if ($page_number > 0)
|
||||
$page_number--;
|
||||
|
||||
$this->page_number = $page_number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nuber of item per page
|
||||
*
|
||||
* @param int $page_size
|
||||
* @return Collection
|
||||
*/
|
||||
public function setPageSize($page_size)
|
||||
{
|
||||
$this->page_size = (int)$page_size;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate uniq alias from association name
|
||||
|
||||
@@ -49,7 +49,6 @@ class ConfigurationTestCore
|
||||
'mysql_support' => false,
|
||||
'config_dir' => 'config',
|
||||
'cache_dir' => 'cache',
|
||||
'sitemap' => 'sitemap.xml',
|
||||
'log_dir' => 'log',
|
||||
'img_dir' => 'img',
|
||||
'mails_dir' => 'mails',
|
||||
|
||||
@@ -298,7 +298,11 @@ class CookieCore
|
||||
|
||||
//checks if the language exists, if not choose the default language
|
||||
if (!$this->_standalone && !Language::getLanguage((int)$this->id_lang))
|
||||
{
|
||||
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
|
||||
// set detect_language to force going through Tools::setCookieLanguage to figure out browser lang
|
||||
$this->detect_language = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+33
-19
@@ -126,7 +126,9 @@ class HookCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'hook_alias` ha
|
||||
INNER JOIN `'._DB_PREFIX_.'hook` h ON ha.name = h.name');
|
||||
foreach ($result as $row)
|
||||
{
|
||||
$hook_ids[$row['name']] = $row['id_hook'];
|
||||
}
|
||||
Cache::store($cache_id, $hook_ids);
|
||||
}
|
||||
else
|
||||
@@ -147,9 +149,23 @@ class HookCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'hook`
|
||||
WHERE `id_hook` = '.(int)$hook_id)
|
||||
);
|
||||
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return hook live edit bool from ID
|
||||
*/
|
||||
public static function getLiveEditById($hook_id)
|
||||
{
|
||||
$cache_id = 'hook_live_editbyid_'.$hook_id;
|
||||
if (!Cache::isStored($cache_id))
|
||||
Cache::store($cache_id, Db::getInstance()->getValue('
|
||||
SELECT `live_edit`
|
||||
FROM `'._DB_PREFIX_.'hook`
|
||||
WHERE `id_hook` = '.(int)$hook_id)
|
||||
);
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of hook alias
|
||||
@@ -315,15 +331,9 @@ class HookCore extends ObjectModel
|
||||
|
||||
$sql->orderBy('hm.`position`');
|
||||
|
||||
// Store results per hook name
|
||||
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
$list = array();
|
||||
|
||||
// Get all available payment module
|
||||
$payment_modules = array();
|
||||
|
||||
if ($results)
|
||||
foreach ($results as $row)
|
||||
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
|
||||
foreach ($result as $row)
|
||||
{
|
||||
$row['hook'] = strtolower($row['hook']);
|
||||
if (!isset($list[$row['hook']]))
|
||||
@@ -353,14 +363,17 @@ class HookCore extends ObjectModel
|
||||
$hook_name = strtolower($hook_name);
|
||||
|
||||
$return = array();
|
||||
$inserted_modules = array();
|
||||
if (isset($list[$hook_name]))
|
||||
$return = $list[$hook_name];
|
||||
foreach ($return as $module)
|
||||
$inserted_modules[] = $module['id_module'];
|
||||
if (isset($list[$retro_hook_name]))
|
||||
$return = array_merge($return, $list[$retro_hook_name]);
|
||||
foreach ($list[$retro_hook_name] as $retro_module_call)
|
||||
if (!in_array($retro_module_call['id_module'], $inserted_modules))
|
||||
$return[] = $retro_module_call;
|
||||
|
||||
if (count($return) > 0)
|
||||
return $return;
|
||||
return false;
|
||||
return (count($return) > 0 ? $return : false);
|
||||
}
|
||||
else
|
||||
return $list;
|
||||
@@ -404,6 +417,7 @@ class HookCore extends ObjectModel
|
||||
// Look on modules list
|
||||
$altern = 0;
|
||||
$output = '';
|
||||
|
||||
foreach ($module_list as $array)
|
||||
{
|
||||
// Check errors
|
||||
@@ -417,7 +431,7 @@ class HookCore extends ObjectModel
|
||||
{
|
||||
$exceptions = $moduleInstance->getExceptions($array['id_hook']);
|
||||
$controller = Dispatcher::getInstance()->getController();
|
||||
|
||||
|
||||
if (in_array($controller, $exceptions))
|
||||
continue;
|
||||
|
||||
@@ -425,7 +439,7 @@ class HookCore extends ObjectModel
|
||||
$matching_name = array(
|
||||
'authentication' => 'auth',
|
||||
'compare' => 'products-comparison',
|
||||
);
|
||||
);
|
||||
if (isset($matching_name[$controller]) && in_array($matching_name[$controller], $exceptions))
|
||||
continue;
|
||||
if (Validate::isLoadedObject($context->employee) && !$moduleInstance->getPermission('view', $context->employee))
|
||||
@@ -459,7 +473,7 @@ class HookCore extends ObjectModel
|
||||
if ($array_return)
|
||||
return $output;
|
||||
else
|
||||
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\'); </script>
|
||||
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\');</script>
|
||||
<div id="'.$hook_name.'" class="dndHook" style="min-height:50px">' : '').$output.($live_edit ? '</div>' : '');// Return html string
|
||||
}
|
||||
|
||||
@@ -468,13 +482,13 @@ class HookCore extends ObjectModel
|
||||
return '<script type="text/javascript"> modules_list.push(\''.Tools::safeOutput($moduleInstance->name).'\');</script>
|
||||
<div id="hook_'.(int)$id_hook.'_module_'.(int)$moduleInstance->id.'_moduleName_'.str_replace('_', '-', Tools::safeOutput($moduleInstance->name)).'"
|
||||
class="dndModule" style="border: 1px dotted red;'.(!strlen($display) ? 'height:50px;' : '').'">
|
||||
<span style="font-family: Georgia;font-size:13px;font-style:italic;">
|
||||
<img style="padding-right:5px;" src="'._MODULE_DIR_.Tools::safeOutput($moduleInstance->name).'/logo.gif">'
|
||||
<span style="font-family: Georgia;font-size:13px;font-style:italic;">
|
||||
<img style="padding-right:5px;" src="'._MODULE_DIR_.Tools::safeOutput($moduleInstance->name).'/logo.gif">'
|
||||
.Tools::safeOutput($moduleInstance->displayName).'<span style="float:right">
|
||||
<a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="moveModule">
|
||||
<img src="'._PS_ADMIN_IMG_.'arrow_out.png"></a>
|
||||
<a href="#" id="'.(int)$id_hook.'_'.(int)$moduleInstance->id.'" class="unregisterHook">
|
||||
<img src="'._PS_ADMIN_IMG_.'delete.gif"></span></a>
|
||||
<img src="'._PS_ADMIN_IMG_.'delete.gif"></a></span>
|
||||
</span>'.$display.'</div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -407,6 +407,7 @@ class ImageManagerCore
|
||||
case 'jpeg':
|
||||
default:
|
||||
$quality = (Configuration::get('PS_JPEG_QUALITY') === false ? 90 : Configuration::get('PS_JPEG_QUALITY'));
|
||||
imageinterlace($resource,1); /// make it PROGRESSIVE
|
||||
$success = imagejpeg($resource, $filename, (int)$quality);
|
||||
break;
|
||||
}
|
||||
|
||||
+25
-31
@@ -192,7 +192,7 @@ class LanguageCore extends ObjectModel
|
||||
|
||||
public function add($autodate = true, $nullValues = false, $only_add = false)
|
||||
{
|
||||
if (!parent::add($autodate))
|
||||
if (!parent::add($autodate, $nullValues))
|
||||
return false;
|
||||
|
||||
if ($only_add)
|
||||
@@ -202,10 +202,9 @@ class LanguageCore extends ObjectModel
|
||||
$this->_generateFiles();
|
||||
|
||||
// @todo Since a lot of modules are not in right format with their primary keys name, just get true ...
|
||||
$resUpdateSQL = $this->loadUpdateSQL();
|
||||
$resUpdateSQL = true;
|
||||
Tools::generateHtaccess();
|
||||
return $resUpdateSQL;
|
||||
$this->loadUpdateSQL();
|
||||
|
||||
return Tools::generateHtaccess();
|
||||
}
|
||||
|
||||
public function toggleStatus()
|
||||
@@ -488,7 +487,8 @@ class LanguageCore extends ObjectModel
|
||||
// Files deletion
|
||||
foreach (Language::getFilesList($this->iso_code, _THEME_NAME_, false, false, false, true, true) as $key => $file)
|
||||
if (file_exists($key))
|
||||
unlink($key);
|
||||
unlink($key);
|
||||
|
||||
$modList = scandir(_PS_MODULE_DIR_);
|
||||
foreach ($modList as $mod)
|
||||
{
|
||||
@@ -510,37 +510,32 @@ class LanguageCore extends ObjectModel
|
||||
Language::recurseDeleteDir(_PS_MAIL_DIR_.$this->iso_code);
|
||||
if (file_exists(_PS_TRANSLATIONS_DIR_.$this->iso_code))
|
||||
Language::recurseDeleteDir(_PS_TRANSLATIONS_DIR_.$this->iso_code);
|
||||
}
|
||||
|
||||
if (!parent::delete())
|
||||
return false;
|
||||
if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL)
|
||||
{
|
||||
// delete images
|
||||
$files_copy = array(
|
||||
'/en.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('thickbox').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('home').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('large').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('medium').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('small').'.jpg'
|
||||
|
||||
$images = array(
|
||||
'.jpg',
|
||||
'-default-'.ImageType::getFormatedName('thickbox').'.jpg',
|
||||
'-default-'.ImageType::getFormatedName('home').'.jpg',
|
||||
'-default-'.ImageType::getFormatedName('large').'.jpg',
|
||||
'-default-'.ImageType::getFormatedName('medium').'.jpg',
|
||||
'-default-'.ImageType::getFormatedName('small').'.jpg'
|
||||
);
|
||||
$tos = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
|
||||
foreach ($tos as $to)
|
||||
foreach ($files_copy as $file)
|
||||
$image_directories = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
|
||||
foreach ($images_directories as $image_directory)
|
||||
foreach ($images as $image)
|
||||
{
|
||||
$name = str_replace('/en', ''.$this->iso_code, $file);
|
||||
|
||||
if (file_exists($to.$name))
|
||||
unlink($to.$name);
|
||||
if (file_exists($image_directory.$this->iso_code.$image))
|
||||
unlink($image_directory.$this->iso_code.$image);
|
||||
if (file_exists(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg'))
|
||||
unlink(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg');
|
||||
}
|
||||
}
|
||||
|
||||
if (!parent::delete())
|
||||
return false;
|
||||
|
||||
return Tools::generateHtaccess();
|
||||
}
|
||||
|
||||
|
||||
public function deleteSelection($selection)
|
||||
{
|
||||
if (!is_array($selection))
|
||||
@@ -549,11 +544,10 @@ class LanguageCore extends ObjectModel
|
||||
$result = true;
|
||||
foreach ($selection as $id)
|
||||
{
|
||||
$this->id = (int)($id);
|
||||
$result = $result && $this->delete();
|
||||
$language = new Language($id);
|
||||
$result = $result && $language->delete();
|
||||
}
|
||||
|
||||
Tools::generateHtaccess();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -91,10 +91,10 @@ class LinkCore
|
||||
if (!$id_lang)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
if ($id_shop === null)
|
||||
$shop = Context::getContext()->shop;
|
||||
else
|
||||
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null)
|
||||
$shop = new Shop($id_shop);
|
||||
else
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
||||
|
||||
|
||||
@@ -70,8 +70,16 @@ class LocalizationPackCore
|
||||
return $res;
|
||||
}
|
||||
foreach ($selection as $selected)
|
||||
if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install'.ucfirst($selected)}($xml))
|
||||
return false;
|
||||
if (strtolower((string)$selected) == 'currencies')
|
||||
{
|
||||
if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install'.ucfirst($selected)}($xml, true))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install'.ucfirst($selected)}($xml))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -239,8 +247,6 @@ class LocalizationPackCore
|
||||
{
|
||||
if (isset($xml->currencies->currency))
|
||||
{
|
||||
|
||||
|
||||
foreach ($xml->currencies->currency as $data)
|
||||
{
|
||||
$attributes = $data->attributes();
|
||||
|
||||
+12
-3
@@ -52,7 +52,8 @@ class MailCore
|
||||
* @param bool $die
|
||||
*/
|
||||
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)
|
||||
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
|
||||
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null)
|
||||
{
|
||||
$configuration = Configuration::getMultiple(array(
|
||||
'PS_SHOP_EMAIL',
|
||||
@@ -146,7 +147,10 @@ class MailCore
|
||||
if ($to_name == null)
|
||||
$to_name = $addr;
|
||||
/* Encode accentuated chars */
|
||||
$to_list->addTo($addr, '=?UTF-8?B?'.base64_encode($to_name).'?=');
|
||||
if (function_exists('mb_encode_mimeheader'))
|
||||
$to_list->addTo($addr, mb_encode_mimeheader($to_name, 'utf-8'));
|
||||
else
|
||||
$to_list->addTo($addr, '=?UTF-8?B?'.base64_encode($to_name).'?=');
|
||||
}
|
||||
$to_plugin = $to[0];
|
||||
$to = $to_list;
|
||||
@@ -155,7 +159,10 @@ class MailCore
|
||||
$to_plugin = $to;
|
||||
if ($to_name == null)
|
||||
$to_name = $to;
|
||||
$to = new Swift_Address($to, '=?UTF-8?B?'.base64_encode($to_name).'?=');
|
||||
if (function_exists('mb_encode_mimeheader'))
|
||||
$to = new Swift_Address($to, mb_encode_mimeheader($to_name, 'utf-8'));
|
||||
else
|
||||
$to = new Swift_Address($to, '=?UTF-8?B?'.base64_encode($to_name).'?=');
|
||||
}
|
||||
try {
|
||||
/* Connect with the appropriate configuration */
|
||||
@@ -230,6 +237,8 @@ class MailCore
|
||||
/* Create mail and attach differents parts */
|
||||
$message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME', null, null, $id_shop).'] '.$subject);
|
||||
|
||||
$message->setCharset('utf-8');
|
||||
|
||||
/* Set Message-ID - getmypid() is blocked on some hosting */
|
||||
$message->setId(Mail::generateId());
|
||||
|
||||
|
||||
+10
-2
@@ -224,7 +224,7 @@ class MediaCore
|
||||
$url_data = parse_url($css_uri);
|
||||
$file_uri = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
|
||||
// check if css files exists
|
||||
if (!@filemtime($file_uri))
|
||||
if (!@filemtime($file_uri) && !array_key_exists('host', $url_data))
|
||||
return false;
|
||||
|
||||
if (Context::getContext()->controller->controller_type == 'admin')
|
||||
@@ -386,6 +386,7 @@ class MediaCore
|
||||
{
|
||||
//inits
|
||||
$css_files_by_media = array();
|
||||
$external_css_files = array();
|
||||
$compressed_css_files = array();
|
||||
$compressed_css_files_not_found = array();
|
||||
$compressed_css_files_infos = array();
|
||||
@@ -400,6 +401,13 @@ class MediaCore
|
||||
$infos = array();
|
||||
$infos['uri'] = $filename;
|
||||
$url_data = parse_url($filename);
|
||||
|
||||
if(array_key_exists('host', $url_data))
|
||||
{
|
||||
$external_css_files[$filename] = $media;
|
||||
continue;
|
||||
}
|
||||
|
||||
$infos['path'] = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, '/', $url_data['path']);
|
||||
$css_files_by_media[$media]['files'][] = $infos;
|
||||
if (!array_key_exists('date', $css_files_by_media[$media]))
|
||||
@@ -461,7 +469,7 @@ class MediaCore
|
||||
$url = str_replace(_PS_THEME_DIR_, _THEMES_DIR_._THEME_NAME_.'/', $filename);
|
||||
$css_files[$protocol_link.Tools::getMediaServer($url).$url] = $media;
|
||||
}
|
||||
return $css_files;
|
||||
return array_merge($external_css_files, $css_files);
|
||||
}
|
||||
|
||||
public static function getBackTrackLimit()
|
||||
|
||||
+29
-24
@@ -535,28 +535,28 @@ abstract class ObjectModelCore
|
||||
return false;
|
||||
|
||||
$object_id = Db::getInstance()->Insert_ID();
|
||||
|
||||
|
||||
if (isset($definition['multilang']) && $definition['multilang'])
|
||||
{
|
||||
$res = Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.bqSQL($definition['table']).'_lang`
|
||||
WHERE `'.bqSQL($definition['primary']).'` = '.(int)$this->id
|
||||
);
|
||||
|
||||
if (!$res)
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.bqSQL($definition['table']).'_lang`
|
||||
WHERE `'.bqSQL($definition['primary']).'` = '.(int)$this->id);
|
||||
if (!$result)
|
||||
return false;
|
||||
|
||||
foreach ($res as $field => &$value)
|
||||
if (isset($definition['fields'][$field]))
|
||||
$value = ObjectModel::formatValue($value, $definition['fields'][$field]['type']);
|
||||
|
||||
foreach ($res as $row)
|
||||
|
||||
foreach ($result as &$row)
|
||||
foreach ($row as $field => &$value)
|
||||
if (isset($definition['fields'][$field]))
|
||||
$value = ObjectModel::formatValue($value, $definition['fields'][$field]['type']);
|
||||
|
||||
// Keep $row2, you cannot use $row because there is an unexplicated conflict with the previous usage of this variable
|
||||
foreach ($result as $row2)
|
||||
{
|
||||
$row[$definition['primary']] = (int)$object_id;
|
||||
if (!Db::getInstance()->insert($definition['table'].'_lang', $row))
|
||||
$row2[$definition['primary']] = (int)$object_id;
|
||||
if (!Db::getInstance()->insert($definition['table'].'_lang', $row2))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$object_duplicated = new $definition['classname']((int)$object_id);
|
||||
@@ -857,8 +857,12 @@ abstract class ObjectModelCore
|
||||
continue;
|
||||
|
||||
$values = $this->$field;
|
||||
|
||||
// If the object has not been loaded in multilanguage, then the value is the one for the current language of the object
|
||||
if (!is_array($values))
|
||||
$values = array($this->id_lang => $values);
|
||||
|
||||
// The value for the default must always be set, so we put an empty string if it does not exists
|
||||
if (!isset($values[Configuration::get('PS_LANG_DEFAULT')]))
|
||||
$values[Configuration::get('PS_LANG_DEFAULT')] = '';
|
||||
|
||||
@@ -979,17 +983,18 @@ abstract class ObjectModelCore
|
||||
$required_fields_database = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array();
|
||||
foreach ($this->def['fields'] as $field => $data)
|
||||
{
|
||||
$value = Tools::getValue($field, $this->{$field});
|
||||
// Check if field is required by user
|
||||
if (in_array($field, $required_fields_database))
|
||||
$data['required'] = true;
|
||||
|
||||
// Checking for required fields
|
||||
if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
|
||||
if (isset($data['required']) && $data['required'] && empty($value) && $value !== '0')
|
||||
if (!$this->id || $field != 'passwd')
|
||||
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
|
||||
|
||||
// Checking for maximum fields sizes
|
||||
if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size'])
|
||||
if (isset($data['size']) && !empty($value) && Tools::strlen($value) > $data['size'])
|
||||
$errors[$field] = sprintf(
|
||||
Tools::displayError('%1$s is too long. Maximum length: %2$d'),
|
||||
self::displayFieldName($field, get_class($this), $htmlentities),
|
||||
@@ -998,7 +1003,7 @@ abstract class ObjectModelCore
|
||||
|
||||
// Checking for fields validity
|
||||
// Hack for postcode required for country which does not have postcodes
|
||||
if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0'))
|
||||
if (!empty($value) || $value === '0' || ($field == 'postcode' && $value == '0'))
|
||||
{
|
||||
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required']))
|
||||
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
|
||||
@@ -1322,7 +1327,7 @@ abstract class ObjectModelCore
|
||||
* @param string $specific_where Only executed for common table
|
||||
* @return bool
|
||||
*/
|
||||
public static function updateMultishopTable($classname, $data, $where, $specific_where = '')
|
||||
public static function updateMultishopTable($classname, $data, $where = '', $specific_where = '')
|
||||
{
|
||||
$def = ObjectModel::getDefinition($classname);
|
||||
$update_data = array();
|
||||
@@ -1342,8 +1347,8 @@ abstract class ObjectModelCore
|
||||
|
||||
$sql = 'UPDATE '._DB_PREFIX_.$def['table'].' a
|
||||
'.Shop::addSqlAssociation($def['table'], 'a', true, null, true).'
|
||||
SET '.implode(', ', $update_data).'
|
||||
WHERE '.$where;
|
||||
SET '.implode(', ', $update_data).
|
||||
(!empty($where) ? ' WHERE '.$where : '');
|
||||
return Db::getInstance()->execute($sql);
|
||||
}
|
||||
|
||||
@@ -1632,4 +1637,4 @@ abstract class ObjectModelCore
|
||||
{
|
||||
$this->update_fields = $fields;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,7 +348,8 @@ abstract class PaymentModuleCore extends Module
|
||||
// Construct order detail table for the email
|
||||
$products_list = '';
|
||||
$virtual_product = true;
|
||||
foreach ($products as $key => $product)
|
||||
|
||||
foreach ($order->product_list as $key => $product)
|
||||
{
|
||||
$price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$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')});
|
||||
@@ -604,7 +605,8 @@ abstract class PaymentModuleCore extends Module
|
||||
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false));
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
|
||||
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
|
||||
|
||||
if (is_array($extra_vars))
|
||||
$data = array_merge($data, $extra_vars);
|
||||
|
||||
+142
-51
@@ -364,7 +364,7 @@ class ProductCore extends ObjectModel
|
||||
),
|
||||
'type' => array(
|
||||
'getter' => 'getWsType',
|
||||
'setter' => false,
|
||||
'setter' => 'setWsType',
|
||||
),
|
||||
),
|
||||
'associations' => array(
|
||||
@@ -668,6 +668,45 @@ class ProductCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given id_product and id_product_attribute, return available date
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $id_product_attribute Optional
|
||||
* @return string/null
|
||||
*/
|
||||
public static function getAvailableDate($id_product, $id_product_attribute = null)
|
||||
{
|
||||
$sql = 'SELECT';
|
||||
|
||||
if ($id_product_attribute === null)
|
||||
$sql .= ' p.`available_date`';
|
||||
else
|
||||
$sql .= ' IF(pa.`available_date` = "0000-00-00", p.`available_date`, pa.`available_date`) AS available_date';
|
||||
|
||||
$sql .= ' FROM `'._DB_PREFIX_.'product` p';
|
||||
|
||||
if ($id_product_attribute !== null)
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.`id_product` = p.`id_product`)';
|
||||
|
||||
$sql .= Shop::addSqlAssociation('product', 'p');
|
||||
|
||||
if ($id_product_attribute !== null)
|
||||
$sql .= Shop::addSqlAssociation('product_attribute', 'pa');
|
||||
|
||||
$sql .= ' WHERE p.`id_product` = '.(int)$id_product;
|
||||
|
||||
if ($id_product_attribute !== null)
|
||||
$sql .= ' AND pa.`id_product` = '.(int)$id_product.' AND pa.`id_product_attribute` = '.(int)$id_product_attribute;
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
|
||||
if ($result == '0000-00-00')
|
||||
$result = null;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function updateIsVirtual($id_product)
|
||||
{
|
||||
Db::getInstance()->update('product', array(
|
||||
@@ -1300,7 +1339,7 @@ class ProductCore extends ObjectModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Supplier Reference
|
||||
* Sets or updates Supplier Reference
|
||||
*
|
||||
* @param int $id_supplier
|
||||
* @param int $id_product_attribute
|
||||
@@ -1313,30 +1352,25 @@ class ProductCore extends ObjectModel
|
||||
//in some case we need to add price without supplier reference
|
||||
if ($supplier_reference === null)
|
||||
$supplier_reference = '';
|
||||
|
||||
|
||||
//Try to set the default supplier reference
|
||||
if ($id_supplier > 0)
|
||||
if (($id_supplier > 0) && ($id_product > 0))
|
||||
{
|
||||
$id_product_supplier = (int)ProductSupplier::getIdByProductAndSupplier($this->id, $id_product_attribute, $id_supplier);
|
||||
|
||||
$product_supplier = new ProductSupplier($id_product_supplier);
|
||||
|
||||
if (!$id_product_supplier)
|
||||
{
|
||||
//create new record
|
||||
$product_supplier_entity = new ProductSupplier();
|
||||
$product_supplier_entity->id_product = (int)$this->id;
|
||||
$product_supplier_entity->id_product_attribute = (int)$id_product_attribute;
|
||||
$product_supplier_entity->id_supplier = (int)$id_supplier;
|
||||
$product_supplier_entity->product_supplier_reference = pSQL($supplier_reference);
|
||||
$product_supplier_entity->product_supplier_price_te = (int)$price;
|
||||
$product_supplier_entity->id_currency = (int)$id_currency;
|
||||
$product_supplier_entity->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$product_supplier = new ProductSupplier((int)$id_product_supplier);
|
||||
$product_supplier->product_supplier_reference = pSQL($supplier_reference);
|
||||
$product_supplier->update();
|
||||
$product_supplier->id_product = (int)$this->id;
|
||||
$product_supplier->id_product_attribute = (int)$id_product_attribute;
|
||||
$product_supplier->id_supplier = (int)$id_supplier;
|
||||
}
|
||||
|
||||
$product_supplier->product_supplier_reference = pSQL($supplier_reference);
|
||||
$product_supplier->product_supplier_price_te = (float)$price;
|
||||
$product_supplier->id_currency = (int)$id_currency;
|
||||
$product_supplier->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1978,13 +2012,7 @@ class ProductCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE product_shop.`active` = 1
|
||||
AND DATEDIFF(
|
||||
product_shop.`date_add`,
|
||||
DATE_SUB(
|
||||
NOW(),
|
||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
|
||||
)
|
||||
) > 0
|
||||
AND product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'"
|
||||
'.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').'
|
||||
AND p.`id_product` IN (
|
||||
SELECT cp.`id_product`
|
||||
@@ -1999,13 +2027,7 @@ class ProductCore extends ObjectModel
|
||||
$sql->select(
|
||||
'p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
|
||||
pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name,
|
||||
DATEDIFF(
|
||||
product_shop.`date_add`,
|
||||
DATE_SUB(
|
||||
NOW(),
|
||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
|
||||
)
|
||||
) > 0 AS new'
|
||||
product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'" as new'
|
||||
);
|
||||
|
||||
$sql->from('product', 'p');
|
||||
@@ -2020,25 +2042,15 @@ class ProductCore extends ObjectModel
|
||||
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
||||
|
||||
$sql->where('product_shop.`active` = 1');
|
||||
|
||||
if ($front)
|
||||
$sql->where('product_shop.`visibility` IN ("both", "catalog")');
|
||||
$sql->where('
|
||||
DATEDIFF(
|
||||
product_shop.`date_add`,
|
||||
DATE_SUB(
|
||||
NOW(),
|
||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
|
||||
)
|
||||
) > 0'
|
||||
);
|
||||
|
||||
$sql->where('product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'"');
|
||||
$sql->where('p.`id_product` IN (
|
||||
SELECT cp.`id_product`
|
||||
FROM `'._DB_PREFIX_.'category_group` cg
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.')'
|
||||
);
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)');
|
||||
$sql->groupBy('product_shop.id_product');
|
||||
|
||||
$sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way));
|
||||
@@ -2372,8 +2384,14 @@ class ProductCore extends ObjectModel
|
||||
WHERE id_product = '.(int)$this->id.'
|
||||
AND id_shop = '.(int)$this->id_shop
|
||||
);
|
||||
if (count($data))
|
||||
Db::getInstance()->insert('product_carrier', $data);
|
||||
|
||||
$uniqueArray = array();
|
||||
foreach($data as $subArray)
|
||||
if(!in_array($subArray, $uniqueArray))
|
||||
$uniqueArray[] = $subArray;
|
||||
|
||||
if (count($uniqueArray))
|
||||
Db::getInstance()->insert('product_carrier', $uniqueArray, false, true, Db::INSERT_IGNORE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4740,6 +4758,44 @@ class ProductCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'product_tag`
|
||||
WHERE `id_product` = '.(int)$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Webservice setter : set tag ids of current product for association
|
||||
*
|
||||
* @param $tag_ids tag ids
|
||||
*/
|
||||
public function setWsTags($tag_ids)
|
||||
{
|
||||
$ids = array();
|
||||
foreach ($tag_ids as $value)
|
||||
$ids[] = $value['id'];
|
||||
if ($this->deleteWsTags())
|
||||
{
|
||||
if ($ids)
|
||||
{
|
||||
$sql_values = '';
|
||||
$ids = array_map('intval', $ids);
|
||||
foreach ($ids as $position => $id)
|
||||
$sql_values[] = '('.(int)$this->id.', '.(int)$id.')';
|
||||
$result = Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'product_tag` (`id_product`, `id_tag`)
|
||||
VALUES '.implode(',', $sql_values)
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete products tags entries without delete tags for webservice usage
|
||||
*
|
||||
* @return array Deletion result
|
||||
*/
|
||||
public function deleteWsTags()
|
||||
{
|
||||
return Db::getInstance()->delete('product_tag', 'id_product = '.(int)$this->id);
|
||||
}
|
||||
|
||||
|
||||
public function getWsManufacturerName()
|
||||
@@ -4751,7 +4807,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
return ObjectModel::updateMultishopTable('product', array(
|
||||
'ecotax' => 0,
|
||||
), '');
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5344,6 +5400,41 @@ class ProductCore extends ObjectModel
|
||||
|
||||
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);
|
||||
return Db::getInstance()->executeS('SELECT id_product_item as id, quantity FROM '._DB_PREFIX_.'pack WHERE id_product_pack = '.(int)$this->id);
|
||||
}
|
||||
}
|
||||
|
||||
public function setWsType($type_str)
|
||||
{
|
||||
$reverse_type_information = array(
|
||||
'simple' => Product::PTYPE_SIMPLE,
|
||||
'pack' => Product::PTYPE_PACK,
|
||||
'virtual' => Product::PTYPE_VIRTUAL,
|
||||
);
|
||||
|
||||
if (!isset($reverse_type_information[$type_str]))
|
||||
return false;
|
||||
|
||||
$type = $reverse_type_information[$type_str];
|
||||
|
||||
if (Pack::isPack((int)$this->id) && $type != Product::PTYPE_PACK)
|
||||
Pack::deleteItems($this->id);
|
||||
|
||||
$this->cache_is_pack = ($type == Product::PTYPE_PACK);
|
||||
$this->is_virtual = ($type == Product::PTYPE_VIRTUAL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setWsProductBundle($items)
|
||||
{
|
||||
if($this->is_virtual)
|
||||
return false;
|
||||
|
||||
Pack::deleteItems($this->id);
|
||||
|
||||
foreach ($items as $item)
|
||||
if((int)$item['id'] > 0)
|
||||
Pack::addItem($this->id, (int)$item['id'], (int)$item['quantity']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,10 +299,10 @@ class ProductDownloadCore extends ObjectModel
|
||||
*/
|
||||
public static function getNewFilename()
|
||||
{
|
||||
$ret = sha1(microtime());
|
||||
if (file_exists(_PS_DOWNLOAD_DIR_.$ret))
|
||||
$ret = ProductDownload::getNewFilename();
|
||||
return $ret;
|
||||
do {
|
||||
$filename = sha1(microtime());
|
||||
} while (file_exists(_PS_DOWNLOAD_DIR_.$filename));
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,4 +314,4 @@ class ProductDownloadCore extends ObjectModel
|
||||
{
|
||||
return Configuration::get('PS_VIRTUAL_PROD_FEATURE_ACTIVE');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class ProductSaleCore
|
||||
if ($nb_products < 1) $nb_products = 10;
|
||||
$final_order_by = $order_by;
|
||||
if (is_null($order_by) || $order_by == 'position' || $order_by == 'price') $order_by = 'sales';
|
||||
if (is_null($order_way) || $order_by == 'sales') $order_way == 'DESC';
|
||||
if (is_null($order_way) || $order_by == 'sales') $order_way = 'DESC';
|
||||
$groups = FrontController::getCurrentCustomerGroups();
|
||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
||||
$interval = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
|
||||
|
||||
+1
-1
@@ -410,7 +410,7 @@ class SearchCore
|
||||
{
|
||||
$db->execute('TRUNCATE '._DB_PREFIX_.'search_index');
|
||||
$db->execute('TRUNCATE '._DB_PREFIX_.'search_word');
|
||||
ObjectModel::updateMultishopTable('Product', array('indexed' => 0), '1');
|
||||
ObjectModel::updateMultishopTable('Product', array('indexed' => 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+41
-6
@@ -343,8 +343,8 @@ class ToolsCore
|
||||
$cookie->id_lang = null;
|
||||
}
|
||||
|
||||
/* Automatically detect language if not already defined */
|
||||
if (!$cookie->id_lang && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
||||
/* Automatically detect language if not already defined, detect_language is set in Cookie::update */
|
||||
if ((!$cookie->id_lang || isset($cookie->detect_language)) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
||||
{
|
||||
$array = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
|
||||
if (Tools::strlen($array[0]) > 2)
|
||||
@@ -358,9 +358,17 @@ class ToolsCore
|
||||
{
|
||||
$lang = new Language(Language::getIdByIso($string));
|
||||
if (Validate::isLoadedObject($lang) && $lang->active)
|
||||
{
|
||||
$language = new Language((int)$lang->id);
|
||||
if (Validate::isLoadedObject($language))
|
||||
Context::getContext()->language = $language;
|
||||
$cookie->id_lang = (int)$lang->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($cookie->detect_language))
|
||||
unset($cookie->detect_language);
|
||||
|
||||
/* If language file not present, you must use default language file */
|
||||
if (!$cookie->id_lang || !Validate::isUnsignedId($cookie->id_lang))
|
||||
@@ -769,6 +777,33 @@ class ToolsCore
|
||||
{
|
||||
return (Tools::dieObject($object, $kill));
|
||||
}
|
||||
|
||||
public static function debug_backtrace($start = 0, $limit = null)
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
array_shift($backtrace);
|
||||
for ($i = 0; $i < $start; ++$i)
|
||||
array_shift($backtrace);
|
||||
|
||||
echo '
|
||||
<div style="margin:10px;padding:10px;border:1px solid #666666">
|
||||
<ul>';
|
||||
$i = 0;
|
||||
foreach ($backtrace as $id => $trace)
|
||||
{
|
||||
if ((int)$limit && (++$i > $limit ))
|
||||
break;
|
||||
$relative_file = (isset($trace['file'])) ? 'in /'.ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/') : '';
|
||||
$current_line = (isset($trace['line'])) ? ':'.$trace['line'] : '';
|
||||
|
||||
echo '<li>
|
||||
<b>'.((isset($trace['class'])) ? $trace['class'] : '').((isset($trace['type'])) ? $trace['type'] : '').$trace['function'].'</b>
|
||||
'.$relative_file.$current_line.'
|
||||
</li>';
|
||||
}
|
||||
echo '</ul>
|
||||
</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* ALIAS OF dieObject() - Display an error with detailed object but don't stop the execution
|
||||
@@ -1388,13 +1423,13 @@ class ToolsCore
|
||||
|
||||
/**
|
||||
* Translates a string with underscores into camel case (e.g. first_name -> firstName)
|
||||
* @prototype string public static function toCamelCase(string $str[, bool $catapitalise_first_char = false])
|
||||
* @prototype string public static function toCamelCase(string $str[, bool $capitalise_first_char = false])
|
||||
*/
|
||||
public static function toCamelCase($str, $catapitalise_first_char = false)
|
||||
{
|
||||
$str = strtolower($str);
|
||||
$str = Tools::strtolower($str);
|
||||
if ($catapitalise_first_char)
|
||||
$str = ucfirst($str);
|
||||
$str = Tools::ucfirst($str);
|
||||
return preg_replace_callback('/_+([a-z])/', create_function('$c', 'return strtoupper($c[1]);'), $str);
|
||||
}
|
||||
|
||||
@@ -2528,7 +2563,7 @@ exit;
|
||||
$fileAttachment = null;
|
||||
if (isset($_FILES[$input]['name']) && !empty($_FILES[$input]['name']) && !empty($_FILES[$input]['tmp_name']))
|
||||
{
|
||||
$fileAttachment['rename'] = uniqid(). self::strtolower(substr($_FILES[$input]['name'], -5));
|
||||
$fileAttachment['rename'] = uniqid(). Tools::strtolower(substr($_FILES[$input]['name'], -5));
|
||||
$fileAttachment['content'] = file_get_contents($_FILES[$input]['tmp_name']);
|
||||
$fileAttachment['tmp_name'] = $_FILES[$input]['tmp_name'];
|
||||
$fileAttachment['name'] = $_FILES[$input]['name'];
|
||||
|
||||
@@ -174,7 +174,7 @@ class ValidateCore
|
||||
*/
|
||||
public static function isMailName($mail_name)
|
||||
{
|
||||
return preg_match(Tools::cleanNonUnicodeSupport('/^[^<>;=#{}]*$/u'), $mail_name);
|
||||
return (is_string($mail_name) && preg_match(Tools::cleanNonUnicodeSupport('/^[^<>;=#{}]*$/u'), $mail_name));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,7 +592,7 @@ class ValidateCore
|
||||
*/
|
||||
public static function isOrderBy($order)
|
||||
{
|
||||
return preg_match('/^[a-zA-Z0-9._-]+$/', $order);
|
||||
return preg_match('/^[a-zA-Z0-9.!_-]+$/', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,8 @@ class AdminControllerCore extends Controller
|
||||
/** @var string Associated table name */
|
||||
public $table;
|
||||
|
||||
public $list_id;
|
||||
|
||||
/** @var string Object identifier inside the associated table */
|
||||
protected $identifier = false;
|
||||
|
||||
@@ -380,6 +382,39 @@ class AdminControllerCore extends Controller
|
||||
break;
|
||||
}
|
||||
$this->toolbar_title = $bread_extended;
|
||||
|
||||
if (Tools::isSubmit('submitFilter'))
|
||||
{
|
||||
$filter = '';
|
||||
foreach ($this->fields_list AS $field => $t)
|
||||
{
|
||||
if ($val = Tools::getValue($this->table.'Filter_'.$field))
|
||||
{
|
||||
if(!is_array($val) && !empty($val))
|
||||
$filter .= ($filter ? ', ' : $this->l(' filter by ')).$t['title'].' : ';
|
||||
|
||||
if (isset($t['type']) && $t['type'] == 'bool')
|
||||
$filter .= ((bool)$val) ? $this->l('yes') : $this->l('no');
|
||||
elseif(is_string($val))
|
||||
$filter .= $val;
|
||||
elseif(is_array($val))
|
||||
{
|
||||
$tmp = '';
|
||||
foreach($val as $v)
|
||||
if(is_string($v) && !empty($v))
|
||||
$tmp .= ' - '.$v;
|
||||
if(Tools::strlen($tmp))
|
||||
{
|
||||
$tmp = ltrim($tmp, ' - ');
|
||||
$filter .= ($filter ? ', ' : $this->l(' filter by ')).$t['title'].' : ';
|
||||
$filter .= $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($filter)
|
||||
$this->toolbar_title[] = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,29 +465,33 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function processFilter()
|
||||
{
|
||||
if (!isset($this->list_id))
|
||||
$this->list_id = $this->table;
|
||||
|
||||
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
|
||||
// Filter memorization
|
||||
if (isset($_POST) && !empty($_POST) && isset($this->table))
|
||||
if (isset($_POST) && !empty($_POST) && isset($this->list_id))
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if (stripos($key, $this->table.'Filter_') === 0)
|
||||
if (stripos($key, $this->list_id.'Filter_') === 0)
|
||||
$this->context->cookie->{$prefix.$key} = !is_array($value) ? $value : serialize($value);
|
||||
elseif(stripos($key, 'submitFilter') === 0)
|
||||
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
|
||||
}
|
||||
|
||||
if (isset($_GET) && !empty($_GET) && isset($this->table))
|
||||
if (isset($_GET) && !empty($_GET) && isset($this->list_id))
|
||||
foreach ($_GET as $key => $value)
|
||||
if (stripos($key, $this->table.'OrderBy') === 0 || stripos($key, $this->table.'Orderway') === 0)
|
||||
if (stripos($key, $this->list_id.'OrderBy') === 0 || stripos($key, $this->list_id.'Orderway') === 0)
|
||||
$this->context->cookie->{$prefix.$key} = $value;
|
||||
|
||||
$filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_');
|
||||
$filters = $this->context->cookie->getFamily($prefix.$this->list_id.'Filter_');
|
||||
|
||||
foreach ($filters as $key => $value)
|
||||
{
|
||||
/* Extracting filters from $_POST on key filter_ */
|
||||
if ($value != null && !strncmp($key, $prefix.$this->table.'Filter_', 7 + Tools::strlen($prefix.$this->table)))
|
||||
if ($value != null && !strncmp($key, $prefix.$this->list_id.'Filter_', 7 + Tools::strlen($prefix.$this->list_id)))
|
||||
{
|
||||
$key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->table));
|
||||
$key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->list_id));
|
||||
/* Table alias could be specified using a ! eg. alias!field */
|
||||
$tmp_tab = explode('!', $key);
|
||||
$filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0];
|
||||
@@ -888,30 +927,32 @@ class AdminControllerCore extends Controller
|
||||
/**
|
||||
* Cancel all filters for this tab
|
||||
*/
|
||||
public function processResetFilters()
|
||||
public function processResetFilters($list_id = null)
|
||||
{
|
||||
if (!isset($list_id))
|
||||
$list_id = isset($this->list_id) ? $this->list_id : $this->table;
|
||||
|
||||
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
|
||||
$filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_');
|
||||
$filters = $this->context->cookie->getFamily($prefix.$list_id.'Filter_');
|
||||
|
||||
foreach ($filters as $cookie_key => $filter)
|
||||
if (strncmp($cookie_key, $prefix.$this->table.'Filter_', 7 + Tools::strlen($prefix.$this->table)) == 0)
|
||||
if (strncmp($cookie_key, $prefix.$list_id.'Filter_', 7 + Tools::strlen($prefix.$list_id)) == 0)
|
||||
{
|
||||
$key = substr($cookie_key, 7 + Tools::strlen($prefix.$this->table));
|
||||
/* Table alias could be specified using a ! eg. alias!field */
|
||||
$tmp_tab = explode('!', $key);
|
||||
$key = (count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]);
|
||||
$key = substr($cookie_key, 7 + Tools::strlen($prefix.$list_id));
|
||||
|
||||
if (is_array($this->fields_list) && array_key_exists($key, $this->fields_list))
|
||||
$this->context->cookie->$cookie_key = null;
|
||||
unset($this->context->cookie->$cookie_key);
|
||||
}
|
||||
|
||||
if (isset($this->context->cookie->{'submitFilter'.$this->table}))
|
||||
unset($this->context->cookie->{'submitFilter'.$this->table});
|
||||
if (isset($this->context->cookie->{'submitFilter'.$list_id}))
|
||||
unset($this->context->cookie->{'submitFilter'.$list_id});
|
||||
|
||||
if (isset($this->context->cookie->{$prefix.$this->table.'Orderby'}))
|
||||
unset($this->context->cookie->{$prefix.$this->table.'Orderby'});
|
||||
if (isset($this->context->cookie->{$prefix.$list_id.'Orderby'}))
|
||||
unset($this->context->cookie->{$prefix.$list_id.'Orderby'});
|
||||
|
||||
if (isset($this->context->cookie->{$prefix.$this->table.'Orderway'}))
|
||||
unset($this->context->cookie->{$prefix.$this->table.'Orderway'});
|
||||
if (isset($this->context->cookie->{$prefix.$list_id.'Orderway'}))
|
||||
unset($this->context->cookie->{$prefix.$list_id.'Orderway'});
|
||||
|
||||
unset($_POST);
|
||||
$this->_filter = false;
|
||||
@@ -1287,7 +1328,7 @@ class AdminControllerCore extends Controller
|
||||
$current_id = Tab::getCurrentParentId();
|
||||
foreach ($tabs as $index => $tab)
|
||||
{
|
||||
if ($tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0)
|
||||
if (($tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0) || $tab['class_name'] == 'AdminCarrierWizard')
|
||||
{
|
||||
unset($tabs[$index]);
|
||||
continue;
|
||||
@@ -1327,7 +1368,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($sub_tabs as $index2 => $sub_tab)
|
||||
{
|
||||
// class_name is the name of the class controller
|
||||
if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool)$sub_tab['active'])
|
||||
if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool)$sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard')
|
||||
{
|
||||
$sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']);
|
||||
$sub_tabs[$index2]['current'] = ($sub_tab['class_name'].'Controller' == get_class($this));
|
||||
@@ -1471,6 +1512,8 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
protected function initTabModuleList()
|
||||
{
|
||||
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400))
|
||||
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));
|
||||
if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800))
|
||||
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, 'http://'.Tab::TAB_MODULE_LIST_URL);
|
||||
|
||||
@@ -1691,6 +1734,7 @@ class AdminControllerCore extends Controller
|
||||
$helper->row_hover = $this->row_hover;
|
||||
$helper->position_identifier = $this->position_identifier;
|
||||
$helper->controller_name = $this->controller_name;
|
||||
$helper->list_id = isset($this->list_id) ? $this->list_id : $this->table;
|
||||
|
||||
// For each action, try to add the corresponding skip elements list
|
||||
$helper->list_skip_actions = $this->list_skip_actions;
|
||||
@@ -1898,11 +1942,14 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function initProcess()
|
||||
{
|
||||
if (!isset($this->list_id))
|
||||
$this->list_id = $this->table;
|
||||
|
||||
// Manage list filtering
|
||||
if (Tools::isSubmit('submitFilter'.$this->table)
|
||||
|| $this->context->cookie->{'submitFilter'.$this->table} !== false
|
||||
|| Tools::getValue($this->table.'Orderby')
|
||||
|| Tools::getValue($this->table.'Orderway'))
|
||||
if (Tools::isSubmit('submitFilter'.$this->list_id)
|
||||
|| $this->context->cookie->{'submitFilter'.$this->list_id} !== false
|
||||
|| Tools::getValue($this->list_id.'Orderby')
|
||||
|| Tools::getValue($this->list_id.'Orderway'))
|
||||
$this->filter = true;
|
||||
|
||||
$this->id_object = (int)Tools::getValue($this->identifier);
|
||||
@@ -2004,7 +2051,7 @@ class AdminControllerCore extends Controller
|
||||
$this->action = 'export';
|
||||
}
|
||||
/* Cancel all filters for this tab */
|
||||
elseif (isset($_POST['submitReset'.$this->table]))
|
||||
elseif (isset($_POST['submitReset'.$this->list_id]))
|
||||
$this->action = 'reset_filters';
|
||||
/* Submit options list */
|
||||
elseif (Tools::getValue('submitOptions'.$this->table) || Tools::getValue('submitOptions'))
|
||||
@@ -2058,14 +2105,17 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
|
||||
{
|
||||
if (!isset($this->list_id))
|
||||
$this->list_id = $this->table;
|
||||
|
||||
/* Manage default params values */
|
||||
$use_limit = true;
|
||||
if ($limit === false)
|
||||
$use_limit = false;
|
||||
elseif (empty($limit))
|
||||
{
|
||||
if (isset($this->context->cookie->{$this->table.'_pagination'}) && $this->context->cookie->{$this->table.'_pagination'})
|
||||
$limit = $this->context->cookie->{$this->table.'_pagination'};
|
||||
if (isset($this->context->cookie->{$this->list_id.'_pagination'}) && $this->context->cookie->{$this->list_id.'_pagination'})
|
||||
$limit = $this->context->cookie->{$this->list_id.'_pagination'};
|
||||
else
|
||||
$limit = $this->_pagination[1];
|
||||
}
|
||||
@@ -2075,8 +2125,8 @@ class AdminControllerCore extends Controller
|
||||
$prefix = str_replace(array('admin', 'controller'), '', Tools::strtolower(get_class($this)));
|
||||
if (empty($order_by))
|
||||
{
|
||||
if ($this->context->cookie->{$prefix.$this->table.'Orderby'})
|
||||
$order_by = $this->context->cookie->{$prefix.$this->table.'Orderby'};
|
||||
if ($this->context->cookie->{$prefix.$this->list_id.'Orderby'})
|
||||
$order_by = $this->context->cookie->{$prefix.$this->list_id.'Orderby'};
|
||||
elseif ($this->_orderBy)
|
||||
$order_by = $this->_orderBy;
|
||||
else
|
||||
@@ -2085,16 +2135,16 @@ class AdminControllerCore extends Controller
|
||||
|
||||
if (empty($order_way))
|
||||
{
|
||||
if ($this->context->cookie->{$prefix.$this->table.'Orderway'})
|
||||
$order_way = $this->context->cookie->{$prefix.$this->table.'Orderway'};
|
||||
if ($this->context->cookie->{$prefix.$this->list_id.'Orderway'})
|
||||
$order_way = $this->context->cookie->{$prefix.$this->list_id.'Orderway'};
|
||||
elseif ($this->_orderWay)
|
||||
$order_way = $this->_orderWay;
|
||||
else
|
||||
$order_way = $this->_defaultOrderWay;
|
||||
}
|
||||
|
||||
$limit = (int)Tools::getValue('pagination', $limit);
|
||||
$this->context->cookie->{$this->table.'_pagination'} = $limit;
|
||||
$limit = (int)Tools::getValue($this->list_id.'_pagination', $limit);
|
||||
$this->context->cookie->{$this->list_id.'_pagination'} = $limit;
|
||||
|
||||
/* Check params validity */
|
||||
if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)
|
||||
@@ -2106,24 +2156,23 @@ class AdminControllerCore extends Controller
|
||||
$order_by = $this->fields_list[$order_by]['filter_key'];
|
||||
|
||||
/* Determine offset from current page */
|
||||
if ((isset($_POST['submitFilter'.$this->table]) ||
|
||||
isset($_POST['submitFilter'.$this->table.'_x']) ||
|
||||
isset($_POST['submitFilter'.$this->table.'_y'])) &&
|
||||
!empty($_POST['submitFilter'.$this->table]) &&
|
||||
is_numeric($_POST['submitFilter'.$this->table]))
|
||||
$start = ((int)$_POST['submitFilter'.$this->table] - 1) * $limit;
|
||||
if ((isset($_POST['submitFilter'.$this->list_id]) ||
|
||||
isset($_POST['submitFilter'.$this->list_id.'_x']) ||
|
||||
isset($_POST['submitFilter'.$this->list_id.'_y'])) &&
|
||||
!empty($_POST['submitFilter'.$this->list_id]) &&
|
||||
is_numeric($_POST['submitFilter'.$this->list_id]))
|
||||
$start = ((int)$_POST['submitFilter'.$this->list_id] - 1) * $limit;
|
||||
|
||||
/* Cache */
|
||||
$this->_lang = (int)$id_lang;
|
||||
$this->_orderBy = $order_by;
|
||||
|
||||
if (preg_match('/[.!]/', $order_by))
|
||||
{
|
||||
$order_by_split = preg_split('/[.!]/', $order_by);
|
||||
$order_by = pSQL($order_by_split[0]).'.`'.pSQL($order_by_split[1]).'`';
|
||||
$this->_orderBy = (isset($order_by_split) && isset($order_by_split[1])) ? $order_by_split[1] : $order_by;
|
||||
}
|
||||
else
|
||||
$this->_orderBy = $order_by;
|
||||
|
||||
$this->_orderWay = Tools::strtoupper($order_way);
|
||||
|
||||
/* SQL table : orders, but class name is Order */
|
||||
@@ -2222,6 +2271,7 @@ class AdminControllerCore extends Controller
|
||||
($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : '').
|
||||
(($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : '');
|
||||
|
||||
$this->_listTotal = 0;
|
||||
if (!($this->_list = Db::getInstance()->executeS($this->_listsql)))
|
||||
$this->_list_error = Db::getInstance()->getMsgError();
|
||||
else
|
||||
@@ -2384,7 +2434,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($rules['required'] as $field)
|
||||
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
||||
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %s field is required.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
@@ -2393,7 +2443,7 @@ class AdminControllerCore extends Controller
|
||||
if (isset($rules['requiredLang']) && is_array($rules['requiredLang']))
|
||||
foreach ($rules['requiredLang'] as $field_lang)
|
||||
if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field_lang.'_'.$default_language->id] = sprintf(
|
||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$default_language->name
|
||||
@@ -2403,7 +2453,7 @@ class AdminControllerCore extends Controller
|
||||
if (isset($rules['size']) && is_array($rules['size']))
|
||||
foreach ($rules['size'] as $field => $max_length)
|
||||
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length)
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %1$s field is too long (%2$d chars max).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name),
|
||||
$max_length
|
||||
@@ -2416,7 +2466,7 @@ class AdminControllerCore extends Controller
|
||||
{
|
||||
$field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']);
|
||||
if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length)
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field_lang.'_'.$language['id_lang']] = sprintf(
|
||||
Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name'],
|
||||
@@ -2431,7 +2481,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($rules['validate'] as $field => $function)
|
||||
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
||||
if (!Validate::$function($value) && !empty($value))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
@@ -2440,12 +2490,12 @@ class AdminControllerCore extends Controller
|
||||
if (($value = Tools::getValue('passwd')) != false)
|
||||
{
|
||||
if ($class_name == 'Employee' && !Validate::isPasswdAdmin($value))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors['passwd'] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
|
||||
);
|
||||
elseif ($class_name == 'Customer' && !Validate::isPasswd($value))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors['passwd'] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
|
||||
);
|
||||
@@ -2457,7 +2507,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($languages as $language)
|
||||
if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value))
|
||||
if (!Validate::$function($value))
|
||||
$this->errors[] = sprintf(
|
||||
$this->errors[$field_lang.'_'.$language['id_lang']] = sprintf(
|
||||
Tools::displayError('The %1$s field (%2$s) is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name']
|
||||
|
||||
@@ -114,18 +114,15 @@ class FrontControllerCore extends Controller
|
||||
$css_files = $this->css_files;
|
||||
$js_files = $this->js_files;
|
||||
|
||||
if ($this->ssl && !Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED'))
|
||||
// If we call a SSL controller without SSL or a non SSL controller with SSL, we redirect with the right protocol
|
||||
if (Configuration::get('PS_SSL_ENABLED') && ($_SERVER['REQUEST_METHOD'] != 'POST') && $this->ssl != Tools::usingSecureMode())
|
||||
{
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Cache-Control: no-cache');
|
||||
header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
|
||||
exit();
|
||||
}
|
||||
elseif (Configuration::get('PS_SSL_ENABLED') && Tools::usingSecureMode() && !($this->ssl))
|
||||
{
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Cache-Control: no-cache');
|
||||
header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']);
|
||||
if ($this->ssl)
|
||||
header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
|
||||
else
|
||||
header('Location: '.Tools::getShopDomain(true).$_SERVER['REQUEST_URI']);
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -808,7 +805,7 @@ class FrontControllerCore extends Controller
|
||||
// 'orderwaydefault' => Tools::getProductsOrder('way'),
|
||||
|
||||
$stock_management = Configuration::get('PS_STOCK_MANAGEMENT') ? true : false; // no display quantity order if stock management disabled
|
||||
$order_by_values = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity');
|
||||
$order_by_values = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity', 7 => 'reference');
|
||||
$order_way_values = array(0 => 'asc', 1 => 'desc');
|
||||
$this->orderBy = Tools::strtolower(Tools::getValue('orderby', $order_by_values[(int)Configuration::get('PS_PRODUCTS_ORDER_BY')]));
|
||||
$this->orderWay = Tools::strtolower(Tools::getValue('orderway', $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')]));
|
||||
@@ -1140,4 +1137,4 @@ class FrontControllerCore extends Controller
|
||||
'logo_url' => $logo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,9 +51,10 @@ abstract class ModuleAdminControllerCore extends AdminController
|
||||
|
||||
public function createTemplate($tpl_name)
|
||||
{
|
||||
if (file_exists($this->getTemplatePath().$this->override_folder.$tpl_name) && $this->viewAccess())
|
||||
if (file_exists(_PS_THEME_DIR_.'modules/'.$this->module->name.'/views/templates/admin/'.$tpl_name) && $this->viewAccess())
|
||||
return $this->context->smarty->createTemplate(_PS_THEME_DIR_.'modules/'.$this->module->name.'/views/templates/admin/'.$tpl_name, $this->context->smarty);
|
||||
elseif (file_exists($this->getTemplatePath().$this->override_folder.$tpl_name) && $this->viewAccess())
|
||||
return $this->context->smarty->createTemplate($this->getTemplatePath().$this->override_folder.$tpl_name, $this->context->smarty);
|
||||
|
||||
return parent::createTemplate($tpl_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ class ModuleFrontControllerCore extends FrontController
|
||||
{
|
||||
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$this->module->name.'/'.$template))
|
||||
$this->template = _PS_THEME_DIR_.'modules/'.$this->module->name.'/'.$template;
|
||||
elseif (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$this->module->name.'/views/templates/front/'.$template))
|
||||
$this->template = _PS_THEME_DIR_.'modules/'.$this->module->name.'/views/templates/front/'.$template;
|
||||
elseif (Tools::file_exists_cache($this->getTemplatePath().$template))
|
||||
$this->template = $this->getTemplatePath().$template;
|
||||
else
|
||||
|
||||
@@ -51,7 +51,7 @@ class PrestaShopExceptionCore extends Exception
|
||||
</style>';
|
||||
echo '<div id="psException">';
|
||||
echo '<h2>['.get_class($this).']</h2>';
|
||||
echo $this->getExentedMessage();
|
||||
echo $this->getExtendedMessage();
|
||||
|
||||
$this->displayFileDebug($this->getFile(), $this->getLine());
|
||||
|
||||
@@ -145,14 +145,23 @@ class PrestaShopExceptionCore extends Exception
|
||||
{
|
||||
$logger = new FileLogger();
|
||||
$logger->setFilename(_PS_ROOT_DIR_.'/log/'.date('Ymd').'_exception.log');
|
||||
$logger->logError($this->getExentedMessage(false));
|
||||
$logger->logError($this->getExtendedMessage(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 1.5.5
|
||||
*/
|
||||
protected function getExentedMessage($html = true)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
return $this->getExtendedMessage($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the content of the Exception
|
||||
* @return string content of the exception
|
||||
*/
|
||||
protected function getExentedMessage($html = true)
|
||||
protected function getExtendedMessage($html = true)
|
||||
{
|
||||
$format = '<p><b>%s</b><br /><i>at line </i><b>%d</b><i> in file </i><b>%s</b></p>';
|
||||
if (!$html)
|
||||
|
||||
@@ -486,18 +486,21 @@ class HelperListCore extends Helper
|
||||
*/
|
||||
public function displayListHeader()
|
||||
{
|
||||
if (!isset($this->list_id))
|
||||
$this->list_id = $this->table;
|
||||
|
||||
$id_cat = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category');
|
||||
|
||||
if (!isset($token) || empty($token))
|
||||
$token = $this->token;
|
||||
|
||||
/* Determine total page number */
|
||||
if (isset($this->context->cookie->{$this->table.'_pagination'}) && $this->context->cookie->{$this->table.'_pagination'})
|
||||
$default_pagination = $this->context->cookie->{$this->table.'_pagination'};
|
||||
if (isset($this->context->cookie->{$this->list_id.'_pagination'}) && $this->context->cookie->{$this->list_id.'_pagination'})
|
||||
$default_pagination = $this->context->cookie->{$this->list_id.'_pagination'};
|
||||
else
|
||||
$default_pagination = $this->_pagination[0];
|
||||
|
||||
$total_pages = ceil($this->listTotal / Tools::getValue('pagination', ($default_pagination)));
|
||||
$total_pages = ceil($this->listTotal / Tools::getValue($this->list_id.'_pagination', ($default_pagination)));
|
||||
|
||||
if (!$total_pages)
|
||||
$total_pages = 1;
|
||||
@@ -510,14 +513,13 @@ class HelperListCore extends Helper
|
||||
$action = $this->currentIndex.$identifier.'&token='.$token.$order.'#'.$this->table;
|
||||
|
||||
/* Determine current page number */
|
||||
$page = (int)Tools::getValue('submitFilter'.$this->table);
|
||||
$page = (int)Tools::getValue('submitFilter'.$this->list_id);
|
||||
if (!$page)
|
||||
$page = 1;
|
||||
|
||||
/* Choose number of results per page */
|
||||
$selected_pagination = Tools::getValue(
|
||||
'pagination',
|
||||
isset($this->context->cookie->{$this->table.'_pagination'}) ? $this->context->cookie->{$this->table.'_pagination'} : null
|
||||
$selected_pagination = Tools::getValue($this->list_id.'_pagination',
|
||||
isset($this->context->cookie->{$this->list_id.'_pagination'}) ? $this->context->cookie->{$this->list_id.'_pagination'} : null
|
||||
);
|
||||
|
||||
// Cleaning links
|
||||
@@ -535,7 +537,7 @@ class HelperListCore extends Helper
|
||||
{
|
||||
if (!isset($params['type']))
|
||||
$params['type'] = 'text';
|
||||
$value = Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.(array_key_exists('filter_key', $params) && $key != 'active' ? $params['filter_key'] : $key)};
|
||||
$value = Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.(array_key_exists('filter_key', $params) && $key != 'active' ? $params['filter_key'] : $key)};
|
||||
switch ($params['type'])
|
||||
{
|
||||
case 'bool':
|
||||
@@ -547,7 +549,7 @@ class HelperListCore extends Helper
|
||||
$value = Tools::unSerialize($value);
|
||||
if (!Validate::isCleanHtml($value[0]) || !Validate::isCleanHtml($value[1]))
|
||||
$value = '';
|
||||
$name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
|
||||
$name = $this->list_id.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
|
||||
$name_id = str_replace('!', '__', $name);
|
||||
|
||||
$params['id_date'] = $name_id;
|
||||
@@ -559,9 +561,9 @@ class HelperListCore extends Helper
|
||||
case 'select':
|
||||
foreach ($params['list'] as $option_value => $option_display)
|
||||
{
|
||||
if (isset(Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.$params['filter_key']})
|
||||
&& Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.$params['filter_key']} == $option_value
|
||||
&& Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.$params['filter_key']} != '')
|
||||
if (isset(Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']})
|
||||
&& Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']} == $option_value
|
||||
&& Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']} != '')
|
||||
$this->fields_list[$key]['select'][$option_value]['selected'] = 'selected';
|
||||
}
|
||||
break;
|
||||
@@ -620,7 +622,8 @@ class HelperListCore extends Helper
|
||||
'table_dnd' => isset($table_dnd) ? $table_dnd : null,
|
||||
'name' => isset($name) ? $name : null,
|
||||
'name_id' => isset($name_id) ? $name_id : null,
|
||||
'row_hover' => $this->row_hover
|
||||
'row_hover' => $this->row_hover,
|
||||
'list_id' => isset($this->list_id) ? $this->list_id : $this->table
|
||||
)));
|
||||
|
||||
return $this->header_tpl->fetch();
|
||||
|
||||
@@ -669,12 +669,14 @@ abstract class ModuleCore
|
||||
return false;
|
||||
|
||||
// Retrocompatibility
|
||||
$hook_name_bak = $hook_name;
|
||||
if ($alias = Hook::getRetroHookName($hook_name))
|
||||
$hook_name = $alias;
|
||||
|
||||
Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
|
||||
// Get hook id
|
||||
$id_hook = Hook::getIdByName($hook_name);
|
||||
$live_edit = Hook::getLiveEditById((int)Hook::getIdByName($hook_name_bak));
|
||||
|
||||
// If hook does not exist, we create it
|
||||
if (!$id_hook)
|
||||
@@ -682,6 +684,7 @@ abstract class ModuleCore
|
||||
$new_hook = new Hook();
|
||||
$new_hook->name = pSQL($hook_name);
|
||||
$new_hook->title = pSQL($hook_name);
|
||||
$new_hook->live_edit = pSQL($live_edit);
|
||||
$new_hook->add();
|
||||
$id_hook = $new_hook->id;
|
||||
if (!$id_hook)
|
||||
@@ -1538,7 +1541,7 @@ abstract class ModuleCore
|
||||
Cache::store($cache_id, $exceptionsCache);
|
||||
}
|
||||
else
|
||||
$exceptionsCache = !Cache::retrieve($cache_id);
|
||||
$exceptionsCache = Cache::retrieve($cache_id);
|
||||
|
||||
$key = $id_hook.'-'.$this->id;
|
||||
$array_return = array();
|
||||
@@ -1600,7 +1603,11 @@ abstract class ModuleCore
|
||||
protected static function _isTemplateOverloadedStatic($module_name, $template)
|
||||
{
|
||||
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$module_name.'/'.$template))
|
||||
return true;
|
||||
return _PS_THEME_DIR_.'modules/'.$module_name.'/'.$template;
|
||||
elseif (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$module_name.'/views/templates/hook/'.$template))
|
||||
return _PS_THEME_DIR_.'modules/'.$module_name.'/views/templates/hook/'.$template;
|
||||
elseif (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$module_name.'/views/templates/front/'.$template))
|
||||
return _PS_THEME_DIR_.'modules/'.$module_name.'/views/templates/front/'.$template;
|
||||
elseif (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/views/templates/hook/'.$template))
|
||||
return false;
|
||||
elseif (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/'.$template))
|
||||
@@ -1615,9 +1622,16 @@ abstract class ModuleCore
|
||||
|
||||
protected function getCacheId($name = null)
|
||||
{
|
||||
if ($name === null)
|
||||
$name = $this->name;
|
||||
return $name.'|'.(int)Tools::usingSecureMode().'|'.(int)$this->context->shop->id.'|'.(int)Group::getCurrent()->id.'|'.(int)$this->context->language->id.'|'.(int)$this->context->currency->id;
|
||||
$cache_array = array(
|
||||
$name !== null ? $name : $this->name,
|
||||
(int)Tools::usingSecureMode(),
|
||||
(int)$this->context->shop->id,
|
||||
(int)Group::getCurrent()->id,
|
||||
(int)$this->context->language->id,
|
||||
(int)$this->context->currency->id,
|
||||
(int)$this->context->country->id
|
||||
);
|
||||
return implode('|', $cache_array);
|
||||
}
|
||||
|
||||
public function display($file, $template, $cacheId = null, $compileId = null)
|
||||
@@ -1661,8 +1675,9 @@ abstract class ModuleCore
|
||||
$overloaded = $this->_isTemplateOverloaded($template);
|
||||
if ($overloaded === null)
|
||||
return null;
|
||||
|
||||
if ($overloaded)
|
||||
return _PS_THEME_DIR_.'modules/'.$this->name.'/'.$template;
|
||||
return $overloaded;
|
||||
else if (file_exists(_PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template))
|
||||
return _PS_MODULE_DIR_.$this->name.'/views/templates/hook/'.$template;
|
||||
else
|
||||
|
||||
@@ -254,7 +254,7 @@ class OrderCore extends ObjectModel
|
||||
public function __construct($id = null, $id_lang = null)
|
||||
{
|
||||
parent::__construct($id, $id_lang);
|
||||
|
||||
|
||||
$is_admin = (is_object(Context::getContext()->controller) && Context::getContext()->controller->controller_type == 'admin');
|
||||
if ($this->id_customer && !$is_admin)
|
||||
{
|
||||
|
||||
@@ -64,6 +64,9 @@ class OrderHistoryCore extends ObjectModel
|
||||
'id_order_state' => array('required' => true, 'xlink_resource'=> 'order_states'),
|
||||
'id_order' => array('xlink_resource' => 'orders'),
|
||||
),
|
||||
'objectMethods' => array(
|
||||
'add' => 'addWs',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -376,7 +379,7 @@ class OrderHistoryCore extends ObjectModel
|
||||
return false;
|
||||
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`
|
||||
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`
|
||||
FROM `'._DB_PREFIX_.'order_history` oh
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON oh.`id_order` = o.`id_order`
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON o.`id_customer` = c.`id_customer`
|
||||
@@ -408,9 +411,23 @@ class OrderHistoryCore extends ObjectModel
|
||||
$data['{order_name}'] = $order->getUniqReference();
|
||||
|
||||
if (Validate::isLoadedObject($order))
|
||||
{
|
||||
// Join PDF invoice if order state is "payment accepted"
|
||||
if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
|
||||
$file_attachement['content'] = $pdf->render(false);
|
||||
$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
|
||||
$file_attachement = null;
|
||||
|
||||
Mail::Send((int)$order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'].' '.$result['lastname'],
|
||||
null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);
|
||||
|
||||
null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop);
|
||||
}
|
||||
|
||||
ShopUrl::resetMainDomainCache();
|
||||
}
|
||||
|
||||
@@ -445,4 +462,27 @@ class OrderHistoryCore extends ObjectModel
|
||||
AND os.`logable` = 1');
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Add method for webservice create resource Order History
|
||||
* If sendemail=1 GET parameter is present sends email to customer otherwise does not
|
||||
* @return bool
|
||||
*/
|
||||
public function addWs()
|
||||
{
|
||||
$sendemail = (bool)Tools::getValue('sendemail', false);
|
||||
if ($sendemail)
|
||||
{
|
||||
//Mail::Send requires link object on context and is not set when getting here
|
||||
$context = Context::getContext();
|
||||
if ($context->link == null)
|
||||
{
|
||||
$protocol_link = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
|
||||
$protocol_content = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
|
||||
$context->link = new Link($protocol_link, $protocol_content);
|
||||
}
|
||||
return $this->addWithemail();
|
||||
}
|
||||
else
|
||||
return $this->add();
|
||||
}
|
||||
}
|
||||
+10
-12
@@ -187,18 +187,16 @@ class ShopCore extends ObjectModel
|
||||
|
||||
public function setUrl()
|
||||
{
|
||||
$sql = 'SELECT su.physical_uri, su.virtual_uri,
|
||||
su.domain, su.domain_ssl, t.id_theme, t.name, t.directory
|
||||
FROM '._DB_PREFIX_.'shop s
|
||||
LEFT JOIN '._DB_PREFIX_.'shop_url su ON (s.id_shop = su.id_shop)
|
||||
LEFT JOIN '._DB_PREFIX_.'theme t ON (t.id_theme = s.id_theme)
|
||||
WHERE s.id_shop = '.(int)$this->id.'
|
||||
AND s.active = 1
|
||||
AND s.deleted = 0
|
||||
AND su.main = 1';
|
||||
|
||||
if (!$row = Db::getInstance()->getRow($sql))
|
||||
return;
|
||||
$row = Db::getInstance()->getRow('
|
||||
SELECT su.physical_uri, su.virtual_uri, su.domain, su.domain_ssl, t.id_theme, t.name, t.directory
|
||||
FROM '._DB_PREFIX_.'shop s
|
||||
LEFT JOIN '._DB_PREFIX_.'shop_url su ON (s.id_shop = su.id_shop)
|
||||
LEFT JOIN '._DB_PREFIX_.'theme t ON (t.id_theme = s.id_theme)
|
||||
WHERE s.id_shop = '.(int)$this->id.'
|
||||
AND s.active = 1 AND s.deleted = 0 AND su.main = 1');
|
||||
|
||||
if (!$row)
|
||||
return false;
|
||||
|
||||
$this->theme_id = $row['id_theme'];
|
||||
$this->theme_name = $row['name'];
|
||||
|
||||
@@ -680,7 +680,7 @@ class StockAvailableCore extends ObjectModel
|
||||
|
||||
// if there is no $id_shop, gets the context one
|
||||
// get shop group too
|
||||
if ($shop === null)
|
||||
if ($shop === null || $shop === $context->shop->id)
|
||||
{
|
||||
if (Shop::getContext() == Shop::CONTEXT_GROUP)
|
||||
$shop_group = Shop::getContextShopGroup();
|
||||
|
||||
@@ -513,7 +513,6 @@ class WebserviceRequestCore
|
||||
$this->setError(501, sprintf('The specific management class is not implemented for the "%s" entity.', $this->urlSegment[0]), 124);
|
||||
else
|
||||
{
|
||||
$this->setFieldsToDisplay();
|
||||
$this->objectSpecificManagement = new $specificObjectName();
|
||||
$this->objectSpecificManagement->setObjectOutput($this->objOutput)
|
||||
->setWsObject($this);
|
||||
|
||||
Reference in New Issue
Block a user