From 79fd72e46118d66f08c420c8fcd4fc4caba58bd6 Mon Sep 17 00:00:00 2001 From: rMalie Date: Mon, 5 Sep 2011 14:56:02 +0000 Subject: [PATCH] // Merge -> revision 8342 git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8344 b9a71923-0436-4b27-9f14-aed3839534dd --- admin-dev/index.php | 1 - admin-dev/tabs/AdminCounty.php | 2 +- admin-dev/tabs/AdminImport.php | 2 +- admin-dev/tabs/AdminUpgrade.php | 387 ++++++++++++--- classes/Backup.php | 12 +- classes/PDF.php | 11 +- classes/PaymentModule.php | 2 +- classes/Tools.php | 18 +- classes/Upgrader.php | 3 +- controllers/GuestTrackingController.php | 4 +- install-dev/classes/LanguagesManager.php | 5 +- install-dev/controller.js | 104 +++-- install-dev/index.php | 72 +-- install-dev/langs/de.php | 4 +- install-dev/langs/es.php | 4 +- install-dev/langs/fr.php | 6 +- install-dev/langs/it.php | 4 +- install-dev/preactivation.php | 4 +- install-dev/sql/db_settings_lite.sql | 4 +- install-dev/sql/upgrade/1.4.2.0.sql | 2 +- install-dev/xml/checkShopInfos.php | 16 +- modules/authorizeaim/authorizeaim.php | 4 +- modules/authorizeaim/config.xml | 2 +- .../blocklayered/blocklayered-ajax-back.php | 4 +- modules/blocklayered/blocklayered-indexer.php | 13 + modules/dateofdelivery/dateofdelivery.php | 2 +- modules/ebay/ajax/eBaySyncProduct.php | 1 + modules/ebay/config.xml | 4 + modules/ebay/ebay.php | 9 +- modules/ekomi/config.xml | 2 +- modules/ekomi/ekomi.php | 6 +- modules/importerosc/importerosc.php | 29 +- .../mondialrelay/classes/MRCreateTickets.php | 1 - modules/mondialrelay/classes/MRTools.php | 12 +- modules/mondialrelay/style.css | 16 +- modules/paypal/config.xml | 2 +- .../paypal/integral_evolution/redirect.tpl | 1 + modules/paypal/paypal.php | 2 +- modules/productscategory/productscategory.tpl | 2 +- modules/shopimporter/ajax.php | 83 +++- modules/shopimporter/shopimporter.js | 439 +++++++++++++++++- modules/shopimporter/shopimporter.php | 235 ++++++++-- modules/themeinstallator/themeinstallator.php | 4 +- modules/treepodia/config.xml | 2 +- modules/treepodia/treepodia.php | 4 +- themes/prestashop/js/order-opc.js | 2 + 46 files changed, 1299 insertions(+), 249 deletions(-) create mode 100644 modules/blocklayered/blocklayered-indexer.php diff --git a/admin-dev/index.php b/admin-dev/index.php index 8622c1334..9af8d30a1 100644 --- a/admin-dev/index.php +++ b/admin-dev/index.php @@ -68,7 +68,6 @@ if (empty($tab) and !sizeof($_POST)) }); });'; - echo '
diff --git a/admin-dev/tabs/AdminCounty.php b/admin-dev/tabs/AdminCounty.php index d97d0eca0..418f7b0ff 100644 --- a/admin-dev/tabs/AdminCounty.php +++ b/admin-dev/tabs/AdminCounty.php @@ -38,7 +38,7 @@ class AdminCounty extends AdminTab $this->fieldsDisplay = array( 'id_county' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'name' => array('title' => $this->l('County'), 'width' => 130, 'filter_key' => 'b!name'), + 'name' => array('title' => $this->l('County'), 'width' => 130, 'filter_key' => 'a!name'), 'state' => array('title' => $this->l('State'), 'width' => 70, 'filter_key' => 's!name'), 'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active')); diff --git a/admin-dev/tabs/AdminImport.php b/admin-dev/tabs/AdminImport.php index 4caaaf2ae..37f7276d2 100644 --- a/admin-dev/tabs/AdminImport.php +++ b/admin-dev/tabs/AdminImport.php @@ -610,7 +610,7 @@ class AdminImport extends AdminTab $product = new Product((int)($info['id'])); $categoryData = Product::getProductCategories((int)($product->id)); foreach ($categoryData as $tmp) - $product->category[] = $tmp['id_category']; + $product->category[] = $tmp; } else $product = new Product(); diff --git a/admin-dev/tabs/AdminUpgrade.php b/admin-dev/tabs/AdminUpgrade.php index 2faf89ff8..d50bdad94 100755 --- a/admin-dev/tabs/AdminUpgrade.php +++ b/admin-dev/tabs/AdminUpgrade.php @@ -25,13 +25,14 @@ * International Registered Trademark & Property of PrestaShop SA */ -include_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php'); +require_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php'); class AdminUpgrade extends AdminPreferences { public $ajax = false; public $nextResponseType = 'json'; // json, xml public $next = 'N/A'; + public $isModule = false; /** * set to false if the current step is a loop @@ -39,12 +40,31 @@ class AdminUpgrade extends AdminPreferences * @var boolean */ public $stepDone = true; + public $status = true; public $error ='0'; public $nextDesc = '.'; public $nextParams = array(); public $nextQuickInfo = array(); public $currentParams = array(); - public $autoupgradePath = ''; + /** + * @var array theses values will be automatically added in "nextParams" + * if their properties exists + */ + public $ajaxParams = array( + // autoupgrade options + 'dontBackupImages', + 'keepDefaultTheme', + 'keepTrad', + 'manualMode', + 'desactivateCustomModule', + + // + 'backupDbFilename', + 'backupFilesFilename', + + + ); + public $autoupgradePath = null; /** * autoupgradeDir * @@ -53,6 +73,7 @@ class AdminUpgrade extends AdminPreferences public $autoupgradeDir = 'autoupgrade'; public $latestRootDir = ''; public $prodRootDir = ''; + public $adminDir = ''; public $rootWritable = false; public $svnDir = 'svn'; public $destDownloadFilename = 'prestashop.zip'; @@ -64,6 +85,9 @@ class AdminUpgrade extends AdminPreferences private $excludeFilesFromUpgrade = array(); private $excludeAbsoluteFilesFromUpgrade = array(); + private $backupFilesFilename = ''; + private $backupDbFilename = ''; + /** * int loopBackupFiles : if your server has a low memory size, lower this value * @TODO remove the static, add a const, and use it like this : min(AdminUpgrade::DEFAULT_LOOP_ADD_FILE_TO_ZIP,Configuration::get('LOOP_ADD_FILE_TO_ZIP'); @@ -84,13 +108,75 @@ class AdminUpgrade extends AdminPreferences protected $_includeContainer = false; + public function encrypt($string) + { + return md5(_COOKIE_KEY_.$string); + } + public function checkToken() + { + // simple checkToken in ajax-mode, to be free of Cookie class (and no Tools::encrypt() too ) + if ($this->ajax) + return ($_COOKIE['autoupgrade'] == $this->encrypt($_COOKIE['id_employee'])); + else + return parent::checkToken(); + } + + /** + * create cookies id_employee, id_tab and autoupgrade (token) + */ + public function createCustomToken() + { + // ajax-mode for autoupgrade, we can't use the classic authentication + // so, we'll create a cookie in admin dir, based on cookie key + global $cookie; + $id_employee = $cookie->id_employee; + + $cookiePath = __PS_BASE_URI__.str_replace($this->prodRootDir,'',trim($this->adminDir,'/')); + setcookie('id_employee', $id_employee, time()+3600, $cookiePath); + setcookie('id_tab', $this->id, time()+3600, $cookiePath); + setcookie('autoupgrade', $this->encrypt($id_employee), time()+3600, $cookiePath); + return false; + } + + + + public function viewAccess($disable = false){ + if ($this->ajax) + return true; + else + { + // simple access : we'll allow only admin + global $cookie; + if ($cookie->profile == 1) + return true; + } + return false; + } + public function __construct() { @set_time_limit(0); @ini_set('max_execution_time', '0'); $this->init(); + // retrocompatibility when used in module : Tab can't work, + // but we saved the tab id in a cookie. + if(class_exists('Tab',false)) parent::__construct(); + else + $this->id = $_COOKIE['id_tab']; + } + + protected function l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE) + { + if($this->isModule) + { + $currentClass = get_class($this); + // need to be called in order to populate $classInModule + return SelfModule::findTranslation('autoupgrade', $string, 'AdminSelfUpgrade'); + } + else + return parent::l($string, $class, $addslashes, $htmlentities); } /** @@ -114,6 +200,11 @@ class AdminUpgrade extends AdminPreferences 'title' => $this->l('Keep translations'), 'cast' => 'intval', 'validation' => 'isBool', 'type' => 'bool', 'desc'=>$this->l('If set too yes, you will keep all your translations'), ); + + $this->_fieldsAutoUpgrade['PS_AUTOUP_CUSTOM_MOD_DESACT'] = array( + 'title' => $this->l('Desactivate custom modules'), 'cast' => 'intval', 'validation' => 'isBool', + 'type' => 'bool', 'desc'=>$this->l('If you don\'t desactivate your modules, you can have some compatibility problem and the Modules page might not load correctly.'), + ); // allow manual mode only for dev if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_) $this->_fieldsAutoUpgrade['PS_AUTOUP_MANUAL_MODE'] = array( @@ -130,6 +221,13 @@ class AdminUpgrade extends AdminPreferences } } + public function configOk() + { + $allowed = (ConfigurationTest::test_fopen() && $this->rootWritable); + $allowed &= !Configuration::get('PS_SHOP_ENABLE'); + + return $allowed; + } /** * isUpgradeAllowed checks if all server configuration is valid for upgrade * @@ -158,6 +256,12 @@ class AdminUpgrade extends AdminPreferences $this->adminDir = _PS_ADMIN_DIR_; // test writable recursively + if ($this->isModule) + { + require_once('ConfigurationTest.php'); + if(!class_exists('ConfigurationTest', false) AND class_exists('ConfigurationTestCore')) + eval('class ConfigurationTest extends ConfigurationTestCore{}'); + } if (ConfigurationTest::test_dir($this->prodRootDir,true)) $this->rootWritable = true; @@ -167,14 +271,15 @@ class AdminUpgrade extends AdminPreferences // If you have defined this somewhere, you know what you do if (defined('_PS_ALLOW_UPGRADE_UNSTABLE_') AND _PS_ALLOW_UPGRADE_UNSTABLE_ AND function_exists('svn_checkout')) { + if (!$this->isModule OR class_exists('Configuration',false)) $this->useSvn = Configuration::get('PS_AUTOUP_USE_SVN'); } else $this->useSvn = false; // from $_POST or $_GET - $this->action = Tools::getValue('action'); - $this->currentParams = Tools::getValue('params'); + $this->action = empty($_REQUEST['action'])?null:$_REQUEST['action']; + $this->currentParams = empty($_REQUEST['params'])?null:$_REQUEST['params']; // If not exists in this sessions, "create" // session handling : from current to next params @@ -184,20 +289,30 @@ class AdminUpgrade extends AdminPreferences if (isset($this->currentParams['filesToUpgrade'])) $this->nextParams['filesToUpgrade'] = $this->currentParams['filesToUpgrade']; + if (class_exists('Configuration',false)) + { + $time = time(); $this->backupDbFilename = Configuration::get('UPGRADER_BACKUPDB_FILENAME'); if(!file_exists($this->backupDbFilename)) { + // If not exists, the filename is generated by Backup.php $this->backupDbFilename = ''; - Configuration::updateValue('UPGRADER_BACKUPDB_FILENAME',''); + Configuration::updateValue('UPGRADER_BACKUPDB_FILENAME', $this->backupDbFilename); } + $this->backupFilesFilename = Configuration::get('UPGRADER_BACKUPFILES_FILENAME'); if(!file_exists($this->backupFilesFilename)) { - $this->backupFilesFilename = ''; - Configuration::updateValue('UPGRADER_BACKUPFILES_FILENAME',''); + $this->backupFilesFilename = $this->autoupgradePath . DIRECTORY_SEPARATOR . 'backupfile-'.date('Y-m-d').'-'.$time.'.zip'; + Configuration::updateValue('UPGRADER_BACKUPFILES_FILENAME', $this->backupFilesFilename); + } + } + else{ + // backupDbFilename should never be empty + $this->backupDbFilename = $this->currentParams['backupDbFilename']; + // backupFilesFilename should never etc. + $this->backupFilesFilename = $this->currentParams['backupFilesFilename']; } - - $this->autoupgradePath = $this->adminDir.DIRECTORY_SEPARATOR.$this->autoupgradeDir; if (!file_exists($this->autoupgradePath)) @@ -214,11 +329,23 @@ class AdminUpgrade extends AdminPreferences // @TODO future option // $this->testRootDir = $this->autoupgradePath.DIRECTORY_SEPARATOR.'test'; - /* optional skips */ + /* option */ + if (class_exists('Configuration',false)) + { $this->dontBackupImages = Configuration::get('PS_AUTOUP_DONT_SAVE_IMAGES'); $this->keepDefaultTheme = Configuration::get('PS_AUTOUP_KEEP_DEFAULT_THEME'); $this->keepTrad = Configuration::get('PS_AUTOUP_KEEP_TRAD'); $this->manualMode = Configuration::get('PS_AUTOUP_MANUAL_MODE'); + $this->desactivateCustomModule = Configuration::get('PS_AUTOUP_CUSTOM_MOD_DESACT'); + } + else + { + $this->dontBackupImages = $this->currentParams['dontBackupImages']; + $this->keepDefaultTheme = $this->currentParams['keepDefaultTheme']; + $this->keepTrad = $this->currentParams['keepTrad']; + $this->manualMode = $this->currentParams['manualMode']; + $this->desactivateCustomModule = $this->current['desactivateCustomModule']; + } // We can add any file or directory in the exclude dir : theses files will be not removed or overwritten // @TODO cache should be ignored recursively, but we have to reconstruct it after upgrade // - compiled from smarty @@ -264,9 +391,11 @@ class AdminUpgrade extends AdminPreferences { $this->_setFields(); - if (!empty($_POST)) + if (sizeof($_POST)>0) + { $this->_postConfig($this->_fieldsAutoUpgrade); } + } public function ajaxProcessUpgradeComplete() { @@ -277,8 +406,19 @@ class AdminUpgrade extends AdminPreferences public function ajaxProcessUpgradeNow() { $this->nextDesc = $this->l('Starting upgrade ...'); - $this->next = 'desactiveShop'; + + if ($this->useSvn) + { + $this->next = 'svnCheckout'; + $this->nextDesc = $this->l('switching to svn checkout (useSvn set to true)'); } + else + { + $this->next = 'download'; + $this->nextDesc = $this->l('Shop desactivated. Now downloading (this can takes some times )...'); + } + } + public function ajaxProcessSvnExport() { if ($this->useSvn) @@ -317,7 +457,9 @@ class AdminUpgrade extends AdminPreferences } public function ajaxProcessUnzip(){ - // @TODO : not require_once like that. + if ($this->isModule AND !class_exists('Tools',false)) + require_once('Tools.php'); + $filepath = $this->getFilePath(); $destExtract = $this->autoupgradePath.DIRECTORY_SEPARATOR.'latest'; if (file_exists($destExtract)) @@ -420,21 +562,6 @@ class AdminUpgrade extends AdminPreferences $this->nextParams['filesToUpgrade'] = $this->toUpgradeFileList; } - public function ajaxProcessDesactiveShop() - { - $this->ShopActiveValue = Configuration::get('PS_SHOP_ENABLE'); - Configuration::updateValue('PS_SHOP_ENABLE',0); - if ($this->useSvn) - { - $this->next = 'svnCheckout'; - $this->nextDesc = $this->l('switching to svn checkout (useSvn set to true)'); - } - else - { - $this->next = 'download'; - $this->nextDesc = $this->l('Shop desactivated. Now downloading (this can takes some times )...'); - } - } public function ajaxProcessUpgradeFiles(){ // @TODO : @@ -488,7 +615,7 @@ class AdminUpgrade extends AdminPreferences } /** - * model_doUpgrade prepare the call to doUpgrade.php file (like model.php) + * _modelDoUpgrade prepare the call to doUpgrade.php file (like model.php) * * @return void */ @@ -528,7 +655,7 @@ class AdminUpgrade extends AdminPreferences // Copy from model.php /////////////////////// $upgrader = $this->upgrader; - $upgrader->checkPSVersion(); + $upgrader->checkPSVersion(true); define('INSTALL_VERSION', $upgrader->version_num); // now the install dir to use is in a subdirectory of the admin dir @@ -573,8 +700,8 @@ class AdminUpgrade extends AdminPreferences // @TODO // 4) upgrade // install/model.php?_=1309193641470&method=doUpgrade&customModule=desactivate - if (isset($this->currentParams['customModule'])) - $_GET['customModule'] = $this->currentParams['customModule']; + if (!empty($this->currentParams['desactivateCustomModule'])) + $_GET['customModule'] = 'desactivate'; if (!$this->_modelDoUpgrade()) { @@ -655,7 +782,7 @@ class AdminUpgrade extends AdminPreferences // 1st, need to analyse what was wrong. $this->nextParams = $this->currentParams; - if (!empty($this->backupFilesFilename)) + if (!empty($this->backupFilesFilename) AND file_exists($this->backupFilesFilename)) { $this->next = 'restoreFiles'; $this->status = 'ok'; @@ -663,7 +790,7 @@ class AdminUpgrade extends AdminPreferences } else { - if (!empty($this->backupDbFilename)) + if (!empty($this->backupDbFilename) AND file_exists($this->backupDbFilename)) { $this->next = 'restoreDb'; $this->status = 'ok'; @@ -689,7 +816,7 @@ class AdminUpgrade extends AdminPreferences public function ajaxProcessRestoreFiles() { // @TODO : workaround max_execution_time / ajax batch unzip - if (!empty($this->backupFilesFilename)) + if (!empty($this->backupFilesFilename) AND file_exists($this->backupFilesFilename)) { // cleanup current PS tree $list = $this->_listArchivedFiles(); @@ -805,6 +932,55 @@ class AdminUpgrade extends AdminPreferences public function ajaxProcessBackupDb() { + if(!class_exists('ObjectModel',false)) + { + require_once(_PS_ROOT_DIR_.'/classes/ObjectModel.php'); + if(!class_exists('ObjectModel',false)) + eval('Class ObjectModel extends ObjectModelCore{}'); + } + + if(!class_exists('Language',false)) + { + require_once(_PS_ROOT_DIR_.'/classes/Language.php'); + if(!class_exists('Language',false)) + eval('Class Language extends LanguageCore{}'); + } + if(!class_exists('Validate',false)) + { + require_once(_PS_ROOT_DIR_.'/classes/Validate.php'); + if(!class_exists('Validate',false)) + eval('Class Validate extends ValidateCore{}'); + } + if(!class_exists('Db',false)) + { + require_once(_PS_ROOT_DIR_.'/classes/Db.php'); + if(!class_exists('Db',false)) + eval('abstract Class Db extends DbCore{}'); + } + if(!class_exists('MySQL',false)) + { + require_once(_PS_ROOT_DIR_.'/classes/MySQL.php'); + if(!class_exists('MySQL',false)) + eval('Class MySQL extends MySQLCore{}'); + } + if(!class_exists('Configuration',false)) + { + require_once(_PS_ROOT_DIR_.'/classes/Configuration.php'); + if(!class_exists('Configuration',false)) + eval('Class Configuration extends ConfigurationCore{}'); + } + if(!class_exists('Backup',false)) + { + require_once('Backup.php'); + if(!class_exists('ObjectModel',false)) + eval('Class ObjectModel extends ObjectModelCore{}'); + } + + if(!defined('_PS_MAGIC_QUOTES_GPC_')) + define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc()); + if(!defined('_PS_MYSQL_REAL_ESCAPE_STRING_')) + define('_PS_MYSQL_REAL_ESCAPE_STRING_', function_exists('mysql_real_escape_string')); + $backup = new Backup(); // for backup db, use autoupgrade directory // @TODO : autoupgrade must not be static @@ -813,6 +989,9 @@ class AdminUpgrade extends AdminPreferences $res = $backup->add(); if ($res) { + $this->nextParams['backupDbFilename'] = $backup->id; + // We need to load configuration to use it ... + Configuration::loadConfiguration(); Configuration::updateValue('UPGRADER_BACKUPDB_FILENAME', $backup->id); $this->next = 'upgradeFiles'; @@ -837,10 +1016,6 @@ class AdminUpgrade extends AdminPreferences if (file_exists($this->backupFilesFilename)) unlink($this->backupFilesFilename); - $time = time(); - $this->backupFilesFilename = $this->autoupgradePath . DIRECTORY_SEPARATOR . 'backupfile-'.date('Y-m-d').'-'.$time.'.zip'; - - Configuration::updateValue('UPGRADER_BACKUPFILES_FILENAME', $this->backupFilesFilename); $this->nextQuickInfo[] = sprintf($this->l('backup files initialized in %s'), $this->backupFilesFilename); } @@ -1068,10 +1243,12 @@ class AdminUpgrade extends AdminPreferences $return['next'] = $this->next; $return['status'] = $this->next == 'error' ? 'error' : 'ok'; $return['nextDesc'] = $this->nextDesc; - if (!empty($this->nextParams)) + + foreach($this->ajaxParams as $v) + if(property_exists($this,$v)) + $this->nextParams[$v] = $this->$v; + $return['nextParams'] = $this->nextParams; - else - $return['nextParams'] = array(); $return['nextParams']['typeResult'] = $this->nextResponseType; @@ -1086,8 +1263,9 @@ class AdminUpgrade extends AdminPreferences */ public function displayConf() { - if (version_compare(_PS_VERSION_,'1.4.4.0','<') AND false) + if(!$this->isModule) { + if (version_compare(_PS_VERSION_,'1.4.4.0','<') AND false) $this->_errors[] = Tools::displayError('This class depends of several files modified in 1.4.4.0 version and should not be used in an older version'); } parent::displayConf(); @@ -1096,10 +1274,12 @@ class AdminUpgrade extends AdminPreferences public function ajaxPreProcess() { - if (Tools::getValue('responseType') == 'json') + if (!empty($_POST['responseType']) AND $_POST['responseType'] == 'json') header('Content-Type: application/json'); - $action = (Tools::getValue('action')); + if(!empty($_POST['action'])) + { + $action = $_POST['action']; if (isset(self::$skipAction[strtolower($action)])) { $this->next = self::$skipAction[$action]; @@ -1113,6 +1293,7 @@ class AdminUpgrade extends AdminPreferences $this->next = 'error'; $this->error = '1'; } + } if ($this->apacheModExists('mod_evasive')) sleep(1); @@ -1126,16 +1307,29 @@ class AdminUpgrade extends AdminPreferences */ function apacheModExists($name) { + if(function_exists('apache_get_modules')) + { static $apacheModuleList = null; - if (!is_array($apacheModuleList) AND function_exists('apache_get_modules')) - { + if (!is_array($apacheModuleList)) $apacheModuleList = apache_get_modules(); - } + // we need strpos (example can be evasive20 foreach($apacheModuleList as $module) if (strpos($name, $module)!==false) return true; + } + else{ + // If apache_get_modules does not exists, + // one solution should be parsing httpd.conf, + // but we could simple parse phpinfo(INFO_MODULES) return string + ob_start(); + phpinfo(INFO_MODULES); + $phpinfo = ob_get_contents(); + ob_end_clean(); + if (strpos($phpinfo, $module) !== false) + return true; + } return false; } @@ -1215,9 +1409,9 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where { echo '
'; } - if (!empty($this->backupFilesFilename)) + if (!empty($this->backupFilesFilename) AND file_exists($this->backupFilesFilename)) echo '
restoreFiles '.sprintf($this->l('click to restore %s'),$this->backupFilesFilename).'

'; - if (!empty($this->backupDbFilename)) + if (!empty($this->backupDbFilename) AND file_exists($this->backupDbFilename)) echo '
restoreDb '.sprintf($this->l('click to restore %s'), $this->backupDbFilename).'

'; echo '
'; @@ -1225,6 +1419,7 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where private function _displayUpgraderForm() { + global $cookie; $pleaseUpdate = $this->upgrader->checkPSVersion(); echo '
'; @@ -1248,15 +1443,15 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where if (Configuration::get('PS_SHOP_ENABLE')) { - $srcShopStatus = '../img/admin/enabled.gif'; - $label = $this->l('Active'); + $srcShopStatus = '../img/admin/disabled.gif'; + $label = $this->l('No'); } else { - $srcShopStatus = '../img/admin/disabled.gif'; - $label = $this->l('Inactive'); + $srcShopStatus = '../img/admin/enabled.gif'; + $label = $this->l('Yes'); } - echo ''.$this->l('Shop status').' : '.''.$label.'

'; + echo ''.$this->l('Shop desactivated').' : '.''.$label.'

'; $max_exec_time = ini_get('max_execution_time'); if ($max_exec_time == 0) @@ -1293,16 +1488,23 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where echo '
'; if ($this->upgrader->needUpgrade) { + if($this->configOk()) echo ''.$this->l('Upgrade PrestaShop now !').''; + else + echo $this->displayWarning('Your current configuration does not allow upgrade.'); } else { - echo '

'.$this->l('Your shop is already up to date').'

'; + echo ''.$this->l('Your shop is already up to date.').' '; } + echo ''.sprintf($this->l('last datetime check : %s '),date('Y-m-d H:i:s',Configuration::get('PS_LAST_VERSION_CHECK'))).' + '.$this->l('Please click to refresh').' + '; echo' -
'; @@ -1315,7 +1517,6 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where echo '
'.$this->l('Step').''; echo '

'.$this->l('Upgrade steps').'

'; echo '
'; - echo 'desactiveShop'; echo 'download'; echo 'unzip'; // unzip in autoupgrade/latest echo 'removeSamples'; // remove samples (iWheel images) @@ -1364,6 +1565,19 @@ echo ''; public function display() { + if(isset($_GET['refreshCurrentVersion'])) + { + $upgrader = new Upgrader(); + $upgrader->checkPSVersion(true); + } + echo ''; $this->displayWarning($this->l('This function is experimental. It\'s highly recommended to make a backup of your files and database before starting the upgrade process.')); // update['name'] = version name @@ -1373,6 +1587,7 @@ echo ''; if ($this->isUpgradeAllowed()) { + $this->createCustomToken(); if ($this->useSvn) echo '

