// Removed deprecated modules

This commit is contained in:
Damien Metzger
2013-10-17 09:36:45 +02:00
parent 2f34af4646
commit fba95afdcc
26 changed files with 0 additions and 3747 deletions
-17
View File
@@ -1,17 +0,0 @@
<?php
include_once('../../config/config.inc.php');
include_once('../../init.php');
include_once('../../modules/importerosc/importerosc.php');
if (!Tools::getValue('ajax') || Tools::getValue('token') != sha1(_COOKIE_KEY_.'importosc'))
die('INVALID TOKEN');
$importOsc = new importerosc();
$importOsc->server = Tools::getValue('server');
$importOsc->user = Tools::getValue('user');
$importOsc->passwd = Tools::getValue('password');
$importOsc->database = Tools::getValue('database');
$importOsc->prefix = Tools::getValue('prefix');
die($importOsc->createLevelAndCalculate());
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>importerosc</name>
<displayName><![CDATA[Importer osCommerce]]></displayName>
<version><![CDATA[1.0]]></version>
<description><![CDATA[This module allows you to import from osCommerce to Prestashop.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[migration_tools]]></tab>
<is_configurable>0</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
-631
View File
@@ -1,631 +0,0 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_'))
exit;
class importerosc extends ImportModule
{
public function __construct()
{
$this->name = 'importerosc';
$this->tab = 'migration_tools';
$this->version = '1.0';
$this->author = 'PrestaShop';
$this->theImporter = 1;
$this->need_instance = 1;
parent::__construct ();
$this->displayName = $this->l('Importer osCommerce');
$this->description = $this->l('This module allows you to import from osCommerce to Prestashop.');
}
public function install()
{
if (!parent::install() || !$this->registerHook('beforeAuthentication'))
return false;
return true;
}
public function uninstall()
{
if (!parent::uninstall())
return false;
return true;
}
public function displaySpecificOptions()
{
$html = '';
if (!$this->checkCategoriesLevel())
$html .= $this->displayCategoriesLevelConf();
$langagues = $this->executeS('SELECT * FROM `'.bqSQL($this->prefix).'languages`');
$curencies = $this->executeS('SELECT * FROM `'.bqSQL($this->prefix).'currencies`');
$html .= '<label style=\'width:220px\'>'.$this->l('Default osCommerce language : ').'</label>
<div class="margin-form">
<select name=\'defaultOscLang\'><option value=\'0\'>------</option>';
foreach($langagues AS $lang)
$html .= '<option value="'.$lang['languages_id'].'">'.$lang['name'].'</option>';
$html .= '</select></div>
<label style=\'width:220px\'>'.$this->l('Default osCommerce currency : ').'</label>
<div class=\'margin-form\'>
<select name=\'defaultOscCurrency\'><option value=\'0\'>------</option>';
foreach($curencies AS $curency)
$html .= '<option value=\''.$curency['currencies_id'].'\'>'.$curency['title'].'</option>';
$html .= '</select></div>';
$html .= '<label style=\'width:220px\'>'.$this->l('Shop url : ').'</label>
<div class=\'margin-form\'>
http://<input type="text" name="shop_url">/
<p>'.$this->l('Specify the root URL of your site oscommerce').'</p>
</div>';
return $html;
}
public function validateSpecificOptions()
{
$errors = array();
if (Tools::getValue('defaultOscLang') == 0)
$errors[] = $this->l('Please select a default language');
if (Tools::getValue('defaultOscCurrency') == 0)
$errors[] = $this->l('Please select a default currency');
if (Tools::getValue('shop_url') == '')
$errors[] = $this->l('Please set your shop url');
if (!sizeof($errors))
die('{"hasError" : false, "error" : []}');
else
die('{"hasError" : true, "error" : '.Tools::jsonEncode($errors).'}');
}
public function getDefaultIdLang ()
{
return Tools::getValue('defaultOscLang');
}
public function getDefaultIdCurrency ()
{
return Tools::getValue('defaultOscCurrency');
}
public function getLangagues($limit = 0, $nrb_import = 100)
{
$identifier = 'id_lang';
$langagues = $this->executeS('
SELECT languages_id as id_lang, name as name, code as iso_code, 1 as active, (\'m/j/Y\') as date_format_lite, (\'m/j/Y H:i:s\') as date_format_full
FROM `'.bqSQL($this->prefix).'languages`
LIMIT '.(int)$limit.' , '.(int)$nrb_import);
return $this->autoFormat($langagues, $identifier);
}
public function getCurrencies($limit = 0, $nrb_import = 100)
{
$identifier = 'id_currency';
$currencies = $this->executeS('
SELECT currencies_id as id_currency, title as name, code as iso_code, 0 as format, 999 as iso_code_num, 1 as decimals,
CONCAT(`symbol_left`, `symbol_right`) as sign, value as conversion_rate
FROM `'.bqSQL($this->prefix).'currencies` LIMIT '.(int)($limit).' , '.(int)$nrb_import
);
return $this->autoFormat($currencies, $identifier);
}
public function getZones($limit = 0, $nrb_import = 100)
{
$identifier = 'id_zone';
$zones = $this->executeS('SELECT geo_zone_id as id_zone, geo_zone_name as name, 1 as active FROM `'.bqSQL($this->prefix).'geo_zones` LIMIT '.(int)($limit).' , '.(int)$nrb_import);
return $this->autoFormat($zones, $identifier);
}
public function getCountries($limit = 0, $nrb_import = 100)
{
$multiLangFields = array('name');
$keyLanguage = 'id_lang';
$identifier = 'id_country';
$defaultIdLang = $this->getDefaultIdLang();
$countries = $this->executeS('
SELECT countries_id as id_country, countries_name as name, countries_iso_code_2 as iso_code, '.(int)$defaultIdLang.' as id_lang,
1 as id_zone, 0 as id_currency, 1 as contains_states, 1 as need_identification_number, 1 as active, 1 as display_tax_label
FROM `'.bqSQL($this->prefix).'countries` as c LIMIT '.(int)($limit).' , '.(int)$nrb_import);
return $this->autoFormat($countries, $identifier, $keyLanguage, $multiLangFields);
}
public function getStates($limit = 0, $nrb_import = 100)
{
$identifier = 'id_state';
$states = array(
0 => array(
'id_state' => 0,
'id_country' => 0,
'id_zone' => 0,
'iso_code' => 999,
'name' => 'osc',
'active' => 0
)
);
return $this->autoFormat($states, $identifier);
}
public function getGroups()
{
$idLang = $this->getDefaultIdLang();
return array( 1 => array(
'id_group' => 1,
'price_display_method' => 0,
'name' => array($idLang => $this->l('Default osCommerce Group'))
)
);
}
public function getCustomers($limit = 0, $nrb_import = 100)
{
$genderMatch = array('m' => 1,'f' => 2);
$identifier = 'id_customer';
$customers = $this->executeS('
SELECT c.`customers_id` as id_customer, 1 as id_default_group, c.`customers_gender` as id_gender, c.`customers_firstname` as firstname,
IFNULL( STRCMP(c.`customers_newsletter`, \'\') , 0 ) as newsletter, c.`customers_lastname` as lastname,
DATE(c.`customers_dob`) as birthday, c.`customers_email_address` as email, c.`customers_password` as passwd, 1 as active,
ci.`customers_info_date_account_created` as date_add
FROM `'.bqSQL($this->prefix).'customers` c
LEFT JOIN `'.bqSQL($this->prefix).'customers_info` ci ON (c.`customers_id` = ci.`customers_info_id`)
LIMIT '.(int)($limit).' , '.(int)$nrb_import
);
foreach($customers AS &$customer)
if (isset($customer['id_gender']) && array_key_exists($customer['id_gender'], $genderMatch))
$customer['id_gender'] = $genderMatch[$customer['id_gender']];
else
$customer['id_gender'] = 0;
return $this->autoFormat($customers, $identifier);
}
public function getAddresses($limit = 0, $nrb_import = 100)
{
$identifier = 'id_address';
$addresses = $this->executeS('
SELECT address_book_id as id_address, customers_id as id_customer, CONCAT(customers_id, \'_address\') as alias, entry_company as company, entry_firstname as firstname,
entry_lastname as lastname, entry_street_address as address1, entry_postcode as postcode, entry_city as city, entry_country_id as id_country, 0 as id_state
FROM `'.bqSQL($this->prefix).'address_book` LIMIT '.(int)($limit).' , '.(int)$nrb_import);
return $this->autoFormat($addresses, $identifier);
}
public function getCategories($limit = 0, $nrb_import = 100)
{
$multiLangFields = array('name', 'link_rewrite');
$keyLanguage = 'id_lang';
$identifier = 'id_category';
$categories = $this->executeS('
SELECT c.categories_id as id_category, c.parent_id as id_parent, level as level_depth, cd.language_id as id_lang, cd.categories_name as name , 1 as active, categories_image as images, c.date_added as date_add
FROM `'.bqSQL($this->prefix).'categories` c
LEFT JOIN `'.bqSQL($this->prefix).'categories_description` cd ON (c.categories_id = cd.categories_id)
WHERE cd.categories_name IS NOT NULL AND cd.language_id IS NOT NULL
ORDER BY c.level ASC , c.`categories_id`
LIMIT '.(int)($limit).' , '.(int)$nrb_import);
foreach($categories as& $cat)
{
$cat['link_rewrite'] = Tools::link_rewrite($cat['name']);
$cat['images'] = array(Tools::getProtocol().Tools::getValue('shop_url').'/images/'.$cat['images']);
}
return $this->autoFormat($categories, $identifier, $keyLanguage, $multiLangFields);
}
public function getAttributesGroups($limit = 0, $nrb_import = 100)
{
$multiLangFields = array('name', 'public_name');
$keyLanguage = 'id_lang';
$identifier = 'id_attribute_group';
$countries = $this->executeS('
SELECT products_options_id as id_attribute_group, products_options_name as name , products_options_name as public_name, language_id as id_lang, 0 as is_color_group
FROM `'.bqSQL($this->prefix).'products_options`
LIMIT '.(int)($limit).' , '.(int)$nrb_import);
return $this->autoFormat($countries, $identifier, $keyLanguage, $multiLangFields);
}
public function getAttributes($limit = 0, $nrb_import = 100)
{
$multiLangFields = array('name');
$keyLanguage = 'id_lang';
$identifier = 'id_attribute';
$countries = $this->executeS('
SELECT p.`products_options_values_id` as id_attribute, p.`products_options_values_name` as name, p.`language_id` as id_lang , po.`products_options_id` as id_attribute_group
FROM `'.bqSQL($this->prefix).'products_options_values` p
LEFT JOIN `'.bqSQL($this->prefix).'products_options_values_to_products_options` po ON (po.products_options_values_id = p.products_options_values_id)
ORDER BY p.`products_options_values_id`
LIMIT '.(int)($limit).' , '.(int)$nrb_import);
return $this->autoFormat($countries, $identifier, $keyLanguage, $multiLangFields);
}
public function getProducts($limit = 0, $nrb_import = 100)
{
$multiLangFields = array('name', 'link_rewrite', 'description');
$keyLanguage = 'id_lang';
$identifier = 'id_product';
$products = $this->executeS('
SELECT p.`products_id` as id_product, p.`products_quantity` as quantity, p.`products_model` as reference, p.`products_price` as price, p.`products_weight` as weight,
IFNULL(STRCMP(p.`products_status`, \'\') , 0 ) as active, p.`manufacturers_id` as id_manufacturer, pd.language_id as id_lang, pd.products_name as name,
pd.products_description as description, CONCAT(\''.pSQL(Tools::getProtocol()).pSQL(Tools::getValue('shop_url')).'\/images/\',p.`products_image`) as images,
(SELECT ptc.categories_id FROM `'.bqSQL($this->prefix).'products_to_categories` ptc WHERE ptc.`products_id` = p.`products_id` LIMIT 1) as id_category_default,
p.`products_date_added` as date_add
FROM `'.bqSQL($this->prefix).'products` p
LEFT JOIN `'.bqSQL($this->prefix).'products_description` pd ON (p.products_id = pd.products_id)
WHERE pd.products_name IS NOT NULL AND pd.language_id IS NOT NULL
ORDER BY p.`products_id`
LIMIT '.(int)($limit).' , '.(int)$nrb_import);
$this->execute('CREATE TABLE IF NOT EXISTS`products_images` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`products_id` int(11) NOT NULL,
`image` varchar(64) DEFAULT NULL,
`htmlcontent` text,
`sort_order` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `products_images_prodid` (`products_id`)
)');
foreach($products as& $product)
{
$result = $this->executeS('SELECT `image` FROM `'.bqSQL($this->prefix).'products_images` WHERE products_id = '.(int)$product['id_product']);
$images = array();
foreach($result as $res)
$images[] = Tools::getProtocol().Tools::getValue('shop_url').'/images/'.$res['image'];
$product['images'] = array_merge(array($product['images']), $images);
$product['link_rewrite'] = Tools::link_rewrite($product['name']);
$result = $this->executeS('SELECT `categories_id` FROM `'.bqSQL($this->prefix).'products_to_categories` WHERE products_id = '.(int)$product['id_product']);
$category_product = array('category_product' => array($product['id_category_default'] => $product['id_product']));
foreach($result as $res)
$category_product['category_product'][$res['categories_id']] = $product['id_product'];
$product['association'] = $category_product;
}
return $this->autoFormat($products, $identifier, $keyLanguage, $multiLangFields);
}
public function getProductsCombination($limit = 0, $nrb_import = 100)
{
$identifier = 'id_product_attribute';
$combinations = $this->executeS('
SELECT products_attributes_id as id_product_attribute, products_id as id_product, options_values_price as price, options_values_id
FROM `'.bqSQL($this->prefix).'products_attributes` LIMIT '.(int)($limit).' , '.(int)$nrb_import);
foreach($combinations as& $combination)
{
$combination['association'] = array('product_attribute_combination' => array($combination['options_values_id'] => $combination['id_product_attribute']));
unset($combination['options_values_id']);
}
return $this->autoFormat($combinations, $identifier);
}
public function getManufacturers($limit = 0, $nrb_import = 100)
{
$identifier = 'id_manufacturer';
$manufacturers = $this->executeS('
SELECT manufacturers_id as id_manufacturer, manufacturers_name as name, 1 as active, manufacturers_image as images
FROM `'.bqSQL($this->prefix).'manufacturers` LIMIT '.(int)($limit).' , '.(int)$nrb_import);
foreach($manufacturers as& $manufacturer)
$manufacturer['images'] = array(Tools::getProtocol().Tools::getValue('shop_url').'/images/'.$manufacturer['images']);
return $this->autoFormat($manufacturers, $identifier);
}
public function getOrdersStates($limit = 0, $nrb_import = 100)
{
$multiLangFields = array('name');
$keyLanguage = 'id_lang';
$identifier = 'id_order_state';
$ordersStates = $this->executeS('
SELECT `orders_status_id` as id_order_state, `language_id` as id_lang, `orders_status_name` as name , 1 as hidden
FROM `'.bqSQL($this->prefix).'orders_status`
LIMIT '.(int)($limit).' , '.(int)$nrb_import);//IF(`public_flag` = 0, 1, 0) as hidden
return $this->autoFormat($ordersStates, $identifier, $keyLanguage, $multiLangFields);
}
public function getOrders($limit = 0, $nrb_import = 100)
{
$orders = array();
$addresses = $this->executeS('SELECT customers_id as id_customer, address_book_id as id_address FROM `'.bqSQL($this->prefix).'address_book` GROUP BY customers_id');
$matchAddresses = array();
foreach($addresses as $address)
$matchAddresses[$address['id_customer']] = $address['id_address'];
$psCarrierDefault = (int)Configuration::get('PS_CARRIER_DEFAULT');
$psCurrency = Currency::getCurrencies();
foreach($psCurrency as $key => $currency)
{
$psCurrency[$currency['iso_code']] = $currency['id_currency'];
unset($psCurrency[$key]);
}
$orders = $this->executeS('
SELECT orders_id as id_cart, '.$psCarrierDefault.' as id_carrier, 1 as id_lang, currency as id_currency, customers_id as id_customer, payment_method as payment, 1 as valid,
date_purchased as date_add, last_modified as date_upd
FROM `'.bqSQL($this->prefix).'orders` LIMIT '.(int)($limit).' , '.(int)$nrb_import);
foreach($orders as $key => $order)
{
$orders[$key]['id_currency'] = (array_key_exists($order['id_currency'], $psCurrency) ? $psCurrency[$order['id_currency']] : 0);
$orders[$key]['id_address_delivery'] = (array_key_exists($order['id_customer'], $matchAddresses) ? $matchAddresses[$order['id_customer']] : 0);
$orders[$key]['id_address_invoice'] = (array_key_exists($order['id_customer'], $matchAddresses) ? $matchAddresses[$order['id_customer']] : 0);
$orders[$key]['total_paid'] = $this->getValue('SELECT value FROM `'.bqSQL($this->prefix).'orders_total` WHERE `orders_id` = '.(int)$order['id_cart'].' AND class=\'ot_total\'');
$orders[$key]['total_paid_real'] = $this->getValue('SELECT value FROM `'.bqSQL($this->prefix).'orders_total` WHERE `orders_id` = '.(int)$order['id_cart'].' AND class=\'ot_total\'');
$orders[$key]['total_products'] = $this->getValue('SELECT value FROM `'.bqSQL($this->prefix).'orders_total` WHERE `orders_id` = '.(int)$order['id_cart'].' AND class=\'ot_shipping\'');
$tax = $this->getValue('SELECT value FROM `'.bqSQL($this->prefix).'orders_total` WHERE `orders_id` = '.(int)$order['id_cart'].' AND class=\'ot_tax\'');
$orders[$key]['total_products_wt'] = $this->getValue('SELECT value FROM `'.bqSQL($this->prefix).'orders_total` WHERE `orders_id` = '.(int)$order['id_cart'].' AND class=\'ot_total\'') - $tax;
$orders[$key]['total_shipping'] = $this->getValue('SELECT value FROM `'.bqSQL($this->prefix).'orders_total` WHERE `orders_id` = '.(int)$order['id_cart'].' AND class=\'ot_shipping\'');
$orders[$key]['total_discounts'] = 0;
$orders[$key]['total_wrapping'] = 0;
$orders[$key]['cart_products'] = $this->executeS('
SELECT `orders_id` as id_cart, `products_id` as id_product, 0 as id_product_attribute, `products_quantity` as quantity
FROM `'.bqSQL($this->prefix).'orders_products` WHERE `orders_id` = '.(int)$order['id_cart']);
$orders[$key]['order_products'] = $this->executeS('
SELECT `orders_id` as id_order, `products_id` as product_id, 0 as product_attribute_id, `products_name` as product_name, `products_quantity` as product_quantity,
`final_price` as product_price, 0 as product_weight
FROM `'.bqSQL($this->prefix).'orders_products` WHERE `orders_id` = '.(int)$order['id_cart']);
$orders[$key]['order_history'] = $this->executeS('
SELECT `orders_status_history_id` as id_order_history, 0 as id_employee, `orders_id` as id_order, `orders_status_id` as id_order_state, `date_added` as date_add
FROM `'.bqSQL($this->prefix).'orders_status_history` WHERE `orders_id` = '.(int)$order['id_cart']);
}
return $orders;
}
private function autoFormat($items, $identifier, $keyLanguage = NULL, $multiLangFields = array())
{
$array = array();
foreach ($items AS $item)
if (sizeof($multiLangFields) && is_array($multiLangFields) && isset($array[$item[$identifier]][$multiLangFields[0]]))
foreach ($multiLangFields AS $key)
$array[$item[$identifier]][$key][$item[$keyLanguage]] = $item[$key];
else
foreach ($item AS $key => $value)
if (sizeof($multiLangFields) AND in_array($key, $multiLangFields))
$array[$item[$identifier]][$key] = array($item[$keyLanguage] => $value);
elseif (sizeof($multiLangFields) AND $key == $keyLanguage)
continue;
else
$array[$item[$identifier]][$key] = $value;
return $array;
}
public function hookbeforeAuthentication($params)
{
$passwd = trim(Tools::getValue('passwd'));
$email = trim(Tools::getValue('email'));
$result = Db::getInstance()->GetRow('
SELECT *
FROM `'._DB_PREFIX_ .'customer`
WHERE `active` = 1 AND `email` = \''.pSQL($email).'\'');
if ($result && !empty($result['passwd_'.$this->name]))
{
if($this->checkPwd($passwd, $result['passwd_'.pSQL($this->name)]))
{
$ps_passwd = md5(pSQL(_COOKIE_KEY_.$passwd));
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'customer`
SET `passwd` = \''.pSQL($ps_passwd).'\', `passwd_'.bqSQL($this->name).'` = \'\'
WHERE `'._DB_PREFIX_.'customer`.`id_customer` ='.(int)$result['id_customer'].' LIMIT 1');
}
}
}
private function checkPwd($passwd, $encrypt_pwd)
{
//checks the type of encryption password
if (preg_match('/^[A-Z0-9]{32}\:[A-Z0-9]{2}$/i', $encrypt_pwd) === 1)
{
//salt
$stack = explode(':', $encrypt_pwd);
if (sizeof($stack) != 2)
return false;
if (md5($stack[1] . $passwd) == $stack[0])
return true;
else
return false;
}
else
{
//phpass
if (file_exists(dirname(__FILE__).'/passwordhash.php'))
{
include(dirname(__FILE__).'/passwordhash.php');
$hasher = new PasswordHash(10, true);
return $hasher->CheckPassword($passwd, $encrypt_pwd);
}
else
return false;
}
}
public function displayConfigConnector()
{
$content = '<script>var type_connector = "db";</script>
<label>'.$this->l('Server').' : </label>
<div class="margin-form">
<input type="text" name="server" id="server" value="">
<p>'.$this->l('(eg : mysql.mydomain.com)').'</p>
</div>
<label>'.$this->l('User').' : </label>
<div class="margin-form">
<input type="text" name="user" id="user" value="">
</div>
<label>'.$this->l('Password').' : </label>
<div class="margin-form">
<input type="password" name="password" id="password" value="">
<p>'.$this->l('(password can be empty)').'</p>
</div>
<label>'.$this->l('Database').' : </label>
<div class="margin-form" style="">
<input type="text" name="database" id="database" value="">
</div>
<label>'.$this->l('Database prefix').' : </label>
<div class="margin-form" style="">
<input type="text" name="prefix" id="prefix" value="">
<p>'.$this->l('(The prefix is optional. If all of your database tables start with "pref_", your prefix is "pref_")').'</p>
</div>';
return $content;
}
public function checkCategoriesLevel()
{
$columns = $this->executeS('SHOW COLUMNS FROM `'.bqSQL($this->prefix).'categories` ');
foreach($columns as $field)
if ($field['Field'] == 'level')
return true;
return false;
}
public function displayCategoriesLevelConf()
{
$html = '<div class="warn" id="warn_category_level" style="width:450px;display:none">
<img src="../img/admin/warn2.png">
'.$this->l('You are trying to import categories and we\'ve detected, that your oscommerce database don\'t have the field "level" in the table categorie. You must have this field to continue the import of categories.');
$html .= '<button class="button" onclick="addAndCalculateLevel();" style="padding:10px;font-size:13px;text:align:center">'.$this->l('Click to add and calculate the filed "level" .').'</button> <span id="loading" style="display:none"><img src="../img/loader.gif"></span></div>
<div class="conf" id="conf_category_level" style="width:450px;display:none"><img src="../img/admin/ok2.png">'.$this->l('Level field\'s has been created and calculated, You can continue').'</div>';
$html .= '
<script>
$(document).ready(function (){
function checkCategorySelected()
{
if ($(\'#id_category_on:radio\').attr(\'checked\'))
{
$(\'#warn_category_level\').show();
$(\'#checkAndSaveConfig\').attr(\'disabled\', \'disabled\');
$(\'#checkAndSaveConfig\').hide();
}
else
{
$(\'#warn_category_level\').hide();
$(\'#checkAndSaveConfig\').removeAttr(\'disabled\');
$(\'#checkAndSaveConfig\').show();
}
}
checkCategorySelected();
$(\'input[name="getCategories"]\').change( function () {
checkCategorySelected();
});
});
function addAndCalculateLevel()
{
if (confirm(\''.$this->l('It is highly recommended to backup your database before proceeding. Did you make a backup?').'\'))
{
$(\'#loading\').show();
$.ajax({
type: "GET",
url: "../modules/importerosc/ajax.php",
async: false,
cache: false,
dataType : "json",
data: "ajax=true&token='.sha1(_COOKIE_KEY_.'importosc').'&server="+$(\'#server\').val()+"&user="+$(\'#user\').val()+"&password="+$(\'#password\').val()+"&database="+$(\'#database\').val()+"&prefix="+$(\'#prefix\').val() ,
success: function (jsonData)
{
if (jsonData.hasError)
alert(jsonData.error);
else
{
$(\'#warn_category_level\').remove();
$(\'#checkAndSaveConfig\').removeAttr(\'disabled\');
$(\'#checkAndSaveConfig\').show();
$(\'#conf_category_level\').show();
}
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
}
});
}
return false;
}
</script>';
return $html;
}
public function createLevelAndCalculate()
{
if ($this->checkCategoriesLevel())
die('{"hasError" : false}');
if ($this->createLevel())
$this->calculateLevel();
else
die('{"hasError" : true, "error" : "'.$this->l('Can not ALTER TABLE').'"}');
}
public function createLevel()
{
return $this->execute('ALTER TABLE `'.bqSQL($this->prefix).'categories` ADD `level` INT NOT NULL');
}
public function calculateLevel()
{
$this->updateLevel($this->getSubCat(0), 1);
die('{"hasError" : false}');
}
public function updateLevel($ids_cat, $level = 1)
{
$this->execute('
UPDATE `'.bqSQL($this->prefix).'categories`
SET level = '.(int)$level.'
WHERE categories_id IN ('.implode(',', $ids_cat).')');
foreach($ids_cat as $id)
if ($sub_cat = $this->getSubCat($id))
$this->updateLevel($sub_cat, $level + 1);
}
public function getSubCat($id_parent)
{
$result = $this->executeS('SELECT `categories_id` FROM `'.bqSQL($this->prefix).'categories` WHERE `parent_id`='.(int)$id_parent);
if (!is_array($result) OR empty($result))
return false;
return $this->formatCategoriesIds($result);
}
public function formatCategoriesIds($result)
{
$return = array();
foreach($result as $key => $val)
$return[] = $val['categories_id'];
return $return;
}
}
?>
-35
View File
@@ -1,35 +0,0 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

-254
View File
@@ -1,254 +0,0 @@
<?php
#
# Portable PHP password hashing framework.
#
# Version 0.3 / genuine.
# Version 0.3 / osCommerce (silenced @is_readable('/dev/urandom'))
#
# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
# the public domain. Revised in subsequent years, still public domain.
#
# There's absolutely no warranty.
#
# The homepage URL for this framework is:
#
# http://www.openwall.com/phpass/
#
# Please be sure to update the Version line if you edit this file in any way.
# It is suggested that you leave the main version number intact, but indicate
# your project name (after the slash) and add your own revision information.
#
# Please do not change the "private" password hashing method implemented in
# here, thereby making your hashes incompatible. However, if you must, please
# change the hash type identifier (the "$P$") to something different.
#
# Obviously, since this code is in the public domain, the above are not
# requirements (there can be none), but merely suggestions.
#
class PasswordHash {
var $itoa64;
var $iteration_count_log2;
var $portable_hashes;
var $random_state;
function PasswordHash($iteration_count_log2, $portable_hashes)
{
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$this->iteration_count_log2 = $iteration_count_log2;
$this->portable_hashes = $portable_hashes;
$this->random_state = microtime();
if (function_exists('getmypid'))
$this->random_state .= getmypid();
}
function get_random_bytes($count)
{
$output = '';
if (@is_readable('/dev/urandom') &&
($fh = @fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count);
fclose($fh);
}
if (strlen($output) < $count) {
$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->random_state =
md5(microtime() . $this->random_state);
$output .=
pack('H*', md5($this->random_state));
}
$output = substr($output, 0, $count);
}
return $output;
}
function encode64($input, $count)
{
$output = '';
$i = 0;
do {
$value = ord($input[$i++]);
$output .= $this->itoa64[$value & 0x3f];
if ($i < $count)
$value |= ord($input[$i]) << 8;
$output .= $this->itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
break;
if ($i < $count)
$value |= ord($input[$i]) << 16;
$output .= $this->itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
break;
$output .= $this->itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return $output;
}
function gensalt_private($input)
{
$output = '$P$';
$output .= $this->itoa64[min($this->iteration_count_log2 +
((PHP_VERSION >= '5') ? 5 : 3), 30)];
$output .= $this->encode64($input, 6);
return $output;
}
function crypt_private($password, $setting)
{
$output = '*0';
if (substr($setting, 0, 2) == $output)
$output = '*1';
$id = substr($setting, 0, 3);
# We use "$P$", phpBB3 uses "$H$" for the same thing
if ($id != '$P$' && $id != '$H$')
return $output;
$count_log2 = strpos($this->itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
return $output;
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
return $output;
# We're kind of forced to use MD5 here since it's the only
# cryptographic primitive available in all versions of PHP
# currently in use. To implement our own low-level crypto
# in PHP would result in much worse performance and
# consequently in lower iteration counts and hashes that are
# quicker to crack (by non-PHP code).
if (PHP_VERSION >= '5') {
$hash = md5($salt . $password, TRUE);
do {
$hash = md5($hash . $password, TRUE);
} while (--$count);
} else {
$hash = pack('H*', md5($salt . $password));
do {
$hash = pack('H*', md5($hash . $password));
} while (--$count);
}
$output = substr($setting, 0, 12);
$output .= $this->encode64($hash, 16);
return $output;
}
function gensalt_extended($input)
{
$count_log2 = min($this->iteration_count_log2 + 8, 24);
# This should be odd to not reveal weak DES keys, and the
# maximum valid value is (2**24 - 1) which is odd anyway.
$count = (1 << $count_log2) - 1;
$output = '_';
$output .= $this->itoa64[$count & 0x3f];
$output .= $this->itoa64[($count >> 6) & 0x3f];
$output .= $this->itoa64[($count >> 12) & 0x3f];
$output .= $this->itoa64[($count >> 18) & 0x3f];
$output .= $this->encode64($input, 3);
return $output;
}
function gensalt_blowfish($input)
{
# This one needs to use a different order of characters and a
# different encoding scheme from the one in encode64() above.
# We care because the last character in our encoded string will
# only represent 2 bits. While two known implementations of
# bcrypt will happily accept and correct a salt string which
# has the 4 unused bits set to non-zero, we do not want to take
# chances and we also do not want to waste an additional byte
# of entropy.
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$output = '$2a$';
$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
$output .= '$';
$i = 0;
do {
$c1 = ord($input[$i++]);
$output .= $itoa64[$c1 >> 2];
$c1 = ($c1 & 0x03) << 4;
if ($i >= 16) {
$output .= $itoa64[$c1];
break;
}
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 4;
$output .= $itoa64[$c1];
$c1 = ($c2 & 0x0f) << 2;
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 6;
$output .= $itoa64[$c1];
$output .= $itoa64[$c2 & 0x3f];
} while (1);
return $output;
}
function HashPassword($password)
{
$random = '';
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
$random = $this->get_random_bytes(16);
$hash =
crypt($password, $this->gensalt_blowfish($random));
if (strlen($hash) == 60)
return $hash;
}
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
if (strlen($random) < 3)
$random = $this->get_random_bytes(3);
$hash =
crypt($password, $this->gensalt_extended($random));
if (strlen($hash) == 20)
return $hash;
}
if (strlen($random) < 6)
$random = $this->get_random_bytes(6);
$hash =
$this->crypt_private($password,
$this->gensalt_private($random));
if (strlen($hash) == 34)
return $hash;
# Returning '*' on error is safe here, but would _not_ be safe
# in a crypt(3)-like function used _both_ for generating new
# hashes and for validating passwords against existing hashes.
return '*';
}
function CheckPassword($password, $stored_hash)
{
$hash = $this->crypt_private($password, $stored_hash);
if ($hash[0] == '*')
$hash = crypt($password, $stored_hash);
return $hash == $stored_hash;
}
}
?>
@@ -1,35 +0,0 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;
-214
View File
@@ -1,214 +0,0 @@
<?php
include_once('../../config/config.inc.php');
include_once('../../init.php');
include_once('../../modules/shopimporter/shopimporter.php');
$moduleName = Tools::getValue('moduleName');
if (!Tools::getValue('ajax') || Tools::getValue('token') != sha1(_COOKIE_KEY_.'ajaxShopImporter') || (!empty($moduleName) && !ctype_alnum($moduleName)))
die;
$className = Tools::getValue('className');
$getMethod = Tools::getValue('getMethod');
$limit = Tools::getValue('limit');
$nbr_import = Tools::getValue('nbr_import');
$server = Tools::getValue('server');
$user = Tools::getValue('user');
$password = Tools::getValue('password');
$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
$shop_importer = new shopImporter();
foreach($shop_importer->supportedImports as $key => $import)
if (array_key_exists('alterTable', $import))
$columns = Db::getInstance()->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.bqSQL($import['table']).'`');
foreach ($columns as $column)
if ($column['Field'] == $import['identifier'].'_'.$moduleName)
Db::getInstance()->execute('ALTER IGNORE TABLE `'._DB_PREFIX_.bqSQL($import['table']).'` DROP `'.bqSQL($import['identifier'].'_'.$moduleName).'`');
if ($link = @mysql_connect(Tools::getValue('server'), Tools::getValue('user'), Tools::getValue('password')))
{
if (!@mysql_select_db(Tools::getValue('database'), $link))
die('{"hasError" : true, "error" : ["'.$shop_importer->l('The database selection cannot be made.', 'ajax').'"]}');
else
{
@mysql_close($link);
die('{"hasError" : false, "error" : []}');
}
}
else
die('{"hasError" : true, "error" : ["'.$shop_importer->l('Link to database cannot be established.', 'ajax').'"]}');
}
if (Tools::isSubmit('getData') || Tools::isSubmit('syncLang') || Tools::isSubmit('syncCurrency'))
{
if (Tools::isSubmit('syncLang'))
$save = true;
if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php'))
{
require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php');
$importModule = new $moduleName();
$importModule->server = $server;
$importModule->user = $user;
$importModule->passwd = $password;
$importModule->database = $database;
$importModule->prefix = $prefix;
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));
$shop_importer = new shopImporter();
$shop_importer->genericImport($className, $return, (bool)$save);
}
}
}
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));
$shop_importer = new shopImporter();
$shop_importer->genericImport($className, $return, (bool)$save);
}
die('{"hasError" : false, "error" : []}');
} catch (Exception $e)
{
die('{"hasError" : true, "error" : ['.json_encode($e->getMessage()).'], "datas" : []}');
}
}
}
if (Tools::isSubmit('truncatTable'))
{
$shop_importer = new shopImporter();
if ($shop_importer->truncateTable($className))
die('{"hasError" : false, "error" : []}');
else
die('{"hasError" : true, "error" : ["'.$className.'"]}');
}
if (Tools::isSubmit('alterTable'))
{
$shop_importer = new shopImporter();
if ($shop_importer->alterTable($className))
die('{"hasError" : false, "error" : []}');
else
die('{"hasError" : true, "error" : ["'.$className.'"]}');
}
if (Tools::isSubmit('displaySpecificOptions'))
{
if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php'))
{
$shop_importer = new shopImporter();
require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php');
$importModule = new $moduleName();
$importModule->server = $server;
$importModule->user = $user;
$importModule->passwd = $password;
$importModule->database = $database;
$importModule->prefix = $prefix;
if ($link = @mysql_connect(Tools::getValue('server'), Tools::getValue('user'), Tools::getValue('password')))
{
if(!@mysql_select_db(Tools::getValue('database'), $link))
die($shop_importer->l('The database selection cannot be made.', 'ajax'));
elseif (method_exists($importModule, 'displaySpecificOptions'))
die($importModule->displaySpecificOptions());
else
die('not_exist');
}
else
die($shop_importer->l('Link to database cannot be established.', 'ajax'));
}
}
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'))
{
require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php');
$importModule = new $moduleName();
if (!method_exists($importModule, 'validateSpecificOptions'))
die('{"hasError" : true, "error" : ["not_exist"]}');
else
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());
}
}
?>
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>shopimporter</name>
<displayName><![CDATA[Shop Importer]]></displayName>
<version><![CDATA[1.0]]></version>
<description><![CDATA[This module allows you to import your shop from another system into Prestashop.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[migration_tools]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 971 B

-35
View File
@@ -1,35 +0,0 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

-35
View File
@@ -1,35 +0,0 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

-910
View File
@@ -1,910 +0,0 @@
var shopImporter = {
token: globalAjaxShopImporterToken,
moduleName: $('#import_module_name').val(),
server: $('#server').val(),
user: $('#user').val(),
password: $('#password').val(),
database: $('#database').val(),
prefix: $('#prefix').val(),
url: $('#url').val(),
loginws: $('#loginws').val(),
apikey: $('#apikey').val(),
specificOptions : '',
imagesOptions : '',
output : 1,
hasErrors : 0,
limit: 0,
nbr_import: parseInt($('#nbr_import').val()),
idMethod: 0,
nbrMethod: 0,
save : 0,
srcError : '../modules/shopimporter/img/error.png',
srcConf : '../modules/shopimporter/img/ok.png',
srcImport : '../modules/shopimporter/img/ajax-loader.gif',
srcWarn : '../modules/shopimporter/img/warn.png',
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('<div id="lang_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">'+jsonData.error+'</div>');
$('#lang_feedback').fadeIn('slow');
onComplete(false);
}
else
onComplete(true);
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
$('#steps').html($('#steps').html()+'<div id="technical_error_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">TECHNICAL ERROR<br><br>Details: '+XMLHttpRequest.responseText+'</div>');
$('#technical_error_feedback').fadeIn('slow');
onComplete(false);
}
});
},
syncLang : function (onComplete)
{
$.ajax({
type: 'GET',
url: '../modules/shopimporter/ajax.php',
async: false,
cache: false,
dataType : "json",
data: 'ajax=true&syncLang&getMethod=getLangagues&token='+this.token+'&className=Language&moduleName='+this.moduleName+'&server='+this.server+'&user='+this.user+'&password='+this.password+'&database='+this.database+'&prefix='+prefix+this.specificOptions+'&nbr_import='+this.nbr_import ,
success: function(jsonData)
{
if (jsonData.hasError)
{
$('#steps').html('<div id="lang_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">'+jsonData.error+'</div>');
$('#lang_feedback').fadeIn('slow');
onComplete(false);
}
else
onComplete(true);
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
$('#steps').html($('#steps').html()+'<div id="technical_error_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">TECHNICAL ERROR<br><br>Details: '+XMLHttpRequest.responseText+'</div>');
$('#technical_error_feedback').fadeIn('slow');
onComplete(false);
}
});
},
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('<div id=\'currency_feedback\' style=\'display:none;\' class=\'error\'><img src=\''+shopImporter.srcError+'\'>'+jsonData.error+'</div>');
$('#currency_feedback').fadeIn('slow');
onComplete(false);
}
else
onComplete(true);
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
$('#steps').html($('#steps').html()+'<div id="technical_error_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">TECHNICAL ERROR<br><br>Details: '+XMLHttpRequest.responseText+'</div>');
$('#technical_error_feedback').fadeIn('slow');
onComplete(false);
}
});
},
syncCurrency : function (onComplete)
{
$.ajax({
type: 'GET',
url: '../modules/shopimporter/ajax.php',
async: false,
cache: false,
dataType : "json",
data: 'ajax=true&token='+this.token+'&syncCurrency&getMethod=getCurrencies&className=Currency&moduleName='+this.moduleName+'&server='+this.server+'&user='+this.user+'&password='+this.password+'&database='+this.database+'&prefix='+prefix+this.specificOptions+'&nbr_import='+this.nbr_import ,
success: function(jsonData)
{
if (jsonData.hasError)
{
$('#steps').html('<div id="currency_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">'+jsonData.error+'</div>');
$('#currency_feedback').fadeIn('slow');
onComplete(false);
}
else
onComplete(true);
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
$('#steps').html($('#steps').html()+'<div id="technical_error_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">TECHNICAL ERROR<br><br>Details: '+XMLHttpRequest.responseText+'</div>');
$('#technical_error_feedback').fadeIn('slow');
onComplete(false);
}
});
},
checkAndSaveConfigWSDL : function (onComplete)
{
$('#checkAndSaveConfig').fadeOut('slow');
$('#steps').html($('#steps').html()+'<div id=\'database_feedback\' style=\'display:none;\' class=\'conf\'><img src=\''+shopImporter.srcConf+'\'>'+wsOk+'</div>');
$('#steps').html($('#steps').html()+'<input style=\'display:none\' type=\'submit\' name=\'next\' id=\'next\' class=\'button\' value="'+testImport+'">');
$('#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 ($('#technical_error_feedback').length)
$('#technical_error_feedback').fadeIn('slow');
$('#checkAndSaveConfig').fadeOut('slow');
$('#steps').html($('#steps').html()+'<div id=\'database_feedback\' style=\'display:none;\' class=\'conf\'><img src=\''+shopImporter.srcConf+'\'>'+databaseOk+'</div>');
$('#steps').html($('#steps').html()+'<input style=\'display:none\' type=\'submit\' name=\'next\' id=\'next\' class=\'button\' value="'+testImport+'">');
$('#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)
{
//sync languages and currency
this.syncLang(function(isOk) {
if (isOk)
{
shopImporter.syncCurrency(function(isOk) {
if (isOk)
{
$.ajax({
type: 'GET',
url: '../modules/shopimporter/ajax.php',
async: true,
cache: false,
dataType : "json",
data: 'ajax=true&token='+this.token+'&checkAndSaveConfig&moduleName='+shopImporter.moduleName+'&server='+shopImporter.server+'&user='+shopImporter.user+'&password='+shopImporter.password+'&database='+shopImporter.database+'&prefix='+prefix+shopImporter.specificOptions+'&nbr_import='+shopImporter.nbr_import ,
success: function(jsonData)
{
if ($('#technical_error_feedback').length)
$('#technical_error_feedback').fadeIn('slow');
if (!jsonData.hasError)
{
$('#checkAndSaveConfig').fadeOut('slow');
$('#steps').html($('#steps').html()+'<div id="database_feedback" style="display:none;" class="conf"><img src="'+shopImporter.srcConf+'">'+databaseOk+'</div>');
$('#steps').html($('#steps').html()+'<input style="display:none" type="submit" name="next" id="next" class="button" value="'+testImport+'">');
$('#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.getDatas(conf[shopImporter.idMethod]);
}
else
{
$('#next').fadeIn('slow', function () {
$('#next').unbind('click').click(function(){
$('#next').fadeOut('fast', function() {
shopImporter.nbrMethod = conf.length;
shopImporter.getDatas(conf[shopImporter.idMethod]);
});
return false;
});
});
}
});
}
else
{
$('#steps').html('<div id="database_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">'+jsonData.error+'</div>');
$('#database_feedback').fadeIn('slow');
}
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
$('#steps').html($('#steps').html()+'<div id=\'technical_error_feedback\' style=\'display:none;\' class=\'error\'><img src="'+shopImporter.srcError+'">TECHNICAL ERROR<br><br>Details: '+XMLHttpRequest.responseText+'</div>');
$('#technical_error_feedback').fadeIn('slow');
}
});
}
});
}
});
},
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()+'<div id=\'ok_feedback_'+methodName[0]+'\' style=\'display:none;\' class="import"><img src=\''+this.srcImport+'\'>'+methodName[1]+'<span id=\'display_error_'+methodName[0]+'\' style=\'display:none\'><span><div id=\'feedback_'+methodName[0]+'_errors_list\'></div></div>');
$('#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+'&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('<img src="'+shopImporter.srcWarn+'">'+methodName[1]+' '+notExist);
return 'warn';
});
}
else
{
for (i=0;i<jsonData.error.length;i++)
jsonError = jsonError+'<li>Id : '+jsonData.error[i]+'</li>';
if ($('#display_error_'+methodName[0]+'_link').length == 0)
{
$('#ok_feedback_'+methodName[0]).html($('#ok_feedback_'+methodName[0]).html()+'<span id="display_error_'+methodName[0]+'" style="float:right;"><a id="display_error_'+methodName[0]+'_link" class="display_error_link" rel="'+methodName[0]+'" href="#" onclick="enableShowErrors(\''+methodName[0]+'\'); return false;">'+showErrors+'(<span id="nbr_errors_'+methodName[0]+'">'+jsonData.error.length+'</span>)'+'</a></span><div style="display:none;" id="feedback_'+methodName[0]+'_errors_list"><ul>'+jsonError+'</ul></div>');
}
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)
{
$('#technical_error_feedback').fadeIn('slow');
$('#checkAndSaveConfig').fadeIn('slow');
}
});
}
},
getDatas : 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.getDatas(conf[shopImporter.idMethod]);
return;
}
if (typeof(methodName) != 'undefined')
{
$('#steps').html($('#steps').html()+'<div id="ok_feedback_'+methodName[0]+'" style="display:none;" class="import"><img src="'+this.srcImport+'">'+methodName[1]+'<span id="display_error_'+methodName[0]+'" style="display:none"><span><div id="feedback_'+methodName[0]+'_errors_list"></div></div>');
$('#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 ,
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('<img src="'+shopImporter.srcWarn+'">'+methodName[1]+' '+notExist);
return 'warn';
});
}
else
{
for (i=0;i<jsonData.error.length;i++)
jsonError = jsonError+'<li>Id : '+jsonData.error[i]+'</li>';
if ($('#display_error_'+methodName[0]+'_link').length == 0)
{
$('#ok_feedback_'+methodName[0]).html($('#ok_feedback_'+methodName[0]).html()+'<span id="display_error_'+methodName[0]+'" style="float:right;"><a id="display_error_'+methodName[0]+'_link" class="display_error_link" rel="'+methodName[0]+'" href="#" onclick="enableShowErrors(\''+methodName[0]+'\'); return false;">'+showErrors+'(<span id="nbr_errors_'+methodName[0]+'">'+jsonData.error.length+'</span>)'+'</a></span><div style="display:none;" id="feedback_'+methodName[0]+'_errors_list"><ul>'+jsonError+'</ul></div>');
}
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.getDatas(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.getDatas(conf[shopImporter.idMethod]);
}
else
{
if (shopImporter.idMethod < shopImporter.nbrMethod)
{
shopImporter.limit += parseInt(shopImporter.nbr_import);
shopImporter.getDatas(conf[shopImporter.idMethod]);
}
else
shopImporter.displayEnd(true);
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
$('#steps').html($('#steps').html()+'<div id="technical_error_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">TECHNICAL ERROR<br><br>Details: '+XMLHttpRequest.responseText+'</div>');
$('#technical_error_feedback').fadeIn('slow');
$('#checkAndSaveConfig').fadeIn('slow');
}
});
}
},
truncatTable : function (className)
{
if (!$('#truncat_feedback').length)
{
$('#steps').html($('#steps').html()+'<div id="truncat_feedback" style="display:none;" class="conf"><img src="'+this.srcConf+'">'+truncateTable+'</div>');
$('#truncat_feedback').css('display', '');
}
$.ajax({
type: 'GET',
url: '../modules/shopimporter/ajax.php',
async: false,
cache: false,
dataType : "json",
data: 'ajax=true&token='+this.token+'&truncatTable&className='+className+this.specificOptions ,
success: function(jsonData)
{
var jsonError;
if (jsonData.hasError)
{
jsonError = '';
for (i=0;i<jsonData.error.length;i++)
jsonError = jsonError+'<li>Table : '+jsonData.error[i]+'</li>';
$('#truncat_feedback').removeClass('import').addClass('error');
$('#truncat_feedback >img:first').attr('src', shopImporter.srcError);
if ($('#display_error_truncat_feedback_link').length == 0)
{
$('#truncat_feedback').html($('#truncat_feedback').html()+'<span id="display_error_truncat" style="float:right;"><a id="display_error_truncat_link" class="display_error_link" rel="truncat" href="#" onclick="enableShowErrorsTruncate(); return false;">'+showErrors+'</a></span><div style="display:none;" id="feedback_truncat_errors_list"><ul>'+jsonError+'</ul></div>');
}
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);
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
$('#steps').html($('#steps').html()+'<div id="technical_error_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">TECHNICAL ERROR<br><br>Details: '+XMLHttpRequest.responseText+'</div>');
$('#technical_error_feedback').fadeIn('slow');
$('#checkAndSaveConfig').fadeIn('slow');
}
});
},
displayEnd : function (finish)
{
if ((this.hasErrors != 0 || ($('.display_error_link').length == 0 && this.hasErrors == 0)) || (this.hasErrors == 1))
{
if (this.save)
{
$('#steps').html($('#steps').html()+'<div id=\'ok_feedback_end\' style=\'display:none;\' class=\'conf\'><img src=\''+shopImporter.srcConf+'\'>'+importFinish+'</div>');
$('#ok_feedback_end').fadeIn('slow');
}
else
{
$('#steps').html($('#steps').html()+'<input style="display:none" type="button" name="submitImport" id="submitImport" class="button" value="'+runImport+'">');
$('#submitImport').fadeIn('slow', function() {
$(this).unbind('click').click(function() {
$.scrollTo($("#steps"), 300 , {
onAfter:function(){
$('#steps').html('');
shopImporter.save = 1;
if(type_connector == 'ws')
shopImporter.checkAndSaveConfigWS(shopImporter.save);
else if (type_connector == 'db')
shopImporter.checkAndSaveConfig(shopImporter.save);
}
});
});
});
}
}
else
{
$('#steps').html($('#steps').html()+'<div id="technical_error_feedback" style="display:none;" class="error"><img src="'+shopImporter.srcError+'">'+importHasErrors+'</div>');
$('#technical_error_feedback').fadeIn('slow');
}
$('#checkAndSaveConfig').fadeIn('slow');
},
};
function enableShowErrors(methodName)
{
$(document).find('#feedback_'+methodName+'_errors_list').slideToggle();
return false;
}
function enableShowErrorsTruncate()
{
$(document).find('#feedback_truncat_errors_list').slideToggle();
return false;
}
function displaySpecificOptions(moduleName, server, user, password, database, prefix, token)
{
$.ajax({
type: 'GET',
url: '../modules/shopimporter/ajax.php',
async: false,
cache: false,
dataType : "html",
data: 'ajax=true&token='+token+'&displaySpecificOptions&moduleName='+moduleName+'&server='+ server+'&user='+user+'&password='+password+'&database='+database+'&prefix='+prefix ,
success: function(htmlData)
{
if (htmlData != 'not_exist')
{
$('#specificOptionsContent').html(htmlData);
$('#specificOptions').show();
$('#importOptions').show();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert('TECHNICAL ERROR\nDetails:\nError thrown: ' + XMLHttpRequest + '\n' + 'Text status: ' + textStatus);
}
});
}
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.length;i++)
jsonError = jsonError+'<li>'+jsonData.error[i]+'</li>';
$('#connectionInformation').slideDown('slow');
$('#connectionInformation').html('<ul>'+jsonError+'</ul>');
$('#connectionInformation').show();
}else
{
$('#connectionInformation').attr('style','width: 400px;background-color: #DFFAD3;border: 1px solid #72CB67');
$('#connectionInformation').slideDown('slow');
$('#connectionInformation').html('<ul>Connection successful</ul>');
$('#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').hide();
$('#importOptions').show();
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert('TECHNICAL ERROR\nDetails:\nError thrown: ' + XMLHttpRequest + '\n' + 'Text status: ' + textStatus);
}
});
}
function validateSpecificOptions(moduleName, specificOptions)
{
$.ajax({
type: 'GET',
url: '../modules/shopimporter/ajax.php',
async: false,
cache: false,
dataType : 'json',
data: 'ajax=true&token='+token+'&validateSpecificOptions&moduleName='+moduleName+specificOptions ,
success: function(jsonData)
{
var jsonError = '';
if (jsonData.hasError)
{
for (i=0;i<jsonData.error.length;i++)
jsonError = jsonError+'<li>'+jsonData.error[i]+'</li>';
$('#specificOptionsErrors').html('<ul>'+jsonError+'</ul>');
$('#specificOptionsErrors').fadeIn('slow');
}
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert('TECHNICAL ERROR\nDetails:\nError thrown: ' + XMLHttpRequest + '\n' + 'Text status: ' + textStatus);
}
});
if ($('#specificOptionsErrors').html().length != 0)
return false;
else
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 () {
$(this).html('');
$('#steps').fadeIn();
});
$('#importOptions').fadeOut('slow');
$('#displayOptions').show();
$('#checkAndSaveConfig').show();
})
});
$('input[name=hasErrors]:radio').change(function () {
if ($(this).val() == 1)
$('#warnSkip').fadeIn('slow');
else
$('#warnSkip').fadeOut('slow');
});
$('#choose_module_name').unbind('click').click(function(){
initConfigConnector();
});
$('#displayOptions').unbind('click').click(function(){
$('#displayOptions').show();
if(type_connector == 'ws')
{
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 (type_connector == 'db')
{
moduleName = $('#import_module_name').val();
server = $('#server').val();
user = $('#user').val();
password = $('#password').val();
database = $('#database').val();
prefix = $('#prefix').val();
token = globalAjaxShopImporterToken;
displaySpecificOptions(moduleName, server, user, password, database, prefix, token);
}
$(this).fadeOut('slow');
$('#importOptions').slideDown('slow');
return false;
});
$('#checkAndSaveConfig').unbind('click').click(function(){
$('#steps, #specificOptionsErrors').html('');
$('#specificOptionsErrors').hide();
shopImporter.specificOptions = '';
$('#specificOptionsContent :input').each(function (){
shopImporter.specificOptions = shopImporter.specificOptions+'&'+$(this).attr('name')+'='+$(this).attr('value');
});
shopImporter.imagesOptions = '';
$('.importImages:input:checked').each(function (){
shopImporter.imagesOptions = shopImporter.imagesOptions+'&'+$(this).attr('name');
});
moduleName = $('#import_module_name').val();
if (validateSpecificOptions(moduleName, shopImporter.specificOptions) == true)
{
if(type_connector == 'ws')
{
$.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.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 (type_connector == 'db')
{
$.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();
shopImporter.database = $('#database').val();
shopImporter.prefix = $('#prefix').val();
shopImporter.token = globalAjaxShopImporterToken;
shopImporter.hasErrors = $('input[name=hasErrors]:radio:checked').val();
shopImporter.checkAndSaveConfig(shopImporter.save);
return false;
}
});
}
}
});
$('#importOptionsYesNo :radio').change( function () {
$('#steps').html('');
onThing = false;
$('#importOptionsYesNo :radio:checked').each( function () {
if ($(this).attr('value') == 1)
onThing = true;
});
if (onThing)
$('#checkAndSaveConfig').fadeIn();
else
{
$('#checkAndSaveConfig').fadeOut();
$('#steps').html('<div id=\'one_thing_error_feedback\' style=\'display:none;\' class=\'error\'><img src=\''+shopImporter.srcError+'\'>'+oneThing+'</div>');
$('#one_thing_error_feedback').fadeIn('slow');
}
});
});
File diff suppressed because it is too large Load Diff
@@ -1,35 +0,0 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;