diff --git a/admin-dev/themes/default/template/controllers/products/images.tpl b/admin-dev/themes/default/template/controllers/products/images.tpl index ce12ce071..1b7bbb3fe 100644 --- a/admin-dev/themes/default/template/controllers/products/images.tpl +++ b/admin-dev/themes/default/template/controllers/products/images.tpl @@ -92,7 +92,7 @@ - image_id + legend legend @@ -332,7 +332,7 @@ function imageLine(id, path, position, cover, shops, legend) { line = $("#lineType").html(); - line = line.replace(/image_id/g, legend); + line = line.replace(/image_id/g, id); line = line.replace(/[a-z]{0,2}-default/g, path); line = line.replace(/image_path/g, path); line = line.replace(/image_position/g, position); diff --git a/classes/Autoload.php b/classes/Autoload.php index b9b5a394e..903484add 100644 --- a/classes/Autoload.php +++ b/classes/Autoload.php @@ -137,24 +137,18 @@ 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))) + $filename_tmp = tempnam(dirname($filename), basename($filename.'.')); + if ($filename_tmp !== false && file_put_contents($filename_tmp, $content, LOCK_EX) !== false) { - header('HTTP/1.1 503 temporarily overloaded'); - // Cannot use PrestaShopException in this context - die('/cache/class_index.php is not writable, please give write permissions (chmod 666) on this file.'); - } - else - { - $filename_tmp = tempnam(dirname($filename), basename($filename.'.')); - if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE) - { - @rename($filename_tmp, $filename); - @chmod($filename, 0666); - } + if (!rename($filename_tmp, $filename)) + unlink($filename_tmp); else - // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die. - error_log('Cannot write temporary file '.$filename_tmp); + @chmod($filename, 0666); } + // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die. + else + error_log('Cannot write temporary file '.$filename_tmp); + $this->index = $classes; } diff --git a/classes/Hook.php b/classes/Hook.php index 30efb0a76..656934e16 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -390,6 +390,10 @@ class HookCore extends ObjectModel */ public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true) { + static $disable_non_native_modules = null; + if ($disable_non_native_modules === null) + $disable_non_native_modules = (bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE'); + // Check arguments validity if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name)) throw new PrestaShopException('Invalid id_module or hook_name'); @@ -419,7 +423,7 @@ class HookCore extends ObjectModel $altern = 0; $output = ''; - if (!isset(Hook::$native_module)) + if ($disable_non_native_modules && !isset(Hook::$native_module)) Hook::$native_module = Module::getNativeModuleList(); foreach ($module_list as $array) @@ -428,7 +432,7 @@ class HookCore extends ObjectModel if ($id_module && $id_module != $array['id_module']) continue; - if ((bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE') && !in_array($array['module'], self::$native_module)) + if ((bool)$disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($array['module'], self::$native_module)) continue; if (!($moduleInstance = Module::getInstanceByName($array['module']))) diff --git a/classes/Tools.php b/classes/Tools.php index 1ee27abca..dc6a74cd4 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -672,10 +672,8 @@ class ToolsCore public static function htmlentitiesUTF8($string, $type = ENT_QUOTES) { if (is_array($string)) - { - $string = array_map(array('Tools', 'htmlentitiesUTF8'), $string); - return (string)array_shift($string); - } + return array_map(array('Tools', 'htmlentitiesUTF8'), $string); + return htmlentities((string)$string, $type, 'utf-8'); } diff --git a/classes/Validate.php b/classes/Validate.php index 1b4d31d03..abcd8e171 100644 --- a/classes/Validate.php +++ b/classes/Validate.php @@ -44,7 +44,7 @@ class ValidateCore */ public static function isEmail($email) { - return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z0-9]+$/ui'), $email); + return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z\p{L}0-9]+$/ui'), $email); } /** @@ -1067,4 +1067,4 @@ class ValidateCore { return (preg_match('/^[0-1]\.[0-9]{1,2}(\.[0-9]{1,2}){0,2}$/', $version) && ip2long($version)); } -} \ No newline at end of file +} diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index 5309aca01..b40cf9f1e 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -175,8 +175,8 @@ abstract class ControllerCore // then using displayAjax[action] if ($this->ajax) { - $action = Tools::getValue('action'); - if (!empty($action) && method_exists($this, 'displayAjax'.Tools::toCamelCase($action, true))) + $action = Tools::toCamelCase(Tools::getValue('action'), true); + if (!empty($action) && method_exists($this, 'displayAjax'.$action)) $this->{'displayAjax'.$action}(); elseif (method_exists($this, 'displayAjax')) $this->displayAjax(); diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 1884cccf0..14c85c0ec 100644 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -850,7 +850,7 @@ class FrontControllerCore extends Controller if (!is_numeric(Tools::getValue('p', 1)) || Tools::getValue('p', 1) < 0) Tools::redirect(self::$link->getPaginationLink(false, false, $this->n, false, 1, false)); - $current_url = tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']); + $current_url = Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']); //delete parameter page $current_url = preg_replace('/(\?)?(&)?p=\d+/', '$1', $current_url); @@ -919,7 +919,7 @@ class FrontControllerCore extends Controller $ips = array_map('trim', $ips); if (is_array($ips) && count($ips)) foreach ($ips as $ip) - if (!empty($ip) && strpos($user_ip, $ip) === 0) + if (!empty($ip) && preg_match('/^'.$ip.'.*/', $user_ip)) $allowed = true; return $allowed; } diff --git a/classes/module/Module.php b/classes/module/Module.php index 3318ca9e4..dea6881fc 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -1296,6 +1296,9 @@ abstract class ModuleCore public static function getNativeModuleList() { $module_list_xml = _PS_ROOT_DIR_.self::CACHE_FILE_MODULES_LIST; + if (!file_exists($module_list_xml)) + return false; + $native_modules = simplexml_load_file($module_list_xml); $native_modules = $native_modules->modules; $modules = array(); diff --git a/controllers/admin/AdminCartRulesController.php b/controllers/admin/AdminCartRulesController.php index 9a0fddeb8..46dff7674 100644 --- a/controllers/admin/AdminCartRulesController.php +++ b/controllers/admin/AdminCartRulesController.php @@ -128,6 +128,8 @@ class AdminCartRulesControllerCore extends AdminController $this->errors[] = Tools::displayError('Reduction amount cannot be lower than zero.'); if (Tools::getValue('code') && ($same_code = (int)CartRule::getIdByCode(Tools::getValue('code'))) && $same_code != Tools::getValue('id_cart_rule')) $this->errors[] = sprintf(Tools::displayError('This cart rule code is already used (conflict with cart rule %d)'), $same_code); + if (Tools::getValue('apply_discount') == 'off' && !Tools::getValue('free_shipping') && !Tools::getValue('free_gift')) + $this->errors[] = Tools::displayError('An action is required for this cart rule.'); } return parent::postProcess(); diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php index cc455ef8b..9d7b2c52b 100644 --- a/controllers/admin/AdminCustomerThreadsController.php +++ b/controllers/admin/AdminCustomerThreadsController.php @@ -320,12 +320,15 @@ class AdminCustomerThreadsControllerCore extends AdminController $cm = new CustomerMessage(); $cm->id_employee = (int)$this->context->employee->id; $cm->id_customer_thread = (int)Tools::getValue('id_customer_thread'); - $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); + $cm->ip_address = ip2long(Tools::getRemoteAddr()); $current_employee = $this->context->employee; $id_employee = (int)Tools::getValue('id_employee_forward'); $employee = new Employee($id_employee); $email = Tools::getValue('email'); - if ($id_employee && $employee && Validate::isLoadedObject($employee)) + $message = Tools::getValue('message_forward'); + if (($error = $cm->validateField('message', $message, null, array(), true)) !== true) + $this->errors[] = $error; + elseif ($id_employee && $employee && Validate::isLoadedObject($employee)) { $params = array( '{messages}' => Tools::nl2br(stripslashes($output)), @@ -344,7 +347,7 @@ class AdminCustomerThreadsControllerCore extends AdminController null, null, _PS_MAIL_DIR_, true)) { $cm->private = 1; - $cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$_POST['message_forward']; + $cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$message; $cm->add(); } } @@ -363,7 +366,7 @@ class AdminCustomerThreadsControllerCore extends AdminController $current_employee->email, $current_employee->firstname.' '.$current_employee->lastname, null, null, _PS_MAIL_DIR_, true)) { - $cm->message = $this->l('Message forwarded to').' '.$email."\n".$this->l('Comment:').' '.$_POST['message_forward']; + $cm->message = $this->l('Message forwarded to').' '.$email."\n".$this->l('Comment:').' '.$message; $cm->add(); } } @@ -379,10 +382,11 @@ class AdminCustomerThreadsControllerCore extends AdminController $cm = new CustomerMessage(); $cm->id_employee = (int)$this->context->employee->id; $cm->id_customer_thread = $ct->id; - + $cm->ip_address = ip2long(Tools::getRemoteAddr()); $cm->message = Tools::getValue('reply_message'); - $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); - if (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0) + if (($error = $cm->validateField('message', $cm->message, null, array(), true)) !== true) + $this->errors[] = $error; + elseif (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0) $this->errors[] = Tools::displayError('An error occurred during the file upload process.'); elseif ($cm->add()) { diff --git a/controllers/admin/AdminManufacturersController.php b/controllers/admin/AdminManufacturersController.php index 2ec73737a..549925472 100644 --- a/controllers/admin/AdminManufacturersController.php +++ b/controllers/admin/AdminManufacturersController.php @@ -718,6 +718,11 @@ class AdminManufacturersControllerCore extends AdminController (int)$image_type['height'] ); } + + $current_logo_file = _PS_TMP_IMG_DIR_.'manufacturer_mini_'.$id_manufacturer.'_'.$this->context->shop->id.'.jpg'; + + if ($res && file_exists($current_logo_file)) + unlink($current_logo_file); } if (!$res) @@ -725,7 +730,7 @@ class AdminManufacturersControllerCore extends AdminController return $res; } - + protected function beforeDelete($object) { return true; diff --git a/controllers/admin/AdminStatusesController.php b/controllers/admin/AdminStatusesController.php index fe4e129e0..62f4e5a1a 100644 --- a/controllers/admin/AdminStatusesController.php +++ b/controllers/admin/AdminStatusesController.php @@ -539,4 +539,20 @@ class AdminStatusesControllerCore extends AdminController $this->initOrdersReturnsList(); return parent::filterToField($key, $filter); } + + protected function afterImageUpload() + { + parent::afterImageUpload(); + + if (($id_order_state = (int)Tools::getValue('id_order_state')) && + isset($_FILES) && count($_FILES) && file_exists(_PS_ORDER_STATE_IMG_DIR_.$id_order_state.'.gif')) + { + $current_file = _PS_TMP_IMG_DIR_.'order_state_mini_'.$id_order_state.'_'.$this->context->shop->id.'.gif'; + + if (file_exists($current_file)) + unlink($current_file); + } + + return true; + } } diff --git a/controllers/admin/AdminSuppliersController.php b/controllers/admin/AdminSuppliersController.php index d2eb52b8d..b120138f4 100644 --- a/controllers/admin/AdminSuppliersController.php +++ b/controllers/admin/AdminSuppliersController.php @@ -354,6 +354,11 @@ class AdminSuppliersControllerCore extends AdminController if (!ImageManager::resize($file, _PS_SUPP_IMG_DIR_.$id_supplier.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], (int)$image_type['height'])) $return = false; } + + $current_logo_file = _PS_TMP_IMG_DIR_.'supplier_mini_'.$id_supplier.'_'.$this->context->shop->id.'.jpg'; + + if (file_exists($current_logo_file)) + unlink($current_logo_file); } return $return; } diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php index 8d3e5689e..c127fa46a 100644 --- a/controllers/front/ContactController.php +++ b/controllers/front/ContactController.php @@ -147,7 +147,7 @@ class ContactControllerCore extends FrontController $cm->message = $message; if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename']))) $cm->file_name = $fileAttachment['rename']; - $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); + $cm->ip_address = ip2long(Tools::getRemoteAddr()); $cm->user_agent = $_SERVER['HTTP_USER_AGENT']; if (!$cm->add()) $this->errors[] = Tools::displayError('An error occurred while sending the message.'); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 2b03955a6..7bde212a6 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -529,8 +529,8 @@ class OrderOpcControllerCore extends ParentOrderController $minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase) return '

'.sprintf( - Tools::displayError('A minimum purchase total of %s is required in order to validate your order.'), - Tools::displayPrice($minimalPurchase, $currency) + Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), + Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ).'

'; /* Bypass payment step if total is 0 */ diff --git a/install-dev/classes/session.php b/install-dev/classes/session.php index a8eabefc5..98d866e5f 100644 --- a/install-dev/classes/session.php +++ b/install-dev/classes/session.php @@ -45,7 +45,7 @@ class InstallSession session_name('install_'.md5($_SERVER['HTTP_HOST'])); $session_started = session_start(); if (!($session_started) - || (!isset($_SESSION['session_mode']) && (isset($_POST['submitNext']) || isset($_POST['submitPrevious']) || isset($_POST['language'])))) + || (!isset($_SESSION['session_mode']) && (isset($_GET['_']) || isset($_POST['submitNext']) || isset($_POST['submitPrevious']) || isset($_POST['language'])))) { InstallSession::$_cookie_mode = true; InstallSession::$_cookie = new Cookie('ps_install', null, time() + 7200, null, true); diff --git a/install-dev/upgrade/sql/1.5.6.1.sql b/install-dev/upgrade/sql/1.5.6.1.sql index a05adbdf0..91d0f9c05 100644 --- a/install-dev/upgrade/sql/1.5.6.1.sql +++ b/install-dev/upgrade/sql/1.5.6.1.sql @@ -7,3 +7,5 @@ ALTER TABLE `PREFIX_currency` CHANGE `conversion_rate` `conversion_rate` DECIMAL UPDATE `PREFIX_orders` SET conversion_rate = 1 WHERE conversion_rate = 0; ALTER TABLE `PREFIX_cms` ADD `indexation` tinyint(1) UNSIGNED NULL DEFAULT '1' AFTER `active`; + +/* PHP:update_order_messages(); */; \ No newline at end of file diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index da283ece7..d8b3ce7b1 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -33,7 +33,7 @@ class BlockCart extends Module { $this->name = 'blockcart'; $this->tab = 'front_office_features'; - $this->version = '1.2'; + $this->version = '1.3'; $this->author = 'PrestaShop'; $this->need_instance = 0; diff --git a/modules/blockcart/config.xml b/modules/blockcart/config.xml index cb1badd0e..711916a70 100755 --- a/modules/blockcart/config.xml +++ b/modules/blockcart/config.xml @@ -2,7 +2,7 @@ blockcart - + diff --git a/modules/blockcategories/blockcategories.php b/modules/blockcategories/blockcategories.php index bdaca904e..bb27d3b51 100644 --- a/modules/blockcategories/blockcategories.php +++ b/modules/blockcategories/blockcategories.php @@ -176,6 +176,7 @@ class BlockCategories extends Module $resultParents = array(); $resultIds = array(); + $isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false); foreach ($result as &$row) { @@ -186,27 +187,6 @@ class BlockCategories extends Module $blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH')); unset($resultParents, $resultIds); - $id_category = (int)Tools::getValue('id_category'); - $id_product = (int)Tools::getValue('id_product'); - - $isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false); - if (Tools::isSubmit('id_category')) - { - $this->context->cookie->last_visited_category = $id_category; - $this->smarty->assign('currentCategoryId', $this->context->cookie->last_visited_category); - } - if (Tools::isSubmit('id_product')) - { - if (!isset($this->context->cookie->last_visited_category) - || !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category))) - || !Category::inShopStatic($this->context->cookie->last_visited_category, $this->context->shop)) - { - $product = new Product($id_product); - if (isset($product) && Validate::isLoadedObject($product)) - $this->context->cookie->last_visited_category = (int)$product->id_category_default; - } - $this->smarty->assign('currentCategoryId', (int)$this->context->cookie->last_visited_category); - } $this->smarty->assign('blockCategTree', $blockCategTree); if (file_exists(_PS_THEME_DIR_.'modules/blockcategories/blockcategories.tpl')) @@ -215,6 +195,29 @@ class BlockCategories extends Module $this->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl'); $this->smarty->assign('isDhtml', $isDhtml); } + + $id_category = (int)Tools::getValue('id_category'); + $id_product = (int)Tools::getValue('id_product'); + + if (Tools::isSubmit('id_category')) + { + $this->context->cookie->last_visited_category = (int)$id_category; + $this->smarty->assign('currentCategoryId', $this->context->cookie->last_visited_category); + } + + if (Tools::isSubmit('id_product')) + { + if (!isset($this->context->cookie->last_visited_category) + || !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category))) + || !Category::inShopStatic($this->context->cookie->last_visited_category, $this->context->shop)) + { + $product = new Product((int)$id_product); + if (isset($product) && Validate::isLoadedObject($product)) + $this->context->cookie->last_visited_category = (int)$product->id_category_default; + } + $this->smarty->assign('currentCategoryId', (int)$this->context->cookie->last_visited_category); + } + $display = $this->display(__FILE__, 'blockcategories.tpl', $this->getCacheId()); return $display; } diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 3d2039ed9..803f63eaa 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -38,7 +38,7 @@ class BlockLayered extends Module { $this->name = 'blocklayered'; $this->tab = 'front_office_features'; - $this->version = '1.8.9'; + $this->version = '1.9.0'; $this->author = 'PrestaShop'; $this->need_instance = 0; @@ -1186,7 +1186,6 @@ class BlockLayered extends Module $this->context->controller->addJS(($this->_path).'blocklayered.js'); - $this->context->controller->addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js'); $this->context->controller->addJQueryUI('ui.slider'); $this->context->controller->addCSS(($this->_path).'blocklayered-15.css', 'all'); $this->context->controller->addJQueryPlugin('scrollTo'); @@ -1686,7 +1685,6 @@ class BlockLayered extends Module
'.$this->l('Build your own filter template').' -