diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php index bc742000a..ee0a0dad3 100644 --- a/admin-dev/ajax.php +++ b/admin-dev/ajax.php @@ -621,7 +621,7 @@ if (Tools::isSubmit('saveHook')) foreach ($hookedModules as $module) { $ids = explode('_', $module); - $value .= '('.$ids[1].', '.$id_shop.', (SELECT id_hook FROM '._DB_PREFIX_.'hook WHERE `name` = \''.pSQL($hook).'\' LIMIT 1), '.$i.'),'; + $value .= '('.(int)$ids[1].', '.$id_shop.', (SELECT id_hook FROM '._DB_PREFIX_.'hook WHERE `name` = \''.pSQL($hook).'\' LIMIT 1), '.(int)$i.'),'; $i++; } $value = rtrim($value, ','); @@ -730,12 +730,12 @@ if (Tools::isSubmit('syncImapMail')) OR !$user = Configuration::get('PS_SAV_IMAP_USER') OR !$password = Configuration::get('PS_SAV_IMAP_PWD')) die('{"hasError" : true, "errors" : ["Configuration is not correct"]}'); - + if (!function_exists('imap_open')) die('{"hasError" : true, "errors" : ["imap is not installed on this server"]}'); - + $mbox = @imap_open('{'.$url.':'.$port.'}', $user, $password); - + //checks if there is no error when connecting imap server $errors = imap_errors(); $str_errors = ''; @@ -747,16 +747,16 @@ if (Tools::isSubmit('syncImapMail')) $str_errors .= '"'.$error.'",'; $str_errors = rtrim($str_errors, ',').''; } - + //checks if imap connexion is active if (!$mbox) die('{"hasError" : true, "errors" : ["Cannot connect to the mailbox"]}'); - + //Returns information about the current mailbox. Returns FALSE on failure. $check = imap_check($mbox); if ($check) die('{"hasError" : true, "errors" : ["Fail to get information about the current mailbox"]}'); - + if ($check->Nmsgs == 0) die('{"hasError" : true, "errors" : ["NO message to sync"]}'); @@ -768,7 +768,7 @@ if (Tools::isSubmit('syncImapMail')) $subject = $overview->subject; else $subject = ''; - + //Creating an md5 to check if message has been allready processed $md5 = md5($overview->date.$overview->from.$subject.$overview->msgno); $exist = Db::getInstance()->getValue( diff --git a/admin-dev/ajaxfilemanager/ajax_create_folder.php b/admin-dev/ajaxfilemanager/ajax_create_folder.php index c343ad85e..48e3497dc 100755 --- a/admin-dev/ajaxfilemanager/ajax_create_folder.php +++ b/admin-dev/ajaxfilemanager/ajax_create_folder.php @@ -10,7 +10,10 @@ require_once('../init.php'); require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php"); @ob_start(); - displayArray($_POST); + $safe_post = array(); + foreach ($_POST AS $key => $value) + $safe_post[Tools::safeOutput($key)] = Tools::safeOutput($value); + displayArray($safe_post); writeInfo(@ob_get_clean()); echo "{"; $error = ""; @@ -72,4 +75,4 @@ echo "error:'" . $error . "'"; echo $info; echo "}"; -?> \ No newline at end of file +?> diff --git a/admin-dev/ajaxfilemanager/ajax_image_editor.php b/admin-dev/ajaxfilemanager/ajax_image_editor.php index 4217a0205..431210266 100755 --- a/admin-dev/ajaxfilemanager/ajax_image_editor.php +++ b/admin-dev/ajaxfilemanager/ajax_image_editor.php @@ -105,7 +105,7 @@
Modes
- +

@@ -131,7 +131,7 @@

- + diff --git a/admin-dev/ajaxfilemanager/ajaxfilemanager.php b/admin-dev/ajaxfilemanager/ajaxfilemanager.php index 53103ada1..2f7f47e31 100755 --- a/admin-dev/ajaxfilemanager/ajaxfilemanager.php +++ b/admin-dev/ajaxfilemanager/ajaxfilemanager.php @@ -74,7 +74,7 @@ --> '; - + $this->displayOptionTypeText($key, $field, $value); echo (isset($field['next']) ? ' '.strval($field['next']) : ''); echo '  '.$this->l('Add my IP').''; diff --git a/admin-dev/tabs/AdminStatsTab.php b/admin-dev/tabs/AdminStatsTab.php index 956cf71f8..aaf527ae0 100644 --- a/admin-dev/tabs/AdminStatsTab.php +++ b/admin-dev/tabs/AdminStatsTab.php @@ -100,7 +100,7 @@ abstract class AdminStatsTab extends AdminPreferences $arrayGridEngines = ModuleGridEngine::getGridEngines(); echo ' - +

'.$this->l('Settings', 'AdminStatsTab').''; echo '

'.$this->l('Graph engine', 'AdminStatsTab').'
'; if (sizeof($arrayGraphEngines)) @@ -153,7 +153,7 @@ abstract class AdminStatsTab extends AdminPreferences return '

'.$translations['Calendar'].'
- +
diff --git a/admin-dev/tabs/AdminTranslations.php b/admin-dev/tabs/AdminTranslations.php index 0b438714f..a0510616e 100644 --- a/admin-dev/tabs/AdminTranslations.php +++ b/admin-dev/tabs/AdminTranslations.php @@ -843,13 +843,13 @@ class AdminTranslations extends AdminTab - + '; return $str_output; } diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 1ce618ec9..a795a9dd5 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -844,7 +844,7 @@ abstract class AdminTabCore if (!Validate::isDate($value[0])) $this->_errors[] = Tools::displayError('\'from:\' date format is invalid (YYYY-MM-DD)'); else - $sqlFilter .= ' AND '.pSQL($key).' >= \''.pSQL(Tools::dateFrom($value[0])).'\''; + $sqlFilter .= ' AND `'.bqSQL($key).'` >= \''.pSQL(Tools::dateFrom($value[0])).'\''; } if (isset($value[1]) AND !empty($value[1])) @@ -852,7 +852,7 @@ abstract class AdminTabCore if (!Validate::isDate($value[1])) $this->_errors[] = Tools::displayError('\'to:\' date format is invalid (YYYY-MM-DD)'); else - $sqlFilter .= ' AND '.pSQL($key).' <= \''.pSQL(Tools::dateTo($value[1])).'\''; + $sqlFilter .= ' AND `'.bqSQL($key).'` <= \''.pSQL(Tools::dateTo($value[1])).'\''; } } else diff --git a/classes/Cart.php b/classes/Cart.php index cbf559c0a..52ed4000d 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -417,10 +417,11 @@ class CartCore extends ObjectModel IF (IFNULL(pa.`supplier_reference`, \'\') = \'\', p.`supplier_reference`, pa.`supplier_reference`) AS supplier_reference, (p.`weight`+ pa.`weight`) weight_attribute, IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13, IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc, - pai.`id_image` as pai_id_image, IFNULL(pa.`minimal_quantity`, p.`minimal_quantity`) as minimal_quantity, pa.`ecotax` AS ecotax_attr'); + pai.`id_image` as pai_id_image, il.`legend` as pai_legend, IFNULL(pa.`minimal_quantity`, p.`minimal_quantity`) as minimal_quantity, pa.`ecotax` AS ecotax_attr'); $sql->leftJoin('product_attribute pa ON pa.`id_product_attribute` = cp.`id_product_attribute`'); $sql->leftJoin('product_attribute_image pai ON pai.`id_product_attribute` = pa.`id_product_attribute`'); + $sql->leftJoin('image_lang il ON il.id_image = pai.id_image AND il.id_lang = '.(int)$this->id_lang); } else $sql->select('p.`reference` AS reference, p.`supplier_reference` AS supplier_reference, p.`ean13`, p.`upc` AS upc, p.`minimal_quantity` AS minimal_quantity'); @@ -465,30 +466,29 @@ class CartCore extends ObjectModel $row['price'] = Product::getPriceStatic((int)$row['id_product'], false, (int)$row['id_product_attribute'], 6, NULL, false, true, $row['cart_quantity'], false, ((int)($this->id_customer) ? (int)($this->id_customer) : NULL), (int)($this->id), ((int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) ? (int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) : NULL), $specificPriceOutput); $row['price_wt'] = Product::getPriceStatic((int)$row['id_product'], true, (int)$row['id_product_attribute'], 2, NULL, false, true, $row['cart_quantity'], false, ((int)($this->id_customer) ? (int)($this->id_customer) : NULL), (int)($this->id), ((int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) ? (int)($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) : NULL)); - /* In case when you use QuantityDiscount, getPriceStatic() can be return more of 2 decimals */ + // In case when you use QuantityDiscount, getPriceStatic() can be return more of 2 decimals $row['price_wt'] = Tools::ps_round($row['price_wt'], 2); $row['total_wt'] = $row['price_wt'] * (int)($row['cart_quantity']); $row['total'] = Tools::ps_round($row['price'] * (int)($row['cart_quantity']), 2); } - $row2 = Db::getInstance()->getRow(' - SELECT i.`id_image`, il.`legend` - FROM `'._DB_PREFIX_.'image` i - LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.') - WHERE '.((isset($row['`pai_id_image`']) AND $row['`pai_id_image`']) - ? 'i.`id_image` = ( - SELECT i2.`id_image` - FROM `'._DB_PREFIX_.'image` i2 - INNER JOIN `'._DB_PREFIX_.'product_attribute_image` pai2 ON (pai2.`id_image` = i2.`id_image`) - WHERE i2.`id_product` = p.`id_product` AND pai2.`id_product_attribute` = pa.`id_product_attribute` - ORDER BY i2.`position` - LIMIT 1 - )' - : 'i.`id_product` = '.(int)$row['id_product'].' AND i.`cover` = 1').' - '); - if (!$row2) - $row2 = array('id_image' => false, 'legend' => false); - $row = array_merge($row, $row2); + if (!isset($row['pai_id_image'])) + { + $row2 = Db::getInstance()->getRow(' + SELECT i.`id_image`, il.`legend` + FROM `'._DB_PREFIX_.'image` i + LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.') + WHERE i.`id_product` = '.(int)$row['id_product'].' AND i.`cover` = 1'); + if (!$row2) + $row2 = array('id_image' => false, 'legend' => false); + else + $row = array_merge($row, $row2); + } + else + { + $row['id_image'] = $row['pai_id_image']; + $row['legend'] = $row['pai_legend']; + } $row['reduction_applies'] = ($specificPriceOutput AND (float)$specificPriceOutput['reduction']); $row['quantity_discount_applies'] = ($specificPriceOutput AND $row['cart_quantity'] >= (int)$specificPriceOutput['from_quantity']); @@ -500,6 +500,7 @@ class CartCore extends ObjectModel $this->_products[] = $row; } + return $this->_products; } diff --git a/classes/Category.php b/classes/Category.php index f6e12e5e5..3ecfd02b4 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -674,7 +674,7 @@ class CategoryCore extends ObjectModel FROM `'._DB_PREFIX_.'category` c3 WHERE c3.`nleft` > c.`nleft` AND c3.`nright` < c.`nright` - AND c3.`id_category` IN ('.$selectedCat.') + AND c3.`id_category` IN ('.array_map('intval', $selectedCat).') )' : '0').' AS nbSelectedSubCat FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.$shop->sqlLang('cl').' @@ -1123,7 +1123,7 @@ class CategoryCore extends ObjectModel FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->sqlLang('cl').') WHERE cl.`id_lang` = '.(int)$id_lang.' - AND c.`id_category` IN ('.implode(',', $ids_category).') + AND c.`id_category` IN ('.implode(',', array_map('intval', $ids_category)).') '); foreach($results as $category) diff --git a/classes/ModuleGraph.php b/classes/ModuleGraph.php index 8c8149619..43fe21731 100644 --- a/classes/ModuleGraph.php +++ b/classes/ModuleGraph.php @@ -1,6 +1,6 @@ NULL, 'x' => NULL, 'y' => NULL); - + /** @var ModuleGraphEngine graph engine */ protected $_render; @@ -58,7 +58,7 @@ abstract class ModuleGraphCore extends Module // Get dates in a manageable format $fromArray = getdate(strtotime($this->_employee->stats_date_from)); $toArray = getdate(strtotime($this->_employee->stats_date_to)); - + // If the granularity is inferior to 1 day if ($this->_employee->stats_date_from == $this->_employee->stats_date_to) { @@ -156,11 +156,11 @@ abstract class ModuleGraphCore extends Module $this->setAllTimeValues($layers); } } - + protected function csvExport($datas) { $context = Context::getContext(); - + $this->setEmployee($context->employee->id); $this->setLang($context->language->id); @@ -168,7 +168,7 @@ abstract class ModuleGraphCore extends Module if (isset($datas['option'])) $this->setOption($datas['option'], $layers); $this->getData($layers); - + // @todo use native CSV PHP functions ? // Generate first line (column titles) if (is_array($this->_titles['main'])) @@ -191,7 +191,7 @@ abstract class ModuleGraphCore extends Module $total += (is_array($this->_values[$i]) ? $this->_values[$i][$key] : $this->_values[$key]); foreach ($this->_legend AS $key => $legend) { - $this->_csv .= $legend.';'; + $this->_csv .= $legend.';'; for ($i = 0; $i < (is_array($this->_titles['main']) ? sizeof($this->_values) : 1); ++$i) { if (!isset($this->_values[$i]) || !is_array($this->_values[$i])) @@ -219,7 +219,7 @@ abstract class ModuleGraphCore extends Module } $this->_displayCsv(); } - + protected function _displayCsv() { ob_end_clean(); @@ -228,33 +228,33 @@ abstract class ModuleGraphCore extends Module echo $this->_csv; exit; } - + public function create($render, $type, $width, $height, $layers) { if (!Tools::file_exists_cache($file = dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php')) die(Tools::displayError()); require_once($file); $this->_render = new $render($type); - + $this->getData($layers); $this->_render->createValues($this->_values); $this->_render->setSize($width, $height); $this->_render->setLegend($this->_legend); $this->_render->setTitles($this->_titles); } - + public function draw() { $this->_render->draw(); } - + /** * @todo Set this method as abstracted ? Quid of module compatibility. */ public function setOption($option, $layers = 1) { } - + public function engine($params) { $context = Context::getContext(); @@ -262,7 +262,7 @@ abstract class ModuleGraphCore extends Module return Tools::displayError('No graph engine selected'); if (!file_exists(dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php')) return Tools::displayError('Graph engine selected is unavailable.'); - + $id_employee = (int)($context->employee->id); $id_lang = (int)($context->language->id); @@ -274,25 +274,25 @@ abstract class ModuleGraphCore extends Module $params['width'] = 550; if (!isset($params['height'])) $params['height'] = 270; - + $urlParams = $params; $urlParams['render'] = $render; $urlParams['module'] = Tools::getValue('module'); $urlParams['id_employee'] = $id_employee; $urlParams['id_lang'] = $id_lang; - $drawer = 'drawer.php?' . http_build_query($urlParams); - + $drawer = 'drawer.php?' . http_build_query(array_map('Tools::safeOutput', $urlParams)); + require_once(dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php'); return call_user_func(array($render, 'hookGraphEngine'), $params, $drawer); } - + protected static function getEmployee($employee = null, Context $context = null) { if (!$context) $context = Context::getContext(); if (!$employee) $employee = $context->employee; - + if (empty($employee->stats_date_from) OR empty($employee->stats_date_to) OR $employee->stats_date_from == '0000-00-00' OR $employee->stats_date_to == '0000-00-00') { if (empty($employee->stats_date_from) OR $employee->stats_date_from == '0000-00-00') @@ -303,18 +303,18 @@ abstract class ModuleGraphCore extends Module } return $employee; } - + public function getDate() { return self::getDateBetween($this->_employee); } - + public static function getDateBetween($employee = null) { $employee = self::getEmployee($employee); return ' \''.$employee->stats_date_from.' 00:00:00\' AND \''.$employee->stats_date_to.' 23:59:59\' '; } - + public function getLang() { return $this->_id_lang; diff --git a/classes/ModuleGrid.php b/classes/ModuleGrid.php index f053c27cc..057b0d511 100644 --- a/classes/ModuleGrid.php +++ b/classes/ModuleGrid.php @@ -100,7 +100,7 @@ abstract class ModuleGridCore extends Module if (!file_exists(dirname(__FILE__).'/../modules/'.$render.'/'.$render.'.php')) return Tools::displayError('Grid engine selected is unavailable.'); - $grider = 'grider.php?render='.$render.'&module='.Tools::getValue('module'); + $grider = 'grider.php?render='.$render.'&module='.Tools::safeOutput(Tools::getValue('module')); $context = Context::getContext(); $grider .= '&id_employee='.(int)($context->employee->id); diff --git a/classes/Product.php b/classes/Product.php index 467a476f6..3d7f765d5 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -1543,7 +1543,7 @@ class ProductCore extends ObjectModel '.$context->shop->sqlAsso('product', 'p').' WHERE p.`active` = 1 AND p.`show_price` = 1 - '.((!$beginning AND !$ending) ? ' AND p.`id_product` IN('.((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').' + '.((!$beginning AND !$ending) ? ' AND p.`id_product` IN('.((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', array_map('intval', $ids_product)) : 0).')' : '').' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg @@ -2809,6 +2809,7 @@ class ProductCore extends ObjectModel public static function defineProductImage($row, $id_lang) { + if (isset($row['id_image'])) if ($row['id_image']) return $row['id_product'].'-'.$row['id_image']; return Language::getIsoById((int)$id_lang).'-default'; @@ -3606,7 +3607,7 @@ class ProductCore extends ObjectModel $row = Db::getInstance()->getRow(' SELECT `reference` FROM `'._DB_PREFIX_.'product` p - WHERE p.reference = "'.$reference.'"'); + WHERE p.reference = "'.pSQL($reference).'"'); return isset($row['reference']); } diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index bfe030217..d7128b605 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -198,8 +198,8 @@ class SpecificPriceCore extends ObjectModel return Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'specific_price_priority` (`id_product`, `priority`) - VALUES ('.(int)$id_product.',\''.rtrim($value, ';').'\') - ON DUPLICATE KEY UPDATE `priority` = \''.rtrim($value, ';').'\' + VALUES ('.(int)$id_product.',\''.pSQL(rtrim($value, ';')).'\') + ON DUPLICATE KEY UPDATE `priority` = \''.pSQL(rtrim($value, ';')).'\' '); } @@ -285,9 +285,9 @@ class SpecificPriceCore extends ObjectModel `id_group` IN(0, '.(int)$id_group.') AND `from_quantity` = 1 AND ( - (`from` = \'0000-00-00 00:00:00\' OR \''.$beginning.'\' >= `from`) + (`from` = \'0000-00-00 00:00:00\' OR \''.pSQL($beginning).'\' >= `from`) AND - (`to` = \'0000-00-00 00:00:00\' OR \''.$ending.'\' <= `to`) + (`to` = \'0000-00-00 00:00:00\' OR \''.pSQL($ending).'\' <= `to`) ) AND `reduction` > 0 diff --git a/classes/Tools.php b/classes/Tools.php index e52d710c5..f87931c7f 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -509,8 +509,8 @@ class ToolsCore public static function safeOutput($string, $html = false) { if (!$html) - $string = @htmlentities(strip_tags($string), ENT_QUOTES, 'utf-8'); - return $string; + $string = strip_tags($string); + return @Tools::htmlentitiesUTF8($string, ENT_QUOTES);; } public static function htmlentitiesUTF8($string, $type = ENT_QUOTES) diff --git a/classes/db/Db.php b/classes/db/Db.php index 30c9f367b..108b6940d 100644 --- a/classes/db/Db.php +++ b/classes/db/Db.php @@ -303,7 +303,7 @@ abstract class DbCore public function delete($table, $where = false, $limit = false, $use_cache = 1) { $this->_result = false; - $sql = 'DELETE FROM `'.pSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)$limit : ''); + $sql = 'DELETE FROM `'.bqSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)$limit : ''); $res = $this->query($sql); if ($use_cache AND _PS_CACHE_ENABLED_) Cache::getInstance()->deleteQuery($sql); diff --git a/config/alias.php b/config/alias.php index 2e4fffde6..2be292588 100644 --- a/config/alias.php +++ b/config/alias.php @@ -57,6 +57,11 @@ function pSQL($string, $htmlOK = false) return Db::getInstance()->escape($string, $htmlOK); } +function bqSQL($string) +{ + return str_replace('`', '\`', pSQL($string)); +} + /** * @deprecated */ diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 404df1172..0261dd534 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -178,6 +178,9 @@ class AuthControllerCore extends FrontController $this->context->cart->secure_key = $customer->secure_key; $this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id)); $this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id)); + + // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated + $this->context->cart->secure_key = $customer->secure_key; $this->context->cart->update(); Module::hookExec('createAccount', array( '_POST' => $_POST, diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index b756df14b..ed18b0519 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -156,15 +156,15 @@ class CategoryControllerCore extends FrontController { $hookExecuted = false; Module::hookExec('productListAssign', array('nbProducts' => &$this->nbProducts, 'catProducts' => &$this->cat_products, 'hookExecuted' => &$hookExecuted)); - if (!$hookExecuted) + if (!$hookExecuted) // The hook was not executed, standard working { - self::$smarty->assign('categoryNameComplement', ''); + $this->context->smarty->assign('categoryNameComplement', ''); $this->nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); - $this->pagination((int)$this->nbProducts); + $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts" $this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); } - else - $this->pagination((int)$this->nbProducts); + else // Hook executed, use the override + $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts" self::$smarty->assign('nb_products', (int)$this->nbProducts); } } diff --git a/localization/gb.xml b/localization/gb.xml index b4e33c0e2..4420d13f0 100644 --- a/localization/gb.xml +++ b/localization/gb.xml @@ -34,7 +34,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -74,4 +74,5 @@ - \ No newline at end of file + + diff --git a/modules/autoupgrade/AdminPreferences.php b/modules/autoupgrade/AdminPreferences.php index ea9a5ccd8..0cda23ace 100644 --- a/modules/autoupgrade/AdminPreferences.php +++ b/modules/autoupgrade/AdminPreferences.php @@ -104,7 +104,7 @@ class AdminPreferences extends AdminTab if (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') { $this->_fieldsGeneral['PS_SSL_ENABLED']['type'] = 'disabled'; - $this->_fieldsGeneral['PS_SSL_ENABLED']['disabled'] = ''.$this->l('Please click here to use HTTPS protocol before enabling SSL.').''; + $this->_fieldsGeneral['PS_SSL_ENABLED']['disabled'] = ''.$this->l('Please click here to use HTTPS protocol before enabling SSL.').''; } parent::__construct(); diff --git a/modules/birthdaypresent/birthdaypresent.php b/modules/birthdaypresent/birthdaypresent.php index a790adb54..ef912cf2f 100644 --- a/modules/birthdaypresent/birthdaypresent.php +++ b/modules/birthdaypresent/birthdaypresent.php @@ -61,7 +61,7 @@ class BirthdayPresent extends Module $this->_html = '
'.$this->displayName.'