'.$this->l('Unstable upgrade').'

'.$this->l('Your current configuration indicate you want to upgrade your system from the unstable development branch, with no version number. If you upgrade, you will not be able to follow the official release process anymore').'.

@@ -1384,6 +1599,14 @@ echo ''; echo '
'; $this->_displayForm('autoUpgradeOptions',$this->_fieldsAutoUpgrade,''.$this->l('Options').'', '','prefs'); + + if ($this->isModule) + { + echo ' + '; + } echo ''; } else @@ -1443,6 +1666,8 @@ function addQuickInfo(arrQuickInfo){ $js .= 'var manualMode = false;'; $js .= ' +var firstTimeParams = '.$this->buildAjaxResult().'; +firstTimeParams = firstTimeParams.nextParams; $(document).ready(function(){ $(".upgradestep").click(function(e) @@ -1459,10 +1684,10 @@ $(document).ready(function(){ // prepare available button here, without params ? - prepareNextButton("#upgradeNow",{}); - prepareNextButton("#rollback",{}); - prepareNextButton("#restoreDb",{}); - prepareNextButton("#restoreFiles",{}); + prepareNextButton("#upgradeNow",firstTimeParams); + prepareNextButton("#rollback",firstTimeParams); + prepareNextButton("#restoreDb",firstTimeParams); + prepareNextButton("#restoreFiles",firstTimeParams); }); @@ -1506,6 +1731,11 @@ function parseXMLResult(xmlRet) return ret }; +function afterUpgradeComplete() +{ + $("#pleaseWait").hide(); + $("#infoStep").html("

'.$this->l('Upgrade Complete ! ').'

"); +} /** * afterBackupDb display the button * @@ -1536,13 +1766,13 @@ function afterBackupFiles() function doAjaxRequest(action, nextParams){ req = $.ajax({ type:"POST", - url : "'.str_replace('index', 'ajax-tab', self::$currentIndex).'", + url : "'.($this->isModule? __PS_BASE_URI__ . trim($this->adminDir,'/').'/autoupgrade/ajax-upgradetab.php' : str_replace('index','ajax-tab',self::$currentIndex)).'", async: true, data : { - dir:"'.$this->adminDir.'", + dir:"'.trim($this->adminDir,'/').'", ajaxMode : "1", token : "'.$this->token.'", - tab : "AdminUpgrade", + tab : "'.get_class($this).'", action : action, params : nextParams }, @@ -1564,13 +1794,28 @@ function doAjaxRequest(action, nextParams){ } else { + try{ res = $.parseJSON(res); nextParams = res.nextParams; } + catch(e){ + res = {status : "error"}; + alert("error during "+action); + /* + nextParams = { + error:"0", + next:"cancelUpgrade", + nextDesc:"Error detected during ["+action+"] step, reverting...", + nextQuickInfo:[], + status:"ok", + "stepDone":true + } + */ + } + } if (res.status == "ok") { - // a $("#"+action).addClass("done"); if (res.stepDone) $("#"+action).addClass("stepok"); @@ -1678,8 +1923,9 @@ function handleError(res) // In case the rollback button has been desactivated, just re-enable it prepareNextButton("#rollback",res.nextParams); // ask if you want to rollback - // @TODO !!! - if (confirm(res.NextDesc+"\r\r'.$this->l('Do you want to rollback ?').'")) + // TODO : be sure there is useful infos + addQuickInfo(res); + if (confirm(res+"\r\r'.$this->l('Do you want to rollback ?').'")) { if (manualMode) alert("'.$this->l('Please go manually go to rollback button').'"); @@ -1698,7 +1944,8 @@ function handleError(res) // as we need theses files for restore operation, we can't remove them. // They will be overwritten $skipDirs = array('backups', 'pclzip', 'autoupgrade', '.', '..', '.svn'); - $skipFiles = array('autoload.php', 'init.php', 'settings.inc.php', 'config.inc.php', 'Tools.php', 'AdminUpgrade.php', 'ajax-tab.php'); + $skipFiles = array('autoload.php', 'init.php', 'settings.inc.php', 'config.inc.php', 'Tools.php', 'AdminUpgrade.php'); + $skipFiles[] = $this->isModule?'ajax-upgradetab.php':'ajax-tab.php'; if (is_dir($path)) { $fp = opendir($path); diff --git a/classes/Backup.php b/classes/Backup.php index d6b8ae165..e679a4d70 100644 --- a/classes/Backup.php +++ b/classes/Backup.php @@ -36,6 +36,9 @@ class BackupCore /** @var string custom backup directory. */ public $customBackupDir = NULL; + public $psBackupAll = true; + public $psBackupDropTable = true; + /** * Creates a new backup object * @@ -45,6 +48,11 @@ class BackupCore { if ($filename) $this->id = $this->getRealBackupPath($filename); + + $psBackupAll = Configuration::get('PS_BACKUP_ALL'); + $psBackupDropTable = Configuration::get('PS_BACKUP_DROP_TABLE'); + $this->psBackupAll = $psBackupAll !== false ? $psBackupAll : true; + $this->psBackupDropTable = $psBackupDropTable !== false ? $psBackupDropTable : true; } /** @@ -169,7 +177,7 @@ class BackupCore return false; } - if (!Configuration::get('PS_BACKUP_ALL')) + if (!$this->psBackupAll) $ignore_insert_table = array(_DB_PREFIX_.'connections', _DB_PREFIX_.'connections_page', _DB_PREFIX_.'connections_source', _DB_PREFIX_.'guest', _DB_PREFIX_.'statssearch'); else $ignore_insert_table = array(); @@ -228,7 +236,7 @@ class BackupCore fwrite($fp, '/* Scheme for table ' . $schema[0]['Table'] . " */\n"); - if (Configuration::get('PS_BACKUP_DROP_TABLE')) + if ($this->psBackupDropTable) fwrite($fp, 'DROP TABLE IF EXISTS `'.$schema[0]['Table'].'`;'."\n"); fwrite($fp, $schema[0]['Create Table'] . ";\n\n"); diff --git a/classes/PDF.php b/classes/PDF.php index ca968dae0..0d9535574 100644 --- a/classes/PDF.php +++ b/classes/PDF.php @@ -897,6 +897,8 @@ class PDFCore extends PDF_PageGroupCore $priceBreakDown['totalsWithTax'][$product['tax_rate']] = 0; if (!isset($priceBreakDown['totalsEcotax'][$product['tax_rate']])) $priceBreakDown['totalsEcotax'][$product['tax_rate']] = 0; + if (!isset($priceBreakDown['totalsEcotaxWithTax'][$product['tax_rate']])) + $priceBreakDown['totalsEcotaxWithTax'][$product['tax_rate']] = 0; if (!isset($priceBreakDown['totalsWithoutTax'][$product['tax_rate']])) $priceBreakDown['totalsWithoutTax'][$product['tax_rate']] = 0; if (!isset($taxes[$product['tax_rate']])) @@ -950,6 +952,7 @@ class PDFCore extends PDF_PageGroupCore } $priceBreakDown['totalsEcotax'][$product['tax_rate']] += ($product['priceEcotax'] * $product['product_quantity']); + $priceBreakDown['totalsEcotaxWithTax'][$product['tax_rate']] += ($product['priceEcotax'] * (1 + ($product['ecotax_tax_rate'] / 100)) * $product['product_quantity']); if ($priceBreakDown['totalsEcotax'][$product['tax_rate']]) $priceBreakDown['hasEcotax'] = 1; $taxes[$product['tax_rate']] += $vat; @@ -965,9 +968,9 @@ class PDFCore extends PDF_PageGroupCore { $priceBreakDown['totalsWithoutTax'][$tax_rate] = Tools::ps_round($priceBreakDown['totalsWithoutTax'][$tax_rate], 2); $priceBreakDown['totalsProductsWithoutTax'][$tax_rate] = Tools::ps_round($priceBreakDown['totalsWithoutTax'][$tax_rate], 2); - $priceBreakDown['totalsWithTax'][$tax_rate] = Tools::ps_round($priceBreakDown['totalsWithoutTax'][$tax_rate] * (1 + $tax_rate / 100), 2); - $priceBreakDown['totalsProductsWithTax'][$tax_rate] = Tools::ps_round($priceBreakDown['totalsProductsWithoutTax'][$tax_rate] * (1 + $tax_rate / 100), 2); - $priceBreakDown['totalsProductsWithTaxAndReduction'][$product['tax_rate']] += Tools::ps_round($priceBreakDown['totalsProductsWithoutTaxAndReduction'][$product['tax_rate']] * (1 + $tax_rate / 100), 2); + $priceBreakDown['totalsWithTax'][$tax_rate] = Tools::ps_round(($priceBreakDown['totalsWithoutTax'][$tax_rate]- $priceBreakDown['totalsEcotax'][$tax_rate]) * (1 + $tax_rate / 100) + $priceBreakDown['totalsEcotaxWithTax'][$tax_rate], 2); + $priceBreakDown['totalsProductsWithTax'][$tax_rate] = Tools::ps_round(($priceBreakDown['totalsProductsWithoutTax'][$tax_rate] - $priceBreakDown['totalsEcotax'][$tax_rate]) * (1 + $tax_rate / 100) + $priceBreakDown['totalsEcotaxWithTax'][$tax_rate], 2); + $priceBreakDown['totalsProductsWithTaxAndReduction'][$tax_rate] += Tools::ps_round(($priceBreakDown['totalsProductsWithoutTaxAndReduction'][$tax_rate] - $priceBreakDown['totalsEcotax'][$tax_rate]) * (1 + $tax_rate / 100) + $priceBreakDown['totalsEcotaxWithTax'][$tax_rate], 2); } else { @@ -1043,7 +1046,7 @@ class PDFCore extends PDF_PageGroupCore $this->SetXY($this->GetX(), $this->GetY() - $lineSize + 3); $this->Cell($w[0], $lineSize, self::l('Products'), 0, 0, 'R'); $this->Cell($w[1], $lineSize, number_format($tax_rate, 3, ',', ' ').' %', 0, 0, 'R'); - $this->Cell($w[2], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalsProductsWithoutTaxAndReduction'][$tax_rate], self::$currency, true)), 0, 0, 'R'); + $this->Cell($w[2], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalsProductsWithoutTaxAndReduction'][$tax_rate] - $priceBreakDown['totalsEcotax'][$tax_rate], self::$currency, true)), 0, 0, 'R'); $this->Cell($w[3], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalsProductsWithTaxAndReduction'][$tax_rate] - $priceBreakDown['totalsProductsWithoutTaxAndReduction'][$tax_rate], self::$currency, true)), 0, 0, 'R'); if ($priceBreakDown['hasEcotax']) $this->Cell($w[4], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalsEcotax'][$tax_rate], self::$currency, true)), 0, 0, 'R'); diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index a77370db2..b16738edc 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -222,7 +222,7 @@ abstract class PaymentModuleCore extends Module if (!empty($product['ecotax'])) $ecotaxTaxRate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); - $product_price = (float)Product::getPriceStatic((int)($product['id_product']), false, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), (Product::getTaxCalculationMethod((int)($order->id_customer)) == PS_TAX_EXC ? 2 : 6), NULL, false, false, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), $specificPrice, true, false); + $product_price = (float)Product::getPriceStatic((int)($product['id_product']), false, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), (Product::getTaxCalculationMethod((int)($order->id_customer)) == PS_TAX_EXC ? 2 : 6), NULL, false, false, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), $specificPrice, false, false); $quantityDiscount = SpecificPrice::getQuantityDiscount((int)$product['id_product'], $this->context->shop->getID(), (int)$cart->id_currency, (int)$vat_address->id_country, (int)$customer->id_default_group, (int)$product['cart_quantity']); $unitPrice = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL), 2, NULL, false, true, 1, false, (int)$order->id_customer, NULL, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $quantityDiscountValue = $quantityDiscount ? ((Product::getTaxCalculationMethod((int)$order->id_customer) == PS_TAX_EXC ? Tools::ps_round($unitPrice, 2) : $unitPrice) - $quantityDiscount['price'] * (1 + $tax_rate / 100)) : 0.00; diff --git a/classes/Tools.php b/classes/Tools.php index d7df1741a..595f6494a 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1934,14 +1934,28 @@ FileETag INode MTime Size * @param string $type by|way * @param string $value If no index given, use default order from admin -> pref -> products */ - public static function getProductsOrder($type, $value = null) + public static function getProductsOrder($type, $value = null, $prefix = false) { switch ($type) { case 'by' : + $orderByPrefix = ''; + if($prefix) { + if ($value == 'id_product' OR $value == 'date_add') + $orderByPrefix = 'p.'; + elseif ($value == 'name') + $orderByPrefix = 'pl.'; + elseif ($value == 'manufacturer') + { + $orderByPrefix = 'm.'; + } + elseif ($value == 'position') + $orderByPrefix = 'cp.'; + } + $value = (is_null($value) || $value === false || $value === '') ? (int)Configuration::get('PS_PRODUCTS_ORDER_BY') : $value; $list = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity'); - return ((isset($list[$value])) ? $list[$value] : ((in_array($value, $list)) ? $value : 'position')); + return $orderByPrefix.((isset($list[$value])) ? $list[$value] : ((in_array($value, $list)) ? $value : 'position')); break; case 'way' : diff --git a/classes/Upgrader.php b/classes/Upgrader.php index e4a5012b8..aa1e07877 100644 --- a/classes/Upgrader.php +++ b/classes/Upgrader.php @@ -27,6 +27,7 @@ class UpgraderCore{ const DEFAULT_CHECK_VERSION_DELAY_HOURS = 24; + private static $rss_version_link = 'http://www.prestashop.com/xml/version.xml'; /** * link contains hte url where to download the file * @@ -98,7 +99,7 @@ class UpgraderCore{ if (!($this->autoUpgrade AND $lastCheck) AND ($force OR ($lastCheck < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))) ) { libxml_set_streams_context(stream_context_create(array('http' => array('timeout' => 3)))); - if ($feed = @simplexml_load_file('http://www.prestashop.com/xml/version.xml')) + if ($feed = @simplexml_load_file(self::$rss_version_link)) { $this->version_name = (string)$feed->version->name; $this->version_num = (string)$feed->version->num; diff --git a/controllers/GuestTrackingController.php b/controllers/GuestTrackingController.php index 5ce2ee483..e4c5a13e5 100644 --- a/controllers/GuestTrackingController.php +++ b/controllers/GuestTrackingController.php @@ -39,6 +39,8 @@ class GuestTrackingControllerCore extends FrontController public function process() { + global $link; + parent::process(); if ($id_order = Tools::getValue('id_order') AND $email = Tools::getValue('email')) @@ -116,7 +118,7 @@ class GuestTrackingControllerCore extends FrontController } $this->context->smarty->assign(array( - 'action' => 'guest-tracking.php', + 'action' => $link->getPageLink('guest-tracking.php'), 'errors' => $this->errors )); } diff --git a/install-dev/classes/LanguagesManager.php b/install-dev/classes/LanguagesManager.php index da8c4f431..4beda9429 100644 --- a/install-dev/classes/LanguagesManager.php +++ b/install-dev/classes/LanguagesManager.php @@ -95,9 +95,9 @@ class LanguageManager */ private function setLanguage() { - if ( !empty($_GET['language'])) + if (isset($_GET['language'])) $id_lang = (int)($_GET['language'])>0 ? $_GET['language'] : 0; - if (empty($id_lang)) + if (!isset($id_lang)) $id_lang = ($this->getIdByHAL()); $this->lang = $this->xml_file->lang[(int)($id_lang)]; } @@ -107,3 +107,4 @@ class LanguageManager return ($this->lang == NULL) ? false : dirname(__FILE__).$this->lang['trad_file']; } } + diff --git a/install-dev/controller.js b/install-dev/controller.js index a5bf754c6..1e03a2da2 100644 --- a/install-dev/controller.js +++ b/install-dev/controller.js @@ -258,7 +258,7 @@ function verifyThisStep() function setInstallerLanguage () { - $("#formSetInstallerLanguage").submit(); + $('#formSetInstallerLanguage').submit(); } function verifyAndSetRequire(firsttime) @@ -446,20 +446,36 @@ function createDB() for (i = 0; countries_ret[i]; i=i+1) { html = html + ''; + else if (id_lang == 2 && countries_ret[i].getAttribute('value') == 6) /* Spain */ + html = html + ' selected="selected" '; + else if (id_lang == 3 && countries_ret[i].getAttribute('value') == 1) /* Germany */ + html = html + ' selected="selected" '; + else if (id_lang == 4 && countries_ret[i].getAttribute('value') == 10) /* Italy */ + html = html + ' selected="selected" '; + html = html + ' >'+countries_ret[i].getAttribute('name')+''; } - $('#infosCountry').html(html); + $('#infosCountry').append(html); html = ''; for (i = 0; timezone_ret[i]; i=i+1) { html = html + ''; } - $('#infosTimezone').html(html); + $('#infosTimezone').append(html); showStep(step+1, 'next'); } else @@ -628,25 +644,25 @@ function moveLanguage(direction) } } -function ajaxRefreshField(nthField, idResultField, fieldsList, inputId) +function ajaxRefreshField(ret, idResultField, fieldMsg) { - var result = fieldsList[nthField].getAttribute("result"); - if (result != "ok") + var pattern = 'field[id='+idResultField+']'; + var result = $(ret).children().find(pattern).attr('result'); + var error = $(ret).children().find(pattern).attr('error'); + + if (error === undefined || result === undefined) + return true; + + if (result != 'ok') { - $("#"+idResultField) - .html( txtError[parseInt(fieldsList[nthField].getAttribute("error"))] ) - .addClass("errorBlock") - .show("slow"); + $('#'+fieldMsg).html(txtError[parseInt(error)]).addClass('errorBlock').show('slow'); if (validShopInfos) - $("#"+inputId).focus(); + $('#'+idResultField).focus(); return false; } else { - $("#"+idResultField) - .html("") - .removeClass("errorBlock") - .show("slow"); + $('#'+fieldMsg).html('').removeClass('errorBlock').show('slow'); return true; } } @@ -664,7 +680,7 @@ function verifyShopInfos() $.ajax( { - url: "model.php", + url: 'model.php', async: true, cache: false, data: @@ -693,21 +709,22 @@ function verifyShopInfos() "&isoCodeLocalLanguage="+isoCodeLocalLanguage, success: function(ret) { - fieldsList = ret.getElementsByTagName('shopConfig')[0].getElementsByTagName('field'); validShopInfos = true; - if (!ajaxRefreshField(0, "resultInfosShop", fieldsList, "infosShop")) validShopInfos = false; - else if (!ajaxRefreshField(4, "resultInfosShop", fieldsList, "validateShop")) validShopInfos = false; - else if (!ajaxRefreshField(1, "resultInfosFirstname", fieldsList, "infosFirstname")) validShopInfos = false; - else if (!ajaxRefreshField(2, "resultInfosName", fieldsList, "infosName")) validShopInfos = false; - else if (!ajaxRefreshField(3, "resultInfosEmail", fieldsList, "infosEmail")) validShopInfos = false; - else if (!ajaxRefreshField(7, "resultInfosPassword", fieldsList, "infosPassword")) validShopInfos = false; - else if (!ajaxRefreshField(8, "resultInfosPasswordRepeat", fieldsList, "infosPasswordRepeat")) validShopInfos = false; - else if (!ajaxRefreshField(9, "resultInfosLanguages", fieldsList, "infosLanguages")) validShopInfos = false; - else if (!ajaxRefreshField(11, "resultInfosSQL", fieldsList, "infosSQL")) validShopInfos = false; - else if (!ajaxRefreshField(10, "resultInfosNotification", fieldsList, "infosNotification")) validShopInfos = false; - else if (!ajaxRefreshField(5, "resultInfosFirstname", fieldsList, "validateFirstname")) validShopInfos = false; - else if (!ajaxRefreshField(6, "resultInfosName", fieldsList, "validateName")) validShopInfos = false; - else if (!ajaxRefreshField(12, "resultCatalogMode", fieldsList, "validateCatalogMode")) validCatalogMode = false; + if (!ajaxRefreshField(ret, 'infosShop', 'resultInfosShop')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosCountry', 'resultInfosCountry')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosTimezone', 'resultInfosTimezone')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'validateShop', 'resultInfosShop')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosFirstname', 'resultInfosFirstname')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosName', 'resultInfosName')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosEmail', 'resultInfosEmail')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosPassword', 'resultInfosPassword')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosPasswordRepeat', 'resultInfosPasswordRepeat')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosLanguages', 'resultInfosLanguages')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosSQL', 'resultInfosSQL')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'infosNotification', 'resultInfosNotification')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'validateFirstname', 'resultInfosFirstname')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'validateName', 'resultInfosName')) validShopInfos = false; + else if (!ajaxRefreshField(ret, 'validateCatalogMode', 'resultCatalogMode')) validCatalogMode = false; else { $('#endShopName').html($('input#infosShop').val()); @@ -721,15 +738,10 @@ function verifyShopInfos() ); } -function autoCheckField(idField, idResultSpan, typeVerif) +function checkRequired(idResultSpan, resValue) { - switch (typeVerif) + if(resValue == "") { - case "required" : - $(idField).blur(function() - { - if($(this).val() == "") - { $(idResultSpan) .show("slow") .addClass("errorBlock") @@ -743,7 +755,15 @@ function autoCheckField(idField, idResultSpan, typeVerif) .html(""); } } - ); + +function autoCheckField(idField, idResultSpan, typeVerif) +{ + switch (typeVerif) + { + case "required" : + $(idField).blur(function() { checkRequired(idResultSpan, $(this).val()); }); + if (idField == '#infosCountry' || idField == '#infosTimezone') + $(idField).change(function() { checkRequired(idResultSpan, $(this).val()); }); break; case "mailFormat" : @@ -998,6 +1018,8 @@ $(document).ready( //autocheck fields autoCheckField("#infosShop", "#resultInfosShop", "required"); autoCheckField("#infosFirstname", "#resultInfosFirstname", "firstnameFormat"); + autoCheckField("#infosCountry", "#resultInfosCountry", "required"); + autoCheckField("#infosTimezone", "#resultInfosTimezone", "required"); autoCheckField("#infosName", "#resultInfosName", "nameFormat"); autoCheckField("#infosEmail", "#resultInfosEmail", "mailFormat"); autoCheckField("#infosPassword", "#resultInfosPassword", "required"); diff --git a/install-dev/index.php b/install-dev/index.php index db6363f03..f2e855564 100644 --- a/install-dev/index.php +++ b/install-dev/index.php @@ -124,10 +124,10 @@ if ($lm->getIncludeTradFilename()) //php to js vars var isoCodeLocalLanguage = "getIsoCodeSelectedLang(); ?>"; var ps_base_uri = ""; - var id_lang = ""; + var id_lang = ; //localWords - var Step1Title = ""; + var Step1Title = ""; var step2title = ""; var step3title = ""; var step4title = ""; @@ -268,6 +268,11 @@ if ($lm->getIncludeTradFilename())
'.lang('Contact us!').'
'.lang('+33 (0)1.40.18.30.04'); ?>
+ getIsoCodeSelectedLang() == 'en'): ?> +
  • +
    '.lang('Contact us!').'
    '.lang('+1 (888) 947-6543'); ?>
    +
  • + @@ -311,7 +316,8 @@ if ($lm->getIncludeTradFilename())
    -

    +

    +


      @@ -326,9 +332,9 @@ if ($lm->getIncludeTradFilename())

        - getAvailableLangs() as $lang): ?> + getAvailableLangs() AS $lang): ?>
      • getIdSelectedLang() ) ? "checked=\"checked\"" : '' ?> id="lang_" name="language" style="vertical-align: middle; margin-right: 0;" />
      • @@ -639,16 +645,20 @@ if ($lm->getIncludeTradFilename())
        - + * +
        - + * +
        @@ -737,6 +747,11 @@ if ($lm->getIncludeTradFilename()) $(".installModuleList.selected").removeClass("selected"); if ($("#modulesList" + $('select#infosCountry option:selected').attr('rel'))) $("#modulesList" + $('select#infosCountry option:selected').attr('rel')).addClass("selected"); + $('#benefitsBlock').show(); + if ($('div .installModuleList:visible').length == 0) + $('#benefitsBlock').hide(); + else + $('#benefitsBlock').show(); $.ajax({ type: "GET", url: "./php?controller=country_to_timezone.php?country="+$("select#infosCountry option:selected").attr('rel'), @@ -744,6 +759,9 @@ if ($lm->getIncludeTradFilename()) $("select#infosTimezone").val(timezone); } }); + + autoCheckField("#infosCountry", "#resultInfosCountry", "required"); + autoCheckField("#infosTimezone", "#resultInfosTimezone", "required"); }); }); @@ -769,35 +787,36 @@ if ($lm->getIncludeTradFilename()) $result = simplexml_load_string($content); if ($result->partner) { - echo ' -

        '.lang('Additional Benefits').'

        -

        '.lang('Exclusive offers dedicated to PrestaShop merchants').'

        '; - $modulesHelpInstall = array(); $modulesDescription = array(); $modulesPrechecked = array(); - foreach ($result->partner as $p) + foreach ($result->partner AS $p) { $modulesDescription[trim($p->key)] = array('name' => trim($p->label), 'logo' => trim($p->logo_medium), 'label' => getPreinstallXmlLang($p, 'label'), 'description' => getPreinstallXmlLang($p, 'description'), 'more' => getPreinstallXmlLang($p, 'more')); - foreach ($p->country as $country_iso_code) + foreach ($p->country AS $country_iso_code) $modulesHelpInstall[trim($country_iso_code)][] = trim($p->key); if ($p->prechecked) - foreach ($p->prechecked as $country_iso_code) + foreach ($p->prechecked AS $country_iso_code) $modulesPrechecked[trim($p->key)][trim($country_iso_code)] = 1; } - echo ' + + if (sizeof($modulesHelpInstall)) + { + echo ' +

        '.lang('Additional Benefits').'

        +

        '.lang('Exclusive offers dedicated to PrestaShop merchants').'

        +
        - - + + -
        ModulesAvantages'.lang('Modules').''.lang('Benefits').'
        - '; + '; - foreach ($modulesHelpInstall as $country_iso_code => $modulesList) + foreach ($modulesHelpInstall AS $country_iso_code => $modulesList) { echo '
        '; - foreach ($modulesList as $module) + foreach ($modulesList AS $module) { echo ' @@ -881,6 +900,7 @@ if ($lm->getIncludeTradFilename()) } } } + } ?> @@ -891,7 +911,7 @@ if ($lm->getIncludeTradFilename())
        - getAvailableLangs() as $lang){ + getAvailableLangs() AS $lang){ if ( $lang['id'] == $lm->getIdSelectedLang() AND $lang['id'] != "0" ){ ?> @@ -916,7 +936,7 @@ if ($lm->getIncludeTradFilename())
        '; + if (Tools::getValue('section') == 'sync') + $html .= ''; if (Configuration::get('EBAY_SYNC_MODE') == 'B') { @@ -1299,10 +1301,7 @@ class Ebay extends Module $(document).ready(function() { $("#catSync").show("slow"); $("#ebay_sync_mode2").attr("checked", true); - '; - if (Tools::getValue('section') == 'sync') - $html .= 'eBaySync();'; - $html .= '}); + }); '; } diff --git a/modules/ekomi/config.xml b/modules/ekomi/config.xml index 7b8783a13..d644e95b9 100644 --- a/modules/ekomi/config.xml +++ b/modules/ekomi/config.xml @@ -2,7 +2,7 @@ ekomi - + diff --git a/modules/ekomi/ekomi.php b/modules/ekomi/ekomi.php index fa7f98f3d..d410c863d 100755 --- a/modules/ekomi/ekomi.php +++ b/modules/ekomi/ekomi.php @@ -37,7 +37,7 @@ class Ekomi extends Module { $this->name = 'ekomi'; $this->tab = 'advertising_marketing'; - $this->version = 1.0; + $this->version = 1.1; $this->need_instance = 0; parent::__construct(); @@ -83,9 +83,9 @@ class Ekomi extends Module

        - + - +

        '.$this->l('Show or don\'t show the block (orders will be sent to eKomi whether you choose to hide or display the block).').'

        diff --git a/modules/importerosc/importerosc.php b/modules/importerosc/importerosc.php index 2743f5e7a..4a2ad6a33 100644 --- a/modules/importerosc/importerosc.php +++ b/modules/importerosc/importerosc.php @@ -307,7 +307,6 @@ class importerosc extends ImportModule { $combination['association'] = array('product_attribute_combination' => array($combination['options_values_id'] => $combination['id_product_attribute'])); unset($combination['options_values_price']); - unset($combination['options_values_id']); } return $this->autoFormat($combinations, $identifier); } @@ -454,6 +453,34 @@ class importerosc extends ImportModule } + public function displayConfigConnector() + { + $content = ' +
        + +

        '.$this->l('(eg : mysql.mydomain.com)').'

        +
        + +
        + +
        + +
        + +

        '.$this->l('(password can be empty)').'

        +
        + +
        + +
        + +
        + +

        '.$this->l('(The prefix is optional. If all of your database tables start with "pref_", your prefix is "pref_")').'

        +
        '; + return $content; +} + } ?> diff --git a/modules/mondialrelay/classes/MRCreateTickets.php b/modules/mondialrelay/classes/MRCreateTickets.php index 0c21a41f0..f2547ab3d 100755 --- a/modules/mondialrelay/classes/MRCreateTickets.php +++ b/modules/mondialrelay/classes/MRCreateTickets.php @@ -275,7 +275,6 @@ class MRCreateTickets implements IMondialRelayWSMethod $this->_fields['list']['Enseigne']['value'] = Configuration::get('MR_ENSEIGNE_WEBSERVICE'); $this->_fields['list']['Expe_Langage']['value'] = Configuration::get('MR_LANGUAGE'); - var_dump(Configuration::get('MR_LANGUAGE')); $this->_fields['list']['Expe_Ad1']['value'] = Configuration::get('PS_MR_SHOP_NAME'); $this->_fields['list']['Expe_Ad3']['value'] = Configuration::get('PS_SHOP_ADDR1'); // Deleted, cause to many failed for the process diff --git a/modules/mondialrelay/classes/MRTools.php b/modules/mondialrelay/classes/MRTools.php index 3baa6a9d1..7b96d20e1 100755 --- a/modules/mondialrelay/classes/MRTools.php +++ b/modules/mondialrelay/classes/MRTools.php @@ -32,10 +32,17 @@ class MRTools { static public function replaceAccentedCharacters($string) { + if (function_exists('iconv')) + { $currentLocale = setlocale(LC_ALL, NULL); setlocale(LC_ALL, 'en_US.UTF8'); $cleanedString = iconv('UTF-8','ASCII//TRANSLIT', $string); setLocale(LC_ALL, $currentLocale); + } + else + $cleanedString = strtr($string, + 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ', + 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'); return $cleanedString; } @@ -48,8 +55,9 @@ class MRTools FROM `'._DB_PREFIX_.'country` WHERE `id_country` = '.(int)$id_country); + // Skip the cheking format if doesn't exist if (!$zipcodeFormat) - return false; + return true; $regxMask = str_replace( array('N', 'C', 'L'), @@ -64,4 +72,4 @@ class MRTools } } -?> \ No newline at end of file +?> diff --git a/modules/mondialrelay/style.css b/modules/mondialrelay/style.css index cd72e769c..f114ed7df 100755 --- a/modules/mondialrelay/style.css +++ b/modules/mondialrelay/style.css @@ -277,11 +277,12 @@ tr.PS_MRSelectedCarrier > td .PS_MRFloatRelayPointSelected a.PS_MRSelectRelayPointButton { + font-size: 10px; float:right; display: block; width: 60px; height: 20px; - padding: 6px 20px 0px 25px; + padding: 7px 20px 0px 25px; text-decoration: none; margin-top: 8px; color:#333333; @@ -313,4 +314,15 @@ div.PS_MRGmapStyle div#PS_MRPersonalizedFields { display:none; -} \ No newline at end of file +} + +.clearfix:before, +.clearfix:after +{ + content: "."; + display: block; + height: 0; + overflow: hidden +} +.clearfix:after {clear: both} +.clearfix {zoom: 1} diff --git a/modules/paypal/config.xml b/modules/paypal/config.xml index 6eea0c3ae..2d3989ea6 100755 --- a/modules/paypal/config.xml +++ b/modules/paypal/config.xml @@ -2,7 +2,7 @@ paypal - + diff --git a/modules/paypal/integral_evolution/redirect.tpl b/modules/paypal/integral_evolution/redirect.tpl index 3843b6aa6..6d14c2654 100644 --- a/modules/paypal/integral_evolution/redirect.tpl +++ b/modules/paypal/integral_evolution/redirect.tpl @@ -76,6 +76,7 @@ {if $header != NULL} + {/if} diff --git a/modules/paypal/paypal.php b/modules/paypal/paypal.php index a5a2928dd..6a609dd8d 100644 --- a/modules/paypal/paypal.php +++ b/modules/paypal/paypal.php @@ -40,7 +40,7 @@ class PayPal extends PaymentModule { $this->name = 'paypal'; $this->tab = 'payments_gateways'; - $this->version = '2.8'; + $this->version = '2.8.1'; $this->currencies = true; $this->currencies_mode = 'radio'; diff --git a/modules/productscategory/productscategory.tpl b/modules/productscategory/productscategory.tpl index b0ed55cec..bcb4e504f 100644 --- a/modules/productscategory/productscategory.tpl +++ b/modules/productscategory/productscategory.tpl @@ -24,7 +24,7 @@ * International Registered Trademark & Property of PrestaShop SA *} -{if count($categoryProducts) > 0} +{if count($categoryProducts) > 0 && $categoryProducts !== false}

        {$categoryProducts|@count} {l s='other products in the same category:' mod='productscategory'}

        {if count($categoryProducts) > 5}{l s='Previous' mod='productscategory'}{/if} diff --git a/modules/shopimporter/ajax.php b/modules/shopimporter/ajax.php index db4602624..2be77de74 100644 --- a/modules/shopimporter/ajax.php +++ b/modules/shopimporter/ajax.php @@ -20,6 +20,10 @@ $database = Tools::getValue('database'); $prefix = Tools::getValue('prefix'); $save = Tools::getValue('save'); +$url = Tools::getValue('url'); +$loginws = Tools::getValue('loginws'); +$apikey = Tools::getValue('apikey'); + if (Tools::isSubmit('checkAndSaveConfig')) { //cleans the database if an import has already been done @@ -69,6 +73,35 @@ if (Tools::isSubmit('getData') || Tools::isSubmit('syncLang') || Tools::isSubmit } } } +if (Tools::isSubmit('getDataWS') || Tools::isSubmit('syncLangWS') || Tools::isSubmit('syncCurrencyWS')) +{ + if (Tools::isSubmit('syncLangWS')) + $save = true; + + if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) + { + require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php'); + + try + { + $importModule = new $moduleName(); + $importModule->connect($url,$loginws,$apikey); + + if (!method_exists($importModule, $getMethod)) + die('{"hasError" : true, "error" : ["not_exist"], "datas" : []}'); + else + { + $return = call_user_func_array(array($importModule, $getMethod), array($limit, $nbr_import)); + $shopImporter = new shopImporter(); + $shopImporter->generiqueImport($className, $return, (bool)$save); + } + die('{"hasError" : false, "error" : []}'); + } catch (Exception $e) + { + die('{"hasError" : true, "error" : ['.json_encode($e->getMessage()).'], "datas" : []}'); + } + } +} if (Tools::isSubmit('truncatTable')) { @@ -114,6 +147,43 @@ if (Tools::isSubmit('displaySpecificOptions')) die(Tools::displayError('Link to database cannot be established.')); } } +elseif (Tools::isSubmit('displaySpecificOptionsWsdl')) +{ + if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) + { + require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php'); + $importModule = new $moduleName(); + + try + { + if (method_exists($importModule, 'displaySpecificOptions')) + die($importModule->displaySpecificOptions()); + else + die('not_exist'); + } catch (Exception $e) + { + die('{"hasError" : true, "error" : ['.json_encode($e->getMessage()).'], "datas" : []}'); + } + } +} +if (Tools::isSubmit('connexionWs')) +{ + if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) + { + require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php'); + try + { + + $importModule = new $moduleName(); + $importModule->connect($url,$loginws,$apikey); + die('{"hasError" : false, "error" : []}'); + } catch (Exception $e) + { + die('{"hasError" : true, "error" : ['.json_encode($e->getMessage()).'], "datas" : []}'); + } + } +} + if (Tools::isSubmit('validateSpecificOptions')) { if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) @@ -126,5 +196,16 @@ if (Tools::isSubmit('validateSpecificOptions')) die($importModule->validateSpecificOptions()); } } - +if (Tools::isSubmit('displayConfigConnector')) +{ + if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) + { + require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php'); + $importModule = new $moduleName(); + if (!method_exists($importModule, 'displayConfigConnector')) + die('{"hasError" : true, "error" : ["not_exist"]}'); + else + die($importModule->displayConfigConnector()); + } +} ?> diff --git a/modules/shopimporter/shopimporter.js b/modules/shopimporter/shopimporter.js index f8e2bc05f..badd18ad3 100644 --- a/modules/shopimporter/shopimporter.js +++ b/modules/shopimporter/shopimporter.js @@ -6,6 +6,9 @@ var shopImporter = { password: $('#password').val(), database: $('#database').val(), prefix: $('#prefix').val(), + url: $('#url').val(), + loginws: $('#loginws').val(), + apikey: $('#apikey').val(), specificOptions : '', imagesOptions : '', output : 1, @@ -22,6 +25,37 @@ var shopImporter = { srcDelete : '../modules/shopimporter/img/delete.gif', + syncLangWS : function (onComplete) + { + + $.ajax({ + type: 'GET', + url: '../modules/shopimporter/ajax.php', + async: false, + cache: false, + dataType : "json", + data: 'ajax=true&syncLangWS&getMethod=getLangagues&token='+this.token+'&className=Language&moduleName='+this.moduleName+'&url='+this.url+'&loginws='+this.loginws+'&apikey='+this.apikey+'&nbr_import='+this.nbr_import , + success: function(jsonData) + { + if (jsonData.hasError) + { + $('#steps').html(''); + $('#lang_feedback').fadeIn('slow'); + onComplete(false); + } + else + onComplete(true); + + }, + error: function(XMLHttpRequest, textStatus, errorThrown) + { + $('#steps').html($('#steps').html()+''); + $('#technical_error_feedback').fadeIn('slow'); + onComplete(false); + } + }); + + }, syncLang : function (onComplete) { $.ajax({ @@ -51,6 +85,36 @@ var shopImporter = { } }); + }, + syncCurrencyWS : function (onComplete) + { + $.ajax({ + type: 'GET', + url: '../modules/shopimporter/ajax.php', + async: false, + cache: false, + dataType : "json", + data: 'ajax=true&token='+this.token+'&syncCurrencyWS&getMethod=getCurrencies&className=Currency&moduleName='+this.moduleName+'&url='+this.url+'&loginws='+this.loginws+'&apikey='+this.apikey+'&nbr_import='+this.nbr_import , + success: function(jsonData) + { + if (jsonData.hasError) + { + $('#steps').html(''); + $('#currency_feedback').fadeIn('slow'); + onComplete(false); + } + else + onComplete(true); + + }, + error: function(XMLHttpRequest, textStatus, errorThrown) + { + $('#steps').html($('#steps').html()+''); + $('#technical_error_feedback').fadeIn('slow'); + onComplete(false); + } + }); + }, syncCurrency : function (onComplete) { @@ -81,6 +145,78 @@ var shopImporter = { } }); + }, + checkAndSaveConfigWSDL : function (onComplete) + { + $('#checkAndSaveConfig').fadeOut('slow'); + $('#steps').html($('#steps').html()+''); + $('#steps').html($('#steps').html()+''); + $('#next').fadeIn('slow', function () { + $('#next').unbind('click').click(function(){ + $('#next').fadeOut('fast', function() { + shopImporter.nbrMethod = conf.length; + shopImporter.getDatasWS(conf[shopImporter.idMethod]); + }); + return false; + }); + }); + $('#database_feedback').fadeIn('slow'); + + }, + checkAndSaveConfigWS : function (save) + { + + //sync languages and currency + this.syncLangWS(function(isOk) { + if (isOk) + { + shopImporter.syncCurrencyWS(function(isOk) { + if (isOk) + { + + if ($('#technical_error_feedback').length) + $('#technical_error_feedback').fadeIn('slow'); + + + $('#checkAndSaveConfig').fadeOut('slow'); + $('#steps').html($('#steps').html()+''); + $('#steps').html($('#steps').html()+''); + $('#database_feedback').fadeIn('slow', function() { + if (save) + { + shopImporter.idMethod = 0; + shopImporter.limit = 0; + shopImporter.nbrMethod = conf.length; + $('.truncateTable:checked').each(function (){ + shopImporter.truncatTable(this.id, 'add'); + }); + + if($('#truncat_feedback').length != 0) + $('#truncat_feedback').removeClass('import').addClass('conf'); + + shopImporter.getDatasWS(conf[shopImporter.idMethod]); + } + else + { + $('#next').fadeIn('slow', function () { + $('#next').unbind('click').click(function(){ + $('#next').fadeOut('fast', function() { + shopImporter.nbrMethod = conf.length; + shopImporter.getDatasWS(conf[shopImporter.idMethod]); + }); + + }); + }); + } + }); + } + }); + } + }); + + + + }, checkAndSaveConfig : function (save) { @@ -158,6 +294,123 @@ var shopImporter = { }, + getDatasWS : function (methodName) + { + //check if method have to be call + if (shopImporter.idMethod >= shopImporter.nbrMethod) + shopImporter.displayEnd(false); + else if ($('input[name='+methodName[0]+']:radio:checked').val() == 0) + { + shopImporter.idMethod ++; + shopImporter.getDatasWS(conf[shopImporter.idMethod]); + return; + } + if (typeof(methodName) != 'undefined') + { + + $('#steps').html($('#steps').html()+''); + $('#ok_feedback_'+methodName[0]).css('display', ''); + + $('#checkAndSaveConfig').fadeIn('slow'); + $.ajax({ + type: 'GET', + url: '../modules/shopimporter/ajax.php', + async: true, + cache: false, + dataType : "json", + //data: 'ajax=true&token='+this.token+'&getData&className='+methodName[2]+'&getMethod='+methodName[0]+'&moduleName='+this.moduleName+'&server='+this.server+'&user='+this.user+'&password='+this.password+'&database='+this.database+'&prefix='+prefix+'&limit='+this.limit+'&nbr_import='+this.nbr_import+'&save='+this.save+'&errors='+this.errors+'&hasErrors='+this.hasErrors+this.specificOptions+this.imagesOptions , + + + data: 'ajax=true&token='+this.token+'&getDataWS&className='+methodName[2]+'&getMethod='+methodName[0]+'&moduleName='+this.moduleName+'&url='+this.url+'&loginws='+this.loginws+'&apikey='+this.apikey+'&limit='+this.limit+'&nbr_import='+this.nbr_import+'&save='+this.save+'&errors='+this.errors+'&hasErrors='+this.hasErrors+this.specificOptions+this.imagesOptions , + success: function(jsonData) + { + var jsonError; + if (jsonData.hasError) + { + jsonError = ''; + if (jsonData.error == 'not_exist') + { + $('#ok_feedback_'+methodName[0]).removeClass('conf').addClass(function() { + $('#ok_feedback_'+methodName[0]).html(''+methodName[1]+' '+notExist); + return 'warn'; + }); + } + else + { + for (i=0;iId : '+jsonData.error[i]+''; + + if ($('#display_error_'+methodName[0]+'_link').length == 0) + { + $('#ok_feedback_'+methodName[0]).html($('#ok_feedback_'+methodName[0]).html()+''+showErrors+'('+jsonData.error.length+')'+''); + } + else + { + var nbrErrors = $('#nbr_errors_'+methodName[0]).html(); + var newNbrError = parseInt(jsonData.error.length) + parseInt(nbrErrors); + $('#nbr_errors_'+methodName[0]).html(newNbrError); + $('#feedback_'+methodName[0]+'_errors_list > ul').html($('#feedback_'+methodName[0]+'_errors_list > ul').html() + jsonError); + } + } + + if (jsonData.datas.length != parseInt(shopImporter.nbr_import)) + { + if ($('#display_error_'+methodName[0]+'_link').length != 0) + $('#ok_feedback_'+methodName[0]).removeClass('import').addClass( function() { + $('#ok_feedback_'+methodName[0]+' >img:first').attr('src', shopImporter.srcError); + return 'error'; + }); + shopImporter.idMethod ++; + shopImporter.limit = 0; + } + else + shopImporter.limit += parseInt(shopImporter.nbr_import); + if ((shopImporter.idMethod < shopImporter.nbrMethod)) + shopImporter.getDatasWS(conf[shopImporter.idMethod]); + else + shopImporter.displayEnd(false); + } + else + { + if (jsonData.datas.length != parseInt(shopImporter.nbr_import)) + { + if ($('#display_error_'+methodName[0]+'_link').length != 0) + { + $('#ok_feedback_'+methodName[0]).removeClass('import').addClass( function() { + $('#ok_feedback_'+methodName[0]+' >img:first').attr('src', shopImporter.srcError); + return 'error'; + }); + }else + { + $('#ok_feedback_'+methodName[0]).removeClass('import').addClass('conf'); + $('#ok_feedback_'+methodName[0]+'>img:first').attr('src', shopImporter.srcConf); + } + shopImporter.idMethod ++; + shopImporter.limit = 0; + + shopImporter.getDatasWS(conf[shopImporter.idMethod]); + } + else + { + if (shopImporter.idMethod < shopImporter.nbrMethod) + { + shopImporter.limit += parseInt(shopImporter.nbr_import); + shopImporter.getDatasWS(conf[shopImporter.idMethod]); + } + else + shopImporter.displayEnd(true); + } + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) + { + $('#steps').html($('#steps').html()+''); + $('#technical_error_feedback').fadeIn('slow'); + $('#checkAndSaveConfig').fadeIn('slow'); + } + }); + } + }, getDatas : function (methodName) { //check if method have to be call @@ -336,13 +589,17 @@ var shopImporter = { } else { - $('#steps').html($('#steps').html()+''); + + $('#steps').html($('#steps').html()+''); $('#submitImport').fadeIn('slow', function() { $(this).unbind('click').click(function() { $.scrollTo($("#steps"), 300 , { onAfter:function(){ $('#steps').html(''); shopImporter.save = 1; + if($('#import_module_name').attr('value') == 'importermagento') + shopImporter.checkAndSaveConfigWS(shopImporter.save); + else if ($('#import_module_name').attr('value') == 'importerosc') shopImporter.checkAndSaveConfig(shopImporter.save); } }); @@ -388,6 +645,7 @@ function displaySpecificOptions(moduleName, server, user, password, database, pr { $('#specificOptionsContent').html(htmlData); $('#specificOptions').show(); + $('#importOptions').show(); } }, error: function(XMLHttpRequest, textStatus, errorThrown) @@ -396,6 +654,69 @@ function displaySpecificOptions(moduleName, server, user, password, database, pr } }); } +function initConnexion (moduleName, url, loginws, apikey, token) +{ + $.ajax({ + type: 'GET', + url: '../modules/shopimporter/ajax.php', + async: false, + cache: false, + dataType : "json", + data: 'ajax=true&token='+token+'&connexionWs&moduleName='+moduleName+'&url='+ url+'&loginws='+loginws+'&apikey='+apikey , + success: function(jsonData) + { + var jsonError = ''; + $('#connectionInformation').removeAttr('style'); + if (jsonData.hasError) + { + $('#connectionInformation').attr("style","width: 400px;background-color: #FAE2E3;border: 1px solid #EC9B9B"); + for (i=0;i'+jsonData.error[i]+''; + $('#connectionInformation').slideDown('slow'); + $('#connectionInformation').html('
          '+jsonError+'
        '); + $('#connectionInformation').show(); + }else + { + + $('#connectionInformation').attr("style","width: 400px;background-color: #DFFAD3;border: 1px solid #72CB67"); + $('#connectionInformation').slideDown('slow'); + $('#connectionInformation').html('
          Connection successful
        '); + $('#connectionInformation').show(); + $('#importOptions').show(); + displaySpecificOptionsWsdl(moduleName, token); + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) + { + alert('TECHNICAL ERROR\nDetails:\nError thrown: ' + XMLHttpRequest + '\n' + 'Text status: ' + textStatus); + + } + }); +} + +function displaySpecificOptionsWsdl(moduleName,token) +{ + + $.ajax({ + type: 'GET', + url: '../modules/shopimporter/ajax.php', + async: false, + cache: false, + dataType : "html", + data: 'ajax=true&token='+token+'&displaySpecificOptionsWsdl&moduleName='+moduleName , + success: function(htmlData) + { + $('#specificOptionsContent').html(htmlData); + $('#specificOptions').show(); + $('#displayOptions').hide(); + $('#importOptions').show(); + }, + error: function(XMLHttpRequest, textStatus, errorThrown) + { + alert('TECHNICAL ERROR\nDetails:\nError thrown: ' + XMLHttpRequest + '\n' + 'Text status: ' + textStatus); + } + }); +} function validateSpecificOptions(moduleName, specificOptions) { $.ajax({ @@ -428,9 +749,51 @@ function validateSpecificOptions(moduleName, specificOptions) return true; } +//init configuration connector (database or webservice) +function initConfigConnector() +{ + if($('#choose_module_name').attr('value')) + { + $('#db_config').hide(); + $('#importOptions').hide(); + $('#steps').html(''); + + if ($('#import_module_name').attr('value') != 0) + { + $('#displayOptions').show(); + $.ajax({ + type: 'GET', + url: '../modules/shopimporter/ajax.php', + async: false, + cache: false, + dataType : "html", + + data: 'ajax=true&token='+globalAjaxShopImporterToken+'&displayConfigConnector&moduleName='+$('#import_module_name').val() , + success: function(html) + { + $('#config_connector').html(html); + $('#config_connector').show(); + $('#db_config').slideDown('slow'); + $('#displayOptions').show(); + $('#checkAndSaveConfig').show(); + }, + error: function(XMLHttpRequest, textStatus, errorThrown) + { + alert('TECHNICAL ERROR\nDetails:\nError thrown: ' + XMLHttpRequest + '\n' + 'Text status: ' + textStatus); + } + }); + } + else + { + $('#db_config').slideUp('slow'); + $('#checkAndSaveConfig').show(); + + } + } +} $(document).ready(function(){ - + $('#displayOptions').hide(); $('#db_input input').each(function () { $(this).keyup(function () { $('#steps').fadeOut(200, function () { @@ -454,26 +817,31 @@ $(document).ready(function(){ }); $('#choose_module_name').unbind('click').click(function(){ - $('#db_config').hide(); - $('#importOptions').hide(); - $('#steps').html(''); - if ($('#import_module_name').attr('value') != 0) - { - $('#db_config').slideDown('slow'); - $('#displayOptions').show(); - $('#checkAndSaveConfig').show(); - } - else - { - $('#db_config').slideUp('slow'); - $('#checkAndSaveConfig').show(); - } - return false; + initConfigConnector(); }); $('#displayOptions').unbind('click').click(function(){ - $(this).fadeOut('slow'); - $('#importOptions').slideDown('slow'); + $('#displayOptions').show(); + if($('#import_module_name').attr('value') == 'importermagento') + { + if($('#loginws').val() == '' || $('#apikey').val() == '' || $('#url').val() == '') + { + $('#connectionInformation').slideDown('slow'); + $('#connectionInformation').html('Url wsdl, User name,API key are required fields'); + $('#connectionInformation').show(); + return false; + }else{ + $('#connectionInformation').hide(); + + + } + token = globalAjaxShopImporterToken; + initConnexion($('#import_module_name').val(), $('#url').val(), $('#loginws').val(), $('#apikey').val(), token); + + return false; + } + else if ($('#import_module_name').attr('value') == 'importerosc') + { moduleName = $('#import_module_name').val(); server = $('#server').val(); user = $('#user').val(); @@ -482,6 +850,10 @@ $(document).ready(function(){ prefix = $('#prefix').val(); token = globalAjaxShopImporterToken; displaySpecificOptions(moduleName, server, user, password, database, prefix, token); + } + $(this).fadeOut('slow'); + $('#importOptions').slideDown('slow'); + return false; }); @@ -499,6 +871,8 @@ $(document).ready(function(){ moduleName = $('#import_module_name').val(); if (validateSpecificOptions(moduleName, shopImporter.specificOptions) == true) { + if($('#import_module_name').attr('value') == 'importermagento') + { $.scrollTo($("#steps"), 300 , { onAfter:function(){ shopImporter.specificOptions = ''; @@ -509,7 +883,33 @@ $(document).ready(function(){ shopImporter.limit = 0; shopImporter.nbr_import = parseInt($('#nbr_import').val()); shopImporter.save = 0; + shopImporter.moduleName = $('#import_module_name').val(); + shopImporter.url = $('#url').val(); + shopImporter.loginws = $('#loginws').val(); + shopImporter.apikey = $('#apikey').val(); + + shopImporter.token = globalAjaxShopImporterToken; + shopImporter.hasErrors = $('input[name=hasErrors]:radio:checked').val(); + + shopImporter.checkAndSaveConfigWS(shopImporter.save); + shopImporter.checkAndSaveConfigWSDL(); + return false; + } + }); + }else if ($('#import_module_name').attr('value') == 'importerosc') + { + $.scrollTo($("#steps"), 300 , { + onAfter:function(){ + shopImporter.specificOptions = ''; + $('#specificOptionsContent :input').each(function (){ + shopImporter.specificOptions = shopImporter.specificOptions+'&'+$(this).attr('name')+'='+$(this).attr('value'); + }); + shopImporter.idMethod = 0; + shopImporter.limit = 0; + shopImporter.nbr_import = parseInt($('#nbr_import').val()); + shopImporter.save = 0; + shopImporter.moduleName = $('#import_module_name').val(); shopImporter.server = $('#server').val(); shopImporter.user = $('#user').val(); shopImporter.password = $('#password').val(); @@ -522,6 +922,7 @@ $(document).ready(function(){ } }); } + } }); diff --git a/modules/shopimporter/shopimporter.php b/modules/shopimporter/shopimporter.php index c2a11d922..9b93033a0 100644 --- a/modules/shopimporter/shopimporter.php +++ b/modules/shopimporter/shopimporter.php @@ -207,7 +207,7 @@ class shopimporter extends ImportModule 'table' => 'product', 'identifier' => 'id_product', 'alterTable' => array('id_product' => 'int(10)'), - 'foreign_key' => array('id_category'), + 'foreign_key' => array('id_category', 'id_manufacturer'), 'delete' => true, 'association' => array( array( @@ -306,6 +306,7 @@ class shopimporter extends ImportModule $html .= ' var notExist = "'.$this->l('is not available in this module').'"; var databaseOk = "'.$this->l('Connection to the database OK').'"; + var wsOk = "'.$this->l('Connection to the web service OK').'"; var showErrors = "'.$this->l('Show errors').'"; var testImport = "'.$this->l('Test import process').'"; var runImport = "'.$this->l('Run Import').'"; @@ -343,33 +344,9 @@ class shopimporter extends ImportModule else $html .= '
        '.$this->l('No import module installed').'
        '; $html .= ' -