From 16351783917601ee6166096206cc1d7b9d9f30c4 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Fri, 8 Mar 2013 17:35:41 +0100 Subject: [PATCH 01/60] //small fix on Category::cleanPositions() --- classes/Category.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Category.php b/classes/Category.php index 7286a630d..40af9a9a7 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -1161,7 +1161,7 @@ class CategoryCore extends ObjectModel UPDATE `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.') - SET cs.`position` = '.(int)$i.' + SET cs.`position` = '.(int)($i+1).' WHERE c.`id_parent` = '.(int)$id_category_parent.' AND c.`id_category` = '.(int)$result[$i]['id_category']; $return &= Db::getInstance()->execute($sql); From 9d0b6de69f9683170ec38b52a8fc379a3f3e0889 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Fri, 8 Mar 2013 18:10:38 +0100 Subject: [PATCH 02/60] [+] MO : new module PrestaShop Cleaner: Check and fix functional integrity constraints and remove default data --- modules/pscleaner/config.xml | 12 + modules/pscleaner/index.php | 35 ++ modules/pscleaner/logo.png | Bin 0 -> 3000 bytes modules/pscleaner/pscleaner.php | 483 +++++++++++++++++++++++ modules/pscleaner/translations/fr.php | 15 + modules/pscleaner/translations/index.php | 35 ++ 6 files changed, 580 insertions(+) create mode 100644 modules/pscleaner/config.xml create mode 100644 modules/pscleaner/index.php create mode 100644 modules/pscleaner/logo.png create mode 100644 modules/pscleaner/pscleaner.php create mode 100644 modules/pscleaner/translations/fr.php create mode 100644 modules/pscleaner/translations/index.php diff --git a/modules/pscleaner/config.xml b/modules/pscleaner/config.xml new file mode 100644 index 000000000..d1f03fa8f --- /dev/null +++ b/modules/pscleaner/config.xml @@ -0,0 +1,12 @@ + + + pscleaner + + + + + + 1 + 0 + + \ No newline at end of file diff --git a/modules/pscleaner/index.php b/modules/pscleaner/index.php new file mode 100644 index 000000000..3f6561f72 --- /dev/null +++ b/modules/pscleaner/index.php @@ -0,0 +1,35 @@ + +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/pscleaner/logo.png b/modules/pscleaner/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..6b43d7e23721bd6186d17461e412293be97bbae5 GIT binary patch literal 3000 zcmV;p3rF;cP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qQF!XYv000XoNkl!;eW{{#_Xk%2O zSO8IabpQeB3igHt3y9f>J;jub?q*|(l@4N!5WBGigUZ?iV+ErOA|eC^rWfLgF@F2M zZx{}0&RNd+&MWuc@B7{VyYJ3}$Npaa^%t)+GSK<-wAjseRxNl`n?3h=?TWM)wb}DX z^Iz1hWLjX*Dx(&@rrvEN8dJ-}JUFkkKW?vDQ2*oP=#9IhMGh}t{K;kW@bV=uFTmUT zcGk>h{l~M>^^aI|y%&S7_vyGI0bSWi=vtMGuGJIKwPq421zl@XNt4mFu9uA0tc~?y z{a4Z0>_q5S#F6g=@{EISLmI>x(;Bw;c#ZmtL3|V7VP8Ezu|dClJoJl0pkFG2J~IOP ztSIOSL{C6^0@1G|BQn&Jv7SH-N+G3oi_TZmy;an{G8uX&v&sD0dsF&LLKG3BHLProfg3x6~LT7|v|KW^o00O1{I)c|NkKufDnc>h;xNcDpv<f!LDN#;!g>uG7C}&ec8g*b0 z=|Kj7ANN2(vt=`8p}hgPDiDB@D)Bl*56qP_ zw3|ep`VQn%heA$N3Zhfa^MP_v2sD>YbH*%$g}q(@Bf$TI&|EnSB~3^%cMKG>JfN69 z9P%kcP!Tm;%sV%Jn51KpGh~woLpIF~vRUqsQ%CjjVs5Yzz&QIJfX)sm>g%Amdjm=d z9c7(wfEdNDl_i_V+XFIs+%l?oXQ~htmW%pW4Lo^MikffbZHDWe0K%O z1v*U3*Wg;l47AN~N88ll_$|eiGF;G_FaRxawm8iIPKjJ4O%rVKB;F2B6W@mF%sv9p zbI;#ceip81_!VtSL}*(S#vR)!thd;`#*8?8xVg#@UZ6$ZM>%Mj;fa>1BhZrSik4&{ zWjIilJ(^ItqViZnjVJM zMdR>WdMKxhE3%NerH+Dim_*^l>%Ya*>7IBxWdxd2-^G)O1JRV|gvap?TvkJr6^@4r z#k^y|F7@}v@$n$C4;rQnLzhAipP@%qcM3P8WNmQKcPQmnd5#KA4h_n#k|A8E|R-+Q7bY> zJ#9w6KYP{#V0`^l1k(I|5+2VQizb4&xNaeG^YW3Ie~$w7ujrFar_ngW3ysq}@M!XI zNG83D`a~ff(5&x|w?bXGIqr=U;9e*nhZ(@35EsdQgsCcppwDgax6?3HTF zjDmzrrQ0HLZ2v~&hE#@>@{R-fC0z}M0I@&p5IRH zk+xs{^adomUZW6%F_(2d)5TYj95!K`E@k@j)Zj7_S^-yzM3o^mg zKmooFqzW7e8YsC$0GGr1;BE-VK$V zP57fO;|+)>Wr_HCk{8Y=xDkX0+HYRv;5#4Q!>y0zbgRC4e&l<~S2%g)_l6I2&e%tF)u(|7JfhKs4f6{pS>%M4E{9@+efMy5pzVVYs|B z9&O?)95@pj%hW<&QI{8pa5}&Or~FKD%7>3r-h7n$(;_Sh5K2z^nd3x&B~Aoe<3vb* zoD3U)`z2ppE5IQy+Js1jzD{CZfuB(FgSRQleJoJ!Yl$*{Ym^1{ zLs^g=4n+(?{fPswK(G)NXsm{@BJBF_AUYmBz^Q4z_}<$b2gjJ=AO#;B%|qE}KJtAC zAkW9S?t5xr9S->P!G2#W?Dw}J^~e4|d+ZN&#VIMW_AqduSw|5_u`dFdV z*M=5Jf0PnLX^;cTlDu$h_g3zcoPnrmrfiFT1%l4o9zVjJgM~OcdmM_#TB3MN9~66; zqr}q`CGG<3qTo_@9`<;c;G5z7ih0>ieWsO+e(MG6P(0ckMKqv@1{Qf+qnIE{{Q99J zzz(|t2VfV0>FLbGyL zM+Xbu`t|F1ZkFaQYn)6^?-*hBXC8s%)4+UYKt=^*Sip>ZY-rU|2$Ns;kt)RQv-Sdl zEf{0TjmsZxfjkP%^Dsp&h38Uu4$VG?!nY0OKVRu6I5Nz}(qYY-HHQC?CnhKJ?QLys z$6J}CEgE2Qc!iV6jcjLAu|a0yY!@bTPAi4xHKd+vgSz|lj4=^sJDG@AI0+1L6o}t< u + * @copyright 2007-2013 PrestaShop SA + * @version Release: $Revision: 7060 $ + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +if (!defined('_CAN_LOAD_FILES_')) + exit; + +class PSCleaner extends Module +{ + public function __construct() + { + $this->name = 'pscleaner'; + $this->tab = 'administration'; + $this->version = '0.9'; + $this->author = 'PrestaShop'; + $this->need_instance = 0; + + parent::__construct(); + + $this->displayName = $this->l('PrestaShop Cleaner'); + $this->description = $this->l('Check and fix functional integrity constraints and remove default data'); + $this->secure_key = Tools::encrypt($this->name); + } + + public function getContent() + { + $html = '

'.$this->l('Be really careful with this tool - There is no possible rollback!').'

'; + if (Tools::isSubmit('submitCheckAndFix')) + $html .= (count($logs = self::checkAndFix()) ? print_r($logs, true) : $this->l('Nothing that need to be cleaned')).'

'; + if (Tools::isSubmit('submitTruncateCatalog')) + { + self::truncate('catalog'); + $html .= $this->l('Catalog truncated').'

'; + } + if (Tools::isSubmit('submitTruncateSales')) + { + self::truncate('sales'); + $html .= $this->l('Orders and customers truncated').'

'; + } + + $html .= ' +
+
'.$this->l('Functional integrity constraints').' + +
+
+

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