'.$this->l('Create a voucher for customers celebrating their birthday and having at least one valid order').'

- +
diff --git a/modules/blockadvertising/blockadvertising.php b/modules/blockadvertising/blockadvertising.php index 08c47ee08..faffa8841 100644 --- a/modules/blockadvertising/blockadvertising.php +++ b/modules/blockadvertising/blockadvertising.php @@ -169,7 +169,7 @@ class BlockAdvertising extends Module $this->postProcess(); $output = ''; $output .= ' - +
'.$this->l('Advertising block configuration').' '; if ($this->adv_img) diff --git a/modules/blockbestsellers/blockbestsellers.php b/modules/blockbestsellers/blockbestsellers.php index 979ac15bd..8b41e09fb 100644 --- a/modules/blockbestsellers/blockbestsellers.php +++ b/modules/blockbestsellers/blockbestsellers.php @@ -78,7 +78,7 @@ class BlockBestSellers extends Module public function displayForm() { return ' - +
'.$this->l('Settings').' diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 5769324fa..bfdeb7058 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -123,7 +123,7 @@ class BlockCart extends Module public function displayForm() { return ' - +
'.$this->l('Settings').' diff --git a/modules/blockcategories/blockcategories.php b/modules/blockcategories/blockcategories.php index 029444a76..bd3169403 100644 --- a/modules/blockcategories/blockcategories.php +++ b/modules/blockcategories/blockcategories.php @@ -95,7 +95,7 @@ class BlockCategories extends Module public function displayForm() { return ' - +
'.$this->l('Settings').' diff --git a/modules/blocklayered/blocklayered-indexer.php b/modules/blocklayered/blocklayered-indexer.php deleted file mode 100644 index 4d0dcb9bf..000000000 --- a/modules/blocklayered/blocklayered-indexer.php +++ /dev/null @@ -1,13 +0,0 @@ -indexUrl($cursor, (int)Tools::getValue('ajax'), (int)Tools::getValue('truncate')); \ No newline at end of file +echo $blockLayered->indexUrl($cursor, (int)Tools::getValue('truncate')); \ No newline at end of file diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 98d5d77e6..634a2f925 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -63,16 +63,16 @@ class BlockLayered extends Module $this->rebuildLayeredStructure(); $this->rebuildLayeredCache(); - self::_installPriceIndexTable(); - $this->_installFriendlyUrlTable(); - $this->_installIndexableAttributeTable(); - $this->_installProductAttributeTable(); + self::installPriceIndexTable(); + $this->installFriendlyUrlTable(); + $this->installIndexableAttributeTable(); + $this->installProductAttributeTable(); $this->indexUrl(); $this->indexAttribute(); if(Db::getInstance()->getValue('SELECT count(*) FROM `'._DB_PREFIX_.'product`') < 10000) // Lock price indexation if too many products - self::fullIndexProcess(); + self::fullPricesIndexProcess(); return true; } @@ -103,7 +103,7 @@ class BlockLayered extends Module return parent::uninstall(); } - private static function _installPriceIndexTable() + private static function installPriceIndexTable() { Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_price_index`'); @@ -115,7 +115,7 @@ class BlockLayered extends Module INDEX `price_min` (`price_min`), INDEX `price_max` (`price_max`)) ENGINE = '._MYSQL_ENGINE_); } - private function _installFriendlyUrlTable() + private function installFriendlyUrlTable() { Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_friendly_url`'); Db::getInstance()->Execute(' @@ -130,7 +130,7 @@ class BlockLayered extends Module Db::getInstance()->Execute('CREATE INDEX `url_key` ON `'._DB_PREFIX_.'layered_friendly_url`(url_key(5))'); } - private function _installIndexableAttributeTable() + private function installIndexableAttributeTable() { // Attributes Groups Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_group`'); @@ -175,7 +175,6 @@ class BlockLayered extends Module INSERT INTO `'._DB_PREFIX_.'layered_indexable_feature` SELECT id_feature, 1 FROM `'._DB_PREFIX_.'feature`'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_lang`'); Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_lang`'); Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_feature_lang` ( @@ -200,7 +199,7 @@ class BlockLayered extends Module * * create table product attribute */ - public function _installProductAttributeTable() + public function installProductAttributeTable() { Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_product_attribute`'); Db::getInstance()->Execute(' @@ -216,9 +215,12 @@ class BlockLayered extends Module * * Generate data product attribute */ - public function indexAttribute() + public function indexAttribute($id_product = null) { + if (is_null($id_product)) Db::getInstance()->execute('TRUNCATE '._DB_PREFIX_.'layered_product_attribute'); + else + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_product_attribute WHERE id_product = '.(int)$id_product); Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`) SELECT pac.id_attribute, pa.id_product, ag.id_attribute_group @@ -226,6 +228,7 @@ class BlockLayered extends Module INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute) INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = a.id_attribute_group + '.(is_null($id_product) ? '' : 'AND pa.id_product = '.(int)$id_product).' GROUP BY a.id_attribute, pa.id_product'); return 1; @@ -238,11 +241,11 @@ class BlockLayered extends Module if($truncate) Db::getInstance()->execute('TRUNCATE '._DB_PREFIX_.'layered_friendly_url'); - $attributeValues = array(); + $attributeValuesByLang = array(); $filters = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT lc.*, id_lang, name, link_rewrite, cl.id_category FROM '._DB_PREFIX_.'layered_category lc INNER JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = lc.id_category AND lc.id_category <> 1 ) - ORDER BY position ASC'); + GROUP BY type, id_value, id_lang'); if (!$filters) return; @@ -265,15 +268,18 @@ class BlockLayered extends Module WHERE a.id_attribute_group = '.(int)$filter['id_value'].' AND agl.id_lang = al.id_lang AND agl.id_lang = '.(int)$filter['id_lang']); foreach ($attributes as $attribute) { - if (!isset($attributeValues[$attribute['id_lang']])) - $attributeValues[$attribute['id_lang']] = array(); - if (!isset($attributeValues[$attribute['id_lang']][$filter['id_category']])) - $attributeValues[$attribute['id_lang']][$filter['id_category']] = array(); - if (!isset($attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']])) - $attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']] = array(); - $attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']][] = array('name' => (!empty($attribute['name_url_name']) ? $attribute['name_url_name'] : $attribute['name']), - 'id_name' => 'c'.$attribute['id_name'], 'value' => (!empty($attribute['value_url_name']) ? $attribute['value_url_name'] : $attribute['value']), 'id_value' => $attribute['id_name'].'_'.$attribute['id_value'], - 'id_id_value' => $attribute['id_value'], 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']); + if (!isset($attributeValuesByLang[$attribute['id_lang']])) + $attributeValuesByLang[$attribute['id_lang']] = array(); + if (!isset($attributeValuesByLang[$attribute['id_lang']]['c'.$attribute['id_name']])) + $attributeValuesByLang[$attribute['id_lang']]['c'.$attribute['id_name']] = array(); + $attributeValuesByLang[$attribute['id_lang']]['c'.$attribute['id_name']][] = array( + 'name' => (!empty($attribute['name_url_name']) ? $attribute['name_url_name'] : $attribute['name']), + 'id_name' => 'c'.$attribute['id_name'], + 'value' => (!empty($attribute['value_url_name']) ? $attribute['value_url_name'] : $attribute['value']), + 'id_value' => $attribute['id_name'].'_'.$attribute['id_value'], + 'id_id_value' => $attribute['id_value'], + 'category_name' => $filter['link_rewrite'], + 'type' => $filter['type']); } break; @@ -292,15 +298,18 @@ class BlockLayered extends Module WHERE fl.id_feature = '.(int)$filter['id_value'].' AND fvl.id_lang = fl.id_lang AND fvl.id_lang = '.(int)$filter['id_lang']); foreach ($features as $feature) { - if (!isset($attributeValues[$feature['id_lang']])) - $attributeValues[$feature['id_lang']] = array(); - if (!isset($attributeValues[$feature['id_lang']][$filter['id_category']])) - $attributeValues[$feature['id_lang']][$filter['id_category']] = array(); - if (!isset($attributeValues[$feature['id_lang']][$filter['id_category']]['f'.$feature['id_name']])) - $attributeValues[$feature['id_lang']][$filter['id_category']]['f'.$feature['id_name']] = array(); - $attributeValues[$feature['id_lang']][$filter['id_category']]['f'.$feature['id_name']][] = array('name' => (!empty($feature['name_url_name']) ? $feature['name_url_name'] : $feature['name']), - 'id_name' => 'f'.$feature['id_name'], 'value' => (!empty($attribute['value_url_name']) ? $attribute['value_url_name'] : $feature['value']), 'id_value' => $feature['id_value'], - 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']); + if (!isset($attributeValuesByLang[$feature['id_lang']])) + $attributeValuesByLang[$feature['id_lang']] = array(); + if (!isset($attributeValuesByLang[$feature['id_lang']]['f'.$feature['id_name']])) + $attributeValuesByLang[$feature['id_lang']]['f'.$feature['id_name']] = array(); + $attributeValuesByLang[$feature['id_lang']]['f'.$feature['id_name']][] = array( + 'name' => (!empty($feature['name_url_name']) ? $feature['name_url_name'] : $feature['name']), + 'id_name' => 'f'.$feature['id_name'], + 'value' => (!empty($feature['value_url_name']) ? $feature['value_url_name'] : $feature['value']), + 'id_value' => $feature['id_name'].'_'.$feature['id_value'], + 'id_id_value' => $feature['id_value'], + 'category_name' => $filter['link_rewrite'], + 'type' => $filter['type']); } break; @@ -309,18 +318,14 @@ class BlockLayered extends Module SELECT cl.name, cl.id_lang, c.id_category FROM '._DB_PREFIX_.'category c INNER JOIN '._DB_PREFIX_.'category_lang cl ON (c.id_category = cl.id_category) - WHERE nleft > (SELECT nleft FROM '._DB_PREFIX_.'category WHERE id_category = '.$filter['id_category'].') - AND nright < (SELECT nright FROM '._DB_PREFIX_.'category WHERE id_category = '.$filter['id_category'].') - AND cl.id_lang = '.(int)$filter['id_lang'].' '); + WHERE cl.id_lang = '.(int)$filter['id_lang']); foreach($categories as $category) { - if (!isset($attributeValues[$category['id_lang']])) - $attributeValues[$category['id_lang']] = array(); - if (!isset($attributeValues[$category['id_lang']][$filter['id_category']])) - $attributeValues[$category['id_lang']][$filter['id_category']] = array(); - if (!isset($attributeValues[$category['id_lang']][$filter['id_category']]['category'])) - $attributeValues[$category['id_lang']][$filter['id_category']]['category'] = array(); - $attributeValues[$category['id_lang']][$filter['id_category']]['category'][] = array('name' => $this->l('Categories'), + if (!isset($attributeValuesByLang[$category['id_lang']])) + $attributeValuesByLang[$category['id_lang']] = array(); + if (!isset($attributeValuesByLang[$category['id_lang']]['category'])) + $attributeValuesByLang[$category['id_lang']]['category'] = array(); + $attributeValuesByLang[$category['id_lang']]['category'][] = array('name' => $this->l('Categories'), 'id_name' => null, 'value' => $category['name'], 'id_value' => $category['id_category'], 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']); } @@ -334,43 +339,45 @@ class BlockLayered extends Module foreach ($manufacturers as $manufacturer) { - if (!isset($attributeValues[$manufacturer['id_lang']])) - $attributeValues[$manufacturer['id_lang']] = array(); - if (!isset($attributeValues[$manufacturer['id_lang']][$filter['id_category']])) - $attributeValues[$manufacturer['id_lang']][$filter['id_category']] = array(); - if (!isset($attributeValues[$manufacturer['id_lang']][$filter['id_category']]['manufacturer'])) - $attributeValues[$manufacturer['id_lang']][$filter['id_category']]['manufacturer'] = array(); - $attributeValues[$manufacturer['id_lang']][$filter['id_category']]['manufacturer'][] = array('name' => $this->translateWord('Manufacturer', $manufacturer['id_lang']), + if (!isset($attributeValuesByLang[$manufacturer['id_lang']])) + $attributeValuesByLang[$manufacturer['id_lang']] = array(); + if (!isset($attributeValuesByLang[$manufacturer['id_lang']]['manufacturer'])) + $attributeValuesByLang[$manufacturer['id_lang']]['manufacturer'] = array(); + $attributeValuesByLang[$manufacturer['id_lang']]['manufacturer'][] = array('name' => $this->translateWord('Manufacturer', $manufacturer['id_lang']), 'id_name' => null, 'value' => $manufacturer['name'], 'id_value' => $manufacturer['id_manufacturer'], 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']); } break; case 'quantity': - foreach (array (0 => $this->translateWord('Not available',(int)$filter['id_lang']), 1 => $this->translateWord('In stock', (int)$filter['id_lang'])) - as $key => $quantity) - $attributeValues[$filter['id_lang']][$filter['id_category']]['quantity'][] = array('name' => $this->translateWord('Availability', (int)$filter['id_lang']), + $avaibility_list = array( + $this->translateWord('Not available', (int)$filter['id_lang']), + $this->translateWord('In stock', (int)$filter['id_lang']) + ); + foreach ($avaibility_list as $key => $quantity) + $attributeValuesByLang[$filter['id_lang']]['quantity'][] = array('name' => $this->translateWord('Availability', (int)$filter['id_lang']), 'id_name' => null, 'value' => $quantity, 'id_value' => $key, 'id_id_value' => 0, 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']); break; case 'condition': - foreach (array('new' => $this->translateWord('New', (int)$filter['id_lang']), 'used' => $this->translateWord('Used', (int)$filter['id_lang']), - 'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang'])) - as $key => $condition) - $attributeValues[$filter['id_lang']][$filter['id_category']]['condition'][] = array('name' => $this->translateWord('Condition', (int)$filter['id_lang']), + $condition_list = array( + 'new' => $this->translateWord('New', (int)$filter['id_lang']), + 'used' => $this->translateWord('Used', (int)$filter['id_lang']), + 'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang']) + ); + foreach ($condition_list as $key => $condition) + $attributeValuesByLang[$filter['id_lang']]['condition'][] = array('name' => $this->translateWord('Condition', (int)$filter['id_lang']), 'id_name' => null, 'value' => $condition, 'id_value' => $key, 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']); break; } // Foreach langs - $attributeValuesKeys = array_keys($attributeValues); - foreach($attributeValues as $id_lang => $attributesByCategoriesByLang) + foreach ($attributeValuesByLang as $id_lang => $attributeValues) { - // Foreach categories - foreach($attributesByCategoriesByLang as $id_category => $attributesByCategory) - foreach($attributesByCategory as $attribute) + // Foreach attributes generate a couple "/_". For example: color_blue + foreach ($attributeValues as $attribute) foreach($attribute as $param) { $selectedFilters = array(); @@ -380,7 +387,8 @@ class BlockLayered extends Module $param['id_id_value'] = $param['id_value']; $selectedFilters[$param['type']][$param['id_id_value']] = $param['id_value']; $urlKey = md5($link); - $idLayeredFriendlyUrl = Db::getInstance()->getValue('SELECT id_layered_friendly_url FROM `'._DB_PREFIX_.'layered_friendly_url` WHERE `id_lang` = '.$id_lang.' AND `url_key` = \''.$urlKey.'\''); + $idLayeredFriendlyUrl = Db::getInstance()->getValue('SELECT id_layered_friendly_url + FROM `'._DB_PREFIX_.'layered_friendly_url` WHERE `id_lang` = '.$id_lang.' AND `url_key` = \''.$urlKey.'\''); if ($idLayeredFriendlyUrl == false) { Db::getInstance()->AutoExecute(_DB_PREFIX_.'layered_friendly_url', array('url_key' => $urlKey, 'data' => serialize($selectedFilters), 'id_lang' => $id_lang), 'INSERT'); @@ -405,7 +413,7 @@ class BlockLayered extends Module { if (!file_exists($file)) return $string; - include $file; + include($file); $_MODULES[$id_lang] = $_MODULE; } @@ -435,7 +443,9 @@ class BlockLayered extends Module global $smarty; if (!Configuration::get('PS_LAYERED_INDEXED')) return; + // Inform the hook was executed $params['hookExecuted'] = true; + // List of product to overrride categoryController $params['catProducts'] = array(); $selectedFilters = $this->getSelectedFilters(); $filterBlock = self::getFilterBlock($selectedFilters); @@ -446,7 +456,7 @@ class BlockLayered extends Module $smarty->assign('categoryNameComplement', $title); $this->getProducts($selectedFilters, $params['catProducts'], $params['nbProducts'], $p, $n, $pages_nb, $start, $stop, $range); - //test nofollow link + // Need a nofollow on the pagination links? $smarty->assign('no_follow', $filterBlock['nofollow']); } @@ -455,7 +465,8 @@ class BlockLayered extends Module if (!$params['id_product']) return; - self::indexProduct((int)$params['id_product']); + self::indexProductPrices((int)$params['id_product']); + $this->indexAttribute((int)$params['id_product']); } public function hookAfterSaveFeature($params) @@ -686,7 +697,8 @@ class BlockLayered extends Module { $languages = Language::getLanguages(false); $default_form_language = (int)(Configuration::get('PS_LANG_DEFAULT')); - $indexable = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT indexable FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']); + $indexable = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT indexable FROM '._DB_PREFIX_.'layered_indexable_attribute_group + WHERE id_attribute_group = '.(int)$params['id_attribute_group']); $langValue = array(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( @@ -804,23 +816,23 @@ class BlockLayered extends Module /* * $cursor $cursor in order to restart indexing from the last state */ - public static function fullIndexProcess($cursor = 0, $ajax = false, $smart = false) + public static function fullPricesIndexProcess($cursor = 0, $ajax = false, $smart = false) { - if ($cursor == 0 AND !$smart) - self::_installPriceIndexTable(); + if ($cursor == 0 && !$smart) + self::installPriceIndexTable(); - return self::_indexer($cursor, true, $ajax, $smart); + return self::indexPrices($cursor, true, $ajax, $smart); } /* * $cursor $cursor in order to restart indexing from the last state */ - public static function indexProcess($cursor = 0, $ajax = false) + public static function pricesIndexProcess($cursor = 0, $ajax = false) { - return self::_indexer($cursor, false, $ajax); + return self::indexPrices($cursor, false, $ajax); } - private static function _indexer($cursor = null, $full = false, $ajax = false, $smart = false) + private static function indexPrices($cursor = null, $full = false, $ajax = false, $smart = false) { if ($full) $nbProducts = (int)Db::getInstance()->getValue('SELECT count(*) FROM '._DB_PREFIX_.'product WHERE `active` = 1'); @@ -838,20 +850,21 @@ class BlockLayered extends Module do { - $cursor = (int)self::_index((int)$cursor, $full, $smart); + $cursor = (int)self::indexPricesUnbreakable((int)$cursor, $full, $smart); $timeElapsed = microtime(true) - $startTime; } - while ($cursor < $nbProducts AND (Tools::getMemoryLimit()) > memory_get_peak_usage() AND $timeElapsed < $maxExecutionTime); + while ($cursor < $nbProducts && (Tools::getMemoryLimit()) > memory_get_peak_usage() && $timeElapsed < $maxExecutionTime); - if (($nbProducts > 0 AND !$full OR $cursor < $nbProducts AND $full) AND !$ajax) + if (($nbProducts > 0 && !$full || $cursor < $nbProducts && $full) && !$ajax) { - if (!Tools::file_get_contents(Tools::getProtocol().Tools::getHttpHost().'/modules/blocklayered/blocklayered-indexer.php?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&cursor='.(int)$cursor.'&full='.(int)$full)) - self::_indexer((int)$cursor, (int)$full); + $token = substr(Tools::encrypt('blocklayered/index'), 0, 10); + if (!Tools::file_get_contents(Tools::getProtocol().Tools::getHttpHost().'/modules/blocklayered/blocklayered-price-indexer.php?token='.$token.'&cursor='.(int)$cursor.'&full='.(int)$full)) + self::indexPrices((int)$cursor, (int)$full); return $cursor; } - if ($ajax AND $nbProducts > 0 AND $cursor < $nbProducts AND $full) + if ($ajax && $nbProducts > 0 && $cursor < $nbProducts && $full) return '{"cursor": '.$cursor.', "count": '.($nbProducts - $cursor).'}'; - elseif ($ajax AND $nbProducts > 0 AND !$full) + else if ($ajax && $nbProducts > 0 && !$full) return '{"cursor": '.$cursor.', "count": '.($nbProducts).'}'; else { @@ -866,7 +879,7 @@ class BlockLayered extends Module /* * $cursor $cursor in order to restart indexing from the last state */ - private static function _index($cursor, $full = false, $smart = false) + private static function indexPricesUnbreakable($cursor, $full = false, $smart = false) { static $length = 100; // Nb of products to index @@ -888,12 +901,12 @@ class BlockLayered extends Module ORDER by id_product LIMIT 0,'.(int)$length; foreach (Db::getInstance()->ExecuteS($query) as $product) - self::indexProduct((int)$product['id_product'], ($smart AND $full)); + self::indexProductPrices((int)$product['id_product'], ($smart && $full)); return (int)($cursor + $length); } - public static function indexProduct($idProduct, $smart = true) + public static function indexProductPrices($idProduct, $smart = true) { static $groups = null; @@ -943,14 +956,14 @@ class BlockLayered extends Module $maxPrice[$currency['id_currency']] = $price; if ($price == 0) continue; - if (is_null($minPrice[$currency['id_currency']]) OR $price < $minPrice[$currency['id_currency']]) + if (is_null($minPrice[$currency['id_currency']]) || $price < $minPrice[$currency['id_currency']]) $minPrice[$currency['id_currency']] = $price; } foreach ($productMinPrices as $specificPrice) foreach ($currencyList as $currency) { - if ($specificPrice['id_currency'] AND $specificPrice['id_currency'] != $currency['id_currency']) + if ($specificPrice['id_currency'] && $specificPrice['id_currency'] != $currency['id_currency']) continue; $price = Product::priceCalculation((($specificPrice['id_shop'] == 0) ? null : (int)$specificPrice['id_shop']), (int)$idProduct, null, (($specificPrice['id_country'] == 0) ? null : $specificPrice['id_country']), null, null, @@ -965,7 +978,7 @@ class BlockLayered extends Module $maxPrice[$currency['id_currency']] = $price; if ($price == 0) continue; - if (is_null($minPrice[$currency['id_currency']]) OR $price < $minPrice[$currency['id_currency']]) + if (is_null($minPrice[$currency['id_currency']]) || $price < $minPrice[$currency['id_currency']]) $minPrice[$currency['id_currency']] = $price; } @@ -983,7 +996,7 @@ class BlockLayered extends Module $maxPrice[$currency['id_currency']] = $price; if ($price == 0) continue; - if (is_null($minPrice[$currency['id_currency']]) OR $price < $minPrice[$currency['id_currency']]) + if (is_null($minPrice[$currency['id_currency']]) || $price < $minPrice[$currency['id_currency']]) $minPrice[$currency['id_currency']] = $price; } @@ -1097,7 +1110,7 @@ class BlockLayered extends Module
'; else { - if (isset($_POST['id_layered_filter']) AND $_POST['id_layered_filter']) + if (isset($_POST['id_layered_filter']) && $_POST['id_layered_filter']) Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_filter WHERE id_layered_filter = '.(int)Tools::getValue('id_layered_filter')); if (Tools::getValue('scope') == 1) @@ -1108,14 +1121,14 @@ class BlockLayered extends Module $_POST['categoryBox'][] = (int)$category['id_category']; } - if (sizeof($_POST['categoryBox'])) + if (count($_POST['categoryBox'])) { /* Clean categoryBox before use */ - if (isset($_POST['categoryBox']) AND is_array($_POST['categoryBox'])) + if (isset($_POST['categoryBox']) && is_array($_POST['categoryBox'])) foreach ($_POST['categoryBox'] as &$categoryBoxTmp) $categoryBoxTmp = (int)$categoryBoxTmp; - Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_category WHERE id_category IN ('.implode(',', $_POST['categoryBox']).')'); + Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_category WHERE id_category IN ('.implode(',', array_map('intval', $_POST['categoryBox'])).')'); $filterValues = array(); foreach ($_POST['categoryBox'] as $idc) @@ -1126,7 +1139,7 @@ class BlockLayered extends Module { $n = 0; foreach ($_POST as $key => $value) - if (substr($key, 0, 17) == 'layered_selection' AND $value == 'on') + if (substr($key, 0, 17) == 'layered_selection' && $value == 'on') { $filterValues[$key] = $value; $n++; @@ -1151,13 +1164,19 @@ class BlockLayered extends Module Db::getInstance()->Execute(rtrim($sqlToInsert, ',')); - $valuesToInsert = array('name' => pSQL(Tools::getValue('layered_tpl_name')), 'filters' => pSQL(serialize($filterValues)), 'n_categories' => (int)sizeof($filterValues['categories']), 'date_add' => date('Y-m-d H:i:s')); - if (isset($_POST['id_layered_filter']) AND $_POST['id_layered_filter']) + $valuesToInsert = array( + 'name' => pSQL(Tools::getValue('layered_tpl_name')), + 'filters' => pSQL(serialize($filterValues)), + 'n_categories' => (int)count($filterValues['categories']), + 'date_add' => date('Y-m-d H:i:s')); + if (isset($_POST['id_layered_filter']) && $_POST['id_layered_filter']) $valuesToInsert['id_layered_filter'] = (int)Tools::getValue('id_layered_filter'); Db::getInstance()->AutoExecute(_DB_PREFIX_.'layered_filter', $valuesToInsert, 'INSERT'); - echo '
'.$this->l('Your filter').' "'.Tools::getValue('layered_tpl_name').'" '.((isset($_POST['id_layered_filter']) AND $_POST['id_layered_filter']) ? $this->l('was updated successfully.') : $this->l('was added successfully.')).'
'; + echo '
+ '.$this->l('Your filter').' "'.Tools::safeOutput(Tools::getValue('layered_tpl_name')).'" '. + ((isset($_POST['id_layered_filter']) && $_POST['id_layered_filter']) ? $this->l('was updated successfully.') : $this->l('was added successfully.')).'
'; } } } @@ -1223,20 +1242,35 @@ class BlockLayered extends Module $categoryList[] = $category['id_category']; $html .= ' -
'.$this->l('Index all missing prices').' + '. + $this->l('Index all missing prices').'
- '.$this->l('Re-build entire price index').' + '. + $this->l('Re-build entire price index').'
- '.$this->l('Build attribute index').' + '. + $this->l('Build attribute index').'
- '.$this->l('Build url index').' + '. + $this->l('Build url index').'

- '.$this->l('You can set a cron job that will re-build price index using the following URL:').'
'.Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&full=1 + '.$this->l('You can set a cron job that will re-build price index using the following URL:').'
'. + Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&full=1
- '.$this->l('You can set a cron job that will re-build url index using the following URL:').'
'.Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-url-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&truncate=1 + '.$this->l('You can set a cron job that will re-build url index using the following URL:').'
'. + Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-url-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&truncate=1
- '.$this->l('You can set a cron job that will re-build attribute index using the following URL:').'
'.Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-attribute-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).' + '.$this->l('You can set a cron job that will re-build attribute index using the following URL:').'
'. + Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-attribute-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'

'.$this->l('A nightly rebuild is recommended.').'
'.$this->l('Add a new link').' - +
'; foreach ($languages as $language) @@ -299,7 +299,7 @@ class BlockLink extends Module
'.$this->l('Block title').' - +
'; foreach ($languages as $language) @@ -318,7 +318,7 @@ class BlockLink extends Module
'.$this->l('Settings').' - +
+


- - '.Tools::getValue('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT')).' + + '.Tools::safeOutput(Tools::getValue('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT'))).'
- + '.$configCurrency->sign.'
@@ -439,12 +439,12 @@ class CanadaPost extends CarrierModule

'.$this->l('Localization configuration').' :

- +

'.$this->l('The weight unit of your shop (eg. kg or lbs)').'

- +

'.$this->l('The dimension unit of your shop (eg. cm or in)').'

@@ -452,13 +452,13 @@ class CanadaPost extends CarrierModule

'.$this->l('Address configuration').' :

-
+
-
+
-

+

-
+
@@ -761,13 +761,13 @@ class CanadaPost extends CarrierModule $path .= $p; } - $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

-
+ $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

+
'.$path.'

-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code`'); @@ -785,7 +785,7 @@ class CanadaPost extends CarrierModule else { $html .= '

'.$this->l('Add a rule').'

- +
-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code`'); @@ -963,10 +963,10 @@ class CanadaPost extends CarrierModule '.$c['additional_charges'].' '.$configCurrency->sign.' '.$services.' - + - + @@ -984,13 +984,13 @@ class CanadaPost extends CarrierModule $configSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_cp_rate_config` = '.(int)(Tools::getValue('id_cp_rate_config'))); $product = new Product((int)$configSelected['id_product'], false, (int)$this->context->language->id); - $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

