From 48a8719d2f9ca22220da86ecc40a7c15cbf2a054 Mon Sep 17 00:00:00 2001 From: fSerny Date: Wed, 23 Nov 2011 00:54:51 +0000 Subject: [PATCH] [-] MO : TNT Carrier (1.2) git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10484 b9a71923-0436-4b27-9f14-aed3839534dd --- modules/tntcarrier/config.xml | 2 +- modules/tntcarrier/follow.php | 31 ++++- .../tntcarrier/relaisColis/postRelaisData.php | 33 ++++- .../tntcarrier/relaisColis/relaisColis.php | 27 ++++ modules/tntcarrier/sql-install.php | 27 +++- modules/tntcarrier/sql-uninstall.php | 28 ++++- modules/tntcarrier/tntGetDepot.php | 26 ++++ modules/tntcarrier/tntcarrier.php | 119 +++++++++++------- 8 files changed, 237 insertions(+), 56 deletions(-) diff --git a/modules/tntcarrier/config.xml b/modules/tntcarrier/config.xml index cf3ef0d9c..13d9b8dd8 100644 --- a/modules/tntcarrier/config.xml +++ b/modules/tntcarrier/config.xml @@ -2,7 +2,7 @@ tntcarrier - + diff --git a/modules/tntcarrier/follow.php b/modules/tntcarrier/follow.php index 6832ecdeb..43b4eeed0 100644 --- a/modules/tntcarrier/follow.php +++ b/modules/tntcarrier/follow.php @@ -1,4 +1,30 @@ +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 1.4 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + require('../../config/config.inc.php'); require_once(_PS_MODULE_DIR_."/tntcarrier/classes/TntWebService.php"); //$erreur = ''; @@ -20,7 +46,6 @@ catch( Exception $e ) $config['date'] = '%d/%m/%y'; $config['time'] = '%I:%M %p'; //$smarty->assign('erreur', $erreur); -$smarty->assign('config',$config); -$smarty->assign( 'follow', $follow ); +$smarty->assign('config', $config); +$smarty->assign( 'follow', $follow); $smarty->display('tpl/follow.tpl' ); -?> \ No newline at end of file diff --git a/modules/tntcarrier/relaisColis/postRelaisData.php b/modules/tntcarrier/relaisColis/postRelaisData.php index 78f677bc5..e5c9bb844 100644 --- a/modules/tntcarrier/relaisColis/postRelaisData.php +++ b/modules/tntcarrier/relaisColis/postRelaisData.php @@ -1,4 +1,30 @@ +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 1.4 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + require('../../../config/config.inc.php'); @@ -13,10 +39,9 @@ $data = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'tnt_carrier_d if (count($data) > 0) { echo "ok"; - Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'tnt_carrier_drop_off` SET `code` = "'.$code.'", `name` = "'.$name.'", - `address` = "'.$address.'", `zipcode` = "'.$zipcode.'", `city` = "'.$city.'" WHERE `id_cart` = "'.(int)($id_cart).'"'); + Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'tnt_carrier_drop_off` SET `code` = "'.pSQL($code).'", `name` = "'.pSQL($name).'", + `address` = "'.pSQL($address).'", `zipcode` = "'.pSQL($zipcode).'", `city` = "'.pSQL($city).'" WHERE `id_cart` = "'.(int)($id_cart).'"'); } else Db::getInstance()->ExecuteS('INSERT INTO `'._DB_PREFIX_.'tnt_carrier_drop_off` (`id_cart`, `code`, `name`, `address`, `zipcode`, `city`) - VALUES ("'.(int)($id_cart).'", "'.$code.'", "'.$name.'", "'.$address.'", "'.$zipcode.'", "'.$city.'")'); -?> \ No newline at end of file + VALUES ("'.(int)($id_cart).'", "'.pSQL($code).'", "'.pSQL($name).'", "'.pSQL($address).'", "'.pSQL($zipcode).'", "'.pSQL($city).'")'); diff --git a/modules/tntcarrier/relaisColis/relaisColis.php b/modules/tntcarrier/relaisColis/relaisColis.php index 0f5517ff7..523a46201 100644 --- a/modules/tntcarrier/relaisColis/relaisColis.php +++ b/modules/tntcarrier/relaisColis/relaisColis.php @@ -1,4 +1,31 @@ +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 1.4 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + require('../../../config/config.inc.php'); $relais = Db::getInstance()->getValue('SELECT c.id_carrier FROM `'._DB_PREFIX_.'carrier` as c, `'._DB_PREFIX_.'tnt_carrier_option` as o diff --git a/modules/tntcarrier/sql-install.php b/modules/tntcarrier/sql-install.php index e898f7a9d..dfed9c5ca 100644 --- a/modules/tntcarrier/sql-install.php +++ b/modules/tntcarrier/sql-install.php @@ -1,4 +1,30 @@ +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 1.4 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + // Init $sql = array(); @@ -39,4 +65,3 @@ `additionnal_charges` double(6,2) DEFAULT NULL, PRIMARY KEY (`id_weight`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;'; -?> diff --git a/modules/tntcarrier/sql-uninstall.php b/modules/tntcarrier/sql-uninstall.php index c8d0cf73b..cabde1b7c 100644 --- a/modules/tntcarrier/sql-uninstall.php +++ b/modules/tntcarrier/sql-uninstall.php @@ -1,4 +1,31 @@ +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 1.4 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + + // Init $sql = array(); @@ -8,4 +35,3 @@ $sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'tnt_carrier_shipping_number`;'; $sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'tnt_carrier_cache_service`;'; -?> diff --git a/modules/tntcarrier/tntGetDepot.php b/modules/tntcarrier/tntGetDepot.php index 48aa976cb..8987454fd 100644 --- a/modules/tntcarrier/tntGetDepot.php +++ b/modules/tntcarrier/tntGetDepot.php @@ -1,4 +1,30 @@ +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 1.4 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + include( '../../config/config.inc.php' ); function genAuth($username, $password) diff --git a/modules/tntcarrier/tntcarrier.php b/modules/tntcarrier/tntcarrier.php index f140f1184..4275da123 100644 --- a/modules/tntcarrier/tntcarrier.php +++ b/modules/tntcarrier/tntcarrier.php @@ -1,13 +1,39 @@ +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 1.4 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + // Avoid direct access to the file +if (!defined('_PS_VERSION_')) + exit; + require_once(_PS_MODULE_DIR_."/tntcarrier/classes/PackageTnt.php"); require_once(_PS_MODULE_DIR_."/tntcarrier/classes/TntWebService.php"); require_once(_PS_MODULE_DIR_."/tntcarrier/classes/OrderInfoTnt.php"); require_once(_PS_MODULE_DIR_."/tntcarrier/classes/serviceCache.php"); -if (!defined('_PS_VERSION_')) - exit; - class TntCarrier extends CarrierModule { public $id_carrier; @@ -26,7 +52,7 @@ class TntCarrier extends CarrierModule { $this->name = 'tntcarrier'; $this->tab = 'shipping_logistics'; - $this->version = '1.1'; + $this->version = '1.2'; $this->author = 'PrestaShop'; $this->limited_countries = array('fr'); @@ -242,11 +268,11 @@ class TntCarrier extends CarrierModule global $smarty; $globalVar = array( - 'tab' => Tools::getValue('tab'), - 'configure' => Tools::getValue('configure'), - 'token' => Tools::getValue('token'), - 'tab_module' => Tools::getValue('tab_module'), - 'module_name' => Tools::getValue('module_name')); + 'tab' => htmlentities(Tools::getValue('tab')), + 'configure' => htmlentities(Tools::getValue('configure')), + 'token' => htmlentities(Tools::getValue('token')), + 'tab_module' => htmlentities(Tools::getValue('tab_module')), + 'module_name' => htmlentities(Tools::getValue('module_name'))); $smarty->assign('glob', $globalVar); @@ -298,9 +324,9 @@ class TntCarrier extends CarrierModule if (isset($_GET['id_tab'])) $html .= ''; return $html; } @@ -308,8 +334,9 @@ class TntCarrier extends CarrierModule private function _displayFormAccount() { global $smarty; - $var = array('login' => Tools::getValue('tnt_carrier_login', Configuration::get('TNT_CARRIER_LOGIN')), 'password' => Tools::getValue('tnt_carrier_password', Configuration::get('TNT_CARRIER_PASSWORD')), - 'account' => Tools::getValue('tnt_carrier_number_account', Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT'))); + $var = array('login' => htmlentities(Tools::getValue('tnt_carrier_login', Configuration::get('TNT_CARRIER_LOGIN'))), + 'password' => htmlentities(Tools::getValue('tnt_carrier_password', Configuration::get('TNT_CARRIER_PASSWORD'))), + 'account' => htmlentities(Tools::getValue('tnt_carrier_number_account', Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT')))); $smarty->assign('varAccount', $var); return $this->display( __FILE__, 'tpl/accountForm.tpl' ); } @@ -349,9 +376,9 @@ class TntCarrier extends CarrierModule } $var = array('serviceList' => $serviceList, - 'action' => Tools::getValue('action'), - 'section' => Tools::getValue('section'), - 'form' => $this->_displayFormService(Tools::getValue('service'))); + 'action' => htmlentities(Tools::getValue('action')), + 'section' => htmlentities(Tools::getValue('section')), + 'form' => $this->_displayFormService(htmlentities(Tools::getValue('service')))); $smarty->assign('varService', $var); return $this->display( __FILE__, 'tpl/service.tpl' ); } @@ -361,17 +388,17 @@ class TntCarrier extends CarrierModule if (Tools::getValue('action') == 'del' && Tools::getValue($cat) != '') { $id = Tools::getValue($cat); - Db::getInstance()->ExecuteS('DELETE FROM `'._DB_PREFIX_.'tnt_carrier_'.$cat.'` WHERE `id_'.$cat.'` = '.(int)$id.''); + Db::getInstance()->ExecuteS('DELETE FROM `'._DB_PREFIX_.'tnt_carrier_'.bqSQL($cat).'` WHERE `id_'.bqSQL($cat).'` = '.(int)$id.''); } $html = ' - + add '.$this->l('Add additional charges depending on the package weight').'