+ +
+
'; + return $html; + } + + public static function checkAndFix() + { + $db = Db::getInstance(); + $logs = array(); + + // Simple Cascade Delete + $queries = array( + // 0 => DELETE FROM __table__, 1 => WHERE __id__ NOT IN, 2 => NOT IN __table__, 3 => __id__ used in the "NOT IN" table + array('access', 'id_profile', 'profile', 'id_profile'), + array('access', 'id_tab', 'tab', 'id_tab'), + array('accessory', 'id_product_1', 'product', 'id_product'), + array('accessory', 'id_product_2', 'product', 'id_product'), + array('address_format', 'id_country', 'country', 'id_country'), + array('attribute', 'id_attribute_group', 'attribute_group', 'id_attribute_group'), + array('carrier_group', 'id_carrier', 'carrier', 'id_carrier'), + array('carrier_group', 'id_group', 'group', 'id_group'), + array('carrier_zone', 'id_carrier', 'carrier', 'id_carrier'), + array('carrier_zone', 'id_zone', 'zone', 'id_zone'), + array('cart_cart_rule', 'id_cart', 'cart', 'id_cart'), + array('cart_product', 'id_cart', 'cart', 'id_cart'), + array('cart_rule_carrier', 'id_cart_rule', 'cart_rule', 'id_cart_rule'), + array('cart_rule_carrier', 'id_carrier', 'carrier', 'id_carrier'), + array('cart_rule_combination', 'id_cart_rule_1', 'cart_rule', 'id_cart_rule'), + array('cart_rule_combination', 'id_cart_rule_2', 'cart_rule', 'id_cart_rule'), + array('cart_rule_country', 'id_cart_rule', 'cart_rule', 'id_cart_rule'), + array('cart_rule_country', 'id_country', 'country', 'id_country'), + array('cart_rule_group', 'id_cart_rule', 'cart_rule', 'id_cart_rule'), + array('cart_rule_group', 'id_group', 'group', 'id_group'), + array('cart_rule_product_rule_group', 'id_cart_rule', 'cart_rule', 'id_cart_rule'), + array('cart_rule_product_rule', 'id_product_rule_group', 'cart_rule_product_rule_group', 'id_product_rule_group'), + array('cart_rule_product_rule_value', 'id_product_rule', 'cart_rule_product_rule', 'id_product_rule'), + array('category_group', 'id_category', 'category', 'id_category'), + array('category_group', 'id_group', 'group', 'id_group'), + array('category_product', 'id_category', 'category', 'id_category'), + array('category_product', 'id_product', 'product', 'id_product'), + array('cms', 'id_cms_category', 'cms_category', 'id_cms_category'), + array('cms_block', 'id_cms_category', 'cms_category', 'id_cms_category'), + array('cms_block_page', 'id_cms', 'cms', 'id_cms'), + array('cms_block_page', 'id_cms_block', 'cms_block', 'id_cms_block'), + array('compare', 'id_customer', 'customer', 'id_customer'), + array('compare_product', 'id_compare', 'compare', 'id_compare'), + array('compare_product', 'id_product', 'product', 'id_product'), + array('connections', 'id_shop_group', 'shop_group', 'id_shop_group'), + array('connections', 'id_shop', 'shop', 'id_shop'), + array('connections_page', 'id_connections', 'connections', 'id_connections'), + array('connections_page', 'id_page', 'page', 'id_page'), + array('connections_source', 'id_connections', 'connections', 'id_connections'), + array('customer', 'id_shop_group', 'shop_group', 'id_shop_group'), + array('customer', 'id_shop', 'shop', 'id_shop'), + array('customer_group', 'id_group', 'group', 'id_group'), + array('customer_group', 'id_customer', 'customer', 'id_customer'), + array('customer_message', 'id_customer_thread', 'customer_thread', 'id_customer_thread'), + array('customer_thread', 'id_shop', 'shop', 'id_shop'), + array('customization', 'id_cart', 'cart', 'id_cart'), + array('customization_field', 'id_product', 'product', 'id_product'), + array('customized_data', 'id_customization', 'customization', 'id_customization'), + array('delivery', 'id_shop', 'shop', 'id_shop'), + array('delivery', 'id_shop_group', 'shop_group', 'id_shop_group'), + array('delivery', 'id_carrier', 'carrier', 'id_carrier'), + array('delivery', 'id_zone', 'zone', 'id_zone'), + array('editorial', 'id_shop', 'shop', 'id_shop'), + array('favorite_product', 'id_product', 'product', 'id_product'), + array('favorite_product', 'id_customer', 'customer', 'id_customer'), + array('favorite_product', 'id_shop', 'shop', 'id_shop'), + array('feature_product', 'id_feature', 'feature', 'id_feature'), + array('feature_product', 'id_product', 'product', 'id_product'), + array('feature_value', 'id_feature', 'feature', 'id_feature'), + array('group_reduction', 'id_group', 'group', 'id_group'), + array('group_reduction', 'id_category', 'category', 'id_category'), + array('homeslider', 'id_shop', 'shop', 'id_shop'), + array('homeslider', 'id_homeslider_slides', 'homeslider_slides', 'id_homeslider_slides'), + array('hook_module', 'id_hook', 'hook', 'id_hook'), + array('hook_module', 'id_module', 'module', 'id_module'), + array('hook_module_exceptions', 'id_hook', 'hook', 'id_hook'), + array('hook_module_exceptions', 'id_module', 'module', 'id_module'), + array('hook_module_exceptions', 'id_shop', 'shop', 'id_shop'), + array('image', 'id_product', 'product', 'id_product'), + array('message', 'id_cart', 'cart', 'id_cart'), + array('message_readed', 'id_message', 'message', 'id_message'), + array('message_readed', 'id_employee', 'employee', 'id_employee'), + array('module_access', 'id_profile', 'profile', 'id_profile'), + array('module_access', 'id_module', 'module', 'id_module'), + array('module_country', 'id_module', 'module', 'id_module'), + array('module_country', 'id_country', 'country', 'id_country'), + array('module_country', 'id_shop', 'shop', 'id_shop'), + array('module_currency', 'id_module', 'module', 'id_module'), + array('module_currency', 'id_currency', 'currency', 'id_currency'), + array('module_currency', 'id_shop', 'shop', 'id_shop'), + array('module_group', 'id_module', 'module', 'id_module'), + array('module_group', 'id_group', 'group', 'id_group'), + array('module_group', 'id_shop', 'shop', 'id_shop'), + array('module_preference', 'id_employee', 'employee', 'id_employee'), + array('orders', 'id_shop', 'shop', 'id_shop'), + array('orders', 'id_shop_group', 'group_shop', 'id_shop_group'), + array('order_carrier', 'id_order', 'orders', 'id_order'), + array('order_cart_rule', 'id_order', 'orders', 'id_order'), + array('order_detail', 'id_order', 'orders', 'id_order'), + array('order_detail_tax', 'id_order_detail', 'order_detail', 'id_order_detail'), + array('order_history', 'id_order', 'orders', 'id_order'), + array('order_invoice', 'id_order', 'orders', 'id_order'), + array('order_invoice_payment', 'id_order', 'orders', 'id_order'), + array('order_invoice_tax', 'id_order_invoice', 'order_invoice', 'id_order_invoice'), + array('order_return', 'id_order', 'orders', 'id_order'), + array('order_return_detail', 'id_order_return', 'order_return', 'id_order_return'), + array('order_slip', 'id_order', 'orders', 'id_order'), + array('order_slip_detail', 'id_order_slip', 'order_slip', 'id_order_slip'), + array('pack', 'id_product_pack', 'product', 'id_product'), + array('pack', 'id_product_item', 'product', 'id_product'), + array('page', 'id_page_type', 'page_type', 'id_page_type'), + array('page_viewed', 'id_shop', 'shop', 'id_shop'), + array('page_viewed', 'id_shop_group', 'shop_group', 'id_shop_group'), + array('page_viewed', 'id_date_range', 'date_range', 'id_date_range'), + array('product_attachment', 'id_attachment', 'attachment', 'id_attachment'), + array('product_attachment', 'id_product', 'product', 'id_product'), + array('product_attribute', 'id_product', 'product', 'id_product'), + array('product_attribute_combination', 'id_product_attribute', 'product_attribute', 'id_product_attribute'), + array('product_attribute_combination', 'id_attribute', 'attribute', 'id_attribute'), + array('product_attribute_image', 'id_image', 'image', 'id_image'), + array('product_attribute_image', 'id_product_attribute', 'product_attribute', 'id_product_attribute'), + array('product_carrier', 'id_product', 'product', 'id_product'), + array('product_carrier', 'id_shop', 'shop', 'id_shop'), + array('product_carrier', 'id_carrier_reference', 'carrier', 'id_reference'), + array('product_country_tax', 'id_product', 'product', 'id_product'), + array('product_country_tax', 'id_country', 'country', 'id_country'), + array('product_country_tax', 'id_tax', 'tax', 'id_tax'), + array('product_download', 'id_product', 'product', 'id_product'), + array('product_group_reduction_cache', 'id_product', 'product', 'id_product'), + array('product_group_reduction_cache', 'id_group', 'group', 'id_group'), + array('product_sale', 'id_product', 'product', 'id_product'), + array('product_supplier', 'id_product', 'product', 'id_product'), + array('product_supplier', 'id_supplier', 'supplier', 'id_supplier'), + array('product_tag', 'id_product', 'product', 'id_product'), + array('product_tag', 'id_tag', 'tag', 'id_tag'), + array('range_price', 'id_carrier', 'carrier', 'id_carrier'), + array('range_weight', 'id_carrier', 'carrier', 'id_carrier'), + array('referrer_cache', 'id_referrer', 'referrer', 'id_referrer'), + array('referrer_cache', 'id_connections_source', 'connections_source', 'id_connections_source'), + array('scene_category', 'id_scene', 'scene', 'id_scene'), + array('scene_category', 'id_category', 'category', 'id_category'), + array('scene_products', 'id_scene', 'scene', 'id_scene'), + array('scene_products', 'id_product', 'product', 'id_product'), + array('search_index', 'id_product', 'product', 'id_product'), + array('search_word', 'id_lang', 'lang', 'id_lang'), + array('search_word', 'id_shop', 'shop', 'id_shop'), + array('shop_url', 'id_shop', 'shop', 'id_shop'), + array('specific_price_priority', 'id_product', 'product', 'id_product'), + array('stock', 'id_warehouse', 'warehouse', 'id_warehouse'), + array('stock', 'id_product', 'product', 'id_product'), + array('stock_available', 'id_product', 'product', 'id_product'), + array('stock_available', 'id_shop', 'shop', 'id_shop'), + array('stock_available', 'id_shop_group', 'shop_group', 'id_shop_group'), + array('stock_mvt', 'id_stock', 'stock', 'id_stock'), + array('tab_module_preference', 'id_employee', 'employee', 'id_employee'), + array('tab_module_preference', 'id_tab', 'tab', 'id_tab'), + array('tax_rule', 'id_country', 'country', 'id_country'), + array('theme_specific', 'id_theme', 'theme', 'id_theme'), + array('theme_specific', 'id_shop', 'shop', 'id_shop'), + array('warehouse_carrier', 'id_warehouse', 'warehouse', 'id_warehouse'), + array('warehouse_carrier', 'id_carrier', 'carrier', 'id_carrier'), + array('warehouse_product_location', 'id_product', 'product', 'id_product'), + array('warehouse_product_location', 'id_warehouse', 'warehouse', 'id_warehouse'), + ); + + $queries = self::bulle($queries); + foreach ($queries as $query_array) + { + $query = 'DELETE FROM `'._DB_PREFIX_.$query_array[0].'` WHERE `'.$query_array[1].'` NOT IN (SELECT `'.$query_array[3].'` FROM `'._DB_PREFIX_.$query_array[2].'`)'; + $db->Execute($query); + if ($affected_rows = $db->Affected_Rows()) + $logs[$query] = $affected_rows; + } + + // _lang table cleaning + $tables = Db::getInstance()->executeS('SHOW TABLES LIKE "'._DB_PREFIX_.'%_\\_lang"'); + foreach ($tables as $table) + { + $table_lang = current($table); + $table = str_replace('_lang', '', $table_lang); + $id_table = 'id_'.preg_replace('/^'._DB_PREFIX_.'/', '', $table); + + $query = 'DELETE FROM `'.bqSQL($table_lang).'` WHERE `'.bqSQL($id_table).'` NOT IN (SELECT `'.bqSQL($id_table).'` FROM `'.bqSQL($table).'`)'; + $db->Execute($query); + if ($affected_rows = $db->Affected_Rows()) + $logs[$query] = $affected_rows; + + $query = 'DELETE FROM `'.bqSQL($table_lang).'` WHERE `id_lang` NOT IN (SELECT `id_lang` FROM `'._DB_PREFIX_.'lang`)'; + $db->Execute($query); + if ($affected_rows = $db->Affected_Rows()) + $logs[$query] = $affected_rows; + } + + // _shop table cleaning + $tables = Db::getInstance()->executeS('SHOW TABLES LIKE "'._DB_PREFIX_.'%_\\_shop"'); + foreach ($tables as $table) + { + $table_shop = current($table); + $table = str_replace('_shop', '', $table_shop); + $id_table = 'id_'.preg_replace('/^'._DB_PREFIX_.'/', '', $table); + + if (in_array($table_shop, array('ps2_carrier_tax_rules_group_shop'))) + continue; + + $query = 'DELETE FROM `'.bqSQL($table_shop).'` WHERE `'.bqSQL($id_table).'` NOT IN (SELECT `'.bqSQL($id_table).'` FROM `'.bqSQL($table).'`)'; + $db->Execute($query); + if ($affected_rows = $db->Affected_Rows()) + $logs[$query] = $affected_rows; + + $query = 'DELETE FROM `'.bqSQL($table_shop).'` WHERE `id_shop` NOT IN (SELECT `id_shop` FROM `'._DB_PREFIX_.'shop`)'; + $db->Execute($query); + if ($affected_rows = $db->Affected_Rows()) + $logs[$query] = $affected_rows; + } + + Category::regenerateEntireNtree(); + + // @Todo: Remove attachment files, images... + Image::clearTmpDir(); + + return $logs; + } + + public function truncate($case) + { + $db = Db::getInstance(); + + switch ($case) + { + case 'catalog': + $id_home = Configuration::get('PS_HOME_CATEGORY'); + $id_root = Configuration::get('PS_ROOT_CATEGORY'); + Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'category` WHERE id_category NOT IN ('.(int)$id_home.', '.(int)$id_root.')'); + Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'category_lang` WHERE id_category NOT IN ('.(int)$id_home.', '.(int)$id_root.')'); + Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'category_shop` WHERE id_category NOT IN ('.(int)$id_home.', '.(int)$id_root.')'); + foreach (scandir(_PS_CAT_IMG_DIR_) as $dir) + if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $dir)) + unlink(_PS_CAT_IMG_DIR_.$dir); + $tables = array( + 'product', + 'product_shop', + 'feature_product', + 'product_lang', + 'category_product', + 'product_tag', + 'image', + 'image_lang', + 'image_shop', + 'specific_price', + 'specific_price_priority', + 'product_carrier', + 'cart_product', + 'compare_product', + 'product_attachment', + 'product_country_tax', + 'product_download', + 'product_group_reduction_cache', + 'product_sale', + 'product_supplier', + 'scene_products', + 'warehouse_product_location', + 'stock', + 'stock_available', + 'stock_mvt', + 'customization', + 'customization_field', + 'supply_order_detail', + 'attribute_impact', + 'product_attribute', + 'product_attribute_shop', + 'product_attribute_combination', + 'product_attribute_image', + 'attribute', + 'attribute_impact', + 'attribute_lang', + 'attribute_group', + 'attribute_group_lang', + 'attribute_group_shop', + 'attribute_shop', + 'product_attribute', + 'product_attribute_shop', + 'product_attribute_combination', + 'product_attribute_image', + 'stock_available', + 'manufacturer', + 'manufacturer_lang', + 'manufacturer_shop', + 'supplier', + 'supplier_lang', + 'supplier_shop', + 'customization', + 'customization_field', + 'customization_field_lang', + 'customized_data', + 'feature', + 'feature_lang', + 'feature_product', + 'feature_shop', + 'feature_value', + 'feature_value_lang', + 'pack', + 'scene', + 'scene_category', + 'scene_lang', + 'scene_products', + 'scene_shop', + 'search_index', + 'search_word', + 'specific_price', + 'specific_price_priority', + 'specific_price_rule', + 'specific_price_rule_condition', + 'specific_price_rule_condition_group', + 'stock', + 'stock_available', + 'stock_mvt', + ); + foreach ($tables as $table) + $db->execute('TRUNCATE TABLE `'._DB_PREFIX_.bqSQL($table).'`'); + $db->execute('DELETE FROM `'._DB_PREFIX_.'address` WHERE id_customer > 0'); + + Image::deleteAllImages(_PS_PROD_IMG_DIR_); + if (!file_exists(_PS_PROD_IMG_DIR_)) + mkdir(_PS_PROD_IMG_DIR_); + foreach (scandir(_PS_MANU_IMG_DIR_) as $dir) + if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $dir)) + unlink(_PS_MANU_IMG_DIR_.$dir); + foreach (scandir(_PS_SUPP_IMG_DIR_) as $dir) + if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $dir)) + unlink(_PS_SUPP_IMG_DIR_.$dir); + break; + + case 'sales': + $tables = array( + 'customer', + 'cart', + 'cart_product', + 'connections', + 'connections_page', + 'connections_source', + 'customer_group', + 'customer_message', + 'customer_message_sync_imap', + 'customer_thread', + 'guest', + 'message', + 'message_readed', + 'orders', + 'order_carrier', + 'order_cart_rule', + 'order_detail', + 'order_detail_tax', + 'order_history', + 'order_invoice', + 'order_invoice_payment', + 'order_invoice_tax', + 'order_payment', + 'order_return', + 'order_return_detail', + 'order_return_state', + 'order_return_state_lang', + 'order_slip', + 'order_slip_detail', + 'page', + 'pagenotfound', + 'page_type', + 'page_viewed', + 'referrer_cache', + 'sekeyword', + ); + foreach ($tables as $table) + $db->execute('TRUNCATE TABLE `'._DB_PREFIX_.bqSQL($table).'`'); + $db->execute('DELETE FROM `'._DB_PREFIX_.'address` WHERE id_manufacturer > 0 OR id_supplier > 0'); + break; + } + } + + public static function cleanAndOptimize() + { + // Clean (carts...) + } + + protected static function bulle($array) + { + $sorted = false; + $size = count($array); + while (!$sorted) + { + $sorted = true; + for ($i = 0; $i < $size - 1; ++$i) + for ($j = $i + 1; $j < $size; ++$j) + { + if ($array[$i][2] == $array[$j][0]) + { + // var_dump(array($array[$i], $array[$j])); + $tmp = $array[$i]; + $array[$i] = $array[$j]; + $array[$j] = $tmp; + $sorted = false; + } + } + } + return $array; + } +} diff --git a/modules/pscleaner/translations/fr.php b/modules/pscleaner/translations/fr.php new file mode 100644 index 000000000..f66fd335a --- /dev/null +++ b/modules/pscleaner/translations/fr.php @@ -0,0 +1,15 @@ +pscleaner_e5a8af934462c05509c7de5f2f2c18a3'] = 'Nettoyage de PrestaShop'; +$_MODULE['<{pscleaner}prestashop>pscleaner_4bcb9cc248b7f6c8dc7f5c323bde76de'] = 'Vérifie et répare les problèmes d\'intégrité fonctionnelle et supprime les données par défaut (produits, commandes, clients)'; +$_MODULE['<{pscleaner}prestashop>pscleaner_752369f18aebeed9ae8384d8f1b5dc5e'] = 'Soyez très attentifs en utilisant cet outil, il n\'y a pas de retour en arrière possible !'; +$_MODULE['<{pscleaner}prestashop>pscleaner_098c3581a731f08d24311bbf515adbbb'] = 'Rien qui ne nécessite d\'être nettoyer'; +$_MODULE['<{pscleaner}prestashop>pscleaner_1bb7c5eb8682aeada82c407b40ec09c8'] = 'Catalogue supprimé'; +$_MODULE['<{pscleaner}prestashop>pscleaner_ed6ecb7169d5476ef5251524bb17552a'] = 'Commandes et clients supprimés'; +$_MODULE['<{pscleaner}prestashop>pscleaner_3535aa31bd9005bde626ad4312b67d6b'] = 'Contraintes d\'intégrité fonctionnelle'; +$_MODULE['<{pscleaner}prestashop>pscleaner_e84c6595e849214a70b35ed8f95d7d16'] = 'Vérifier et réparer'; +$_MODULE['<{pscleaner}prestashop>pscleaner_f6068daa29dbb05a7ead1e3b5a48bbee'] = 'Données'; +$_MODULE['<{pscleaner}prestashop>pscleaner_b2d7c99e984831bd36221baf34e9c26e'] = 'Supprimer le catalogue'; +$_MODULE['<{pscleaner}prestashop>pscleaner_17ca7f22baf84821b6b73462c96fb1e3'] = 'Supprimer les commandes et clients'; diff --git a/modules/pscleaner/translations/index.php b/modules/pscleaner/translations/index.php new file mode 100644 index 000000000..3f6561f72 --- /dev/null +++ b/modules/pscleaner/translations/index.php @@ -0,0 +1,35 @@ + +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file From 87ab3be15a430b316412a10b5e6bf9e2d548ff4d Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Fri, 8 Mar 2013 20:07:08 +0100 Subject: [PATCH 03/60] [-] MO: pscleaner - fixed bugs We need to know that 'editorial' is a module and not always install (so, table can not be there). ps2 need to be _DB_PREFIX_ ! --- modules/pscleaner/pscleaner.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/pscleaner/pscleaner.php b/modules/pscleaner/pscleaner.php index a2bd99a05..22eecf236 100644 --- a/modules/pscleaner/pscleaner.php +++ b/modules/pscleaner/pscleaner.php @@ -85,7 +85,7 @@ class PSCleaner extends Module // Simple Cascade Delete $queries = array( - // 0 => DELETE FROM __table__, 1 => WHERE __id__ NOT IN, 2 => NOT IN __table__, 3 => __id__ used in the "NOT IN" table + // 0 => DELETE FROM __table__, 1 => WHERE __id__ NOT IN, 2 => NOT IN __table__, 3 => __id__ used in the "NOT IN" table, 4 => module_name array('access', 'id_profile', 'profile', 'id_profile'), array('access', 'id_tab', 'tab', 'id_tab'), array('accessory', 'id_product_1', 'product', 'id_product'), @@ -138,7 +138,7 @@ class PSCleaner extends Module array('delivery', 'id_shop_group', 'shop_group', 'id_shop_group'), array('delivery', 'id_carrier', 'carrier', 'id_carrier'), array('delivery', 'id_zone', 'zone', 'id_zone'), - array('editorial', 'id_shop', 'shop', 'id_shop'), + array('editorial', 'id_shop', 'shop', 'id_shop', 'editorial'), array('favorite_product', 'id_product', 'product', 'id_product'), array('favorite_product', 'id_customer', 'customer', 'id_customer'), array('favorite_product', 'id_shop', 'shop', 'id_shop'), @@ -244,10 +244,13 @@ class PSCleaner extends Module $queries = self::bulle($queries); foreach ($queries as $query_array) { - $query = 'DELETE FROM `'._DB_PREFIX_.$query_array[0].'` WHERE `'.$query_array[1].'` NOT IN (SELECT `'.$query_array[3].'` FROM `'._DB_PREFIX_.$query_array[2].'`)'; - $db->Execute($query); - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; + if(!isset($query_array[4]) || (isset($query_array[4]) && Module::isInstalled($query_array[4]))) + { + $query = 'DELETE FROM `'._DB_PREFIX_.$query_array[0].'` WHERE `'.$query_array[1].'` NOT IN (SELECT `'.$query_array[3].'` FROM `'._DB_PREFIX_.$query_array[2].'`)'; + $db->Execute($query); + if ($affected_rows = $db->Affected_Rows()) + $logs[$query] = $affected_rows; + } } // _lang table cleaning @@ -277,7 +280,7 @@ class PSCleaner extends Module $table = str_replace('_shop', '', $table_shop); $id_table = 'id_'.preg_replace('/^'._DB_PREFIX_.'/', '', $table); - if (in_array($table_shop, array('ps2_carrier_tax_rules_group_shop'))) + if (in_array($table_shop, array(_DB_PREFIX_.'carrier_tax_rules_group_shop'))) continue; $query = 'DELETE FROM `'.bqSQL($table_shop).'` WHERE `'.bqSQL($id_table).'` NOT IN (SELECT `'.bqSQL($id_table).'` FROM `'.bqSQL($table).'`)'; From f69e80f2a15c98f64f83102006e275952d66f26e Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Fri, 8 Mar 2013 22:12:44 +0100 Subject: [PATCH 04/60] [-] MO: followup - fix bug in template vars --- modules/followup/followup.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/followup/followup.php b/modules/followup/followup.php index 8011b8bf7..cd270ee6c 100644 --- a/modules/followup/followup.php +++ b/modules/followup/followup.php @@ -298,7 +298,7 @@ class Followup extends Module $voucher = $this->createDiscount(1, (float)($conf['PS_FOLLOW_UP_AMOUNT_1']), (int)($email['id_customer']), strftime('%Y-%m-%d', strtotime('+'.(int)($conf['PS_FOLLOW_UP_DAYS_1']).' day')), $this->l('Discount for your cancelled cart')); if ($voucher !== false) { - $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_1'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_1'], '{voucher_num}' => $voucher->name); + $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_1'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_1'], '{voucher_num}' => $voucher->code); $result = Mail::Send((int)$email['id_lang'], 'followup_1', Mail::l('Your cart and your discount', (int)$email['id_lang']), $templateVars, $email['email'], $email['firstname'].' '.$email['lastname'], NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); $this->logEmail(1, (int)($voucher->id), (int)($email['id_customer']), (int)($email['id_cart'])); } @@ -369,7 +369,7 @@ class Followup extends Module $voucher = $this->createDiscount(2, (float)($conf['PS_FOLLOW_UP_AMOUNT_2']), (int)($email['id_customer']), strftime('%Y-%m-%d', strtotime('+'.(int)($conf['PS_FOLLOW_UP_DAYS_2']).' day')), $this->l('Thank you for your order.')); if ($voucher !== false) { - $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_2'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_2'], '{voucher_num}' => $voucher->name); + $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_2'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_2'], '{voucher_num}' => $voucher->code); $result = Mail::Send((int)$email['id_lang'], 'followup_2', Mail::l('Thanks for your order', (int)$email['id_lang']), $templateVars, $email['email'], $email['firstname'].' '.$email['lastname'], NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); $this->logEmail(2, (int)($voucher->id), (int)($email['id_customer']), (int)($email['id_cart'])); } @@ -406,7 +406,7 @@ class Followup extends Module $voucher = $this->createDiscount(3, (float)($conf['PS_FOLLOW_UP_AMOUNT_3']), (int)($email['id_customer']), strftime('%Y-%m-%d', strtotime('+'.(int)($conf['PS_FOLLOW_UP_DAYS_3']).' day')), $this->l('You are one of our best customers!')); if ($voucher !== false) { - $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_3'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_3'], '{voucher_num}' => $voucher->name); + $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_3'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_3'], '{voucher_num}' => $voucher->code); $result = Mail::Send((int)$email['id_lang'], 'followup_3', Mail::l('You are one of our best customers', (int)$email['id_lang']), $templateVars, $email['email'], $email['firstname'].' '.$email['lastname'], NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); $this->logEmail(3, (int)($voucher->id), (int)($email['id_customer']), (int)($email['id_cart'])); } @@ -449,7 +449,7 @@ class Followup extends Module $voucher = $this->createDiscount(4, (float)($conf['PS_FOLLOW_UP_AMOUNT_4']), (int)($email['id_customer']), strftime('%Y-%m-%d', strtotime('+'.(int)($conf['PS_FOLLOW_UP_DAYS_4']).' day')), $this->l('We miss you!')); if ($voucher !== false) { - $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_4'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_4'], '{days_threshold}' => (int)(Configuration::get('PS_FOLLOW_UP_DAYS_THRESHOLD_4')), '{voucher_num}' => $voucher->name); + $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_4'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_4'], '{days_threshold}' => (int)(Configuration::get('PS_FOLLOW_UP_DAYS_THRESHOLD_4')), '{voucher_num}' => $voucher->code); $result = Mail::Send((int)$email['id_lang'], 'followup_4', Mail::l('We miss you', (int)$email['id_lang']), $templateVars, $email['email'], $email['firstname'].' '.$email['lastname'], NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); $this->logEmail(4, (int)($voucher->id), (int)($email['id_customer']), (int)($email['id_cart'])); } From fe8070cde2854c62b981bcbf3f5870f0b502b835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 11 Mar 2013 10:55:56 +0100 Subject: [PATCH 05/60] // PR-313 --- classes/stock/StockAvailable.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/classes/stock/StockAvailable.php b/classes/stock/StockAvailable.php index bc97c0d91..fbdaa1a2f 100644 --- a/classes/stock/StockAvailable.php +++ b/classes/stock/StockAvailable.php @@ -367,9 +367,11 @@ class StockAvailableCore extends ObjectModel */ public function add($autodate = true, $null_values = false) { - if (!parent::add($autodate, $null_values)) + if (!$result = parent::add($autodate, $null_values)) return false; - $this->postSave(); + + $result &= $this->postSave(); + return $result; } /** @@ -378,9 +380,11 @@ class StockAvailableCore extends ObjectModel */ public function update($null_values = false) { - if (!parent::update($null_values)) + if (!$result = parent::update($null_values)) return false; - return $this->postSave(); + + $result &= $this->postSave(); + return $result; } /** From dfba5630d2e46cfea2c36c76878d4562e390022b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 11 Mar 2013 11:51:32 +0100 Subject: [PATCH 06/60] // remove useless content on 404.php deprecated file --- 404.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/404.php b/404.php index d90d7df7a..9fd4270f4 100644 --- a/404.php +++ b/404.php @@ -24,18 +24,6 @@ * International Registered Trademark & Property of PrestaShop SA */ -/* Send the proper status code in HTTP headers */ -header('HTTP/1.1 404 Not Found'); -header('Status: 404 Not Found'); - -if (in_array(substr($_SERVER['REQUEST_URI'], -3), array('png', 'jpg', 'gif'))) -{ - require_once(dirname(__FILE__).'/config/settings.inc.php'); - header('Location: '.__PS_BASE_URI__.'img/404.gif'); - exit; -} -elseif (in_array(substr($_SERVER['REQUEST_URI'], -3), array('.js', 'css'))) - die(''); - require_once(dirname(__FILE__).'/config/config.inc.php'); +Tools::displayFileAsDeprecated(); Controller::getController('PageNotFoundController')->run(); From fdeba0497de7da785cc1aab8cfe66aec521d64bb Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 11 Mar 2013 11:38:24 +0100 Subject: [PATCH 07/60] // Small fix (module installation and pscleaner) --- controllers/admin/AdminModulesController.php | 3 ++- modules/pscleaner/pscleaner.php | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 0a1dae094..f28874948 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -599,7 +599,7 @@ class AdminModulesControllerCore extends AdminController } // If Addons module, download and unzip it before installing it - if (!is_dir('../modules/'.$name.'/')) + if (!file_exists('../modules/'.$name.'/'.$name.'.php')) { $filesList = array( array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0), @@ -623,6 +623,7 @@ class AdminModulesControllerCore extends AdminController } } } + // Check potential error if (!($module = Module::getInstanceByName(urldecode($name)))) $this->errors[] = $this->l('Module not found'); diff --git a/modules/pscleaner/pscleaner.php b/modules/pscleaner/pscleaner.php index 22eecf236..549ce1b4a 100644 --- a/modules/pscleaner/pscleaner.php +++ b/modules/pscleaner/pscleaner.php @@ -244,13 +244,14 @@ class PSCleaner extends Module $queries = self::bulle($queries); foreach ($queries as $query_array) { - if(!isset($query_array[4]) || (isset($query_array[4]) && Module::isInstalled($query_array[4]))) - { - $query = 'DELETE FROM `'._DB_PREFIX_.$query_array[0].'` WHERE `'.$query_array[1].'` NOT IN (SELECT `'.$query_array[3].'` FROM `'._DB_PREFIX_.$query_array[2].'`)'; - $db->Execute($query); - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; - } + // If this is a module and the module is not installed, we continue + if (isset($query_array[4]) && !Module::isInstalled($query_array[4])) + continue; + + $query = 'DELETE FROM `'._DB_PREFIX_.$query_array[0].'` WHERE `'.$query_array[1].'` NOT IN (SELECT `'.$query_array[3].'` FROM `'._DB_PREFIX_.$query_array[2].'`)'; + $db->Execute($query); + if ($affected_rows = $db->Affected_Rows()) + $logs[$query] = $affected_rows; } // _lang table cleaning From e9e74a171d9e97d0cb052363746a84e1e0693e2c Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 11 Mar 2013 12:31:28 +0100 Subject: [PATCH 08/60] // Improved pscleaner --- modules/pscleaner/pscleaner.php | 56 ++++++++++++++++++++++----- modules/pscleaner/translations/fr.php | 14 +++++-- 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/modules/pscleaner/pscleaner.php b/modules/pscleaner/pscleaner.php index 549ce1b4a..353f82f4f 100644 --- a/modules/pscleaner/pscleaner.php +++ b/modules/pscleaner/pscleaner.php @@ -53,31 +53,67 @@ class PSCleaner extends Module if (Tools::isSubmit('submitTruncateCatalog')) { self::truncate('catalog'); - $html .= $this->l('Catalog truncated').'

'; + $html .= '
'.$this->l('Catalog truncated').'
'; } if (Tools::isSubmit('submitTruncateSales')) { self::truncate('sales'); - $html .= $this->l('Orders and customers truncated').'

'; + $html .= '
'.$this->l('Orders and customers truncated').'
'; } $html .= ' -
-
'.$this->l('Functional integrity constraints').' - + + +
'.$this->l('Catalog').' +

+ +

+ +
+ +

+
+
'.$this->l('Orders and customers').' +

+ +

+


-
'.$this->l('Data').' - -

- +
'.$this->l('Functional integrity constraints').' +
'; return $html; } - + public static function checkAndFix() { $db = Db::getInstance(); diff --git a/modules/pscleaner/translations/fr.php b/modules/pscleaner/translations/fr.php index f66fd335a..9ab5efbb6 100644 --- a/modules/pscleaner/translations/fr.php +++ b/modules/pscleaner/translations/fr.php @@ -8,8 +8,16 @@ $_MODULE['<{pscleaner}prestashop>pscleaner_752369f18aebeed9ae8384d8f1b5dc5e'] = $_MODULE['<{pscleaner}prestashop>pscleaner_098c3581a731f08d24311bbf515adbbb'] = 'Rien qui ne nécessite d\'être nettoyer'; $_MODULE['<{pscleaner}prestashop>pscleaner_1bb7c5eb8682aeada82c407b40ec09c8'] = 'Catalogue supprimé'; $_MODULE['<{pscleaner}prestashop>pscleaner_ed6ecb7169d5476ef5251524bb17552a'] = 'Commandes et clients supprimés'; +$_MODULE['<{pscleaner}prestashop>pscleaner_dd9941a63f2ab06ce2ce783336c6a811'] = 'Merci de cocher la case ci-dessus'; +$_MODULE['<{pscleaner}prestashop>pscleaner_6c69628e1d57fa6e39162b039a82133b'] = 'Souhaitez-vous supprimer le catalogue produit ?'; +$_MODULE['<{pscleaner}prestashop>pscleaner_6a68264705f23c8e3d505fd2c93a87ba'] = 'Souhaitez-vous supprimer commandes et clients ?'; +$_MODULE['<{pscleaner}prestashop>pscleaner_c32516babc5b6c47eb8ce1bfc223253c'] = 'Catalogue'; +$_MODULE['<{pscleaner}prestashop>pscleaner_eb75fcd36740a94a399e925f7da722d3'] = 'Je comprends que tout le catalogue sera supprimé sans possibilité de retour en arrière :'; +$_MODULE['<{pscleaner}prestashop>pscleaner_b7b592ffce03366a32dc8edd5fdf06cf'] = 'produits, caractéristiques, catégories, tags, images, prix, fichiers joints, scènes, stocks, groupes et valeurs d\'attributs, marques, fournisseurs...'; +$_MODULE['<{pscleaner}prestashop>pscleaner_b2d7c99e984831bd36221baf34e9c26e'] = 'Supprimer le catalogue'; +$_MODULE['<{pscleaner}prestashop>pscleaner_3300d0bf086fa38cf593fe4feff351f1'] = 'Commandes et clients'; +$_MODULE['<{pscleaner}prestashop>pscleaner_1bc469bb2c64bc19a27796374da3a2a8'] = 'Je comprends que tous les clients et commandes seront supprimés sans possibilité de retour en arrière :'; +$_MODULE['<{pscleaner}prestashop>pscleaner_a9c01b717760cf9e17bccd8c5eb647e0'] = 'clients, paniers, commandes, connexions, visiteurs, stats...'; +$_MODULE['<{pscleaner}prestashop>pscleaner_17ca7f22baf84821b6b73462c96fb1e3'] = 'Supprimer les commandes et clients'; $_MODULE['<{pscleaner}prestashop>pscleaner_3535aa31bd9005bde626ad4312b67d6b'] = 'Contraintes d\'intégrité fonctionnelle'; $_MODULE['<{pscleaner}prestashop>pscleaner_e84c6595e849214a70b35ed8f95d7d16'] = 'Vérifier et réparer'; -$_MODULE['<{pscleaner}prestashop>pscleaner_f6068daa29dbb05a7ead1e3b5a48bbee'] = 'Données'; -$_MODULE['<{pscleaner}prestashop>pscleaner_b2d7c99e984831bd36221baf34e9c26e'] = 'Supprimer le catalogue'; -$_MODULE['<{pscleaner}prestashop>pscleaner_17ca7f22baf84821b6b73462c96fb1e3'] = 'Supprimer les commandes et clients'; From 6bd6f283a579daf920cc275276dd2b43e07b65a9 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 11 Mar 2013 12:35:23 +0100 Subject: [PATCH 09/60] [-] FO : Fix bug #PSCFV-7946 delete customized product with several custos --- modules/blockcart/ajax-cart.js | 21 ++++++++-------- themes/default/css/product.css | 5 +++- themes/default/js/cart-summary.js | 40 ++++++++++++++----------------- themes/default/js/order-opc.js | 24 +++++++++---------- 4 files changed, 44 insertions(+), 46 deletions(-) diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index a15000549..307bc301c 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -52,11 +52,8 @@ var ajaxCart = { var customizationId = 0; var productId = 0; var productAttributeId = 0; - if ($($(this).parent().parent()).attr('name') == 'customization') - // Reverse two levels: a >> div >> li - var customizableProductDiv = $($(this).parent().parent()).find("div[id^=deleteCustomizableProduct_]"); - else - var customizableProductDiv = $($(this).parent()).find("div[id^=deleteCustomizableProduct_]"); + var customizableProductDiv = $($(this).parent().parent()).find("div[id^=deleteCustomizableProduct_]"); + if (customizableProductDiv && $(customizableProductDiv).length) { $(customizableProductDiv).each(function(){ @@ -185,7 +182,7 @@ var ajaxCart = { return ; } emptyCustomizations(); - //disabled the button when adding to do not double add if user double click + //disabled the button when adding to not double add if user double click if (addedFromProductPage) { $('#add_to_cart input').attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled'); @@ -466,9 +463,10 @@ var ajaxCart = { //else update the product's line else { - var jsonProduct = this; - if($('#cart_block_product_' + domIdProduct + ' .quantity').text() != jsonProduct.quantity || $('dt#cart_block_product_' + domIdProduct + ' .price').text() != jsonProduct.priceByLine) + var jsonProduct = this; + if($.trim($('#cart_block_product_' + domIdProduct + ' .quantity').text()) != jsonProduct.quantity || $.trim($('dt#cart_block_product_' + domIdProduct + ' .price').text()) != jsonProduct.priceByLine) { + // Usual product if (!this.is_gift) $('#cart_block_product_' + domIdProduct + ' .price').text(jsonProduct.priceByLine); @@ -521,11 +519,12 @@ var ajaxCart = { content += '
    '; } - $(product.customizedDatas).each(function(){ + $(product.customizedDatas).each(function() + { var done = 0; customizationId = parseInt(this.customizationId); productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination); - content += '
  • ' + parseInt(this.quantity) + 'x'; + content += '
  • ' + parseInt(this.quantity) + 'x'; // Give to the customized product the first textfield value as name $(this.datas).each(function(){ @@ -595,7 +594,7 @@ var ajaxCart = { //update general cart informations everywhere in the page updateCartEverywhere : function(jsonData) { - $('.ajax_cart_total').text(jsonData.productTotal); + $('.ajax_cart_total').text($.trim(jsonData.productTotal)); if (parseFloat(jsonData.shippingCostFloat) > 0 || jsonData.nbTotalProducts < 1) $('.ajax_cart_shipping_cost').text(jsonData.shippingCost); diff --git a/themes/default/css/product.css b/themes/default/css/product.css index b02f2f6ea..ba0945bbb 100644 --- a/themes/default/css/product.css +++ b/themes/default/css/product.css @@ -490,7 +490,10 @@ ul#uploadable_files,ul#text_fields { .customizationUploadLine { padding-bottom:10px; } - +.customizationUploadBrowse img + a { + position: relative; + top: -51px; +} .customizationUploadLine label { display:inline-block; width:150px; diff --git a/themes/default/js/cart-summary.js b/themes/default/js/cart-summary.js index 3fb110b21..27861fa06 100644 --- a/themes/default/js/cart-summary.js +++ b/themes/default/js/cart-summary.js @@ -282,7 +282,8 @@ function deleteProductFromSummary(id) +'&ajax=true&delete=true&summary=true' +'&id_product='+productId +'&ipa='+productAttributeId - +'&id_address_delivery='+id_address_delivery+ ( (customizationId !== 0) ? '&id_customization='+customizationId : '') + +'&id_address_delivery='+id_address_delivery + + ((customizationId !== 0) ? '&id_customization=' + customizationId : '') +'&token=' + static_token +'&allow_refresh=1', success: function(jsonData) @@ -334,17 +335,18 @@ function deleteProductFromSummary(id) exist = true; // if all customization removed => delete product line - if (!exist && customizationId) + if (!exist && customizationId && parseInt($('#cart_quantity_custom_' + productId + (productAttributeId > 0 ? '_' + productAttributeId : '') + '_0_' + id_address_delivery).html()) == 1) $('#product_' + productId + '_' + productAttributeId + '_0_' + id_address_delivery).fadeOut('slow', function() { $(this).remove(); refreshOddRow(); }); } + updateCartSummary(jsonData.summary); updateCustomizedDatas(jsonData.customizedDatas); updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); - if (typeof(getCarrierListAndUpdate) !== 'undefined') + if (typeof(getCarrierListAndUpdate) !== 'undefined' && jsonData.summary.products.length > 0) getCarrierListAndUpdate(); } }, @@ -589,42 +591,36 @@ function updateCartSummary(json) if (reduction && typeof(initial_price) !== 'undefined') { if (initial_price !== '' && product_list[i].price_without_quantity_discount > product_list[i].price) - initial_price_text = ''+initial_price+'
    '; + initial_price_text = '' + initial_price + '
    '; } - key_for_blockcart = product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery; + key_for_blockcart = product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_' + product_list[i].id_address_delivery; - $('#cart_block_product_'+key_for_blockcart+' span.quantity').html(product_list[i].quantity); + $('#cart_block_product_'+ key_for_blockcart + ' span.quantity').html(product_list[i].quantity); if (priceDisplayMethod !== 0) { - $('#cart_block_product_'+key_for_blockcart+' span.price').html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank)); - $('#product_price_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery).html(initial_price_text+current_price); - $('#total_product_price_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery).html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank)); + $('#cart_block_product_' + key_for_blockcart + ' span.price').html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank)); + $('#product_price_' + key_for_blockcart).html(initial_price_text+current_price); + $('#total_product_price_' + key_for_blockcart).html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank)); } else { - $('#cart_block_product_'+key_for_blockcart+' span.price').html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank)); - $('#product_price_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery).html(initial_price_text+current_price); - $('#total_product_price_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery).html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank)); + $('#cart_block_product_' + key_for_blockcart + ' span.price').html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank)); + $('#product_price_' + key_for_blockcart).html(initial_price_text+current_price); + $('#total_product_price_' + key_for_blockcart).html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank)); } nbrProducts += parseInt(product_list[i].quantity); - $('input[name=quantity_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_0_'+product_list[i].id_address_delivery+']').val(product_list[i].quantity_without_customization); - $('input[name=quantity_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_0_'+product_list[i].id_address_delivery+'_hidden]').val(product_list[i].quantity_without_customization); + $('input[name=quantity_' + product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_0_' + product_list[i].id_address_delivery + ']').val(product_list[i].quantity_without_customization); + $('input[name=quantity_' + product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_0_' + product_list[i].id_address_delivery + '_hidden]').val(product_list[i].quantity_without_customization); if (typeof(product_list[i].customizationQuantityTotal) !== 'undefined') { - $('#cart_quantity_custom_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_address_delivery) + $('#cart_quantity_custom_' + key_for_blockcart) .html(product_list[i].customizationQuantityTotal); - $('input[name=quantity_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+product_list[i].id_customization+'_'+product_list[i].id_address_delivery+']') - .val(product_list[i].customizationQuantityTotal); + $('input[name=quantity_' + product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_' + product_list[i].id_customization + '_' + product_list[i].id_address_delivery + ']').val(product_list[i].customizationQuantityTotal); } - // Show / hide quantity button if minimal quantity - if (parseInt(product_list[i].minimal_quantity) === parseInt(product_list[i].quantity) && product_list[i].minimal_quantity !== 1) - $('#cart_quantity_down_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+Number(product_list[i].id_customization)+'_'+product_list[i].id_address_delivery).fadeTo('slow',0.3); - else - $('#cart_quantity_down_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_'+Number(product_list[i].id_customization)+'_'+product_list[i].id_address_delivery).fadeTo('slow',1); } // Update discounts diff --git a/themes/default/js/order-opc.js b/themes/default/js/order-opc.js index 1a9604b67..b8a78d3ee 100644 --- a/themes/default/js/order-opc.js +++ b/themes/default/js/order-opc.js @@ -174,19 +174,19 @@ function getCarrierListAndUpdate() data: 'ajax=true&method=getCarrierList&token=' + static_token, success: function(jsonData) { - if (jsonData.hasError) - { - var errors = ''; - for(var error in jsonData.errors) - //IE6 bug fix - if(error !== 'indexOf') - errors += jsonData.errors[error] + "\n"; - alert(errors); - } - else - updateCarrierList(jsonData); - $('#opc_delivery_methods-overlay').fadeOut('slow'); + if (jsonData.hasError) + { + var errors = ''; + for(var error in jsonData.errors) + //IE6 bug fix + if(error !== 'indexOf') + errors += jsonData.errors[error] + "\n"; + alert(errors); } + else + updateCarrierList(jsonData); + $('#opc_delivery_methods-overlay').fadeOut('slow'); + } }); } From 7bd2bb9cb6f104e4b6068b13b203ac003a411438 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 11 Mar 2013 14:05:27 +0100 Subject: [PATCH 10/60] // This reverts commit 9ebe9e189456a93047c0e95c2a7e1a4219563c0e. "Changed modules list button" --- admin-dev/themes/default/css/admin.css | 38 ++++---- admin-dev/themes/default/template/toolbar.tpl | 91 +++++++++---------- classes/controller/AdminController.php | 11 +++ controllers/admin/AdminEmailsController.php | 1 + controllers/admin/AdminStatsTabController.php | 1 + 5 files changed, 73 insertions(+), 69 deletions(-) diff --git a/admin-dev/themes/default/css/admin.css b/admin-dev/themes/default/css/admin.css index b057f2c6e..349f6e998 100644 --- a/admin-dev/themes/default/css/admin.css +++ b/admin-dev/themes/default/css/admin.css @@ -199,7 +199,7 @@ a.module_toggle_all{color: #268CCD;} /*toolbarBox*/ .toolbar-placeholder {position:relative} -.toolbarBox {background-color: #F8F8F8; border: 1px solid #CCCCCC; margin-bottom:10px; padding: 5px 0; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;-o-border-radius:3px;position:relative;width: auto !important;} +.toolbarBox {background-color: #F8F8F8; border: 1px solid #CCCCCC; margin-bottom:10px; padding: 5px 0; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px;-o-border-radius:3px;position:relative} .toolbarBox .pageTitle { margin-left:10px; line-height:48px} .toolbarBox .pageTitle h3 {font-size: 1.6em; font-weight: normal; line-height: 52px; margin: 0; padding: 0; text-shadow:0 1px 0 #fff;} .toolbarBox ul.cc_button {float:right;margin:0 5px 0 0;padding:0;} @@ -243,7 +243,7 @@ a.module_toggle_all{color: #268CCD;} .toolbarReduced {margin-right:221px} #modules_list_button {width:211px;height:63px;border:none;position:absolute;top:0;right:0;background-image:url('../img/modules_list_button.png');font-size: 1.6em;cursor:pointer;padding-left:45px} -#modules_list_container { +.toolbarBox #modules_list_container { background: none repeat scroll 0 0 #FFF; border: solid 1px #CCC; display: block; @@ -252,7 +252,7 @@ a.module_toggle_all{color: #268CCD;} width: 300px; position: absolute; right: 13px; - top: 83px; + top: 63px; z-index: 100; padding: 10px; box-shadow: 1px 5px 5px #CCCCCC; @@ -261,29 +261,29 @@ a.module_toggle_all{color: #268CCD;} opacity: 1; } -#modules_list_container #modules_list_container_content +.toolbarBox #modules_list_container #modules_list_container_content { max-height: 500px; overflow: auto; } -#modules_list_container #modules_list_container_tab {margin-top: 10px;width: auto;height: auto; } -#modules_list_container #modules_list_container_tab table {width: 100%;border-spacing: 0px; } -#modules_list_container #modules_list_container_tab tr { height: auto} -#modules_list_container #modules_list_container_tab tr.rowalt {background-color: #EEE} -#modules_list_container #modules_list_container_tab #tab_module_switch {margin-bottom: 10px;} -#modules_list_container #modules_list_loader {margin-top: 10px} -#modules_list_container .nav-tabs-modules:after {clear:both} -#modules_list_container .nav-tabs-modules > li {height: 19px;float:left} -#modules_list_container .nav-tabs-modules > li > a { +.toolbarBox #modules_list_container #modules_list_container_tab {margin-top: 10px;width: auto;height: auto; } +.toolbarBox #modules_list_container #modules_list_container_tab table {width: 100%;border-spacing: 0px; } +.toolbarBox #modules_list_container #modules_list_container_tab tr { height: auto} +.toolbarBox #modules_list_container #modules_list_container_tab tr.rowalt {background-color: #EEE} +.toolbarBox #modules_list_container #modules_list_container_tab #tab_module_switch {margin-bottom: 10px;} +.toolbarBox #modules_list_container #modules_list_loader {margin-top: 10px} +.toolbarBox #modules_list_container .nav-tabs-modules:after {clear: both;} +.toolbarBox #modules_list_container .nav-tabs-modules > li {height: 19px;} +.toolbarBox #modules_list_container .nav-tabs-modules > li > a { padding-right: 12px; padding-left: 12px; margin-right: 2px; line-height: 14px; } -#modules_list_container .nav-tabs-modules > li > a { +.toolbarBox #modules_list_container .nav-tabs-modules > li > a { padding-top: 8px; padding-bottom: 7px; border: 1px solid transparent; @@ -293,15 +293,15 @@ a.module_toggle_all{color: #268CCD;} border-radius: 4px 4px 0 0; } -#modules_list_container .nav-tabs-modules > li > a:hover { +.toolbarBox #modules_list_container .nav-tabs-modules > li > a:hover { border-color: #C0C0C0; background-color: #ffffff; } -#modules_list_container .nav-tabs-modules > li > a {border: 1px solid #ddd;border-bottom:none;} +.toolbarBox #modules_list_container .nav-tabs-modules > li > a {border: 1px solid #ddd;border-bottom:none;} -#modules_list_container .nav-tabs-modules > .active > a, -#modules_list_container .nav-tabs-modules > .active > a:hover { +.toolbarBox #modules_list_container .nav-tabs-modules > .active > a, +.toolbarBox #modules_list_container .nav-tabs-modules > .active > a:hover { color: #555555; cursor: default; background-color: #EEE; @@ -312,7 +312,7 @@ a.module_toggle_all{color: #268CCD;} -div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0.9;z-index:500;width:90% !important;margin:auto} +div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0.9;z-index:500;margin:auto} /*button upload files*/ #content .qq-upload-button { diff --git a/admin-dev/themes/default/template/toolbar.tpl b/admin-dev/themes/default/template/toolbar.tpl index 07b6ac9d2..d833fd276 100644 --- a/admin-dev/themes/default/template/toolbar.tpl +++ b/admin-dev/themes/default/template/toolbar.tpl @@ -24,7 +24,7 @@ *}
    -
    +
    {block name=toolbarBox}
      {foreach from=$toolbar_btn item=btn key=k} @@ -33,6 +33,15 @@
      {$btn.desc}
      + {if $k == 'modules-list'} + + {/if} {/foreach}
    @@ -108,51 +117,13 @@ } {/block} } - }); - //]]> - - {/block} -
    -

    {block name=pageTitle} - - {if $title} - {foreach $title as $key => $item name=title} - {* Use strip_tags because if the string already has been through htmlentities using escape will break it *} - {$item|strip_tags} - {if !$smarty.foreach.title.last} - > - {/if} - - {/foreach} - {else} -   + {if isset($tab_modules_open)} + if ({$tab_modules_open}) + openModulesList(); {/if} - - {/block} -

    -
    -
    - {if isset($tab_modules_list)} - -
     
    - - - {/if} -
    \ No newline at end of file + {/if} + //]]> + + {/block} +
    +

    {block name=pageTitle} + + {if $title} + {foreach $title as $key => $item name=title} + {* Use strip_tags because if the string already has been through htmlentities using escape will break it *} + {$item|strip_tags} + {if !$smarty.foreach.title.last} + > + {/if} + + {/foreach} + {else} +   + {/if} + + {/block} +

    +
    +
    + diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 4cf15f4e7..8832def8c 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1069,6 +1069,7 @@ class AdminControllerCore extends Controller 'desc' => $this->l('Export') ); } + $this->addToolBarModulesListButton(); } /** @@ -1466,6 +1467,7 @@ class AdminControllerCore extends Controller $this->filter_modules_list = $this->tab_modules_list['default_list']; elseif (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) { + $this->addToolBarModulesListButton(); $this->context->smarty->assign(array( 'tab_modules_list' => implode(',', $this->tab_modules_list['slider_list']), 'admin_module_ajax_url' => $this->context->link->getAdminLink('AdminModules'), @@ -1474,6 +1476,15 @@ class AdminControllerCore extends Controller )); } } + + protected function addToolBarModulesListButton() + { + if (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) + $this->toolbar_btn['modules-list'] = array( + 'href' => '#', + 'desc' => $this->l('Modules List') + ); + } /** * initialize the invalid doom page of death diff --git a/controllers/admin/AdminEmailsController.php b/controllers/admin/AdminEmailsController.php index 2fca6ae50..a29d7888f 100644 --- a/controllers/admin/AdminEmailsController.php +++ b/controllers/admin/AdminEmailsController.php @@ -173,6 +173,7 @@ class AdminEmailsControllerCore extends AdminController { $this->initTabModuleList(); $this->initToolbar(); + $this->addToolBarModulesListButton(); unset($this->toolbar_btn['save']); $back = $this->context->link->getAdminLink('AdminHome'); diff --git a/controllers/admin/AdminStatsTabController.php b/controllers/admin/AdminStatsTabController.php index 06fb26911..260573c10 100644 --- a/controllers/admin/AdminStatsTabController.php +++ b/controllers/admin/AdminStatsTabController.php @@ -37,6 +37,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor public function initContent() { $this->initTabModuleList(); + $this->addToolBarModulesListButton(); $this->toolbar_title = $this->l('Stats', 'AdminStatsTab'); if ($this->display == 'view') { From 9be5d8ac6428a29cedd79264407253a48849585a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 11 Mar 2013 14:15:22 +0100 Subject: [PATCH 11/60] // uncomment trigger_error on Tools::throwDeprecated --- classes/Tools.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 52a253171..151c62adb 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1799,20 +1799,14 @@ exit; */ public static function displayAsDeprecated($message = null) { - if (_PS_DISPLAY_COMPATIBILITY_WARNING_) - { $backtrace = debug_backtrace(); $callee = next($backtrace); - if ($message) - trigger_error($message, E_USER_WARNING); - else - { - trigger_error('Function '.$callee['function'].'() is deprecated in '.$callee['file'].' on line '.$callee['line'].'
    ', E_USER_WARNING); - $message = 'The function '.$callee['function'].' (Line '.$callee['line'].') is deprecated and will be removed in the next major version.'; - } $class = isset($callee['class']) ? $callee['class'] : null; - Logger::addLog($message, 3, $class); - } + if ($message === null) + $message = 'The function '.$callee['function'].' (Line '.$callee['line'].') is deprecated and will be removed in the next major version.'; + $error = 'Function '.$callee['function'].'() is deprecated in '.$callee['file'].' on line '.$callee['line'].'
    '; + + Tools::throwDeprecated($error, $message, $class); } /** @@ -1824,9 +1818,8 @@ exit; $callee = next($backtrace); $error = 'Parameter '.$parameter.' in function '.$callee['function'].'() is deprecated in '.$callee['file'].' on line '.$callee['Line'].'
    '; $message = 'The parameter '.$parameter.' in function '.$callee['function'].' (Line '.$callee['Line'].') is deprecated and will be removed in the next major version.'; - - trigger_error($message, E_WARNING); $class = isset($callee['class']) ? $callee['class'] : null; + Tools::throwDeprecated($error, $message, $class); } @@ -1836,8 +1829,8 @@ exit; $callee = current($backtrace); $error = 'File '.$callee['file'].' is deprecated
    '; $message = 'The file '.$callee['file'].' is deprecated and will be removed in the next major version.'; - $class = isset($callee['class']) ? $callee['class'] : null; + Tools::throwDeprecated($error, $message, $class); } @@ -1845,7 +1838,7 @@ exit; { if (_PS_DISPLAY_COMPATIBILITY_WARNING_) { -// trigger_error($error, E_USER_WARNING); + trigger_error($error, E_USER_WARNING); Logger::addLog($message, 3, $class); } } From eb48c91eacc4ee8c5a84e99f173051b5afe49bd6 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 11 Mar 2013 14:43:37 +0100 Subject: [PATCH 12/60] [-] FO : remove "Invalid address warning" when not "same" an no invoice address --- controllers/front/OrderController.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/controllers/front/OrderController.php b/controllers/front/OrderController.php index 49927ce98..fba49388c 100644 --- a/controllers/front/OrderController.php +++ b/controllers/front/OrderController.php @@ -249,15 +249,19 @@ class OrderControllerCore extends ParentOrderController { if (!Tools::getValue('multi-shipping')) $this->context->cart->setNoMultishipping(); - + + $same = Tools::isSubmit('same'); + if(!Tools::getValue('id_address_invoice', false) && !$same) + $same = true; + if (!Customer::customerHasAddress($this->context->customer->id, (int)Tools::getValue('id_address_delivery')) - || (!Tools::isSubmit('same') && Tools::getValue('id_address_delivery') != Tools::getValue('id_address_invoice') + || (!$same && Tools::getValue('id_address_delivery') != Tools::getValue('id_address_invoice') && !Customer::customerHasAddress($this->context->customer->id, (int)Tools::getValue('id_address_invoice')))) $this->errors[] = Tools::displayError('Invalid address', !Tools::getValue('ajax')); else { $this->context->cart->id_address_delivery = (int)Tools::getValue('id_address_delivery'); - $this->context->cart->id_address_invoice = Tools::isSubmit('same') ? $this->context->cart->id_address_delivery : (int)Tools::getValue('id_address_invoice'); + $this->context->cart->id_address_invoice = $same ? $this->context->cart->id_address_delivery : (int)Tools::getValue('id_address_invoice'); CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); From 418995b96d0682fb6f09106ca8cd9c3a74a56a05 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 11 Mar 2013 15:00:42 +0100 Subject: [PATCH 13/60] [-] FO : minimum purchase total with wurrency --- controllers/front/OrderOpcController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index e0ca928ca..5c0b16fc8 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -455,7 +455,7 @@ class OrderOpcControllerCore extends ParentOrderController $minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase) return '

    '.sprintf( - Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'), + Tools::displayError('A minimum purchase total of %s is required in order to validate your order.'), Tools::displayPrice($minimalPurchase, $currency) ).'

    '; From 68c9da5f2522118cd2637516553efd3dfb322795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 11 Mar 2013 15:03:38 +0100 Subject: [PATCH 14/60] [-] Installer: download the language pack even if this is a native language on installation --- classes/LocalizationPack.php | 69 ++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/classes/LocalizationPack.php b/classes/LocalizationPack.php index 8c0bccfa1..cb96729de 100644 --- a/classes/LocalizationPack.php +++ b/classes/LocalizationPack.php @@ -292,53 +292,46 @@ class LocalizationPackCore foreach ($xml->languages->language as $data) { $attributes = $data->attributes(); - if (Language::getIdByIso($attributes['iso_code'])) - continue; - $native_lang = Language::getLanguages(); - $native_iso_code = array(); - foreach ($native_lang as $lang) - $native_iso_code[] = $lang['iso_code']; // if we are not in an installation context or if the pack is not available in the local directory - if (!$install_mode || !in_array((string)$attributes['iso_code'], $native_iso_code)) + if (Language::getIdByIso($attributes['iso_code']) && !$install_mode) + continue; + + $errno = 0; + $errstr = ''; + if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$attributes['iso_code'])) + $this->_errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.'); + elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link)) + $this->_errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.'); + elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.$attributes['iso_code'].'.gzip')) { - $errno = 0; - $errstr = ''; - if (!@fsockopen('api.prestashop.com', 80, $errno, $errstr, 5)) - $this->_errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.'); - elseif (!($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$attributes['iso_code'])))) - $this->_errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.'); - elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.$attributes['iso_code'].'.gzip')) + $file = _PS_TRANSLATIONS_DIR_.$attributes['iso_code'].'.gzip'; + if (file_put_contents($file, $content)) { - $file = _PS_TRANSLATIONS_DIR_.$attributes['iso_code'].'.gzip'; - if (file_put_contents($file, $content)) + $gz = new Archive_Tar($file, true); + $files_list = $gz->listContent(); + + if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false)) { - $gz = new Archive_Tar($file, true); - $files_list = $gz->listContent(); - - if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false)) - { - $this->_errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$attributes['iso_code']; - return false; - } - else - { - AdminTranslationsController::checkAndAddMailsFiles($attributes['iso_code'], $files_list); - AdminTranslationsController::addNewTabs($attributes['iso_code'], $files_list); - } - - if (!Language::checkAndAddLanguage((string)$attributes['iso_code'])) - { - $this->_errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$attributes['iso_code']; - return false; - } - - @unlink($file); + $this->_errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$attributes['iso_code']; + return false; } else - $this->_errors[] = Tools::displayError('Server does not have permissions for writing.'); + { + AdminTranslationsController::checkAndAddMailsFiles($attributes['iso_code'], $files_list); + AdminTranslationsController::addNewTabs($attributes['iso_code'], $files_list); + } + if (!Language::checkAndAddLanguage((string)$attributes['iso_code'])) + { + $this->_errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$attributes['iso_code']; + return false; + } + @unlink($file); } + else + $this->_errors[] = Tools::displayError('Server does not have permissions for writing.'); } } + } // change the default language if there is only one language in the localization pack if (!count($this->_errors) && $install_mode && isset($attributes['iso_code']) && count($xml->languages->language) == 1) From 8625f39c078bb52ec4adedc4b31fe00a5c4713cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 11 Mar 2013 15:06:57 +0100 Subject: [PATCH 15/60] // oops --- classes/LocalizationPack.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/LocalizationPack.php b/classes/LocalizationPack.php index cb96729de..7e862fa59 100644 --- a/classes/LocalizationPack.php +++ b/classes/LocalizationPack.php @@ -331,8 +331,6 @@ class LocalizationPackCore $this->_errors[] = Tools::displayError('Server does not have permissions for writing.'); } } - } - // change the default language if there is only one language in the localization pack if (!count($this->_errors) && $install_mode && isset($attributes['iso_code']) && count($xml->languages->language) == 1) $this->iso_code_lang = $attributes['iso_code']; From 0688061b0a64499f7d4d9238e2ad19ace0853506 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Mon, 11 Mar 2013 15:10:22 +0100 Subject: [PATCH 16/60] //replace dirname(__FILE__) by _PS_ADMIN_DIR_ to prevent cache bug with __FILE__ --- admin-dev/ajax-tab.php | 4 ++-- admin-dev/ajax.php | 2 +- admin-dev/ajax_products_list.php | 2 +- admin-dev/displayImage.php | 4 ++-- admin-dev/drawer.php | 2 +- admin-dev/get-file-admin.php | 2 +- admin-dev/grider.php | 2 +- admin-dev/index.php | 4 ++-- admin-dev/searchcron.php | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/admin-dev/ajax-tab.php b/admin-dev/ajax-tab.php index 684278d34..24c751f9d 100755 --- a/admin-dev/ajax-tab.php +++ b/admin-dev/ajax-tab.php @@ -25,8 +25,8 @@ */ define('_PS_ADMIN_DIR_', getcwd()); -require(dirname(__FILE__).'/../config/config.inc.php'); -require(dirname(__FILE__).'/functions.php'); +require(_PS_ADMIN_DIR_.'/../config/config.inc.php'); +require(_PS_ADMIN_DIR_.'/functions.php'); // For retrocompatibility with "tab" parameter if (!isset($_GET['controller']) && isset($_GET['tab'])) diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php index 5ec0197ac..8f41e44cb 100644 --- a/admin-dev/ajax.php +++ b/admin-dev/ajax.php @@ -27,7 +27,7 @@ define('_PS_ADMIN_DIR_', getcwd()); include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); /* Getting cookie or logout */ -require_once(dirname(__FILE__).'/init.php'); +require_once(_PS_ADMIN_DIR_.'/init.php'); $context = Context::getContext(); diff --git a/admin-dev/ajax_products_list.php b/admin-dev/ajax_products_list.php index 64ee54211..f14a9a8c8 100644 --- a/admin-dev/ajax_products_list.php +++ b/admin-dev/ajax_products_list.php @@ -27,7 +27,7 @@ define('_PS_ADMIN_DIR_', getcwd()); include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); /* Getting cookie or logout */ -require_once(dirname(__FILE__).'/init.php'); +require_once(_PS_ADMIN_DIR_.'/init.php'); $query = Tools::getValue('q', false); if (!$query OR $query == '' OR strlen($query) < 1) diff --git a/admin-dev/displayImage.php b/admin-dev/displayImage.php index e48f4f290..f873fdb22 100644 --- a/admin-dev/displayImage.php +++ b/admin-dev/displayImage.php @@ -25,8 +25,8 @@ */ define('_PS_ADMIN_DIR_', getcwd()); -require_once(dirname(__FILE__).'/../config/config.inc.php'); -require_once(dirname(__FILE__).'/init.php'); +require_once(_PS_ADMIN_DIR_.'/../config/config.inc.php'); +require_once(_PS_ADMIN_DIR_.'/init.php'); if (isset($_GET['img']) AND Validate::isMd5($_GET['img']) AND isset($_GET['name']) AND Validate::isGenericName($_GET['name']) AND file_exists(_PS_UPLOAD_DIR_.$_GET['img'])) { diff --git a/admin-dev/drawer.php b/admin-dev/drawer.php index d155d25c5..c52ea4547 100644 --- a/admin-dev/drawer.php +++ b/admin-dev/drawer.php @@ -25,7 +25,7 @@ */ define('_PS_ADMIN_DIR_', getcwd()); -include_once(dirname(__FILE__).'/../config/config.inc.php'); +include_once(_PS_ADMIN_DIR_.'/../config/config.inc.php'); $module = Tools::getValue('module'); $render = Tools::getValue('render'); diff --git a/admin-dev/get-file-admin.php b/admin-dev/get-file-admin.php index 1a6c855db..b37f691e5 100644 --- a/admin-dev/get-file-admin.php +++ b/admin-dev/get-file-admin.php @@ -25,5 +25,5 @@ */ define('_PS_ADMIN_DIR_', getcwd()); -require(dirname(dirname(__FILE__)).'/config/config.inc.php'); +require(_PS_ADMIN_DIR_.'/config/config.inc.php'); Controller::getController('GetFileController')->run(); \ No newline at end of file diff --git a/admin-dev/grider.php b/admin-dev/grider.php index 0ba54a8a6..6e97baf68 100644 --- a/admin-dev/grider.php +++ b/admin-dev/grider.php @@ -25,7 +25,7 @@ */ define('_PS_ADMIN_DIR_', getcwd()); -include_once(dirname(__FILE__).'/../config/config.inc.php'); +include_once(_PS_ADMIN_DIR_.'/../config/config.inc.php'); $module = Tools::getValue('module'); $render = Tools::getValue('render'); diff --git a/admin-dev/index.php b/admin-dev/index.php index 6da63272e..f5fcc246d 100644 --- a/admin-dev/index.php +++ b/admin-dev/index.php @@ -27,8 +27,8 @@ $timer_start = microtime(true); define('_PS_ADMIN_DIR_', getcwd()); -require(dirname(__FILE__).'/../config/config.inc.php'); -require(dirname(__FILE__).'/functions.php'); +require(_PS_ADMIN_DIR_.'/../config/config.inc.php'); +require(_PS_ADMIN_DIR_.'/functions.php'); //small test to clear cache after upgrade if (Configuration::get('PS_UPGRADE_CLEAR_CACHE')) diff --git a/admin-dev/searchcron.php b/admin-dev/searchcron.php index d3f75c9b4..c6a772464 100644 --- a/admin-dev/searchcron.php +++ b/admin-dev/searchcron.php @@ -25,7 +25,7 @@ */ define('_PS_ADMIN_DIR_', getcwd()); -include(dirname(__FILE__).'/../config/config.inc.php'); +include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); Context::getContext()->shop->setContext(Shop::CONTEXT_ALL); if (substr(_COOKIE_KEY_, 34, 8) != Tools::getValue('token')) From 78ebf6636ca6b27d018c751a33ac36dd2c656ad1 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Mon, 11 Mar 2013 16:29:33 +0100 Subject: [PATCH 17/60] [-] FO : fixed bug #PSCFV-5744 - Using attribute values with decimal points numbers and its ten multiple, have the same url --- controllers/front/ProductController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 4f43d3e73..e6138d495 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -472,7 +472,7 @@ class ProductControllerCore extends FrontController $attributes_combinations = Product::getAttributesInformationsByProduct($this->product->id); foreach ($attributes_combinations as &$ac) foreach ($ac as &$val) - $val = str_replace('-', '_', Tools::link_rewrite($val)); + $val = str_replace('-', '_', Tools::link_rewrite(str_replace(array(',', '.'), '-', $val))); $this->context->smarty->assign('attributesCombinations', $attributes_combinations); } From 54ee8a21d870447461db28e9ca3151ca91b8a7d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 11 Mar 2013 17:03:17 +0100 Subject: [PATCH 18/60] // small typo fix --- controllers/admin/AdminCustomerPreferencesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminCustomerPreferencesController.php b/controllers/admin/AdminCustomerPreferencesController.php index 122141e6a..07e7393dd 100644 --- a/controllers/admin/AdminCustomerPreferencesController.php +++ b/controllers/admin/AdminCustomerPreferencesController.php @@ -74,7 +74,7 @@ class AdminCustomerPreferencesControllerCore extends AdminController ), 'PS_PASSWD_TIME_FRONT' => array( 'title' => $this->l('Regenerate password'), - 'desc' => $this->l('Minimum time requirted to to regenerate a password.'), + 'desc' => $this->l('Minimum time required to regenerate a password.'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'size' => 5, From d73fcdf41244dfeb77a58ad6b4f2d0ea38d0ef1c Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 11 Mar 2013 17:39:13 +0100 Subject: [PATCH 19/60] [-] BO : Fix bug #PSCFV-7468 required phone in address creation --- admin-dev/themes/default/template/helpers/form/form.tpl | 4 ++-- controllers/admin/AdminAddressesController.php | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/admin-dev/themes/default/template/helpers/form/form.tpl b/admin-dev/themes/default/template/helpers/form/form.tpl index 02538c893..f8e6bea7d 100644 --- a/admin-dev/themes/default/template/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/helpers/form/form.tpl @@ -50,7 +50,7 @@ {else} {if $input.name == 'id_state'} -
    +
    {/if} {block name="label"} {if isset($input.label)}{/if} @@ -318,7 +318,7 @@ {if isset($input.required) && $input.required && $input.type != 'radio'} *{/if} {/block}{* end block input *} {block name="description"} - {if isset($input.desc)} + {if isset($input.desc) && !empty($input.desc)}

    {if is_array($input.desc)} {foreach $input.desc as $p} diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index bab4bdfd9..5aeaa332c 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -126,7 +126,7 @@ class AdminAddressesControllerCore extends AdminController 'name' => 'phone_mobile', 'size' => 33, 'required' => false, - 'desc' => sprintf($this->l('You must register at least one phone number %s'), '*') + 'desc' => Configuration::get('PS_ONE_PHONE_AT_LEAST')? sprintf($this->l('You must register at least one phone number %s'), '*') : '' ), array( 'type' => 'textarea', @@ -367,6 +367,9 @@ class AdminAddressesControllerCore extends AdminController $this->errors[] = Tools::displayError('Your Postal Code/Zip Code is incorrect.'); } + if (Configuration::get('PS_ONE_PHONE_AT_LEAST') && !Tools::getValue('phone') && !Tools::getValue('phone_mobile')) + $this->errors[] = Tools::displayError('You must register at least one phone number'); + /* If this address come from order's edition and is the same as the other one (invoice or delivery one) ** we delete its id_address to force the creation of a new one */ if ((int)Tools::getValue('id_order')) From f3579dd5eb39852a1f59f2146e2e30db8471bdee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Mon, 11 Mar 2013 18:51:48 +0100 Subject: [PATCH 20/60] [*] Installer: check if sessions path if writable --- classes/ConfigurationTest.php | 8 ++++++++ install-dev/controllers/http/system.php | 2 ++ 2 files changed, 10 insertions(+) diff --git a/classes/ConfigurationTest.php b/classes/ConfigurationTest.php index a6d27bad4..c7782c2bc 100644 --- a/classes/ConfigurationTest.php +++ b/classes/ConfigurationTest.php @@ -47,6 +47,7 @@ class ConfigurationTestCore 'upload' => false, 'gd' => false, 'mysql_support' => false, + 'sessions' => false, 'config_dir' => 'config', 'cache_dir' => 'cache', 'sitemap' => 'sitemap.xml', @@ -305,6 +306,13 @@ class ConfigurationTestCore return function_exists('mcrypt_encrypt'); } + public static function test_sessions() + { + if (!$path = @ini_get('session.save_path')) + return true; + + return ConfigurationTest::test_dir($path); + } public static function test_dom() { return extension_loaded('Dom'); diff --git a/install-dev/controllers/http/system.php b/install-dev/controllers/http/system.php index fbdf19a5c..84f652d64 100644 --- a/install-dev/controllers/http/system.php +++ b/install-dev/controllers/http/system.php @@ -74,6 +74,7 @@ class InstallControllerHttpSystem extends InstallControllerHttp if (!isset($this->tests['optional'])) $this->tests['optional'] = $this->model_system->checkOptionalTests(); + $session_path = @ini_get('session.save_path'); // Generate display array $this->tests_render = array( 'required' => array( @@ -86,6 +87,7 @@ class InstallControllerHttpSystem extends InstallControllerHttp 'system' => $this->l('Cannot create new files and folders'), 'gd' => $this->l('GD Library is not installed'), 'mysql_support' => $this->l('MySQL support is not activated'), + 'sessions' => $this->l('Your PHP sessions path is not writable - check with your hosting provider:').' '.$session_path, ) ), array( From a03bf13b8fc43ac4b2d1af1cfc5d951774fc2efd Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 11 Mar 2013 19:01:58 +0100 Subject: [PATCH 21/60] [-] FO : Fix bug #PSCFV-5168, required phone in all templates --- controllers/front/OrderOpcController.php | 4 +--- themes/default/address.tpl | 6 +++--- themes/default/authentication.tpl | 4 ++-- themes/default/css/authentication.css | 9 ++------- themes/default/css/global.css | 2 +- themes/default/css/order-opc.css | 6 +++--- themes/default/order-opc-new-account.tpl | 18 ++++++++++++------ 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 5c0b16fc8..d8284cae3 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -321,9 +321,7 @@ class OrderOpcControllerCore extends ParentOrderController 'errorTOS' => Tools::displayError('You must accept the Terms of Service before', false), 'isPaymentStep' => (bool)(isset($_GET['isPaymentStep']) && $_GET['isPaymentStep']), 'genders' => Gender::getGenders(), - )); - /* Call a hook to display more information on form */ - $this->context->smarty->assign(array( + 'one_phone_at_least' => (int)Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop') )); diff --git a/themes/default/address.tpl b/themes/default/address.tpl index 7c33539ef..79b1d1474 100644 --- a/themes/default/address.tpl +++ b/themes/default/address.tpl @@ -206,14 +206,14 @@ $(function(){ldelim}

    {if $one_phone_at_least} -

    {l s='You must register at least one phone number.'} *

    +

    {l s='You must register at least one phone number.'}

    {/if}

    -

    - +

    +

    diff --git a/themes/default/authentication.tpl b/themes/default/authentication.tpl index 3c846cfca..811ef0e6f 100644 --- a/themes/default/authentication.tpl +++ b/themes/default/authentication.tpl @@ -551,8 +551,8 @@ $(document).ready(function() {

    -

    - +

    +

    diff --git a/themes/default/css/authentication.css b/themes/default/css/authentication.css index 305b31f23..5649e0179 100644 --- a/themes/default/css/authentication.css +++ b/themes/default/css/authentication.css @@ -68,14 +68,9 @@ font-size: 12px; color:#666; } -#account-creation_form span.form_info { +#account-creation_form span.form_info, #account-creation_form p.inline-infos { display:block; - margin:5px 0 0 265px; - color:#666; -} -#account-creation_form p.inline-infos { - margin:0 0 0 100px !important; - font-size:12px; + margin:5px 0 0 265px!important; color:#666; } #account-creation_form .id_state, #account-creation_form .dni, #account-creation_form .postcode { diff --git a/themes/default/css/global.css b/themes/default/css/global.css index 18ee641ab..84d6bc9ca 100644 --- a/themes/default/css/global.css +++ b/themes/default/css/global.css @@ -1403,7 +1403,7 @@ a.iframe {font-weight:bold} #addresses #center_column{width:757px} #address p.inline-infos { - margin:0 0 0 100px !important; + margin:0 0 0 265px !important; font-size:12px; color:#666; } diff --git a/themes/default/css/order-opc.css b/themes/default/css/order-opc.css index b40575fd1..5209953f2 100644 --- a/themes/default/css/order-opc.css +++ b/themes/default/css/order-opc.css @@ -70,9 +70,9 @@ color:#666 } #new_account_form span.form_info, -#new_account_form span.inline-infos { +#new_account_form span.inline-infos, #new_account_form p.inline-infos { display:block; - margin:5px 0 0 265px; + margin:5px 0 0 265px!important; color:#666 } #new_account_form .id_state, #new_account_form .dni, #new_account_form .postcode { @@ -87,4 +87,4 @@ float: right; margin-right: 20px; padding: 0; -} +} \ No newline at end of file diff --git a/themes/default/order-opc-new-account.tpl b/themes/default/order-opc-new-account.tpl index 419002291..bd7a1a0e6 100644 --- a/themes/default/order-opc-new-account.tpl +++ b/themes/default/order-opc-new-account.tpl @@ -259,12 +259,15 @@

    -

    + {if $one_phone_at_least} +

    {l s='You must register at least one phone number.'}

    + {/if} +

    -

    - +

    +

    @@ -357,12 +360,15 @@

    -

    + {if $one_phone_at_least} +

    {l s='You must register at least one phone number.'}

    + {/if} +

    -

    - +

    +

    From 213b232278e154ea696e887c09bc6746b9ee2874 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Tue, 12 Mar 2013 10:16:54 +0100 Subject: [PATCH 22/60] // Moved layered rules from top to bottom in order to avoid conflicts --- classes/Dispatcher.php | 25 ++++++++++--------- .../admin/AdminPerformanceController.php | 4 +++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php index a0381064c..497ef6d03 100644 --- a/classes/Dispatcher.php +++ b/classes/Dispatcher.php @@ -45,18 +45,6 @@ class DispatcherCore * @var array List of default routes */ public $default_routes = array( - 'layered_rule' => array( - 'controller' => 'category', - 'rule' => '{id}-{rewrite}{/:selected_filters}', - 'keywords' => array( - 'id' => array('regexp' => '[0-9]+', 'param' => 'id_category'), - /* Selected filters is used by the module blocklayered */ - 'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'), - 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), - ), - ), 'category_rule' => array( 'controller' => 'category', 'rule' => '{id}-{rewrite}', @@ -136,6 +124,19 @@ class DispatcherCore 'tags' => array('regexp' => '[a-zA-Z0-9-\pL]*'), ), ), + // Must be after the product and category rules in order to avoid conflict + 'layered_rule' => array( + 'controller' => 'category', + 'rule' => '{id}-{rewrite}{/:selected_filters}', + 'keywords' => array( + 'id' => array('regexp' => '[0-9]+', 'param' => 'id_category'), + /* Selected filters is used by the module blocklayered */ + 'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'), + 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), + ), + ), ); /** diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index 6f2716319..be2ff4b25 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -649,6 +649,10 @@ class AdminPerformanceControllerCore extends AdminController $base_urls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_'); $base_urls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_'); $base_urls['_MEDIA_SERVER_3_'] = Tools::getValue('_MEDIA_SERVER_3_'); + if ($base_urls['_MEDIA_SERVER_1_'] || $base_urls['_MEDIA_SERVER_2_'] || $base_urls['_MEDIA_SERVER_3_']) + Configuration::updateValue('PS_MEDIA_SERVERS', 1); + else + Configuration::updateValue('PS_MEDIA_SERVERS', 0); rewriteSettingsFile($base_urls, null, null); Tools::generateHtaccess(null, null, null, '', null, array($base_urls['_MEDIA_SERVER_1_'], $base_urls['_MEDIA_SERVER_2_'], $base_urls['_MEDIA_SERVER_3_'])); unset($this->_fieldsGeneral['_MEDIA_SERVER_1_']); From 690d761258c1657f76adb005072284c7d6302cc7 Mon Sep 17 00:00:00 2001 From: fram Date: Tue, 12 Mar 2013 10:28:35 +0100 Subject: [PATCH 23/60] // fixed Bulgarian PDF generation --- classes/pdf/PDFGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/pdf/PDFGenerator.php b/classes/pdf/PDFGenerator.php index 7861d4de7..1458075ed 100755 --- a/classes/pdf/PDFGenerator.php +++ b/classes/pdf/PDFGenerator.php @@ -39,7 +39,7 @@ class PDFGeneratorCore extends TCPDF public $content; public $font; - public $font_by_lang = array('ja' => 'cid0jp', 'ru' => 'freeserif', 'el' => 'freeserif', 'vn' => 'dejavusans', 'pl' => 'dejavusans'); + public $font_by_lang = array('ja' => 'cid0jp', 'bg' => 'freeserif', 'ru' => 'freeserif', 'el' => 'freeserif', 'vn' => 'dejavusans', 'pl' => 'dejavusans'); public function __construct($use_cache = false) From 5441a97c283ff3bc3fdbb85798c1c121835a434f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 12 Mar 2013 10:30:44 +0100 Subject: [PATCH 24/60] // small installer fix --- classes/ConfigurationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/ConfigurationTest.php b/classes/ConfigurationTest.php index c7782c2bc..c8a070fee 100644 --- a/classes/ConfigurationTest.php +++ b/classes/ConfigurationTest.php @@ -311,7 +311,7 @@ class ConfigurationTestCore if (!$path = @ini_get('session.save_path')) return true; - return ConfigurationTest::test_dir($path); + return is_writable($path); } public static function test_dom() { From fd23b5e862f201b390558ef8817689c28072837b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 12 Mar 2013 11:03:30 +0100 Subject: [PATCH 25/60] // typo fix --- controllers/admin/AdminMetaController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminMetaController.php b/controllers/admin/AdminMetaController.php index 85cef7942..ffd5e6317 100644 --- a/controllers/admin/AdminMetaController.php +++ b/controllers/admin/AdminMetaController.php @@ -449,7 +449,7 @@ class AdminMetaControllerCore extends AdminController $rule = Tools::getValue('PS_ROUTE_'.$route_id); if (!Validate::isRoutePattern($rule)) - $this->errors[] = sprintf('The route %s is not valide', htmlspecialchars($rule)); + $this->errors[] = sprintf('The route %s is not valid', htmlspecialchars($rule)); else { if (!$rule || $rule == $default_routes[$route_id]['rule']) From a83d8d0cd873da3958e8f3e1edc69e12aafa5061 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 12 Mar 2013 12:09:47 +0100 Subject: [PATCH 26/60] [*] BO : file_put_contents returns length when success not true --- controllers/admin/AdminPerformanceController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index be2ff4b25..74ea8d846 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -705,7 +705,7 @@ class AdminPerformanceControllerCore extends AdminController // If there is not settings file modification or if the backup and replacement of the settings file worked if ($new_settings == $prev_settings || ( copy(dirname(__FILE__).'/../../config/settings.inc.php', dirname(__FILE__).'/../../config/settings.old.php') - && file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $new_settings) + && (bool)file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $new_settings) )) { Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo); @@ -774,7 +774,7 @@ class AdminPerformanceControllerCore extends AdminController // If there is not settings file modification or if the backup and replacement of the settings file worked if ($new_settings == $prev_settings || ( copy(dirname(__FILE__).'/../../config/settings.inc.php', dirname(__FILE__).'/../../config/settings.old.php') - && file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $new_settings) + && (bool)file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $new_settings) )) $redirectAdmin = true; else From 5907d4b8d7295dd1c5c814b6c54c8942bbf7a2c6 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Tue, 12 Mar 2013 12:19:22 +0100 Subject: [PATCH 27/60] // Added hook call in adminperformance --- controllers/admin/AdminPerformanceController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index 74ea8d846..8c1c4e2f5 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -548,6 +548,7 @@ class AdminPerformanceControllerCore extends AdminController return; } + Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this)); if (Tools::isSubmit('submitAddServer')) { if ($this->tabAccess['add'] === '1') @@ -742,13 +743,13 @@ class AdminPerformanceControllerCore extends AdminController if ($cache_active && $caching_system == 'CacheMemcache' && !extension_loaded('memcache')) $this->errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.').' http://www.php.net/manual/en/memcache.installation.php'; - else if ($cache_active && $caching_system == 'CacheApc' && !extension_loaded('apc')) + elseif ($cache_active && $caching_system == 'CacheApc' && !extension_loaded('apc')) $this->errors[] = Tools::displayError('To use APC cache, you must install the APC PECL extension on your server.').' http://fr.php.net/manual/fr/apc.installation.php'; - else if ($cache_active && $caching_system == 'CacheXcache' && !extension_loaded('xcache')) + elseif ($cache_active && $caching_system == 'CacheXcache' && !extension_loaded('xcache')) $this->errors[] = Tools::displayError('To use Xcache, you must install the Xcache extension on your server.').' http://xcache.lighttpd.net'; - else if ($cache_active && $caching_system == 'CacheFs' && !is_writable(_PS_CACHEFS_DIRECTORY_)) + elseif ($cache_active && $caching_system == 'CacheFs' && !is_writable(_PS_CACHEFS_DIRECTORY_)) $this->errors[] = sprintf( Tools::displayError('To use CacheFS the directory %s must be writable.'), realpath(_PS_CACHEFS_DIRECTORY_) @@ -765,7 +766,7 @@ class AdminPerformanceControllerCore extends AdminController Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth); } } - else if ($caching_system == 'CacheMemcache' && $cache_active && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'CacheMemcache') + elseif ($caching_system == 'CacheMemcache' && $cache_active && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'CacheMemcache') Cache::getInstance()->flush(); if (!count($this->errors)) @@ -785,7 +786,10 @@ class AdminPerformanceControllerCore extends AdminController $this->errors[] = Tools::displayError('You do not have permission to edit here.'); } if ($redirectAdmin && (!isset($this->errors) || !count($this->errors))) + { + Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => '')); Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); + } else return parent::postProcess(); } From 32e9c7ff4f36f78694fed828fbe9e8d4ea078b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 12 Mar 2013 12:28:40 +0100 Subject: [PATCH 28/60] // check fields before change products statuse --- controllers/admin/AdminProductsController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 58b328c70..58532b636 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1735,6 +1735,19 @@ class AdminProductsControllerCore extends AdminController return false; } + public function processStatus() + { + $this->loadObject(true); + if (!Validate::isLoadedObject($this->object)) + return false; + if (($error = $this->object->validateFields(false, true)) !== true) + $this->errors[] = $error; + if (($error = $this->object->validateFieldsLang(false, true)) !== true) + $this->errors[] = $error; + + return !count($this->errors) ? parent::processStatus() : false; + } + public function processUpdate() { $this->checkProduct(); From a0d25c399c3ce64a4b82d5becb6891ac0b3c4233 Mon Sep 17 00:00:00 2001 From: Francois Gaillard Date: Tue, 12 Mar 2013 14:16:52 +0100 Subject: [PATCH 29/60] [-] FO : Fixed mobile theme authentication CSS --- controllers/front/AuthController.php | 3 ++- themes/default/mobile/authentication-choice.tpl | 2 +- themes/default/mobile/css/global.css | 13 +------------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 244e4fe7c..cb481f084 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -56,7 +56,8 @@ class AuthControllerCore extends FrontController public function setMedia() { parent::setMedia(); - $this->addCSS(_THEME_CSS_DIR_.'authentication.css'); + if (Context::getContext()->getMobileDevice() === false) + $this->addCSS(_THEME_CSS_DIR_.'authentication.css'); $this->addJqueryPlugin('typewatch'); $this->addJS(_THEME_JS_DIR_.'tools/statesManagement.js'); } diff --git a/themes/default/mobile/authentication-choice.tpl b/themes/default/mobile/authentication-choice.tpl index da84c96de..4bbfb00bc 100644 --- a/themes/default/mobile/authentication-choice.tpl +++ b/themes/default/mobile/authentication-choice.tpl @@ -1,6 +1,6 @@
    -