-
+ $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

+
'.$product->name.'

-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code`'); @@ -1008,7 +1008,7 @@ class CanadaPost extends CarrierModule else { $html .= '

'.$this->l('Add a rule').'

- +

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code`'); diff --git a/modules/crossselling/crossselling.php b/modules/crossselling/crossselling.php index 88f9b0037..da180be01 100755 --- a/modules/crossselling/crossselling.php +++ b/modules/crossselling/crossselling.php @@ -82,7 +82,7 @@ class CrossSelling extends Module $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully')); } $this->_html .= ' - +
'.$this->l('Settings').'
diff --git a/modules/dejala/dejala.php b/modules/dejala/dejala.php index 46c2ead50..8253989dd 100644 --- a/modules/dejala/dejala.php +++ b/modules/dejala/dejala.php @@ -1,6 +1,6 @@ version = 1.4; $this->internal_version = '1.3'; parent::__construct(); - + $this->id_lang = $this->context->language->id; $this->wday_labels = array($this->l('Sunday'), $this->l('Monday'), $this->l('Tuesday'), $this->l('Wednesday'), $this->l('Thursday'), $this->l('Friday'), $this->l('Saturday')); @@ -74,30 +74,30 @@ class Dejala extends CarrierModule $this->page = basename(__FILE__, '.php'); $this->displayName = $this->l('Dejala.com : Courier delivery'); $this->description = $this->l('Lets Dejala.com handle your deliveries by courier'); - + // load configuration only if installed if ($this->id) { - if (true !== extension_loaded('curl')) + if (true !== extension_loaded('curl')) { $this->warning = $this->l('The Dejala module requires php extension cURL to function properly. Please install the php extension "cURL"'); } $this->dejalaConfig = new DejalaConfig(); $this->dejalaConfig->loadConfig(); - + // Update table schema - if (!isset($this->dejalaConfig->internal_version) || $this->dejalaConfig->internal_version < $this->internal_version) + if (!isset($this->dejalaConfig->internal_version) || $this->dejalaConfig->internal_version < $this->internal_version) { $this->unregisterHook('cart') ; $res = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'dejala_cart` LIMIT 1') ; - if ($res) + if ($res) { - if (!array_key_exists('cart_date_upd', (int)$res[0])) + if (!array_key_exists('cart_date_upd', (int)$res[0])) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'dejala_cart` ADD COLUMN cart_date_upd DATETIME DEFAULT 0;'); } - if (!array_key_exists('delivery_price', (int)$res[0])) + if (!array_key_exists('delivery_price', (int)$res[0])) { Db::getInstance()->Execute('ALTER TABLE `'._DB_PREFIX_.'dejala_cart` ADD COLUMN delivery_price FLOAT DEFAULT NULL;'); } @@ -114,16 +114,16 @@ class Dejala extends CarrierModule */ public function install() { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) + if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) return (false); elseif (!$sql = file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) return (false); $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); $sql = preg_split("/;\s*[\r\n]+/",$sql); - - foreach ($sql as $query) - if (!empty($query)) + + foreach ($sql as $query) + if (!empty($query)) { if (!Db::getInstance()->Execute(trim($query))) return (false); @@ -139,7 +139,7 @@ class Dejala extends CarrierModule $this->dejalaConfig = new DejalaConfig(); if (!$this->dejalaConfig->saveConfig()) return (false); - + DejalaCarrierUtils::createDejalaCarrier($this->dejalaConfig) ; return (true); } @@ -151,9 +151,9 @@ class Dejala extends CarrierModule if (Configuration::get('PS_CARRIER_DEFAULT') == (int)($djlCarrier->id)) { $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); - foreach($carriers as $carrier) + foreach($carriers as $carrier) { - if ($carrier['active'] AND !$carrier['deleted'] AND ($carrier['external_module_name'] != $this->name)) + if ($carrier['active'] AND !$carrier['deleted'] AND ($carrier['external_module_name'] != $this->name)) { Configuration::updateValue('PS_CARRIER_DEFAULT', (int)$carrier['id_carrier']); break ; @@ -162,14 +162,14 @@ class Dejala extends CarrierModule } $djlCarrier->deleted = 1; if (!$djlCarrier->update()) return false; - + $this->dejalaConfig->uninstall(); if (!parent::uninstall() OR !$this->unregisterHook('updateOrderStatus') OR !$this->unregisterHook('extraCarrier') OR !$this->unregisterHook('processCarrier')) return false; - + return true; } @@ -182,7 +182,7 @@ class Dejala extends CarrierModule $errors = array(); $method = Tools::getValue('method'); - if ($method == 'signin') + if ($method == 'signin') { if (empty($_POST['login'])) $errors[] = $this->l('login is required.'); @@ -204,7 +204,7 @@ class Dejala extends CarrierModule if (empty($_POST['country'])) $errors[] = $this->l('country is required.'); } - else if ($method == 'products') + else if ($method == 'products') { $products = array(); $djlUtil = new DejalaUtils(); @@ -235,7 +235,7 @@ class Dejala extends CarrierModule break; } } - if ($product) + if ($product) { $vat_factor = (1+ ($product['vat'] / 100)); $public_price = round($product['price']*$vat_factor, 2); @@ -272,13 +272,13 @@ class Dejala extends CarrierModule { $this->dejalaConfig->saveConfig(); } - else + else { if ($response['status'] == 401) $errors[] = $this->l('An error occurred while authenticating your account on Dejala.com. Your credentials were not recognized.'); else $errors[] = $this->l('Unable to process the action.') . '(' . $response['status'] . ')'; - + $this->dejalaConfig->login = null; $this->dejalaConfig->password = null; } @@ -300,7 +300,7 @@ class Dejala extends CarrierModule $errors[] = $this->l('Please choose another login'); elseif ($response['status'] == 403) $errors[] = $this->l('Dejala Server cannot be reached by your Prestashop server. This is most likely due to a limit set by your hosting provider. Please contact their technical support and ask if your server is authorized to initiate outbound HTTP connections.'); - else + else $errors[] = $this->l('Unable to process the action.') . '(' . $response['status'] . ')'; $this->dejalaConfig->loadConfig(); } @@ -337,7 +337,7 @@ class Dejala extends CarrierModule if ($maxSatuses > 30) $maxSatuses = 30; $selectedTriggers=array(); - for ($i = 0; $i < $maxSatuses; $i++) + for ($i = 0; $i < $maxSatuses; $i++) { $l_val = Tools::getValue('status_'.$i); if ($l_val) @@ -348,7 +348,7 @@ class Dejala extends CarrierModule $this->dejalaConfig->saveConfig(); $this->dejalaConfig->loadConfig(); } - else if ($method == 'delivery_options') + else if ($method == 'delivery_options') { $djlUtil = new DejalaUtils(); $response = $djlUtil->setStoreCalendar($this->dejalaConfig, $_POST); @@ -363,32 +363,32 @@ class Dejala extends CarrierModule if ($response['status'] != 200) $errors[] = $this->l('An error occurred while updating products'); - } - else if ($method == 'golive') + } + else if ($method == 'golive') { $djlUtil = new DejalaUtils(); $response = $djlUtil->goLive($this->dejalaConfig, $_POST); } - else if ($method == 'switchMode') + else if ($method == 'switchMode') { $l_mode = Tools::getValue('mode'); - if ( ('PROD' == $l_mode) || ('TEST' == $l_mode) ) + if ( ('PROD' == $l_mode) || ('TEST' == $l_mode) ) { $this->dejalaConfig->mode = $l_mode; $this->dejalaConfig->saveConfig(); } - } - else if ($method == 'switchActive') + } + else if ($method == 'switchActive') { $l_active = Tools::getValue('visibility_status'); - if (($l_active == "visible") || ($l_active == "invisible")) + if (($l_active == "visible") || ($l_active == "invisible")) { $this->dejalaConfig->visibility_status = $l_active; $this->dejalaConfig->saveConfig(); } - if ($l_active == "visible_limited") + if ($l_active == "visible_limited") { $l_active_list = Tools::getValue('visible_users_list'); if ($l_active_list == "") @@ -398,7 +398,7 @@ class Dejala extends CarrierModule $errors[] = $this->l('You must provide at least one email address to restrict Dejala\'s visibility.'); } - else + else { $this->dejalaConfig->visibility_status = $l_active; $this->dejalaConfig->visible_users_list = $l_active_list; @@ -408,7 +408,7 @@ class Dejala extends CarrierModule } else $errors[] = $this->l('Unable to process the action.'); - + return ($errors); } @@ -457,12 +457,12 @@ class Dejala extends CarrierModule $registered = TRUE; if ((0 == strlen($this->dejalaConfig->login)) || (0 == strlen($this->dejalaConfig->password))) $registered= FALSE; - - if ($registered) + + if ($registered) { $djlUtil = new DejalaUtils(); $responsePing = $djlUtil->ping($this->dejalaConfig, $this->dejalaConfig->mode); - if (200 != $responsePing['status']) + if (200 != $responsePing['status']) { if (401 == $responsePing['status']) $errors[] = $this->l('An error occurred while authenticating your account on Dejala.com. Your credentials were not recognized.'); @@ -474,19 +474,19 @@ class Dejala extends CarrierModule } $this->context->smarty->assign("registered", $registered?"1":"0"); - + if (!isset($_GET['cat']) || ($_GET['cat']==='home') || ($_GET['cat']==='')) - $currentTab="home"; + $currentTab = "home"; else - $currentTab=$_GET['cat']; - + $currentTab = $_GET['cat']; + $this->context->smarty->assign("currentTab", $currentTab); $this->context->smarty->assign("moduleConfigURL", 'index.php?tab=AdminModules&configure=dejala&token='.$_GET['token']); - $this->context->smarty->assign("formAction", $_SERVER['REQUEST_URI']); + $this->context->smarty->assign("formAction", Tools::safeOutput($_SERVER['REQUEST_URI'])); $outputMenu = $this->display(__FILE__, 'dejala_menu.tpl'); - if ($currentTab==='home') + if ($currentTab === 'home') { $this->context->smarty->assign("login", html_entity_decode(Configuration::get('PS_SHOP_EMAIL'), ENT_COMPAT, 'UTF-8')); if ($registered) @@ -507,7 +507,7 @@ class Dejala extends CarrierModule } $outputMain = $this->display(__FILE__, 'dejala_home.tpl'); } - else if ($currentTab==='contacts') + else if ($currentTab==='contacts') { $contacts = array(); $djlUtil = new DejalaUtils(); @@ -531,7 +531,7 @@ class Dejala extends CarrierModule { foreach ($location as $key=>$value) $this->context->smarty->assign($key, $value); - + $outputMain = $this->display(__FILE__, 'dejala_location.tpl'); } } @@ -544,11 +544,11 @@ class Dejala extends CarrierModule { foreach ($processes as $key=>$value) $this->context->smarty->assign($key, $value); - + $outputMain = $this->display(__FILE__, 'dejala_processes.tpl'); } } - else if ($currentTab==='prices') + else if ($currentTab==='prices') { $products = array(); $djlUtil = new DejalaUtils(); @@ -568,7 +568,7 @@ class Dejala extends CarrierModule $outputMain = $this->display(__FILE__, 'dejala_products.tpl'); } } - else if ($currentTab === 'accounting') + else if ($currentTab === 'accounting') { $smartifyErrors = $this->smartyfyStoreAttributes(); if (isset($smartifyErrors) && count($smartifyErrors)) @@ -579,17 +579,17 @@ class Dejala extends CarrierModule $responseArray = $djlUtil->getStoreDeliveries($this->dejalaConfig, $deliveries); if ('200'==$responseArray['status']) { - foreach ($deliveries as &$delivery) + foreach ($deliveries as &$delivery) { $delivery['creation_date'] = date('d/m/Y', $delivery['creation_utc']); $delivery['creation_time'] = date('H\hi', $delivery['creation_utc']); - if (isset($delivery['shipping_start_utc'])) + if (isset($delivery['shipping_start_utc'])) { $delivery['shipping_date'] = date('d/m/Y', $delivery['shipping_start_utc']); $delivery['shipping_start'] = date('H\hi', $delivery['shipping_start_utc']); $delivery['shipping_stop'] = date('H\hi', (int)($delivery['shipping_start_utc']) + 3600*(int)($delivery['timelimit']) ); } - else + else { $delivery['shipping_date'] = ''; $delivery['shipping_start'] = ''; @@ -609,7 +609,7 @@ class Dejala extends CarrierModule $outputMain = $this->display(__FILE__, 'dejala_deliveries.tpl'); } } - else if ($currentTab==='delivery_options') + else if ($currentTab==='delivery_options') { $outputMain = $this->displayDeliveryOptions(); } @@ -716,7 +716,7 @@ class Dejala extends CarrierModule $calendar = array(); $response = $djlUtil->getStoreCalendar($this->dejalaConfig, $calendar); - if ($response['status'] == 200) + if ($response['status'] == 200) { $this->context->smarty->assign("calendar", $calendar); $this->context->smarty->assign("timetableTpl", dirname(__FILE__)."/dejala_picking_timetable.tpl"); @@ -729,7 +729,7 @@ class Dejala extends CarrierModule /** * Retourne FALSE si un des produits du cart n'est pas en stock, retourne FALSE sinon **/ - function isCartOutOfStock($cart) + function isCartOutOfStock($cart) { $products = $cart->getProducts(); foreach ($products as $product) @@ -749,7 +749,7 @@ class Dejala extends CarrierModule /** ** Affiche le transporteur Dejala.com dans la liste des transporteurs sur le Front Office */ - public function hookExtraCarrier($params) + public function hookExtraCarrier($params) { $cart = $params['cart']; @@ -759,8 +759,8 @@ class Dejala extends CarrierModule // Check if Dejala should be visible if ($this->dejalaConfig->visibility_status == "invisible") return ; - - if (($this->dejalaConfig->visibility_status == "visible_limited") && ((int)$this->context->customer->id > 0)) + + if (($this->dejalaConfig->visibility_status == "visible_limited") && ((int)$this->context->customer->id > 0)) { $customer = $this->context->customer; if (!in_array($customer->email, preg_split("/[\s,]+/", $this->dejalaConfig->visible_users_list))) @@ -789,10 +789,10 @@ class Dejala extends CarrierModule $id_zone = (int)Address::getZoneById((int)($cart->id_address_delivery)); else $id_zone = (int)$this->context->country->id_zone; - + $djlCarrier = DejalaCarrierUtils::getCarrierByName($this->name) ; - - $this->mylog("electedCarrier=" . $this->logValue($djlCarrier,1)); + + $this->mylog("electedCarrier=" . $this->logValue($djlCarrier,1)); if ($djlCarrier == null) return null ; @@ -811,11 +811,11 @@ class Dejala extends CarrierModule $this->mylog("productCalendar=" . $this->logValue($productCalendar,1)); $this->mylog("storeCalendar=" . $this->logValue($storeCalendar,1)); $this->mylog("response['status']=" . $response['status']); - if ($response['status'] == 200) + if ($response['status'] == 200) { - foreach ($storeCalendar['entries'] as $weekday=>$calEntry) + foreach ($storeCalendar['entries'] as $weekday=>$calEntry) { - if (isset($productCalendar[$weekday])) + if (isset($productCalendar[$weekday])) { $calendar[$weekday]["weekday"] = $weekday; $calendar[$weekday]["start_hour"] = max((int)($productCalendar[$weekday]["start_hour"]), (int)($calEntry["start_hour"])); @@ -840,7 +840,7 @@ class Dejala extends CarrierModule if ($dateUtc == NULL) return ; - if ($deliveryDelay > 0) + if ($deliveryDelay > 0) { if ($skipCurDay) $dateUtc = $calUtils->skipCurDay($dateUtc); @@ -861,7 +861,7 @@ class Dejala extends CarrierModule $dates = array(); $balladUtc = $dateUtc; - do + do { $wd = date("w", $balladUtc); if ((int)($calendar[$wd]['stop_hour']) < (int)($calendar[$wd]['start_hour'])) continue ; @@ -881,9 +881,9 @@ class Dejala extends CarrierModule return ; $now = (int)(date("H", $ctime)) ; - if ((int)($dates[0]['stop_hour']) > $now && (int)($dates[0]['start_hour']) < $now) + if ((int)($dates[0]['stop_hour']) > $now && (int)($dates[0]['start_hour']) < $now) $dates[0]['start_hour'] = $now ; - elseif ((int)($dates[0]['ts']) == $now && (int)($dates[0]['stop_hour']) < $now) + elseif ((int)($dates[0]['ts']) == $now && (int)($dates[0]['stop_hour']) < $now) array_shift($dates) ; @@ -930,7 +930,7 @@ class Dejala extends CarrierModule $this->mylog("shipping_date=" . $this->logValue($deliveryDateSelected)); foreach ($dates as $l_key=>$l_date) { - if ($l_date['value'] == $deliveryDateSelected) + if ($l_date['value'] == $deliveryDateSelected) { $this->context->smarty->assign("deliveryDateIndexSelected", $l_key); $this->context->smarty->assign("deliveryDateSelected", $deliveryDateSelected); @@ -939,7 +939,7 @@ class Dejala extends CarrierModule } } } - if ($setDefaultDate) + if ($setDefaultDate) { $this->context->smarty->assign("deliveryDateIndexSelected", 0); $this->context->smarty->assign("deliveryDateSelected", date("Y/m/d", $dateUtc)); @@ -947,7 +947,7 @@ class Dejala extends CarrierModule } $this->context->smarty->assign("isCartOutOfStock", $isCartOutOfStock); - if (!$isCartOutOfStock) + if (!$isCartOutOfStock) { $buffer = $this->display(__FILE__, 'dejala_carrier.tpl'); $buffer = $buffer . $this->display(__FILE__, 'dejala_timetable.tpl'); @@ -967,7 +967,7 @@ class Dejala extends CarrierModule $this->myLog("POST=" . $this->logValue($_POST)); $this->myLog('dejala_action=' . Tools::getValue('dejala_action') ); - if (Tools::getValue('dejala_action')=='order') + if (Tools::getValue('dejala_action')=='order') { $this->myLog('inside - id_cart=' . $id_cart); $mOrderId = (int)Order::getOrderByCartId($id_cart); @@ -980,14 +980,14 @@ class Dejala extends CarrierModule $mDejalaProductID = $djlCart->id_dejala_product; $mShippingDate = $djlCart->shipping_date; echo '