'; - $List = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'tnt_carrier_'.$cat.'` ORDER BY `id_'.$cat.'`'); + $List = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'tnt_carrier_'.bqSQL($cat).'` ORDER BY `id_'.bqSQL($cat).'`'); $irow = 0; foreach ($List as $v) { @@ -381,15 +408,15 @@ class TntCarrier extends CarrierModule '; } $html .= '
'.$this->l('ID').''.$this->l('Weight Min').''.$this->l('Weight Max').''.$this->l('Additionnal charge (Euros)').'
'.((float)$v[''.$cat.'_max'] == 0 ? '∞' : $v[''.$cat.'_max']).' '.$v['additionnal_charges'].' - + edit - + delete

-
'.((Tools::getValue('action') == 'edit' || Tools::getValue('action') == 'new') && Tools::getValue('section') == $cat ? $this->_displayFormInfo($cat, Tools::getValue($cat)) : '').'
+
'.((Tools::getValue('action') == 'edit' || Tools::getValue('action') == 'new') && Tools::getValue('section') == $cat ? $this->_displayFormInfo(htmlentities($cat), htmlentities(Tools::getValue($cat))) : '').'
'; return $html; @@ -401,11 +428,11 @@ class TntCarrier extends CarrierModule $var = array( 'country' => $country, - 'overcost' => (Configuration::get('TNT_CARRIER_'.strtoupper($country).'_OVERCOST') ? Configuration::get('TNT_CARRIER_'.strtoupper($country).'_OVERCOST') : '0'), - 'action' => Tools::getValue('action'), - 'section' => Tools::getValue('section'), - 'getCountry' => Tools::getValue('country'), - 'form' => (Tools::getValue('country') != '' ? $this->_displayFormCountry(Tools::getValue('country')) : '') + 'overcost' => (Configuration::get('TNT_CARRIER_'.strtoupper($country).'_OVERCOST') ? Configuration::get('TNT_CARRIER_'.strtoupper($country).'_OVERCOST') : '0'), + 'action' => htmlentities(Tools::getValue('action')), + 'section' => htmlentities(Tools::getValue('section')), + 'getCountry' => htmlentities(Tools::getValue('country')), + 'form' => (Tools::getValue('country') != '' ? $this->_displayFormCountry(htmlentities(Tools::getValue('country'))) : '') ); $smarty->assign('varCountry', $var); return $this->display( __FILE__, 'tpl/country.tpl' ); @@ -434,7 +461,7 @@ class TntCarrier extends CarrierModule $display = $service[0]['deleted']; } } - $var = array('id' => $id,'name' => $name, 'description' => $description, 'code' => $code, 'charge' => $charge, 'display' => $display); + $var = array('id' => $id, 'name' => $name, 'description' => $description, 'code' => $code, 'charge' => $charge, 'display' => $display); $smarty->assign('varServiceForm', $var); return $this->display( __FILE__, 'tpl/serviceForm.tpl' ); } @@ -454,8 +481,8 @@ class TntCarrier extends CarrierModule } $html = ' -
- '.($id != null ? '' : '').' + + '.($id != null ? '' : '').' @@ -623,12 +650,12 @@ class TntCarrier extends CarrierModule Db::getInstance()->autoExecute(_DB_PREFIX_.'tnt_carrier_option', array('id_carrier' => (int)($id_carrier), - 'option' => $code, + 'option' => pSQL($code), 'additionnal_charges' => (float)($charge)),'INSERT'); - Configuration::updateValue('TNT_CARRIER_'.$code.'_ID', (int)($id_carrier)); - Configuration::updateValue('TNT_CARRIER_'.$code.'_OVERCOST', (float)($charge)); - $this->_fieldsList['TNT_CARRIER_'.$code.'_OVERCOST'] = (float)($charge); - $this->_fieldsList['TNT_CARRIER_'.$code.'_ID'] = (float)($id_carrier); + Configuration::updateValue('TNT_CARRIER_'.pSQL($code).'_ID', (int)($id_carrier)); + Configuration::updateValue('TNT_CARRIER_'.pSQL($code).'_OVERCOST', (float)($charge)); + $this->_fieldsList['TNT_CARRIER_'.pSQL($code).'_OVERCOST'] = (float)($charge); + $this->_fieldsList['TNT_CARRIER_'.pSQL($code).'_ID'] = (float)($id_carrier); $this->_html .= $this->displayConfirmation($this->l('Service updated')); } } @@ -655,13 +682,13 @@ class TntCarrier extends CarrierModule if (!$this->_postErrors) { - Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'carrier` SET `name` = "'.$name.'", `deleted` = "'.(int)($display).'" WHERE `id_carrier` = '.(int)($id).''); - Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'carrier_lang` SET `delay` = "'.$description.'" WHERE `id_carrier` = '.(int)($id).''); - Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'tnt_carrier_option` SET `option` = "'.$code.'" WHERE `id_carrier` = '.(int)($id).''); - Configuration::updateValue('TNT_CARRIER_'.$code.'_OVERCOST', (float)($charge)); - Configuration::updateValue('TNT_CARRIER_'.$code.'_ID', (int)($id)); - $this->_fieldsList['TNT_CARRIER_'.$code.'_OVERCOST'] = (float)($charge); - $this->_fieldsList['TNT_CARRIER_'.$code.'_ID'] = (float)($id); + Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'carrier` SET `name` = "'.pSQL($name).'", `deleted` = "'.(int)($display).'" WHERE `id_carrier` = '.(int)($id).''); + Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'carrier_lang` SET `delay` = "'.pSQL($description).'" WHERE `id_carrier` = '.(int)($id).''); + Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'tnt_carrier_option` SET `option` = "'.pSQL($code).'" WHERE `id_carrier` = '.(int)($id).''); + Configuration::updateValue('TNT_CARRIER_'.pSQL($code).'_OVERCOST', (float)($charge)); + Configuration::updateValue('TNT_CARRIER_'.pSQL($code).'_ID', (int)($id)); + $this->_fieldsList['TNT_CARRIER_'.pSQL($code).'_OVERCOST'] = (float)($charge); + $this->_fieldsList['TNT_CARRIER_'.pSQL($code).'_ID'] = (float)($id); $this->_html .= $this->displayConfirmation($this->l('Service updated')); } } @@ -671,10 +698,10 @@ class TntCarrier extends CarrierModule $info_min = Tools::getValue('tnt_carrier_'.$cat.'_min'); $info_max = Tools::getValue('tnt_carrier_'.$cat.'_max'); $charge = Tools::getValue('tnt_carrier_'.$cat.'_charge'); - Db::getInstance()->autoExecute(_DB_PREFIX_.'tnt_carrier_'.$cat.'', + Db::getInstance()->autoExecute(_DB_PREFIX_.'tnt_carrier_'.bqSQL($cat).'', array( - ''.$cat.'_min' => (float)($info_min), - ''.$cat.'_max' => (float)($info_max), + ''.pSQL($cat).'_min' => (float)($info_min), + ''.pSQL($cat).'_max' => (float)($info_max), 'additionnal_charges' => (float)($charge)),'INSERT'); $this->_html .= $this->displayConfirmation($this->l('Service updated')); } @@ -716,7 +743,7 @@ class TntCarrier extends CarrierModule { global $smarty; $id_cart = $params['cart']->id; - $smarty->assign('id_cart', $id_cart); + $smarty->assign('id_cart', (int)$id_cart); return $this->display( __FILE__, 'tpl/relaisColis.tpl' ); }
'.$this->l('Weight min').''.$this->l('Weight max (can be empty)').''.$this->l('Additionnal charge').'