'; - if ($djlCart->mode !== 'PROD') + if ($djlCart->mode !== 'PROD') echo 'MODE : TEST
'; if (!empty($mShippingDate) && ($mShippingDate != 0)) echo $this->l('Shipping date selected') . ' : ' .date('d/m/Y',$mShippingDate). ', ' . $this->l('starting at') . ' : ' .date('H\hi', $mShippingDate) .'
'; else echo $this->l('Shipping date not yet selected by the customer') .'
'; - + if ( ($djlCart->id_delivery) && Validate::isUnsignedId($djlCart->id_delivery) ) { $l_delivery = array(); @@ -1001,11 +1001,11 @@ class Dejala extends CarrierModule else echo $this->l('Order sent to Dejala') . '
'; } - } + } else { $_html = ''; - $_html .= ''; + $_html .= ''; $_html .= ''; $_html .= ''; $_html .= '
'; @@ -1021,7 +1021,7 @@ class Dejala extends CarrierModule { $text = print_r($var, true); - if (is_array($arrayOfObjectsToHide)) + if (is_array($arrayOfObjectsToHide)) { foreach ($arrayOfObjectsToHide as $objectName) { @@ -1035,7 +1035,7 @@ class Dejala extends CarrierModule $text = preg_replace('#(\w+)(\s+Object\s+\()#s', '$1$2', $text); // color code object properties $text = preg_replace('#\[(\w+)\:(public|private|protected)\]#', '[$1:$2]', $text); - + echo '
'.$text.'
'; } @@ -1050,13 +1050,13 @@ class Dejala extends CarrierModule $dejalaCarrierID = (int)Tools::getValue('dejala_id_carrier'); $carrierID = (int)Tools::getValue('id_carrier'); $dejalaProductID = (int)Tools::getValue('dejala_id_product'); - + if ( !empty($dejalaCarrierID) && !empty($carrierID) && ((int)($dejalaCarrierID) == (int)($carrierID)) ) { $id_cart = (int)($cartParams->id); $product = $this->getDejalaProduct($cartParams, $dejalaProductID) ; - + $timelimit = 10; if (isset($product['timelimit'])) $timelimit = (int)($product['timelimit']); @@ -1075,7 +1075,7 @@ class Dejala extends CarrierModule if ($shippingTime > time() - 5 * 60) $date_shipping = $shippingTime; } - + $djlCart = $this->getDejalaCart($cartParams->id) ; $djlCart->shipping_date = $date_shipping; $djlCart->id_dejala_product = $dejalaProductID; @@ -1087,7 +1087,7 @@ class Dejala extends CarrierModule $djlCart->cart_date_upd = date('Y-m-d H:i:s') ; $djlCart->save() ; } - + // FO: VERY DIRTY HACK.... Re-assign the global cart to what it was before. $this->context->cart = $cartParams ; } @@ -1116,7 +1116,7 @@ class Dejala extends CarrierModule $this->mylog("triggeringStatusList=" . $triggeringStatusList); $triggeringStatuses = explode(",", $triggeringStatusList); $orderID = $params["id_order"]; - + if ((NULL !== $orderID) && (TRUE === in_array($currentOrderStatusID, $triggeringStatuses))) { $mOrder = new Order($orderID); @@ -1157,20 +1157,20 @@ class Dejala extends CarrierModule if ("201" === $statusCode) { $this->mylog("updating dejala cart cart_id=" . $cartId); - if (Validate::isUnsignedId($delivery['id'])) + if (Validate::isUnsignedId($delivery['id'])) { $this->mylog("updating dejala cart id_delivery=" . $delivery['id']); $djlCart->id_delivery = $delivery['id']; $djlCart->update(); } - + if (is_null($mOrder->shipping_number) || (0 === strlen($mOrder->shipping_number))) { $this->myLog('setting Order->shipping_number to ' . $delivery['tracking_number']); $mOrder->shipping_number = $delivery['tracking_number']; $mOrder->save(); } - + $this->myLog("OK - Order sent to dejala.com"); } else @@ -1184,7 +1184,7 @@ class Dejala extends CarrierModule public function getInfoFromOrder($orderID, &$delivery) { $mOrder = new Order((int)$orderID); - if (NULL !== $mOrder) + if (NULL !== $mOrder) { $mDeliveryAddress = new Address($mOrder->id_address_delivery); if (NULL !== $mDeliveryAddress) @@ -1221,9 +1221,9 @@ class Dejala extends CarrierModule $mDejalaProductID = (int)$djlCart->id_dejala_product; $delivery["product_id"] = (int)($mDejalaProductID); $mShippingDate = $djlCart->shipping_date; - if ( is_null($mShippingDate) || empty($mShippingDate) ) + if ( is_null($mShippingDate) || empty($mShippingDate) ) $mShippingDate = 0; - + $delivery["shipping_start_utc"]=$mShippingDate; } } @@ -1236,11 +1236,11 @@ class Dejala extends CarrierModule return $this->getOrderShippingCost($cart, 0); } - public function getOrderShippingCost($cart, $shipping_cost) + public function getOrderShippingCost($cart, $shipping_cost) { return $this->getDejalaProductPrice($cart) ; } - + private function getDejalaCart($cartId) { return DejalaCart::getInstance($cartId) ; @@ -1249,9 +1249,9 @@ class Dejala extends CarrierModule private function getDejalaProductPrice($cart) { $djlCart = $this->getDejalaCart($cart->id) ; - if (isset($djlCart->delivery_price) && $cart->date_upd <= $djlCart->cart_date_upd) + if (isset($djlCart->delivery_price) && $cart->date_upd <= $djlCart->cart_date_upd) return $djlCart->delivery_price ; - + $product = $this->getDejalaProduct($cart) ; return $product["price"] ; } @@ -1262,7 +1262,7 @@ class Dejala extends CarrierModule $djlCart = $this->getDejalaCart($cart->id) ; if (isset($djlCart->delivery_price) && $cart->date_upd <= $djlCart->cart_date_upd && isset($djlCart->product)) - if ($productId >= 0 && $djlCart->product["id"] == $productId) + if ($productId >= 0 && $djlCart->product["id"] == $productId) return $djlCart->product ; @@ -1280,9 +1280,9 @@ class Dejala extends CarrierModule $acceptPartial = false; if ( ($isCartOutOfStock == '1') && !$acceptPartial) return ; - + $address = new Address($cart->id_address_delivery) ; - + // ask dejala.com for a quotation $quotation["receiver_name"] = $address->lastname; $quotation["receiver_firstname"] = $address->firstname; @@ -1319,7 +1319,7 @@ class Dejala extends CarrierModule $djlCart->id_dejala_product = (int)$electedProduct["id"]; $djlCart->id_delivery = NULL; $djlCart->mode = $this->dejalaConfig->mode; - + $vat_factor = (1+ ($electedProduct['vat'] / 100)); $priceTTC = round(($electedProduct['price']*$vat_factor) + $electedProduct['margin'], 2); $priceHT = round($priceTTC/$vat_factor, 2); @@ -1331,7 +1331,7 @@ class Dejala extends CarrierModule $djlCart->save() ; return $electedProduct ; - + } public function mylog($msg) { diff --git a/modules/ebay/ebay.php b/modules/ebay/ebay.php index 8d08f8af6..82327c9f2 100755 --- a/modules/ebay/ebay.php +++ b/modules/ebay/ebay.php @@ -526,7 +526,7 @@ class Ebay extends Module if (Tools::getValue('ebay_country_default_fr') == 'ok') $this->context->cookie->ebay_country_default_fr = true; if (strtolower($this->context->country->iso_code) != 'fr' && !isset($this->context->cookie->ebay_country_default_fr)) - return $this->_html.$this->displayError($this->l('eBay module currently works only for eBay.fr').'. '.$this->l('Continue anyway ?').''); + return $this->_html.$this->displayError($this->l('eBay module currently works only for eBay.fr').'. '.$this->l('Continue anyway ?').''); // Checking Extension @@ -653,7 +653,7 @@ class Ebay extends Module success: function(data) { if (data == \'OK\') - window.location.href = \''.$_SERVER['REQUEST_URI'].'&action=validateToken\'; + window.location.href = \''.Tools::safeOutput($_SERVER['REQUEST_URI']).'&action=validateToken\'; else setTimeout ("checkToken()", 5000); } @@ -690,7 +690,7 @@ class Ebay extends Module }); }); -
+
'.$this->l('Register the module on eBay').' @@ -763,9 +763,9 @@ class Ebay extends Module if (isset($_GET['id_tab'])) $html .= ''; return $html; } @@ -777,22 +777,22 @@ class Ebay extends Module // Display Form - $html = ' + $html = '

'.$this->l('To export your products on eBay, you have to create a pro account on eBay (see Help) and configure your eBay-Prestashop module.').'

- +

'.(Configuration::get('EBAY_IDENTIFIER') ? ''.$this->l('Your products on eBay').'' : $this->l('Your eBay identifier')).'

- +

'.(Configuration::get('EBAY_SHOP') ? ''.$this->l('Your shop on eBay').'' : $this->l('Your eBay shop name')).'

- +

'.$this->l('You have to set your PayPal e-mail account, it\'s the only payment available with this module').'

@@ -805,12 +805,12 @@ class Ebay extends Module

- '.$configCurrency->sign.' + '.$configCurrency->sign.'

'.$this->l('Shipping cost configuration for your products on eBay').'

- +

'.$this->l('Your shop\'s postal code').'

@@ -932,13 +932,13 @@ class Ebay extends Module // Display header $html = '

'.$this->l('To export your products on eBay, you have to associate each one of your shop categories to an eBay category. You can also define an impact of your price on eBay.').'


- +

'.$this->l('You can use the button below to associate automatically the categories which have no association for the moment with an eBay suggested category.').'


-
+ @@ -1108,10 +1108,10 @@ class Ebay extends Module $ad = dirname($_SERVER["PHP_SELF"]); // Display Form - $html = ' + $html = '

'.$this->l('You can customise the template for your products page on eBay').' :

-
+
'.(substr(_PS_VERSION_, 0, 3) == '1.3' ? ' @@ -1289,7 +1289,7 @@ class Ebay extends Module
- +

'.$this->l('You will now push your products on eBay.').' '.$this->l('Reminder,').' '.$this->l('you will not have to pay any fees if you have a shop on eBay.').'




diff --git a/modules/editorial/editorial.php b/modules/editorial/editorial.php index 8437048cc..54cc0076b 100644 --- a/modules/editorial/editorial.php +++ b/modules/editorial/editorial.php @@ -196,7 +196,7 @@ class Editorial extends Module '; $this->_html .= ' - +
'.$this->displayName.' @@ -252,7 +252,7 @@ class Editorial extends Module $this->_html .= '

'.$this->l('Filesize').' '.(filesize(dirname(__FILE__).'/homepage_logo.jpg') / 1000).'kb

- + '.$this->l('Delete').' '.$this->l('Delete').'
'; diff --git a/modules/envoimoinscher/AdminEnvoiMoinsCher.php b/modules/envoimoinscher/AdminEnvoiMoinsCher.php index f3fc6ce0c..79c8569c1 100755 --- a/modules/envoimoinscher/AdminEnvoiMoinsCher.php +++ b/modules/envoimoinscher/AdminEnvoiMoinsCher.php @@ -50,7 +50,7 @@ class AdminEnvoiMoinsCher extends AdminTab $orderToExport[] = self::getOrderDetails((int)($id)); } echo ' - + '; self::inputMaker($orderToExport); @@ -65,7 +65,7 @@ class AdminEnvoiMoinsCher extends AdminTab else echo '
nok '.$emc->lang('No order to export').'
-

Retour

'; +

Retour

'; } else { @@ -73,7 +73,7 @@ class AdminEnvoiMoinsCher extends AdminTab AND Configuration::get('EMC_ADDRESS') AND Configuration::get('EMC_ZIP_CODE') AND Configuration::get('EMC_CITY') AND Configuration::get('EMC_COUNTRY') AND Configuration::get('EMC_PHONE') AND Configuration::get('EMC_EMAIL') AND Configuration::get('EMC_LOGIN')) { - echo ''; + echo ''; $orders = self::getOrders(); self::displayOrders($orders); echo '

diff --git a/modules/envoimoinscher/envoimoinscher.php b/modules/envoimoinscher/envoimoinscher.php index 3150aa7c6..72b50212f 100755 --- a/modules/envoimoinscher/envoimoinscher.php +++ b/modules/envoimoinscher/envoimoinscher.php @@ -172,10 +172,10 @@ class Envoimoinscher extends Module &facturation.contact_ville='.(isset($confs['EMC_CITY']) ? htmlspecialchars($confs['EMC_CITY'], ENT_COMPAT, 'UTF-8') : '' ).' &facturation.contact_tel='.(isset($confs['EMC_PHONE']) ? htmlspecialchars($confs['EMC_PHONE'], ENT_COMPAT, 'UTF-8') : '' ).' &facturation.contact_email='.(isset($confs['EMC_EMAIL']) ? htmlspecialchars($confs['EMC_EMAIL'], ENT_COMPAT, 'UTF-8') : '' ).' - &url_renvoi='.urlencode(Tools::getProtocol().htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').$_SERVER['REQUEST_URI']).'">'; + &url_renvoi='.urlencode(Tools::getProtocol().htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').Tools::safeOutput($_SERVER['REQUEST_URI'])).'">'; - $this->_html .= ' + $this->_html .= '
'.$link.'

'.$this->l('Create Envoimoinscher account:').'

'.$this->l('To create your account on Envoimoinscher, click the image below. You will go to a dedicated personal space where you will find the necessary tools for easy management of your shipments.').'

diff --git a/modules/fedexcarrier/config.xml b/modules/fedexcarrier/config.xml index c7599ae8c..53b25ab10 100755 --- a/modules/fedexcarrier/config.xml +++ b/modules/fedexcarrier/config.xml @@ -2,7 +2,7 @@ fedexcarrier - + diff --git a/modules/fedexcarrier/fedexcarrier.php b/modules/fedexcarrier/fedexcarrier.php index 79651aabe..4f5d7579c 100644 --- a/modules/fedexcarrier/fedexcarrier.php +++ b/modules/fedexcarrier/fedexcarrier.php @@ -56,7 +56,7 @@ class FedexCarrier extends CarrierModule { $this->name = 'fedexcarrier'; $this->tab = 'shipping_logistics'; - $this->version = '1.2.1'; + $this->version = '1.2.3'; $this->author = 'PrestaShop'; $this->limited_countries = array('us'); @@ -432,9 +432,9 @@ class FedexCarrier extends CarrierModule if (isset($_GET['id_tab'])) $html .= ''; return $html; } @@ -468,30 +468,30 @@ class FedexCarrier extends CarrierModule - +

'.$this->l('General configuration').' :

-
+
-
+
-
+


- - '.Tools::getValue('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT')).' + + '.Tools::safeOutput(Tools::getValue('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT'))).'
- + '.$configCurrency->sign.'
@@ -500,12 +500,12 @@ class FedexCarrier extends CarrierModule

'.$this->l('Localization configuration').' :

- +

'.$this->l('The weight unit of your shop (eg. kg or lbs)').'

- +

'.$this->l('The dimension unit of your shop (eg. cm or in)').'

@@ -513,13 +513,13 @@ class FedexCarrier extends CarrierModule

'.$this->l('Address configuration').' :

-
+
-
+
-

+

-
+
@@ -861,8 +861,8 @@ class FedexCarrier extends CarrierModule $path .= $p; } - $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

- + $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

+
'.$path.'

@@ -882,7 +882,7 @@ class FedexCarrier extends CarrierModule $html .= ' -

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'fedex_rate_service_code`'); @@ -900,7 +900,7 @@ class FedexCarrier extends CarrierModule else { $html .= '

'.$this->l('Add a rule').'

- +
-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'fedex_rate_service_code`'); @@ -1102,10 +1102,10 @@ class FedexCarrier extends CarrierModule
@@ -1123,8 +1123,8 @@ class FedexCarrier extends CarrierModule $configSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'fedex_rate_config` WHERE `id_fedex_rate_config` = '.(int)(Tools::getValue('id_fedex_rate_config'))); $product = new Product((int)$configSelected['id_product'], false, (int)$this->context->language->id); - $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

- + $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

+
'.$product->name.'

@@ -1144,13 +1144,14 @@ class FedexCarrier extends CarrierModule $html .= ' -

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'fedex_rate_service_code`'); foreach($rateServiceList as $rateService) { - $configServiceSelected = Db::getInstance()->getValue('SELECT `id_fedex_rate_service_code` FROM `'._DB_PREFIX_.'fedex_rate_config_service` WHERE `id_fedex_rate_config` = '.(int)(Tools::getValue('id_fedex_rate_config')).' AND `id_fedex_rate_service_code` = '.(int)($rateService['id_fedex_rate_service_code'])); + $configServiceSelected = Db::getInstance()->getValue('SELECT `id_fedex_rate_service_code` FROM `'._DB_PREFIX_.'fedex_rate_config_service` WHERE `id_fedex_rate_config` = '.(int)( + Tools::getValue('id_fedex_rate_config')).' AND `id_fedex_rate_service_code` = '.(int)($rateService['id_fedex_rate_service_code'])); $html .= '_isPostCheck($rateService['id_fedex_rate_service_code']) == 1 || $configServiceSelected > 0) ? 'checked="checked"' : '').' /> '.$rateService['service'].'
'; } $html .= ' @@ -1162,7 +1163,7 @@ class FedexCarrier extends CarrierModule else { $html .= '

'.$this->l('Add a rule').'

- +
-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'fedex_rate_service_code`'); @@ -1692,7 +1693,7 @@ class FedexCarrier extends CarrierModule Db::getInstance()->autoExecute(_DB_PREFIX_.'fedex_cache_test', array('hash' => pSQL(md5(var_export($requestHash, true))), 'result' => pSQL(serialize($resultTab)), 'date_add' => pSQL(date('Y-m-d H:i:s')), 'date_upd' => pSQL(date('Y-m-d H:i:s'))), 'INSERT'); // Return results - if (isset($resultTab->HighestSeverity) && $resultTab->HighestSeverity == 'SUCCESS') + if (isset($resultTab->HighestSeverity) && $resultTab->HighestSeverity != 'ERROR' && isset($resultTab->RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount)) return true; if (isset($resultTab->HighestSeverity) && $resultTab->HighestSeverity == 'ERROR') @@ -1763,7 +1764,7 @@ class FedexCarrier extends CarrierModule // Get Rates try { $resultTab = $client->getRates($request); } - catch (Exception $e) { return array('connect' => false, 'cost' => 0); } + catch (Exception $e) { } // Check currency @@ -1775,7 +1776,7 @@ class FedexCarrier extends CarrierModule } // Return results - if (isset($resultTab->HighestSeverity) && $resultTab->HighestSeverity == 'SUCCESS') + if (isset($resultTab->HighestSeverity) && $resultTab->HighestSeverity != 'ERROR' && isset($resultTab->RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount)) return array('connect' => true, 'cost' => number_format($resultTab->RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount,2,'.',',') * $conversionRate); if (isset($resultTab->HighestSeverity) && $resultTab->HighestSeverity == 'ERROR') diff --git a/modules/followup/followup.php b/modules/followup/followup.php index 94f58d999..5a1d90729 100644 --- a/modules/followup/followup.php +++ b/modules/followup/followup.php @@ -108,7 +108,7 @@ class Followup extends Module echo '

'.$this->l('Customer follow-up').'

- +
'.$this->l('Settings').'

'.$this->l('Four kinds of e-mail alerts available in order to stay in touch with your customers!').'

diff --git a/modules/gadsense/gadsense.php b/modules/gadsense/gadsense.php index d1e088f0b..d17c70738 100644 --- a/modules/gadsense/gadsense.php +++ b/modules/gadsense/gadsense.php @@ -79,11 +79,11 @@ class GAdsense extends Module public function displayForm() { $output = ' - +

'.$this->l('Settings').'
- +

'.$this->l('Example:').'

diff --git a/modules/ganalytics/ganalytics.php b/modules/ganalytics/ganalytics.php index 9ca8209b9..935349cc6 100644 --- a/modules/ganalytics/ganalytics.php +++ b/modules/ganalytics/ganalytics.php @@ -78,12 +78,12 @@ class GAnalytics extends Module public function displayForm() { $output = ' - +
'.$this->l('Settings').'
- +

'.$this->l('Example:').' UA-1234567-1

diff --git a/modules/gcheckout/gcheckout.php b/modules/gcheckout/gcheckout.php index c1887332b..7c3a18533 100644 --- a/modules/gcheckout/gcheckout.php +++ b/modules/gcheckout/gcheckout.php @@ -1,6 +1,6 @@ tab = 'payments_gateways'; $this->version = '1.2'; $this->author = 'PrestaShop'; - + $this->currencies = true; $this->currencies_mode = 'radio'; @@ -44,7 +44,7 @@ class GCheckout extends PaymentModule $this->displayName = $this->l('Google Checkout'); $this->description = $this->l('Google Checkout API implementation'); - + if (!sizeof(Currency::checkPaymentCurrencies($this->id))) $this->warning = $this->l('No currency set for this module'); @@ -57,13 +57,13 @@ class GCheckout extends PaymentModule } public function install() - { - if (!parent::install() OR !$this->registerHook('payment') OR - !$this->registerHook('paymentReturn') OR - !Configuration::updateValue('GCHECKOUT_MERCHANT_ID', '822305931131113') OR - !Configuration::updateValue('GCHECKOUT_MERCHANT_KEY', '2Lv_osMomVIocnLK0aif3A') OR - !Configuration::updateValue('GCHECKOUT_LOGS', '1') OR - !Configuration::updateValue('GCHECKOUT_MODE', 'real') OR + { + if (!parent::install() OR !$this->registerHook('payment') OR + !$this->registerHook('paymentReturn') OR + !Configuration::updateValue('GCHECKOUT_MERCHANT_ID', '822305931131113') OR + !Configuration::updateValue('GCHECKOUT_MERCHANT_KEY', '2Lv_osMomVIocnLK0aif3A') OR + !Configuration::updateValue('GCHECKOUT_LOGS', '1') OR + !Configuration::updateValue('GCHECKOUT_MODE', 'real') OR !Configuration::updateValue('GCHECKOUT_NO_SHIPPING', '0')) return false; return true; @@ -71,14 +71,14 @@ class GCheckout extends PaymentModule public function uninstall() { - return (parent::uninstall() AND - Configuration::deleteByName('GCHECKOUT_MERCHANT_ID') AND + return (parent::uninstall() AND + Configuration::deleteByName('GCHECKOUT_MERCHANT_ID') AND Configuration::deleteByName('GCHECKOUT_MERCHANT_KEY') AND - Configuration::deleteByName('GCHECKOUT_MODE') AND - Configuration::deleteByName('GCHECKOUT_LOGS') AND + Configuration::deleteByName('GCHECKOUT_MODE') AND + Configuration::deleteByName('GCHECKOUT_LOGS') AND Configuration::deleteByName('GCHECKOUT_NO_SHIPPING')); } - + public function getContent() { if (Tools::isSubmit('submitGoogleCheckout')) @@ -98,20 +98,20 @@ class GCheckout extends PaymentModule Configuration::updateValue('GCHECKOUT_LOGS', 1); else Configuration::updateValue('GCHECKOUT_LOGS', 0); - + if (Tools::getValue('gcheckout_no_shipping')) Configuration::updateValue('GCHECKOUT_NO_SHIPPING', 1); else Configuration::updateValue('GCHECKOUT_NO_SHIPPING', 0); - if (!sizeof($errors)) - Tools::redirectAdmin(AdminTab::$currentIndex.'&configure=gcheckout&token='.Tools::getValue('token').'&conf=4'); + if (!$errors) + Tools::redirectAdmin(AdminTab::$currentIndex.'&configure=gcheckout&token='.Tools::safeOutput(Tools::getValue('token')).'&conf=4'); foreach ($errors as $error) echo $error; } - + $html = '

'.$this->displayName.'

- +
'.$this->l('Settings').'

@@ -139,13 +139,13 @@ class GCheckout extends PaymentModule '.$this->l('Merchant ID').'

- +
- +

'.$this->l('If you click this box, buyers will be able to see the shipping fees you have setup in Google Checkout on the purchase page.').'

'; - + return $html; } @@ -185,22 +185,22 @@ class GCheckout extends PaymentModule $this->context->smarty->assign('buttonText', $this->l('Pay with GoogleCheckout')); return $this->display(__FILE__, 'payment.tpl'); } - + public function hookPaymentReturn($params) { if (!$this->active) return; return $this->display(__FILE__, 'payment_return.tpl'); } - + public function preparePayment() { require_once(dirname(__FILE__).'/library/googlecart.php'); require_once(dirname(__FILE__).'/library/googleitem.php'); require_once(dirname(__FILE__).'/library/googleshipping.php'); - + $currency = $this->getCurrency($this->context->cart->id_currency); - + if ($this->context->cart->id_currency != $currency->id) { $this->context->cart->id_currency = (int)$currency->id; @@ -208,29 +208,29 @@ class GCheckout extends PaymentModule $this->context->cart->update(); Tools::redirect('modules/'.$this->name.'/payment.php'); } - + $googleCart = new GoogleCart( - Configuration::get('GCHECKOUT_MERCHANT_ID'), - Configuration::get('GCHECKOUT_MERCHANT_KEY'), + Configuration::get('GCHECKOUT_MERCHANT_ID'), + Configuration::get('GCHECKOUT_MERCHANT_KEY'), Configuration::get('GCHECKOUT_MODE'), $currency->iso_code); - + foreach ($this->context->cart->getProducts() AS $product) $googleCart->AddItem(new GoogleItem(utf8_decode($product['name']. - ((isset($product['attributes']) AND !empty($product['attributes'])) ? - ' - '.$product['attributes'] : '')), utf8_decode($product['description_short']), - (int)$product['cart_quantity'], $product['price_wt'], + ((isset($product['attributes']) AND !empty($product['attributes'])) ? + ' - '.$product['attributes'] : '')), utf8_decode($product['description_short']), + (int)$product['cart_quantity'], $product['price_wt'], strtoupper(Configuration::get('PS_WEIGHT_UNIT')), (float)$product['weight'])); - + if ($wrapping = $this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING)) $googleCart->AddItem(new GoogleItem(utf8_decode($this->l('Wrapping')), '', 1, $wrapping)); foreach ($this->context->cart->getDiscounts() AS $voucher) - $googleCart->AddItem(new GoogleItem(utf8_decode($voucher['name']), + $googleCart->AddItem(new GoogleItem(utf8_decode($voucher['name']), utf8_decode($voucher['description']), 1, '-'.$voucher['value_real'])); - + if (!Configuration::get('GCHECKOUT_NO_SHIPPING')) { $carrier = new Carrier((int)($this->context->cart->id_carrier), $this->context->language->id); - $googleCart->AddShipping(new GoogleFlatRateShipping(utf8_decode($carrier->name), + $googleCart->AddShipping(new GoogleFlatRateShipping(utf8_decode($carrier->name), $this->context->cart->getOrderShippingCost($this->context->cart->id_carrier))); } @@ -238,9 +238,9 @@ class GCheckout extends PaymentModule $googleCart->SetContinueShoppingUrl(Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'order-confirmation.php'); $googleCart->SetRequestBuyerPhone(false); $googleCart->SetMerchantPrivateData($this->context->cart->id.'|'.$this->context->cart->secure_key); - + $total = $this->context->cart->getOrderTotal(); - + $this->context->smarty->assign(array( 'googleCheckoutExtraForm' => $googleCart->CheckoutButtonCode($this->l('Pay with GoogleCheckout'), 'LARGE'), 'total' => $total, diff --git a/modules/hipay/hipay.php b/modules/hipay/hipay.php index 12a68eea3..4dd1a0883 100644 --- a/modules/hipay/hipay.php +++ b/modules/hipay/hipay.php @@ -1,6 +1,6 @@ currencies_mode = 'radio'; parent::__construct(); - + $this->displayName = $this->l('Hipay'); $this->description = $this->l('Secure payement with Visa, Mastercard and European solutions.'); @@ -58,12 +58,12 @@ class Hipay extends PaymentModule foreach ($result as $num => $iso) $this->limited_countries[] = $iso['iso_code']; - + if ($this->id) { $this->prod = (int)Tools::getValue('HIPAY_PROD', Configuration::get('HIPAY_PROD')); // Define extracted from mapi/mapi_defs.php - if (!defined('HIPAY_GATEWAY_URL')) + if (!defined('HIPAY_GATEWAY_URL')) define('HIPAY_GATEWAY_URL','https://'.($this->prod ? '' : 'test.').'payment.hipay.com/order/'); } } @@ -71,36 +71,36 @@ class Hipay extends PaymentModule public function install() { Configuration::updateValue('HIPAY_SALT', uniqid()); - // Force using Prod mod + // Force using Prod mod Configuration::updateValue('HIPAY_PROD', 1); if (!Configuration::get('HIPAY_UNIQID')) Configuration::updateValue('HIPAY_UNIQID', uniqid()); if (!Configuration::get('HIPAY_RATING')) Configuration::updateValue('HIPAY_RATING', 'ALL'); - + if (!(parent::install() AND $this->registerHook('payment'))) return false; - + $result = Db::getInstance()->ExecuteS(' SELECT `id_zone`, `name` FROM `'._DB_PREFIX_.'zone` WHERE `active` = 1 '); - + foreach ($result as $rowNumber => $rowValues) { Configuration::deleteByName('HIPAY_AZ_'.$rowValues['id_zone']); Configuration::deleteByName('HIPAY_AZ_ALL_'.$rowValues['id_zone']); } Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'module_country` WHERE `id_module` = '.(int)$this->id); - + return true; } /** * Set shipping zone search - * + * * @param string $searchField = 'z.id_zone' * @param int $defaultZone = 1 * @return string @@ -112,20 +112,20 @@ class Hipay extends PaymentModule FROM `'._DB_PREFIX_.'zone` WHERE `active` = 1 '); - + $tmp = null; - foreach ($result as $rowNumber => $rowValues) + foreach ($result as $rowNumber => $rowValues) if (strcmp(Configuration::get('HIPAY_AZ_'.$rowValues['id_zone']), 'ok') == 0) $tmp .= $searchField.' = '.$rowValues['id_zone'].' OR '; - + if ($tmp == null) $tmp = $searchField.' = '.$defaultZone; else $tmp = substr($tmp, 0, strlen($tmp) - strlen(' OR ')); - + return $tmp; } - + public function hookPayment($params) { $currency = new Currency($this->getModuleCurrency($this->context->cart)); @@ -133,7 +133,7 @@ class Hipay extends PaymentModule $hipayPassword = ($this->prod ? Configuration::get('HIPAY_PASSWORD_'.$currency->iso_code) : Configuration::get('HIPAY_PASSWORD_TEST_'.$currency->iso_code)); $hipaySiteId = ($this->prod ? Configuration::get('HIPAY_SITEID_'.$currency->iso_code) : Configuration::get('HIPAY_SITEID_TEST_'.$currency->iso_code)); $hipayCategory = ($this->prod ? Configuration::get('HIPAY_CATEGORY_'.$currency->iso_code) : Configuration::get('HIPAY_CATEGORY_TEST_'.$currency->iso_code)); - + if ($hipayAccount AND $hipayPassword AND $hipaySiteId AND $hipayCategory AND Configuration::get('HIPAY_RATING')) { $this->context->smarty->assign('hipay_prod', $this->prod); @@ -145,12 +145,12 @@ class Hipay extends PaymentModule private function getModuleCurrency($cart) { $id_currency = (int)self::MysqlGetValue('SELECT id_currency FROM `'._DB_PREFIX_.'module_currency` WHERE id_module = '.(int)$this->id); - + if (!$id_currency OR $id_currency == -2) $id_currency = Configuration::get('PS_CURRENCY_DEFAULT'); elseif ($id_currency == -1) $id_currency = $cart->id_currency; - + return $id_currency; } @@ -161,7 +161,7 @@ class Hipay extends PaymentModule if ($this->context->cart->id_currency != $id_currency) if (Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'cart SET id_currency = '.(int)$id_currency.' WHERE id_cart = '.(int)$this->context->cart->id)) $this->context->cart->id_currency = $id_currency; - + $currency = new Currency($id_currency); $language = new Language($this->context->cart->id_lang); $customer = new Customer($this->context->cart->id_customer); @@ -169,7 +169,7 @@ class Hipay extends PaymentModule $id_zone = self::MysqlGetValue('SELECT id_zone FROM '._DB_PREFIX_.'address a INNER JOIN '._DB_PREFIX_.'country c ON a.id_country = c.id_country WHERE id_address = '.(int)$this->context->cart->id_address_delivery); require_once(dirname(__FILE__).'/mapi/mapi_package.php'); - + $hipayAccount = ($this->prod ? Configuration::get('HIPAY_ACCOUNT_'.$currency->iso_code) : Configuration::get('HIPAY_ACCOUNT_TEST_'.$currency->iso_code)); $hipayPassword = ($this->prod ? Configuration::get('HIPAY_PASSWORD_'.$currency->iso_code) : Configuration::get('HIPAY_PASSWORD_TEST_'.$currency->iso_code)); $hipaySiteId = ($this->prod ? Configuration::get('HIPAY_SITEID_'.$currency->iso_code) : Configuration::get('HIPAY_SITEID_TEST_'.$currency->iso_code)); @@ -202,14 +202,14 @@ class Hipay extends PaymentModule $item->setRef($this->context->cart->id); $item->setCategory($hipaycategory); $item->setPrice($this->context->cart->getOrderTotal()); - + try { if (!$item->check()) return $this->l('[Hipay] Error: cannot create "Cart" Product'); } catch (Exception $e) { return $this->l('[Hipay] Error: cannot create "Cart" Product'); } - + $items = array($item); $order = new HIPAY_MAPI_Order(); @@ -234,11 +234,11 @@ class Hipay extends PaymentModule else { include(dirname(__FILE__).'/../../header.php'); - + $this->context->smarty->assign('errors', array('[Hipay] '.strval($err_msg).' ('.$output.')')); $_SERVER['HTTP_REFERER'] = self::getHttpHost(true, true).'index.php?controller=order&step=3'; $this->context->smarty->display(_PS_THEME_DIR_.'errors.tpl'); - + include(dirname(__FILE__).'/../../footer.php'); } } @@ -250,7 +250,7 @@ class Hipay extends PaymentModule if (_PS_MAGIC_QUOTES_GPC_) $_POST['xml'] = stripslashes($_POST['xml']); - + require_once(dirname(__FILE__).'/mapi/mapi_package.php'); if (HIPAY_MAPI_COMM_XML::analyzeNotificationXML($_POST['xml'], $operation, $status, $date, $time, $transid, $amount, $currency, $id_cart, $data) === false) @@ -258,7 +258,7 @@ class Hipay extends PaymentModule file_put_contents('logs'.Configuration::get('HIPAY_UNIQID').'.txt', '['.date('Y-m-d H:i:s').'] Analysis error: '.htmlentities($_POST['xml'])."\n", FILE_APPEND); return false; } - + $cart = new Cart((int)$id_cart); if ($cart->secure_key != Tools::getValue('token')) file_put_contents('logs'.Configuration::get('HIPAY_UNIQID').'.txt', '['.date('Y-m-d H:i:s').'] Token error: '.htmlentities($_POST['xml'])."\n", FILE_APPEND); @@ -275,11 +275,11 @@ class Hipay extends PaymentModule /* Paiement remboursé sur Hipay */ if (!($id_order = Order::getOrderByCartId((int)($id_cart)))) die(Tools::displayError()); - + $order = new Order((int)($id_order)); if (!$order->valid OR $order->getCurrentState() === Configuration::get('PS_OS_REFUND')) die(Tools::displayError()); - + $orderHistory = new OrderHistory(); $orderHistory->id_order = (int)($order->id); $orderHistory->changeIdOrderState((int)(Configuration::get('PS_OS_REFUND')), (int)($id_order)); @@ -290,48 +290,48 @@ class Hipay extends PaymentModule /** * Uninstall and clean the module settings - * + * * @return bool */ public function uninstall() { parent::uninstall(); - + $result = Db::getInstance()->ExecuteS(' SELECT `id_zone`, `name` FROM `'._DB_PREFIX_.'zone` WHERE `active` = 1 '); - + foreach ($result as $rowValues) { Configuration::deleteByName('HIPAY_AZ_'.$rowValues['id_zone']); Configuration::deleteByName('HIPAY_AZ_ALL_'.$rowValues['id_zone']); } Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'module_country` WHERE `id_module` = '.(int)$this->id); - + return (true); } - + public function getContent() { $currencies = DB::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT c.iso_code, c.name, c.sign FROM '._DB_PREFIX_.'currency c'); - - if (Tools::isSubmit('submitHipayAZ')) + + if (Tools::isSubmit('submitHipayAZ')) { // Delete all configurated zones - foreach ($_POST as $key => $val) + foreach ($_POST as $key => $val) { - if (strncmp($key, 'HIPAY_AZ_ALL_', strlen('HIPAY_AZ_ALL_')) == 0) + if (strncmp($key, 'HIPAY_AZ_ALL_', strlen('HIPAY_AZ_ALL_')) == 0) { $id = substr($key, -(strlen($key) - strlen('HIPAY_AZ_ALL_'))); Configuration::updateValue('HIPAY_AZ_'.$id, 'ko'); } } Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'module_country` WHERE `id_module` = '.(int)$this->id); - + // Add the new configuration zones - foreach ($_POST as $key => $val) + foreach ($_POST as $key => $val) { if (strncmp($key, 'HIPAY_AZ_', strlen('HIPAY_AZ_')) == 0) Configuration::updateValue($key, 'ok'); @@ -340,13 +340,13 @@ class Hipay extends PaymentModule $results = Db::getInstance()->ExecuteS($request.$this->getRequestZones('id_zone')); foreach ($results as $rowValues) Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'module_country VALUE('.(int)$this->id.', '.(int)$rowValues['id_country'].')'); - + } elseif (Tools::isSubmit('submitHipay')) { Configuration::updateValue('HIPAY_PROD', Tools::getValue('HIPAY_PROD')); $this->prod = (int)Tools::getValue('HIPAY_PROD', Configuration::get('HIPAY_PROD')); - + $accounts = array(); foreach ($currencies as $currency) { @@ -354,34 +354,34 @@ class Hipay extends PaymentModule Configuration::updateValue('HIPAY_CATEGORY_'.$currency['iso_code'], false); if (Configuration::get('HIPAY_SITEID_TEST_'.$currency['iso_code']) != Tools::getValue('HIPAY_SITEID_TEST_'.$currency['iso_code'])) Configuration::updateValue('HIPAY_CATEGORY_TEST_'.$currency['iso_code'], false); - + Configuration::updateValue('HIPAY_ACCOUNT_'.$currency['iso_code'], trim(Tools::getValue('HIPAY_ACCOUNT_'.$currency['iso_code']))); Configuration::updateValue('HIPAY_PASSWORD_'.$currency['iso_code'], trim(Tools::getValue('HIPAY_PASSWORD_'.$currency['iso_code']))); Configuration::updateValue('HIPAY_SITEID_'.$currency['iso_code'], trim(Tools::getValue('HIPAY_SITEID_'.$currency['iso_code']))); Configuration::updateValue('HIPAY_CATEGORY_'.$currency['iso_code'], Tools::getValue('HIPAY_CATEGORY_'.$currency['iso_code'])); - + if ($this->prod AND Tools::getValue('HIPAY_ACCOUNT_'.$currency['iso_code'])) $accounts[Tools::getValue('HIPAY_ACCOUNT_'.$currency['iso_code'])] = 1; - + Configuration::updateValue('HIPAY_ACCOUNT_TEST_'.$currency['iso_code'], trim(Tools::getValue('HIPAY_ACCOUNT_TEST_'.$currency['iso_code']))); Configuration::updateValue('HIPAY_PASSWORD_TEST_'.$currency['iso_code'], trim(Tools::getValue('HIPAY_PASSWORD_TEST_'.$currency['iso_code']))); Configuration::updateValue('HIPAY_SITEID_TEST_'.$currency['iso_code'], trim(Tools::getValue('HIPAY_SITEID_TEST_'.$currency['iso_code']))); Configuration::updateValue('HIPAY_CATEGORY_TEST_'.$currency['iso_code'], Tools::getValue('HIPAY_CATEGORY_TEST_'.$currency['iso_code'])); - + if (!$this->prod AND Tools::getValue('HIPAY_ACCOUNT_TEST_'.$currency['iso_code'])) - $accounts[Tools::getValue('HIPAY_ACCOUNT_TEST_'.$currency['iso_code'])] = 1; + $accounts[Tools::getValue('HIPAY_ACCOUNT_TEST_'.$currency['iso_code'])] = 1; } - + $i = 1; $dataSync = 'http://www.prestashop.com/modules/hipay.png?mode='.($this->prod ? 'prod' : 'test'); foreach ($accounts as $account => $null) $dataSync .= '&account'.($i++).'='.urlencode($account); - + Configuration::updateValue('HIPAY_RATING', Tools::getValue('HIPAY_RATING')); - + echo $this->displayConfirmation($this->l('Configuration updated').''); } - + // Check configuration $allow_url_fopen = ini_get('allow_url_fopen'); $openssl = extension_loaded('openssl'); @@ -390,18 +390,18 @@ class Hipay extends PaymentModule $online = (in_array(Tools::getRemoteAddr(), array('127.0.0.1', '::1')) ? false : true); $categories = true; $categoryRetrieval = true; - + foreach ($currencies as $currency) { if (($hipaySiteId = Configuration::get('HIPAY_SITEID_'.$currency['iso_code']) AND $hipayAccountId = Configuration::get('HIPAY_ACCOUNT_'.$currency['iso_code']) AND !count($this->getHipayCategories(true, $hipaySiteId, $hipayAccountId))) OR ($hipaySiteIdTest = Configuration::get('HIPAY_SITEID_TEST_'.$currency['iso_code']) AND $hipayAccountIdTest = Configuration::get('HIPAY_ACCOUNT_TEST_'.$currency['iso_code']) AND !count($this->getHipayCategories(false, $hipaySiteIdTest, $hipayAccountIdTest)))) $categoryRetrieval = false; - + if ((Configuration::get('HIPAY_SITEID_'.$currency['iso_code']) AND !Configuration::get('HIPAY_CATEGORY_'.$currency['iso_code'])) OR (Configuration::get('HIPAY_SITEID_TEST_'.$currency['iso_code']) AND !Configuration::get('HIPAY_CATEGORY_TEST_'.$currency['iso_code']))) $categories = false; } - + if (!$allow_url_fopen OR !$openssl OR !$curl OR !$ping OR !$categories OR !$categoryRetrieval OR !$online) { echo ' @@ -416,7 +416,7 @@ class Hipay extends PaymentModule
'; } - $link = AdminTab::$currentIndex.'&configure='.$this->name.'&token='.Tools::getValue('token'); + $link = AdminTab::$currentIndex.'&configure='.$this->name.'&token='.Tools::safeOutput(Tools::getValue('token')); $form = ' - +
'.$c['additional_charges'].' '.$configCurrency->sign.' '.$services.' - + - +
'.$c['additional_charges'].' '.$configCurrency->sign.' '.$services.' - + - +
'; foreach ($arrayConf as $conf => $translations) $html .= ' - '; $html .= '
'.$arrayColors[0].' '.$this->l('Not enough').''.$arrayColors[2].' '.$this->l('Alright').'
'.$translations['name'].''.$this->l('lower than').' '.$translations['text'].' - '.$this->l('greater than').' '.$translations['text'].' + '.$this->l('lower than').' '.$translations['text'].' + '.$this->l('greater than').' '.$translations['text'].'
 
-
+ '.$this->l('Order by').' diff --git a/modules/trustedshops/lib/TrustedShopsRating.php b/modules/trustedshops/lib/TrustedShopsRating.php index a0537e144..0652ebae9 100644 --- a/modules/trustedshops/lib/TrustedShopsRating.php +++ b/modules/trustedshops/lib/TrustedShopsRating.php @@ -311,7 +311,7 @@ class TrustedShopsRating extends AbsTrustedShops '; $content = $javascript . - ' + '
'.$this->l('Basic Settings').'

'.$this->l('Please fill your Trusted Shops ID (one different ID per language):').'

diff --git a/modules/twenga/twenga.php b/modules/twenga/twenga.php index 95c616c88..4ba8da99f 100644 --- a/modules/twenga/twenga.php +++ b/modules/twenga/twenga.php @@ -29,7 +29,7 @@ * Twenga module allow to use the Twenga API to : * 1. subscribe to their Ready to Sell engine, * 2. activate a tracking for order process if user has been used twenga engine, - * 3. submit a xml feed of shop products to Twenga. + * 3. submit a xml feed of shop products to Twenga. * @author Nans Pellicari - Prestashop * @version 1.3 */ @@ -44,7 +44,7 @@ class Twenga extends PaymentModule * @var string */ private static $base_dir; - + /** * Url path to access of module file. * @var string @@ -54,53 +54,53 @@ class Twenga extends PaymentModule * @var TwengaObj */ private static $obj_twenga; - + /** * @var PrestashopStats */ private static $obj_ps_stats; - + /** * @var string url used for the subscription to Twenga and prestashop - */ + */ private $site_url; - + /** * @var string url to acces of the product list for Twenga */ private $feed_url; - + /** * @var string url returned by Twenga API */ private $inscription_url; - + /** * @var string used for displaying html */ private $_html; - + /** * @var string */ private $current_index; - + /** * @var string */ private $token; - + /** * Countries where Twenga works. * need to be in lowercase * @var array */ public $limited_countries = array('fr', 'de', 'gb', 'uk', 'it', 'es', 'nl'); - + private $_allowToWork = true; private $_currentIsoCodeCountry = NULL; - + const ONLY_PRODUCTS = 1; const ONLY_DISCOUNTS = 2; const BOTH = 3; @@ -108,7 +108,7 @@ class Twenga extends PaymentModule const ONLY_SHIPPING = 5; const ONLY_WRAPPING = 6; const ONLY_PRODUCTS_WITHOUT_SHIPPING = 7; - + /** * The current country iso code for the shop. * @var string @@ -123,9 +123,9 @@ class Twenga extends PaymentModule $this->name = 'twenga'; $this->tab = 'smart_shopping'; $this->version = '1.8'; - + parent::__construct(); - + $this->displayName = $this->l('Twenga API'); $this->description = $this->l('Module role: export of your products on Twenga and installation of the sales tracking brought by Twenga (requires sign up to Twenga)'); @@ -137,15 +137,15 @@ class Twenga extends PaymentModule self::$base_dir = _PS_ROOT_DIR_.'/modules/twenga/'; self::$base_path = $this->site_url.'/modules/twenga/'; $this->feed_url = self::$base_path.'export.php?twenga_token='.sha1(Configuration::get('TWENGA_TOKEN')._COOKIE_KEY_); - + self::$shop_country = $this->context->country->iso_code; - + require_once realpath(self::$base_dir.'/lib/PrestashopStats.php'); require_once realpath(self::$base_dir.'/lib/TwengaObj.php'); - - // set the base dir to load files needed for the TwengaObj class + + // set the base dir to load files needed for the TwengaObj class TwengaObj::$base_dir = self::$base_dir.'/lib'; - + TwengaObj::setTranslationObject($this); TwengaException::setTranslationObject($this); if (!in_array(strtolower(self::$shop_country), $this->limited_countries)) @@ -154,7 +154,7 @@ class Twenga extends PaymentModule $this->warning = $this->l('Twenga module works only in specific countries (iso code list:').' '.implode(', ',$this->limited_countries).').';; return false; } - + // instanciate (just once) the TwengaObj and PrestashopStats if (self::$obj_twenga === NULL) self::$obj_twenga = new TwengaObj(); @@ -162,7 +162,7 @@ class Twenga extends PaymentModule self::$obj_ps_stats = new PrestashopStats($this->site_url); $this->_initCurrentIsoCodeCountry(); } - + public function install() { if (Configuration::updateValue('TWENGA_TOKEN', Tools::passwdGen())) @@ -170,7 +170,7 @@ class Twenga extends PaymentModule else return false; } - + /** * For uninstall just need to delete the Merchant Login. * @return bool see parent class. @@ -190,7 +190,7 @@ class Twenga extends PaymentModule FROM '._DB_PREFIX_.'country as c LEFT JOIN '._DB_PREFIX_.'country_lang as c_l ON c_l.id_country = c.id_country - WHERE c_l.id_lang = '.(int)$this->context->language->id.' + WHERE c_l.id_lang = '.(int)$this->context->language->id.' AND c.id_country = '.(int)Configuration::get('PS_COUNTRY_DEFAULT')); if (isset($country[0]['iso'])) @@ -198,14 +198,14 @@ class Twenga extends PaymentModule } public function ajaxRequestType() - { + { if (isset($_POST) && isset($_POST['type']) && isset($_POST['base'])) { $link = 'http://addons.prestashop.com/'.Language::getIsoById($_POST['id_lang']). '/2053-twenga-ready-to-sell.html'; - $type = (($_POST['type'] == 'desactive') ? $this->l('Disable') : - (($_POST['type'] == 'reset') ? $this->l('Reset') : + $type = (($_POST['type'] == 'desactive') ? $this->l('Disable') : + (($_POST['type'] == 'reset') ? $this->l('Reset') : (($_POST['type'] == 'uninstall') ? $this->l('Uninstall') : $this->l('Delete')))); if ($_POST['type'] == 'delete') @@ -213,7 +213,7 @@ class Twenga extends PaymentModule $url = $_POST['base'].'&token='.$_POST['token'].'&module_name='. $_POST['module_name'].'&tab_module='.$_POST['tab_module'].'&'. $_POST['type'].'='.$_POST['module_name']; - + $msg = ' - +

'.$this->l('General configuration').' :

-
+
-
+
-
+


- - '.Tools::getValue('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT')).' + + '.Tools::safeOutput(Tools::getValue('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT'))).'
- + '.$configCurrency->sign.'
@@ -486,12 +486,12 @@ class UpsCarrier extends CarrierModule

'.$this->l('Localization configuration').' :

- +

'.$this->l('The weight unit of your shop (eg. kg or lbs)').'

- +

'.$this->l('The dimension unit of your shop (eg. cm or in)').'

@@ -499,13 +499,13 @@ class UpsCarrier extends CarrierModule

'.$this->l('Address configuration').' :

-
+
-
+
-

+

-
+
@@ -877,8 +877,8 @@ class UpsCarrier extends CarrierModule $path .= $p; } - $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

-
+ $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

+
'.$path.'

@@ -890,7 +890,7 @@ class UpsCarrier extends CarrierModule $html .= '
-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'ups_rate_service_code` WHERE `id_ups_rate_service_group` = '.(int)Configuration::get('UPS_CARRIER_RATE_SERVICE_GROUP')); @@ -908,7 +908,7 @@ class UpsCarrier extends CarrierModule else { $html .= '

'.$this->l('Add a rule').'

- +
-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'ups_rate_service_code` WHERE `id_ups_rate_service_group` = '.(int)Configuration::get('UPS_CARRIER_RATE_SERVICE_GROUP')); @@ -1099,10 +1099,10 @@ class UpsCarrier extends CarrierModule '.$c['additionnal_charges'].' '.$configCurrency->sign.' '.$services.' - + - + @@ -1120,8 +1120,8 @@ class UpsCarrier extends CarrierModule $configSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'ups_rate_config` WHERE `id_ups_rate_config` = '.(int)(Tools::getValue('id_ups_rate_config'))); $product = new Product((int)$configSelected['id_product'], false, $this->context->language->id); - $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

-
+ $html .= '

'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ?)

+
'.$product->name.'

@@ -1133,7 +1133,7 @@ class UpsCarrier extends CarrierModule $html .= '
-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'ups_rate_service_code` WHERE `id_ups_rate_service_group` = '.(int)Configuration::get('UPS_CARRIER_RATE_SERVICE_GROUP')); @@ -1151,7 +1151,7 @@ class UpsCarrier extends CarrierModule else { $html .= '

'.$this->l('Add a rule').'

- +
-

+

'; $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'ups_rate_service_code` WHERE `id_ups_rate_service_group` = '.(int)Configuration::get('UPS_CARRIER_RATE_SERVICE_GROUP')); diff --git a/modules/watermark/watermark.php b/modules/watermark/watermark.php index 5be952a0c..1e42013e9 100644 --- a/modules/watermark/watermark.php +++ b/modules/watermark/watermark.php @@ -149,7 +149,7 @@ class Watermark extends Module { $imageTypes = ImageType::getImagesTypes('products'); $this->_html .= - ' + '
'.$this->l('Watermark details').'

'.$this->l('Once you have set up the module, regenerate the images using the "Images" tool in Preferences. However, the watermark will be added automatically to new images.').'

diff --git a/themes/prestashop/guest-tracking.tpl b/themes/prestashop/guest-tracking.tpl index a9ecb3fbd..1cd6c4218 100644 --- a/themes/prestashop/guest-tracking.tpl +++ b/themes/prestashop/guest-tracking.tpl @@ -24,17 +24,13 @@ * International Registered Trademark & Property of PrestaShop SA *} -{capture name=path}{l s='Guests: Track your order'}{/capture} +{capture name=path}{l s='Track your order'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} -

{l s='Guests: Track your order'}

+

{l s='Track your order'}

{if isset($order)} -
-
{include file="$tpl_dir./order-detail.tpl"} -
-

{l s='Create your customer account'}