// MERGE with 1.4 r7770

This commit is contained in:
rMalie
2011-07-28 09:20:57 +00:00
parent 60b07cacb9
commit c17e7c236d
968 changed files with 26082 additions and 3937 deletions
+91
View File
@@ -0,0 +1,91 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
define('_PS_ADMIN_DIR_', getcwd());
define('PS_ADMIN_DIR', _PS_ADMIN_DIR_); // Retro-compatibility
include(_PS_ADMIN_DIR_.'/../config/config.inc.php');
include(_PS_ADMIN_DIR_.'/functions.php');
include(_PS_ADMIN_DIR_.'/init.php');
if (empty($tab) and !sizeof($_POST))
{
$tab = 'AdminHome';
$_POST['tab'] = 'AdminHome';
$_POST['token'] = Tools::getAdminTokenLite($tab);
}
if ($id_tab = checkingTab($tab))
{
$isoUser = Language::getIsoById(intval($cookie->id_lang));
if (Validate::isLoadedObject($adminObj))
{
$adminObj->ajax = true;
if ($adminObj->checkToken())
{
// the differences with index.php is here
$adminObj->ajaxPreProcess();
$action = Tools::getValue('action');
// no need to use displayConf() here
if (!empty($action) AND method_exists($adminObj, 'ajaxProcess'.Tools::toCamelCase($action)) )
$adminObj->{'ajaxProcess'.Tools::toCamelCase($action)}();
else
$adminObj->ajaxProcess();
// @TODO We should use a displayAjaxError
$adminObj->displayErrors();
if (!empty($action) AND method_exists($adminObj, 'displayAjax'.Tools::toCamelCase($action)) )
$adminObj->{'displayAjax'.$action}();
else
$adminObj->displayAjax();
}
else
{
// If this is an XSS attempt, then we should only display a simple, secure page
ob_clean();
// ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17)
$url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$adminObj->token.'$2', $_SERVER['REQUEST_URI']);
if (false === strpos($url, '?token=') AND false === strpos($url, '&token='))
$url .= '&token='.$adminObj->token;
// we can display the correct url
// die(Tools::jsonEncode(array(translate('Invalid security token'),$url)));
die(Tools::jsonEncode(translate('Invalid security token')));
}
}
}
+5 -5
View File
@@ -30,8 +30,6 @@ include(PS_ADMIN_DIR.'/../config/config.inc.php');
/* Getting cookie or logout */
require_once(dirname(__FILE__).'/init.php');
require_once(PS_ADMIN_DIR.'/tabs/AdminCounty.php');
$context = Context::getContext();
if (isset($_GET['changeParentUrl']))
@@ -491,12 +489,12 @@ if (Tools::isSubmit('saveImportMatchs'))
if (Tools::isSubmit('deleteImportMatchs'))
{
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'import_match` WHERE id_import_match = '.pSQL(Tools::getValue('idImportMatchs')));
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'import_match` WHERE `id_import_match` = '.(int)Tools::getValue('idImportMatchs'));
}
if (Tools::isSubmit('loadImportMatchs'))
{
$return = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'import_match` WHERE id_import_match = '.pSQL(Tools::getValue('idImportMatchs')));
$return = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'import_match` WHERE `id_import_match` = '.(int)Tools::getValue('idImportMatchs'));
die('{"id" : "'.$return[0]['id_import_match'].'", "matchs" : "'.$return[0]['match'].'", "skip" : "'.$return[0]['skip'].'"}');
}
@@ -508,6 +506,8 @@ if (Tools::isSubmit('toggleScreencast'))
if (Tools::isSubmit('ajaxAddZipCode') OR Tools::isSubmit('ajaxRemoveZipCode'))
{
require_once(PS_ADMIN_DIR.'/tabs/AdminCounty.php');
$zipcodes = Tools::getValue('zipcodes');
$id_county = (int)Tools::getValue('id_county');
@@ -688,7 +688,7 @@ if (Tools::isSubmit('getAdminHomeElement'))
if (Tools::isSubmit('getChildrenCategories') && Tools::getValue('id_category_parent'))
{
$children_categories = Category::getChildrenWithNbSelectedSubCatForProduct(Tools::getValue('id_category_parent'), Tools::getValue('id_product', 0), Tools::getValue('post_selected_cat', null), $cookie->id_lang);
$children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat', array()), $cookie->id_lang);
die(Tools::jsonEncode($children_categories));
}
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -31,7 +31,11 @@ eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^
//media.js end
//ajaxfileupload start
jQuery.extend({ createUploadIframe: function(id, uri)
{ var frameId = 'jUploadFrame' + id; if(window.ActiveXObject) { var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />'); if(typeof uri== 'boolean'){ io.src = 'javascript:false';}
{ var frameId = 'jUploadFrame' + id; if(window.ActiveXObject) {
var io = document.createElement('iframe');
io.setAttribute('id', frameId);
io.setAttribute('name', frameId);
if(typeof uri== 'boolean'){ io.src = 'javascript:false';}
else if(typeof uri== 'string'){ io.src = uri;}
}
else { var io = document.createElement('iframe'); io.id = frameId; io.name = frameId;}
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+4 -5
View File
@@ -82,7 +82,7 @@ function rewriteSettingsFile($baseUrls = NULL, $theme = NULL, $arrayDB = NULL)
$defines['_PS_CACHING_SYSTEM_'] = _PS_CACHING_SYSTEM_;
$defines['_PS_CACHE_ENABLED_'] = _PS_CACHE_ENABLED_;
$defines['_DB_NAME_'] = (($arrayDB AND isset($arrayDB['_DB_NAME_'])) ? $arrayDB['_DB_NAME_'] : _DB_NAME_);
$defines['_MYSQL_ENGINE_'] = _MYSQL_ENGINE_;
$defines['_MYSQL_ENGINE_'] = (($arrayDB AND isset($arrayDB['_MYSQL_ENGINE_'])) ? $arrayDB['_MYSQL_ENGINE_'] : _MYSQL_ENGINE_);
$defines['_DB_SERVER_'] = (($arrayDB AND isset($arrayDB['_DB_SERVER_'])) ? $arrayDB['_DB_SERVER_'] : _DB_SERVER_);
$defines['_DB_USER_'] = (($arrayDB AND isset($arrayDB['_DB_USER_'])) ? $arrayDB['_DB_USER_'] : _DB_USER_);
$defines['_DB_PREFIX_'] = (($arrayDB AND isset($arrayDB['_DB_PREFIX_'])) ? $arrayDB['_DB_PREFIX_'] : _DB_PREFIX_);
@@ -207,10 +207,9 @@ function createDir($path, $rights)
function checkPSVersion()
{
libxml_set_streams_context(stream_context_create(array('http' => array('timeout' => 3))));
if ($feed = @simplexml_load_file('http://www.prestashop.com/xml/version.xml') AND _PS_VERSION_ < $feed->version->num)
return array('name' => $feed->version->name, 'link' => $feed->download->link);
return false;
$upgrader = new Upgrader();
return $upgrader->checkPSVersion();
}
function translate($string)
+1 -1
View File
@@ -52,7 +52,7 @@ if (empty($tab) and !sizeof($_POST))
? '<a href="?tab='.$item['class_name'].'&token='.Tools::getAdminToken($item['class_name'].intval($item['id_tab']).intval($cookie->id_employee)).'">'
: '').'
'.$item['name'].((sizeof($tabs) - 1 > $key) ? '</a>' : '');
// @TODO : a way to desactivate this feature
echo'<script type="text/javascript">
$(function() {
-3
View File
@@ -28,9 +28,6 @@
ob_start();
$timerStart = microtime(true);
$context = Context::getContext();
$context->cookie = $cookie;
if (isset($_GET['logout']))
$cookie->logout();
+1 -1
View File
@@ -64,7 +64,7 @@ if (isset($_POST['Submit']))
$errors[] = Tools::displayError('An error occurred during your password change.');
else
{
Mail::Send((int)$id_lang, 'password', Mail::l('Your new admin password'), array('{email}' => $employee->email, '{lastname}' => $employee->lastname, '{firstname}' => $employee->firstname, '{passwd}' => $pwd), $employee->email, $employee->firstname.' '.$employee->lastname);
if(Mail::Send((int)$id_lang, 'password', Mail::l('Your new admin password'), array('{email}' => $employee->email, '{lastname}' => $employee->lastname, '{firstname}' => $employee->firstname, '{passwd}' => $pwd), $employee->email, $employee->firstname.' '.$employee->lastname))
$confirmation = 'ok';
}
}
+3 -3
View File
@@ -349,7 +349,7 @@ class AdminAddresses extends AdminTab
{
echo '
<label>'.$this->l('Address').' (2):</label>
<label>'.$this->l('Address').' (2)</label>
<div class="margin-form">
<input type="text" size="33" name="address2" value="'.htmlentities($this->getFieldValue($obj, 'address2'), ENT_COMPAT, 'UTF-8').'" />
</div>';
@@ -480,8 +480,8 @@ class AdminAddresses extends AdminTab
$selectedCountry = ($tmp_addr && $tmp_addr->id_country) ? $tmp_addr->id_country :
(int)(Configuration::get('PS_COUNTRY_DEFAULT'));
$inv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry);
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry);
$inv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry, false, true);
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry, false, true);
$inv_all_fields = array();
$dlv_all_fields = array();
-1
View File
@@ -59,7 +59,6 @@ class AdminAliases extends AdminTab
if (!sizeof($this->_errors))
{
Alias::deleteAliases($search);
foreach ($aliases AS $alias)
{
$obj = new Alias(NULL, trim($alias), trim($search));
+37
View File
@@ -29,6 +29,9 @@ include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminAttachments extends AdminTab
{
private $_productAttachements = array();
public function __construct()
{
$this->table = 'attachment';
@@ -128,4 +131,38 @@ class AdminAttachments extends AdminTab
</fieldset>
</form>';
}
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
{
parent::getList((int)$id_lang, $orderBy, $orderWay, $start, $limit);
if(sizeof($this->_list))
$this->_productAttachements = Attachment::getProductAttached((int)$id_lang, $this->_list);
}
protected function _displayDeleteLink($token = NULL, $id)
{
global $currentIndex;
$_cacheLang['Delete'] = $this->l('Delete');
$_cacheLang['DeleteItem'] = $this->l('Delete item #', __CLASS__, TRUE, FALSE);
if (isset($this->_productAttachements[$id]))
{
$productList = '';
foreach($this->_productAttachements[$id] as $product)
$productList .= $product.', ';
}
echo '
<script>
function confirmProductAttached(productList)
{
if (confirm(\''.$_cacheLang['DeleteItem'].$id.'\'))
return confirm(\''.$this->l('This attachment is used by the following products:').'\r\n\' + productList);
return false;
}
</script>
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'"
onclick="'.(isset($this->_productAttachements[$id]) ? 'return confirmProductAttached(\''.$productList.'\')' : 'return confirm(\''.$_cacheLang['DeleteItem'].$id.' ?'.(!is_null($this->specificConfirmDelete) ? '\r'.rtrim($this->specificConfirmDelete, ', ') : '').'\')' ).'">
<img src="../img/admin/delete.gif" alt="'.$_cacheLang['Delete'].'" title="'.$_cacheLang['Delete'].'" /></a>';
}
}
+1 -1
View File
@@ -241,7 +241,7 @@ class AdminBackup extends AdminTab
if (preg_match('/^([\d]+-[a-z\d]+)\.sql(\.gz|\.bz2)?$/', $file, $matches) == 0)
continue;
$timestamp = (int)($matches[1]);
$date = date('Y-m-d h:i:s', $timestamp);
$date = date('Y-m-d H:i:s', $timestamp);
$age = time() - $timestamp;
if ($age < 3600)
$age = '< 1 '.$this->l('hour');
+9 -1
View File
@@ -131,9 +131,17 @@ class AdminCarriers extends AdminTab
<label>'.$this->l('Zone').'</label>
<div class="margin-form">';
$carrier_zones = $obj->getZones();
$carrier_zones_ids = array();
if (is_array($carrier_zones))
foreach($carrier_zones as $carrier_zone)
$carrier_zones_ids[] = $carrier_zone['id_zone'];
$zones = Zone::getZones(false);
foreach ($zones AS $zone)
echo '<input type="checkbox" id="zone_'.$zone['id_zone'].'" name="zone_'.$zone['id_zone'].'" value="true" '.(Tools::getValue('zone_'.$zone['id_zone'], (is_array($carrier_zones) AND in_array(array('id_carrier' => $obj->id, 'id_zone' => $zone['id_zone'], 'name' => $zone['name'], 'active' => $zone['active']), $carrier_zones))) ? ' checked="checked"' : '').'><label class="t" for="zone_'.$zone['id_zone'].'">&nbsp;<b>'.$zone['name'].'</b></label><br />';
echo '<input type="checkbox" id="zone_'.$zone['id_zone'].'" name="zone_'.$zone['id_zone'].'" value="true" '.
Tools::getValue('zone_'.$zone['id_zone'], (in_array($zone['id_zone'], $carrier_zones_ids) ? ' checked="checked"' : '')).'>
<label class="t" for="zone_'.$zone['id_zone'].'"> <b>'.$zone['name'].'</b></label><br />';
echo '<p>'.$this->l('The zone in which this carrier is to be used').'</p>
</div>
<label>'.$this->l('Group access').'</label>
-18
View File
@@ -111,15 +111,6 @@ class AdminCatalog extends AdminTab
}
$this->attributeGenerator->postProcess();
}
elseif (isset($_GET['imageresize']))
{
if (!isset($this->imageResize))
{
include_once(PS_ADMIN_DIR.'/tabs/AdminImageResize.php');
$this->imageResize = new AdminImageResize();
}
$this->imageResize->postProcess();
}
$this->adminProducts->postProcess($this->token);
}
@@ -158,15 +149,6 @@ class AdminCatalog extends AdminTab
}
$this->attributeGenerator->displayForm();
}
elseif (isset($_GET['imageresize']))
{
if (!isset($this->imageResize))
{
include_once(PS_ADMIN_DIR.'/tabs/AdminImageResize.php');
$this->imageResize = new AdminImageResize();
}
$this->imageResize->displayForm();
}
elseif (!isset($_GET['editImage']))
{
$home = false;
+1 -31
View File
@@ -100,36 +100,6 @@ class AdminCategories extends AdminTab
}
}
}
/* Change object statuts (active, inactive) */
elseif (isset($_GET['status']) AND Tools::getValue($this->identifier))
{
if ($this->tabAccess['edit'] === '1')
{
if (Validate::isLoadedObject($object = $this->loadObject()))
{
if ($object->toggleStatus())
{
$target = '';
if (($id_category = (int)(Tools::getValue('id_category'))) AND Tools::getValue('id_product'))
$target = '&id_category='.(int)($id_category);
else
{
$referrer = Tools::secureReferrer($_SERVER['HTTP_REFERER']);
if (preg_match('/id_category=(\d+)/', $referrer, $matches))
$target = '&id_category='.(int)($matches[1]);
}
Module::hookExec('categoryUpdate');
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.$target.'&token='.Tools::getValue('token'));
}
else
$this->_errors[] = Tools::displayError('An error occurred while updating status.');
}
else
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
/* Delete object */
elseif (isset($_GET['delete'.$this->table]))
{
@@ -259,7 +229,7 @@ class AdminCategories extends AdminTab
foreach ($this->_languages AS $language)
echo '
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<textarea name="description_'.$language['id_lang'].'" rows="5" cols="40">'.htmlentities($this->getFieldValue($obj, 'description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
<textarea name="description_'.$language['id_lang'].'" rows="10" cols="100">'.htmlentities($this->getFieldValue($obj, 'description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
echo ' <p class="clear"></p>
</div>
+1 -1
View File
@@ -83,7 +83,7 @@ class AdminContact extends AdminPreferences
'PS_SHOP_PHONE' => 'phone');
$this->_fieldsShop = array();
$orderedFields = AddressFormat::getOrderedAddressFields(Configuration::get('PS_SHOP_COUNTRY_ID'));
$orderedFields = AddressFormat::getOrderedAddressFields(Configuration::get('PS_SHOP_COUNTRY_ID'), false, true);
foreach($orderedFields as $lineFields)
if (($patterns = explode(' ', $lineFields)))
+19 -7
View File
@@ -129,24 +129,32 @@ class AdminCustomerThreads extends AdminTab
'{messages}' => $output,
'{employee}' => $currentEmployee->firstname.' '.$currentEmployee->lastname,
'{comment}' => stripslashes($_POST['message_forward']));
Mail::Send($context->language->id, 'forward_msg', Mail::l('Fwd: Customer message'), $params,
if (Mail::Send($context->language->id, 'forward_msg', Mail::l('Fwd: Customer message'), $params,
$employee->email, $employee->firstname.' '.$employee->lastname,
$currentEmployee->email, $currentEmployee->firstname.' '.$currentEmployee->lastname);
$currentEmployee->email, $currentEmployee->firstname.' '.$currentEmployee->lastname,
NULL, NULL, _PS_MAIL_DIR_, true))
{
$cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$_POST['message_forward'];
$cm->add();
}
}
elseif (($email = Tools::getValue('email')) AND Validate::isEmail($email))
{
$params = array(
'{messages}' => $output,
'{employee}' => $currentEmployee->firstname.' '.$currentEmployee->lastname,
'{comment}' => stripslashes($_POST['message_forward']));
Mail::Send($context->language->id, 'forward_msg', Mail::l('Fwd: Customer message'), $params,
if (Mail::Send((int)($cookie->id_lang), 'forward_msg', Mail::l('Fwd: Customer message'), $params,
$email, NULL,
$currentEmployee->email, $currentEmployee->firstname.' '.$currentEmployee->lastname);
$currentEmployee->email, $currentEmployee->firstname.' '.$currentEmployee->lastname,
NULL, NULL, _PS_MAIL_DIR_, true))
{
$cm->message = $this->l('Message forwarded to').' '.$email."\n".$this->l('Comment:').' '.$_POST['message_forward'];
$cm->add();
}
}
else
echo '<div class="alert error">'.Tools::displayError('Email invalid.').'</div>';
}
@@ -173,9 +181,13 @@ class AdminCustomerThreads extends AdminTab
'{reply}' => Tools::nl2br(Tools::getValue('reply_message')),
'{link}' => Tools::url($context->link->getPageLink('contact', true), 'id_customer_thread='.(int)($ct->id).'&token='.$ct->token),
);
Mail::Send($ct->id_lang, 'reply_msg', Mail::l('An answer to your message is available'), $params, Tools::getValue('msg_email'), NULL, NULL, NULL, $fileAttachment);
$ct->status = 'closed';
$ct->update();
if (Mail::Send($ct->id_lang, 'reply_msg', Mail::l('An answer to your message is available'),
$params, Tools::getValue('msg_email'), NULL, NULL, NULL, $fileAttachment, NULL,
_PS_MAIL_DIR_, true))
{
$ct->status = 'closed';
$ct->update();
}
Tools::redirectAdmin(self::$currentIndex.'&id_customer_thread='.(int)$id_customer_thread.'&viewcustomer_thread&token='.Tools::getValue('token'));
}
else
+5
View File
@@ -82,6 +82,11 @@ class AdminDb extends AdminPreferences
$tables_engine[$table['Name']] = $table['Engine'];
$engineType = pSQL(Tools::getValue('engineType'));
/* Datas are not saved in database but in config/settings.inc.php */
$settings = array('_MYSQL_ENGINE_' => $engineType);
rewriteSettingsFile(NULL, NULL, $settings);
foreach ($_POST['tablesBox'] AS $table)
{
if ($engineType == $tables_engine[$table])
+2 -2
View File
@@ -81,8 +81,8 @@ class AdminEmails extends AdminPreferences
<fieldset class="width2" style="margin-top: 10px;">
<legend><img src="../img/admin/email.gif" alt="" /> '.$this->l('Test your e-mail configuration').'</legend>
<script type="text/javascript">
var textMsg = "'.$this->l('This is a test message, your server is now available to send email').'";
var textSubject = "'.$this->l('Test message - Prestashop').'";
var textMsg = "'.urlencode($this->l('This is a test message, your server is now available to send email')).'";
var textSubject = "'.urlencode($this->l('Test message - Prestashop')).'";
var textSendOk = "'.$this->l('Mail is sent').'";
var textSendError= "'.$this->l('Error: please check your configuration').'";
var errorMail = "'.$this->l('This email address is wrong!').'";
+8 -1
View File
@@ -62,6 +62,12 @@ class AdminGenerator extends AdminTab
<p>'.$this->l('Enable only if your server allows URL rewriting.').'</p>
</div>
<div class="clear">&nbsp;</div>
<label for="imageCacheControl">'.$this->l('Disable apache multiviews').'</label>
<div class="margin-form">
<input type="checkbox" name="PS_HTACCESS_DISABLE_MULTIVIEWS" id="PS_HTACCESS_CACHE_CONTROL" value="1" '.(Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS') == 1 ? 'checked="checked"' : '').' />
<p>'.$this->l('Enable this option only if you have problems with some pages URL rewriting.').'</p>
</div>
<div class="clear">&nbsp;</div>
<label for="specific_configuration">'.$this->l('Specific configuration').'</label>
<div class="margin-form">
<textarea rows="10" class="width3" id="specific_configuration" name="ps_htaccess_specific">'.Configuration::get('PS_HTACCESS_SPECIFIC').'</textarea>
@@ -112,8 +118,9 @@ class AdminGenerator extends AdminTab
{
Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int)Tools::getValue('PS_HTACCESS_CACHE_CONTROL'));
Configuration::updateValue('PS_REWRITING_SETTINGS', (int)Tools::getValue('PS_REWRITING_SETTINGS'));
Configuration::updateValue('PS_HTACCESS_DISABLE_MULTIVIEWS', (int)Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'));
Configuration::updateValue('PS_HTACCESS_SPECIFIC', Tools::getValue('ps_htaccess_specific'), true);
if (Tools::generateHtaccess($this->_htFile, Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Tools::getValue('ps_htaccess_specific')))
if (Tools::generateHtaccess($this->_htFile, Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Tools::getValue('ps_htaccess_specific'), Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')))
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
$this->_errors[] = $this->l('Cannot write into file:').' <b>'.$this->_htFile.'</b><br />'.$this->l('Please check write permissions.');
}
+4 -2
View File
@@ -207,7 +207,7 @@ class AdminGroups extends AdminTab
$customers = $obj->getCustomers(false, $from, $customersPerPage);
echo '<tr>
echo '<table><tr>
<form method="post" action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'">
<td style="vertical-align: bottom;"><span style="float: left; height:30px">';
@@ -235,7 +235,9 @@ class AdminGroups extends AdminTab
echo ' </select> / '.$nbCustomers.' result(s)
</span><span class="clear"></span></td>
</form>
</tr>';
</tr>
</table>
<div class="clear"></div>';
// Pagination End
echo '<table cellspacing="0" cellpadding="0" class="table widthfull">
+9 -2
View File
@@ -94,6 +94,7 @@ class AdminHome extends AdminTab
if ($rewrite + $htaccessOptimized + $smartyOptimized + $cccOptimized + $shopEnabled + $htaccessAfterUpdate + $indexRebuiltAfterUpdate != 14)
{
echo '
<div class="admin-box1">
<h5>'.$this->l('A good beginning...')
@@ -146,6 +147,8 @@ class AdminHome extends AdminTab
</ul>
</div>';
}
}
public function display()
{
$context = Context::getContext();
@@ -159,9 +162,13 @@ class AdminHome extends AdminTab
<h1>'.$this->l('Dashboard').'</h1>
<hr style="background-color: #812143;color: #812143;" />
<br />';
if (@ini_get('allow_url_fopen') AND $update = checkPSVersion())
if (@ini_get('allow_url_fopen'))
{
$upgrade = new Upgrader();
if($update = $upgrade->checkPSVersion())
echo '<div class="warning warn" style="margin-bottom:30px;"><h3>'.$this->l('New PrestaShop version available').' : <a style="text-decoration: underline;" href="'.$update['link'].'" target="_blank">'.$this->l('Download').'&nbsp;'.$update['name'].'</a> !</h3></div>';
elseif (!@ini_get('allow_url_fopen'))
}
else
{
echo '<p>'.$this->l('Update notification unavailable').'</p>';
echo '<p>&nbsp;</p>';
-99
View File
@@ -1,99 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision: 7310 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminImageResize extends AdminTab
{
public function postProcess()
{
$context = Context::getContext();
if (isset($_POST['resize']))
{
$imagesTypes = ImageType::getImagesTypes('products');
$sourceFile['tmp_name'] = _PS_IMG_DIR_.'/p/'.Tools::getValue('id_product').'-'.Tools::getValue('id_image').'.jpg';
foreach ($imagesTypes AS $k => $imageType)
if (!imageCut
($sourceFile,
_PS_IMG_DIR_.'p/'.Tools::getValue('id_product').'-'.Tools::getValue('id_image').'-'.stripslashes($imageType['name']).'.jpg',
$imageType['width'],
$imageType['height'],
'jpg',
$_POST[$imageType['id_image_type'].'_x1'],
$_POST[$imageType['id_image_type'].'_y1']))
$this->_errors = Tools::displayError('An error occurred while copying image.').' '.stripslashes($imageType['name']);
// Save and stay on same form
if (Tools::getValue('saveandstay') == 'on')
Tools::redirectAdmin(self::$currentIndex.'&id_product='.Tools::getValue('id_product').'&id_category='.(int)(Tools::getValue('id_category')).'&addproduct&conf=4&tabs=1&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id));
// Default behavior (save and back)
Tools::redirectAdmin(self::$currentIndex.'&id_category='.(int)(Tools::getValue('id_category')).'&conf='.(int)(Tools::getValue('conf')).'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id));
} else
parent::postProcess();
}
public function displayForm($isMainTab = true)
{
$context = Context::getContext();
parent::displayForm();
$imagesTypes = ImageType::getImagesTypes();
$imageObj = new Image(Tools::getValue('id_image'));
echo '
<script type="text/javascript" src="../js/cropper/prototype.js"></script>
<script type="text/javascript" src="../js/cropper/scriptaculous.js"></script>
<script type="text/javascript" src="../js/cropper/builder.js"></script>
<script type="text/javascript" src="../js/cropper/dragdrop.js"></script>
<script type="text/javascript" src="../js/cropper/cropper.js"></script>
<script type="text/javascript" src="../js/cropper/loader.js"></script>
<form enctype="multipart/form-data" method="post" action="'.self::$currentIndex.'&imageresize&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id).'">
<input type="hidden" name="id_product" value="'.Tools::getValue('id_product').'" />
<input type="hidden" name="id_category" value="'.Tools::getValue('id_category').'" />
<input type="hidden" name="saveandstay" value="'.Tools::getValue('submitAddAndStay').'" />
<input type="hidden" name="conf" value="'.(Tools::getValue('toconf')).'" />
<input type="hidden" name="imageresize" value="imageresize" />
<input type="hidden" name="id_image" value="'.Tools::getValue('id_image').'" />
<fieldset>
<legend><img src="../img/admin/picture.gif" />'.$this->l('Image resize').'</legend>
'.$this->l('Using your mouse, define which area of the image is to be used for generating each type of thumbnail.').'
<br /><br />
<img src="'._THEME_PROD_DIR_.$imageObj->getExistingImgPath().'.jpg" id="testImage">
<label for="imageChoice">'.$this->l('Thumbnails format').'</label>
<div class="margin-form"">
<select name="imageChoice" id="imageChoice">';
foreach ($imagesTypes AS $type)
echo '<option value="../img/p/'.$imageObj->getExistingImgPath().'.jpg|'.$type['width'].'|'.$type['height'].'|'.$type['id_image_type'].'">'.$type['name'].'</option>';
echo ' </select>
<input type="submit" class="button" style="margin-left : 40px;" name="resize" value="'.$this->l(' Save all ').'" />
</div>';
foreach ($imagesTypes AS $type)
echo '
<input type="hidden" name="'.$type['id_image_type'].'_x1" id="'.$type['id_image_type'].'_x1" value="0" />
<input type="hidden" name="'.$type['id_image_type'].'_y1" id="'.$type['id_image_type'].'_y1" value="0" />
<input type="hidden" name="'.$type['id_image_type'].'_x2" id="'.$type['id_image_type'].'_x2" value="0" />
<input type="hidden" name="'.$type['id_image_type'].'_y2" id="'.$type['id_image_type'].'_y2" value="0" />';
echo ' </fieldset>
</form>';
}
}
+104 -13
View File
@@ -50,6 +50,7 @@ class AdminImages extends AdminTab
public function displayList()
{
parent::displayList();
$this->displayImagePreferences();
$this->displayRegenerate();
$this->displayMoveImages();
}
@@ -66,7 +67,34 @@ class AdminImages extends AdminTab
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}elseif (Tools::getValue('submitMoveImages'.$this->table))
$this->_moveImagesToNewFileSystem();
{
if ($this->tabAccess['edit'] === '1')
{
if($this->_moveImagesToNewFileSystem())
Tools::redirectAdmin($currentIndex.'&conf=25'.'&token='.$this->token);
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}elseif (Tools::getValue('submitImagePreferences'))
{
if ($this->tabAccess['edit'] === '1')
{
if ((int)Tools::getValue('PS_JPEG_QUALITY') < 0
|| (int)Tools::getValue('PS_JPEG_QUALITY') > 100)
$this->_errors[] = Tools::displayError('Incorrect value for JPEG image quality.');
elseif ((int)Tools::getValue('PS_PNG_QUALITY') < 0
|| (int)Tools::getValue('PS_PNG_QUALITY') > 9)
$this->_errors[] = Tools::displayError('Incorrect value for PNG image quality.');
elseif (!Configuration::updateValue('PS_IMAGE_QUALITY', Tools::getValue('PS_IMAGE_QUALITY'))
|| !Configuration::updateValue('PS_JPEG_QUALITY', Tools::getValue('PS_JPEG_QUALITY'))
|| !Configuration::updateValue('PS_PNG_QUALITY', Tools::getValue('PS_PNG_QUALITY')))
$this->_errors[] = Tools::displayError('Unknown error.');
else
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
else
parent::postProcess();
}
@@ -177,11 +205,13 @@ class AdminImages extends AdminTab
);
echo '
<h2 class="space">'.$this->l('Regenerate thumbnails').'</h2>
'.$this->l('Regenerates thumbnails for all existing product images').'.<br /><br />';
'.$this->l('Regenerates thumbnails for all existing product images').'.<br /><br /><div class="width4">';
$this->displayWarning($this->l('Please be patient, as this can take several minutes').'<br />'.$this->l('Be careful! Manually generated thumbnails will be erased by automatically generated thumbnails.'));
echo '
echo '</div>
<form action="'.self::$currentIndex.'&token='.$this->token.'" method="post">
<fieldset class="width2">
<fieldset class="width4">
<legend><img src="../img/admin/picture.gif" /> '.$this->l('Regenerate thumbnails').'</legend><br />
<label>'.$this->l('Select image').'</label>
<div class="margin-form">
@@ -229,6 +259,8 @@ class AdminImages extends AdminTab
*/
private function _deleteOldImages($dir, $type, $product = false)
{
if (!is_dir($dir))
return false;
$toDel = scandir($dir);
foreach ($toDel AS $d)
foreach ($type AS $imageType)
@@ -260,6 +292,8 @@ class AdminImages extends AdminTab
// Regenerate images
private function _regenerateNewImages($dir, $type, $productsImages = false)
{
if (!is_dir($dir))
return false;
$errors = false;
$toRegen = scandir($dir);
if (!$productsImages)
@@ -331,17 +365,19 @@ class AdminImages extends AdminTab
{
$productsImages = Image::getAllImages();
foreach ($productsImages AS $k => $image)
{
$imageObj = new Image($image['id_image']);
if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg'))
foreach ($result AS $k => $module)
{
if ($moduleInstance = Module::getInstanceByName($module['name']) AND is_callable(array($moduleInstance, 'hookwatermark')))
call_user_func(array($moduleInstance, 'hookwatermark'), array('id_image' => $image['id_image'], 'id_product' => $image['id_product']));
call_user_func(array($moduleInstance, 'hookwatermark'), array('id_image' => $imageObj->id, 'id_product' => $imageObj->id_product));
if (time() - $this->start_time > $this->max_execution_time - 4) // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
return 'timeout';
}
}
}
}
private function _regenerateThumbnails($type = 'all', $deleteOldImages = false)
{
@@ -401,12 +437,18 @@ class AdminImages extends AdminTab
*/
public function displayMoveImages()
{
$safe_mode = ini_get('safe_mode');
echo '
<br /><h2 class="space">'.$this->l('Move images').'</h2>'.
$this->l('A new storage system for product images is now used by PrestaShop. It offers better performance if your shop has a very large number of products.').'<br />'.
'<br />
'<br />';
if($safe_mode)
echo $this->displayWarning('PrestaShop has detected that your server configuration is not compatible with the new storage system (directive "safe_mode" is activated). You should continue to use the actual system.');
else
echo '
<form action="'.self::$currentIndex.'&token='.$this->token.'" method="post">
<fieldset class="width3">
<fieldset class="width4">
<legend><img src="../img/admin/picture.gif" /> '.$this->l('Move images').'</legend><br />'.
$this->l('You can choose to keep your images stored in the previous system - nothing wrong with that.').'<br />'.
$this->l('You can also decide to move your images to the new storage system: in this case, click on the "Move images" button below. Please be patient, as this can take several minutes.').
@@ -425,11 +467,60 @@ class AdminImages extends AdminTab
*/
private function _moveImagesToNewFileSystem()
{
ini_set('max_execution_time', $this->max_execution_time); // ini_set may be disabled, we need the real value
$this->max_execution_time = (int)ini_get('max_execution_time');
$result = Image::moveToNewFileSystem($this->max_execution_time);
if ($result === 'timeout')
$this->_errors[] = Tools::displayError('Not all images have been moved, server timed out before finishing. Click on \"Move images\" again to resume moving images');
Tools::redirectAdmin(self::$currentIndex.'&conf=25'.'&token='.$this->token);
if (!Image::testFileSystem())
$this->_errors[] = Tools::displayError('Error: your server configuration is not compatible with the new image system. No images were moved');
else
{
ini_set('max_execution_time', $this->max_execution_time); // ini_set may be disabled, we need the real value
$this->max_execution_time = (int)ini_get('max_execution_time');
$result = Image::moveToNewFileSystem($this->max_execution_time);
if ($result === 'timeout')
$this->_errors[] = Tools::displayError('Not all images have been moved, server timed out before finishing. Click on \"Move images\" again to resume moving images');
else if ($result === false)
$this->_errors[] = Tools::displayError('Error: some or all images could not be moved.');
}
return (sizeof($this->_errors) > 0 ? false : true);
}
/**
* Display the block for moving images
*/
public function displayImagePreferences()
{
global $currentIndex;
echo '<br />
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
<fieldset class="width4">
<legend><img src="../img/admin/picture.gif" /> '.$this->l('Images').'</legend>'.'
<p>'.$this->l('JPEG images have a small file size and standard quality. PNG images have a bigger file size, a higher quality and support transparency. Note that in all cases the image files will have the .jpg extension.').'
<br /><br />'.$this->l('WARNING: This feature may not be compatible with your theme or with some modules. In particular, PNG mode is not compatible with the Watermark module. If you encounter any issue, turn it off by selecting "Use JPEG".').'</p>
<br />
<label>'.$this->l('Image quality').' </label>
<div class="margin-form">
<input type="radio" value="jpg" name="PS_IMAGE_QUALITY" id="PS_IMAGE_QUALITY_0" '.(Configuration::get('PS_IMAGE_QUALITY') == 'jpg' ? 'checked="checked"' : '').' />
<label class="t" for="PS_IMAGE_QUALITY_0">'.$this->l('Use JPEG').'</label>
<br />
<input type="radio" value="png" name="PS_IMAGE_QUALITY" id="PS_IMAGE_QUALITY_1" '.(Configuration::get('PS_IMAGE_QUALITY') == 'png' ? 'checked="checked"' : '').' />
<label class="t" for="PS_IMAGE_QUALITY_1">'.$this->l('Use PNG only if the base image is in PNG format').'</label>
<br />
<input type="radio" value="png_all" name="PS_IMAGE_QUALITY" id="PS_IMAGE_QUALITY_2" '.(Configuration::get('PS_IMAGE_QUALITY') == 'png_all' ? 'checked="checked"' : '').' />
<label class="t" for="PS_IMAGE_QUALITY_2">'.$this->l('Use PNG for all images').'</label>
</div>
<br />
<label for="PS_JPEG_QUALITY">'.$this->l('JPEG quality').'</label>
<div class="margin-form">
<input type="text" name="PS_JPEG_QUALITY" id="PS_JPEG_QUALITY" value="'.(int)Configuration::get('PS_JPEG_QUALITY').'" size="3" />
<p>'.$this->l('Ranges from 0 (worst quality, smallest file) to 100 (best quality, biggest file)').'</p>
</div>
<label for="PS_PNG_QUALITY">'.$this->l('PNG quality').'</label>
<div class="margin-form">
<input type="text" name="PS_PNG_QUALITY" id="PS_PNG_QUALITY" value="'.(int)Configuration::get('PS_PNG_QUALITY').'" size="3" />
<p>'.$this->l('Ranges from 9 (worst quality, smallest file) to 0 (best quality, biggest file)').'</p>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitImagePreferences" class="button" />
</div>
</fieldset>
</form>';
}
}
+101 -42
View File
@@ -27,7 +27,8 @@
include_once(PS_ADMIN_DIR.'/../images.inc.php');
@ini_set('max_execution_time', 0);
define('MAX_LINE_SIZE', 4096);
// No max line limit since the lines can be more than 4096. Performance impact is not significant.
define('MAX_LINE_SIZE', 0);
define('UNFRIENDLY_ERROR', false); // Used for validatefields diying without user friendly error or not
@@ -93,7 +94,10 @@ class AdminImport extends AdminTab
'ecotax' => array('label' => $this->l('Ecotax')),
'quantity' => array('label' => $this->l('Quantity')),
'weight' => array('label' => $this->l('Weight')),
'default_on' => array('label' => $this->l('Default'))
'default_on' => array('label' => $this->l('Default')),
'image_position' => array('label' => $this->l('Image position'),
'help' => $this->l('Position of the product image to use for this combination. If you use this field, leave image URL empty.')),
'image_url' => array('label' => $this->l('Image URL')),
);
self::$default_values = array(
@@ -164,6 +168,9 @@ class AdminImport extends AdminTab
'link_rewrite' => array('label' => $this->l('URL rewritten')),
'available_now' => array('label' => $this->l('Text when in-stock')),
'available_later' => array('label' => $this->l('Text if back-order allowed')),
'available_for_order' => array('label' => $this->l('Available for order')),
'date_add' => array('label' => $this->l('Date add product')),
'show_price' => array('label' => $this->l('Show price')),
'image' => array('label' => $this->l('Image URLs (x,y,z...)')),
'delete_existing_images' => array(
'label' => $this->l('Delete existing images (0 = no, 1 = yes)'),
@@ -190,6 +197,8 @@ class AdminImport extends AdminTab
'online_only' => 0,
'condition' => 'new',
'shop' => Configuration::get('PS_SHOP_DEFAULT'),
'date_add' => date('Y-m-d H:i:s'),
'condition' => 'new',
);
break;
@@ -286,6 +295,15 @@ class AdminImport extends AdminTab
parent::__construct();
}
private static function rewindBomAware($handle)
{
// A rewind wrapper that skip BOM signature wrongly
rewind($handle);
if (($bom = fread($handle,3)) != "\xEF\xBB\xBF") {
rewind($handle);
}
}
private static function getBoolean($field)
{
return (boolean)$field;
@@ -300,11 +318,18 @@ class AdminImport extends AdminTab
private static function split($field)
{
if (empty($field))
return array();
$separator = ((is_null(Tools::getValue('multiple_value_separator')) OR trim(Tools::getValue('multiple_value_separator')) == '' ) ? ',' : Tools::getValue('multiple_value_separator'));
$tab = explode($separator, $field);
$res = array_map('strval', $tab);
$res = array_map('trim', $tab);
$temp = tmpfile();
fwrite($temp,$field);
rewind($temp);
$tab = fgetcsv($temp, MAX_LINE_SIZE, $separator);
fclose($temp);
if (empty($tab) || (!is_array($tab)))
return array();
return $tab;
}
private static function createMultiLangField($field)
@@ -409,22 +434,7 @@ class AdminImport extends AdminTab
return true;
}
public static function fgetcsv($handle, $lenght, $delimiter)
{
if (feof($handle))
return false;
$line = fgets($handle, $lenght);
if ($line === false)
return false;
$tmpTab = explode($delimiter, $line);
foreach ($tmpTab AS &$row)
if (preg_match ('/^".*"$/Uims',$row))
$row = trim($row, '"');
return $tmpTab;
}
static public function array_walk(&$array, $funcname, &$user_data = false)
public static function array_walk(&$array, $funcname, &$user_data = false)
{
if (!is_callable($funcname)) return false;
@@ -434,8 +444,6 @@ class AdminImport extends AdminTab
return true;
}
/**
* copyImg copy an image located in $url and save it in a path
* according to $entity->$id_entity .
@@ -457,8 +465,7 @@ class AdminImport extends AdminTab
default:
case 'products':
$imageObj = new Image($id_image);
$imageObj->createImgFolder();
$path = _PS_PROD_IMG_DIR_.$imageObj->getImgPath();
$path = $imageObj->getPathForCreation();
break;
case 'categories':
$path = _PS_CAT_IMG_DIR_.(int)($id_entity);
@@ -609,16 +616,14 @@ class AdminImport extends AdminTab
$product = new Product();
self::setEntityDefaultValues($product);
self::array_walk($info, array('AdminImport', 'fillInfo'), $product);
$trg_id = (int)$product->id_tax_rules_group;
if ($product->id_tax_rules_group == 0 || !Validate::isLoadedObject(new TaxRulesGroup($trg_id)))
$this->_addProductWarning('id_tax_rules_group', $product->id_tax_rules_group, Tools::displayError('Invalid tax rule group ID, you first need a group with this ID.'));
else
if ((int)$product->id_tax_rules_group != 0)
{
if(Validate::isLoadedObject(new TaxRulesGroup($product->id_tax_rules_group)))
$product->tax_rate = TaxRulesGroup::getTaxesRate((int)$product->id_tax_rules_group, Configuration::get('PS_COUNTRY_DEFAULT'), 0, 0);
else
$this->_addProductWarning('id_tax_rules_group', $product->id_tax_rules_group, Tools::displayError('Invalid tax rule group ID, you first need a group with this ID.'));
}
if (isset($product->manufacturer) AND is_numeric($product->manufacturer) AND Manufacturer::manufacturerExists((int)($product->manufacturer)))
$product->id_manufacturer = (int)($product->manufacturer);
elseif (isset($product->manufacturer) AND is_string($product->manufacturer) AND !empty($product->manufacturer))
@@ -724,6 +729,7 @@ class AdminImport extends AdminTab
$product->id_category_default = isset($product->id_category[0]) ? (int)($product->id_category[0]) : '';
$link_rewrite = (is_array($product->link_rewrite) && count($product->link_rewrite)) ? $product->link_rewrite[$defaultLanguageId] : '';
$valid_link = Validate::isLinkRewrite($link_rewrite);
if ((isset($product->link_rewrite[$defaultLanguageId]) AND empty($product->link_rewrite[$defaultLanguageId])) OR !$valid_link)
@@ -756,8 +762,13 @@ class AdminImport extends AdminTab
}
// If no id_product or update failed
if (!$res)
{
if (isset($product->date_add) && $product->date_add != '')
$res = $product->add(false);
else
$res = $product->add();
}
}
// If both failed, mysql error
if (!$res)
{
@@ -889,6 +900,7 @@ class AdminImport extends AdminTab
public function attributeImport()
{
global $cookie;
$defaultLanguage = Configuration::get('PS_LANG_DEFAULT');
$groups = array();
foreach (AttributeGroup::getAttributesGroups($defaultLanguage) AS $group)
@@ -909,8 +921,47 @@ class AdminImport extends AdminTab
$info = array_map('trim', $info);
self::setDefaultValues($info);
$product = new Product((int)($info['id_product']), false, $defaultLanguage);
$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($info['ecotax']), (int)($info['quantity']), null, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int)($info['default_on']), strval($info['upc']));
$id_image = null;
if (isset($info['image_url']) && $info['image_url'])
{
$productHasImages = (bool)Image::getImages((int)($cookie->id_lang), (int)($product->id));
$url = $info['image_url'];
$image = new Image();
$image->id_product = (int)($product->id);
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = (!$productHasImages) ? true : false;
$image->legend = self::createMultiLangField($product->name);
if (($fieldError = $image->validateFields(UNFRIENDLY_ERROR, true)) === true AND ($langFieldError = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true AND $image->add())
{
if (!self::copyImg($product->id, $image->id, $url))
$this->_warnings[] = Tools::displayError('Error copying image: ').$url;
else
$id_image = array($image->id);
}
else
{
$this->_warnings[] = $image->legend[$defaultLanguageId].(isset($image->id_product) ? ' ('.$image->id_product.')' : '').' '.Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : '').mysql_error();
}
} elseif (isset($info['image_position']) && $info['image_position'])
{
$images = $product->getImages($defaultLanguage);
if ($images)
foreach ($images as $row)
if($row['position'] == (int)$info['image_position'])
{
$id_image = array($row['id_image']);
break;
}
if (!$id_image)
$this->_warnings[] = Tools::displayError('No image found for combination with id_product = '.$product->id.' and image position = '.(int)$info['image_position'].'.');
}
$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($info['ecotax']), (int)($info['quantity']), $id_image, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int)($info['default_on']), strval($info['upc']));
foreach (explode($fsep, $info['options']) as $option)
{
list($group, $attribute) = array_map('trim', explode(':', $option));
@@ -1291,8 +1342,6 @@ class AdminImport extends AdminTab
if (preg_match('/^\..*|index\.php/i', $filename))
unset($filesToImport[$k]);
unset($filename);
if (sizeof($filesToImport))
{
echo '
<div class="space">
<form id="preview_import" action="'.self::$currentIndex.'&token='.$this->token.'" method="post" style="display:inline" enctype="multipart/form-data" class="clear" onsubmit="if ($(\'#truncate\').get(0).checked) {if (confirm(\''.$this->l('Are you sure you want to delete', __CLASS__, true, false).'\' + \' \' + $(\'#entity > option:selected\').text().toLowerCase() + \''.$this->l('?', __CLASS__, true, false).'\')){this.submit();} else {return false;}}">
@@ -1309,7 +1358,10 @@ class AdminImport extends AdminTab
echo'>'.$entity.'</option>';
}
echo ' </select>
</div>
</div>';
if (sizeof($filesToImport))
{
echo '
<label class="clear">'.$this->l('Select your .CSV file:').' </label>
<div class="margin-form">
<select name="csv">';
@@ -1346,6 +1398,16 @@ class AdminImport extends AdminTab
<div>
'.$this->l('Note that the category import does not support categories of the same name').'
</div>
';
}
else
echo '
<div class="warn">
'.$this->l('No CSV file is available, please upload one file above.').'<br /><br />
'.$this->l('You can get many informations about CSV import at:').' <a href="http://www.prestashop.com/wiki/Troubleshooting_6/" target="_blank">http://www.prestashop.com/wiki/Troubleshooting_6/</a><br /><br />
'.$this->l('More about CSV format at: ').' <a href="http://en.wikipedia.org/wiki/Comma-separated_values" target="_blank">http://en.wikipedia.org/wiki/Comma-separated_values</a>
</div>';
echo '
</fieldset>
</form>
<fieldset style="display: inline; float: right; margin-left: 20px;">
@@ -1380,7 +1442,6 @@ class AdminImport extends AdminTab
if (Tools::getValue('entity'))
echo' <script type="text/javascript">$("select#entity").change();</script>';
}
}
public function utf8_encode_array($array)
{
@@ -1396,7 +1457,7 @@ class AdminImport extends AdminTab
private function getNbrColumn($handle, $glue)
{
$tmp = fgetcsv($handle, MAX_LINE_SIZE, $glue);
fseek($handle, 0);
self::rewindBomAware($handle);
return sizeof($tmp);
}
@@ -1415,14 +1476,12 @@ class AdminImport extends AdminTab
{
$handle = fopen(dirname(__FILE__).'/../import/'.strval(preg_replace('/\.{2,}/', '.',Tools::getValue('csv'))), 'r');
/* No BOM allowed */
$bom = fread($handle, 3);
if ($bom != '\xEF\xBB\xBF')
rewind($handle);
if (!$handle)
die(Tools::displayError('Cannot read the CSV file'));
self::rewindBomAware($handle);
for ($i = 0; $i < (int)(Tools::getValue('skip')); ++$i)
$line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator', ';'));
return $handle;
@@ -1468,7 +1527,7 @@ class AdminImport extends AdminTab
echo '</tr>';
}
echo '</table>';
fseek($handle, 0);
self::rewindBomAware($handle);
}
public function displayCSV()
+8
View File
@@ -350,6 +350,14 @@ class AdminLanguages extends AdminTab
<input type="file" name="no-picture" /> <sup>*</sup>
<p>'.$this->l('Image displayed when "no picture found"').'</p>
</div>
<label>'.$this->l('Is RTL language:').' </label>
<div class="margin-form">
<input type="radio" name="is_rtl" id="is_rtl_on" value="1" '.(($this->getFieldValue($obj, 'is_rtl')) ? 'checked="checked" ' : '').'/>
<label class="t" for="is_rtl_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Yes').'" /></label>
<input type="radio" name="is_rtl" id="active_off" value="0" '.((!$this->getFieldValue($obj, 'is_rtl')) ? 'checked="checked" ' : '').'/>
<label class="t" for="is_rtl_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('No').'" /></label>
<p>'.$this->l('To active if this language is a right to left language').' '.$this->l('(Experimental: your theme must be compliant with RTL language)').'</p>
</div>
<label>'.$this->l('Status:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" '.((!$obj->id OR $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '').'/>
+6 -2
View File
@@ -93,9 +93,13 @@ class AdminLocalization extends AdminPreferences
<label>'.$this->l('Localization pack you want to import:').'</label>
<div class="margin-form">
<select id="iso_localization_pack" name="iso_localization_pack">';
$localization_packs = @simplexml_load_file('http://www.prestashop.com/rss/localization.xml');
$localization_packs = Tools::simplexml_load_file('http://www.prestashop.com/rss/localization.xml');
if (!$localization_packs)
$localization_packs = simplexml_load_file(dirname(__FILE__).'/../../localization/localization.xml');
{
$localizationFile = dirname(__FILE__).'/../../localization/localization.xml';
if (file_exists($localizationFile))
$localization_packs = simplexml_load_file($localizationFile);
}
if ($localization_packs)
foreach($localization_packs->pack as $pack)
echo '<option value="'.$pack->iso.'">'.$pack->name.'</option>';
+1
View File
@@ -46,6 +46,7 @@ class AdminManufacturers extends AdminTab
$countries = Country::getCountries($context->language->id);
foreach ($countries AS $country)
$this->countriesArray[$country['id_country']] = $country['name'];
$this->fieldsDisplayAddresses = array(
'id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'm!manufacturer_name' => array('title' => $this->l('Manufacturer'), 'width' => 100),
+7 -6
View File
@@ -747,9 +747,9 @@ class AdminModules extends AdminTab
}
return false;
});
'.(!$goto ? '': '$(\'#'.$goto.'_content\').slideToggle( function (){
'.(!$goto ? '': 'if ($(\'#'.$goto.'_content\').length > 0) $(\'#'.$goto.'_content\').slideToggle( function (){
$(\'#'.$goto.'_img\').attr(\'src\', \'../img/admin/less.png\');
'.(!$goto ? '' : '$.scrollTo($("#modgo_'.Tools::getValue('module_name').'"), 300 ,
'.(!$goto ? '' : 'if ($("#modgo_'.Tools::getValue('module_name').'").length > 0) $.scrollTo($("#modgo_'.Tools::getValue('module_name').'"), 300 ,
{onAfter:function(){
$("#modgo_'.Tools::getValue('module_name').'").fadeTo(100, 0, function (){
$(this).fadeTo(100, 0, function (){
@@ -875,18 +875,19 @@ class AdminModules extends AdminTab
$return = '';
$href = self::$currentIndex.'&token='.$this->token.'&module_name='.
urlencode($module->name).'&tab_module='.$module->tab;
if ($module->id)
$return .= '<a class="action_module" '.($module->active && method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('desactive', $href).'"' : '').' href="'.self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&'.($module->active ? 'enable=0' : 'enable=1').'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'" '.((Tools::isMultiShopActivated()) ? 'title="'.htmlspecialchars($module->active ? $this->l('Disable this module') : $this->l('Enable this module for all shops')).'"' : '').'>'.($module->active ? $this->l('Disable') : $this->l('Enable')).'</a>&nbsp;&nbsp;';
if ($module->id AND $module->active)
$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('reset', $href).'"' : '').' href="'.self::$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Reset').'</a>&nbsp;&nbsp;';
if ($module->id AND (method_exists($module, 'getContent') OR (isset($module->is_configurable) AND $module->is_configurable) OR Tools::isMultiShopActivated()))
$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('configure', $href).'"' : '').' href="'.self::$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Configure').'</a>&nbsp;&nbsp;';
$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('delete', $href).'"' : '').' onclick="return confirm(\''.$this->l('This action will permanently remove the module from the server. Are you sure you want to do this ?').'\');" href="'.self::$currentIndex.'&deleteModule='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Delete').'</a>&nbsp;&nbsp;';
$hrefDelete = self::$currentIndex.'&deleteModule='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name);
$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('delete', $hrefDelete).'"' : '').' onclick="return confirm(\''.$this->l('This action will permanently remove the module from the server. Are you sure you want to do this ?').'\');" href="'.$hrefDelete.'">'.$this->l('Delete').'</a>&nbsp;&nbsp;';
return $return;
}
+17 -10
View File
@@ -96,7 +96,9 @@ class AdminOrders extends AdminTab
'{lastname}' => $customer->lastname,
'{id_order}' => (int)($order->id)
);
@Mail::Send((int)($order->id_lang), 'in_transit', Mail::l('Package in transit'), $templateVars, $customer->email, $customer->firstname.' '.$customer->lastname);
@Mail::Send((int)($order->id_lang), 'in_transit', Mail::l('Package in transit'), $templateVars,
$customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,
_PS_MAIL_DIR_, true);
}
}
else
@@ -120,13 +122,13 @@ class AdminOrders extends AdminTab
$order = new Order((int)$order->id);
$carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang));
$templateVars = array();
if ($history->id_order_state == _PS_OS_SHIPPING_ AND $order->shipping_number)
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') AND $order->shipping_number)
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
elseif ($history->id_order_state == _PS_OS_CHEQUE_)
elseif ($history->id_order_state == Configuration::get('PS_OS_CHEQUE'))
$templateVars = array(
'{cheque_name}' => (Configuration::get('CHEQUE_NAME') ? Configuration::get('CHEQUE_NAME') : ''),
'{cheque_address_html}' => (Configuration::get('CHEQUE_ADDRESS') ? nl2br(Configuration::get('CHEQUE_ADDRESS')) : ''));
elseif ($history->id_order_state == _PS_OS_BANKWIRE_)
elseif ($history->id_order_state == Configuration::get('PS_OS_BANKWIRE'))
$templateVars = array(
'{bankwire_owner}' => (Configuration::get('BANK_WIRE_OWNER') ? Configuration::get('BANK_WIRE_OWNER') : ''),
'{bankwire_details}' => (Configuration::get('BANK_WIRE_DETAILS') ? nl2br(Configuration::get('BANK_WIRE_DETAILS')) : ''),
@@ -182,7 +184,9 @@ class AdminOrders extends AdminTab
if (Validate::isLoadedObject($order))
{
$varsTpl = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order}' => $message->id_order, '{message}' => (Configuration::get('PS_MAIL_TYPE') == 2 ? $message->message : Tools::nl2br($message->message)));
if (@Mail::Send((int)($order->id_lang), 'order_merchant_comment', Mail::l('New message regarding your order'), $varsTpl, $customer->email, $customer->firstname.' '.$customer->lastname))
if (@Mail::Send((int)($order->id_lang), 'order_merchant_comment',
Mail::l('New message regarding your order'), $varsTpl, $customer->email,
$customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL, _PS_MAIL_DIR_, true))
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$id_order.'&vieworder&conf=11'.'&token='.$this->token);
}
}
@@ -319,7 +323,9 @@ class AdminOrders extends AdminTab
else
{
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list));
@Mail::Send((int)($order->id_lang), 'credit_slip', Mail::l('New credit slip regarding your order'), $params, $customer->email, $customer->firstname.' '.$customer->lastname);
@Mail::Send((int)$order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order', $order->id_lang),
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,
_PS_MAIL_DIR_, true);
}
}
@@ -333,7 +339,9 @@ class AdminOrders extends AdminTab
$currency = $context->currency;
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
$params['{voucher_num}'] = $voucher->name;
@Mail::Send((int)($order->id_lang), 'voucher', Mail::l('New voucher regarding your order'), $params, $customer->email, $customer->firstname.' '.$customer->lastname);
@Mail::Send((int)($order->id_lang), 'voucher', Mail::l('New voucher regarding your order'),
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
NULL, _PS_MAIL_DIR_, true);
}
}
}
@@ -589,7 +597,7 @@ class AdminOrders extends AdminTab
if (sizeof($sources))
{
echo '<br />
<fieldset style="width: 400px;"><legend><img src="../img/admin/tab-stats.gif" /> '.$this->l('Sources').'</legend><ul '.(sizeof($sources) > 3 ? 'style="overflow-y: scroll; height: 200px"' : '').'>';
<fieldset style="width: 400px;"><legend><img src="../img/admin/tab-stats.gif" /> '.$this->l('Sources').'</legend><ul '.(sizeof($sources) > 3 ? 'style="height: 200px; overflow-y: scroll; width: 360px;"' : '').'>';
foreach ($sources as $source)
echo '<li>
'.Tools::displayDate($source['date_add'], $context->language->id, true).'<br />
@@ -865,7 +873,7 @@ class AdminOrders extends AdminTab
<form action="'.$_SERVER['REQUEST_URI'].'&token='.$this->token.'" method="post" onsubmit="if (getE(\'visibility\').checked == true) return confirm(\''.$this->l('Do you want to send this message to the customer?', __CLASS__, true, false).'\');">
<fieldset style="width: 400px;">
<legend style="cursor: pointer;" onclick="$(\'#message\').slideToggle();$(\'#message_m\').slideToggle();return false"><img src="../img/admin/email_edit.gif" /> '.$this->l('New message').'</legend>
<div id="message_m" style="display: '.(Tools::getValue('message') ? 'none' : 'block').'">
<div id="message_m" style="display: '.(Tools::getValue('message') ? 'none' : 'block').'; overflow: auto; width: 400px;">
<a href="#" onclick="$(\'#message\').slideToggle();$(\'#message_m\').slideToggle();return false"><b>'.$this->l('Click here').'</b> '.$this->l('to add a comment or send a message to the customer').'</a>
</div>
<div id="message" style="display: '.(Tools::getValue('message') ? 'block' : 'none').'">
@@ -949,7 +957,6 @@ class AdminOrders extends AdminTab
'avoid' => array()
//'avoid' => array('address2')
);
return AddressFormat::generateAddress($addressDelivery, $patternRules, '<br />');
}
+1 -1
View File
@@ -183,7 +183,7 @@ class AdminPayment extends AdminTab
if ($nameId == 'country' && isset($module->limited_countries) &&
count($module->limited_countries))
{
if (in_array($item['iso_code'], $module->limited_countries))
if (in_array(strtoupper($item['iso_code']), array_map('strtoupper', $module->limited_countries)))
echo '<input type="checkbox" name="'.$module->name.'_'.
$nameId.'[]" value="'.$item['id_'.$nameId].'"'.
(in_array($item['id_'.$nameId.''], $value) ?
+4 -10
View File
@@ -72,7 +72,6 @@ class AdminPreferences extends AdminTab
);
foreach (CMS::listCms($context->language->id) as $cms_file)
$cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']);
$this->_fieldsGeneral = array(
'PS_SHOP_ENABLE' => array('title' => $this->l('Enable Shop'), 'desc' => $this->l('Activate or deactivate your shop. Deactivate your shop while you perform maintenance on it. Please note that the webservice will not be disabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_MAINTENANCE_IP' => array('title' => $this->l('Maintenance IP'), 'desc' => $this->l('IP addresses allowed to access the Front Office even if shop is disabled. Use a comma to separate them (e.g., 42.24.4.2,127.0.0.1,99.98.97.96)'), 'validation' => 'isGenericName', 'type' => 'maintenance_ip', 'size' => 30, 'default' => ''),
@@ -80,6 +79,8 @@ class AdminPreferences extends AdminTab
'PS_COOKIE_CHECKIP' => array('title' => $this->l('Check IP on the cookie'), 'desc' => $this->l('Check the IP address of the cookie in order to avoid your cookie being stolen'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0', 'visibility' => Shop::CONTEXT_ALL),
'PS_TOKEN_ENABLE' => array('title' => $this->l('Increase Front Office security'), 'desc' => $this->l('Enable or disable token on the Front Office in order to improve PrestaShop security'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0', 'visibility' => Shop::CONTEXT_ALL),
'PS_HELPBOX' => array('title' => $this->l('Back Office help boxes'), 'desc' => $this->l('Enable yellow help boxes which are displayed under form fields in the Back Office'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_ALL),
'PS_COOKIE_LIFETIME_FO' => array('title' => $this->l('Lifetime of the Front Office cookie'), 'desc' => $this->l('Indicate the number of hours'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text', 'default' => '480', 'visibility' => Shop::CONTEXT_ALL),
'PS_COOKIE_LIFETIME_BO' => array('title' => $this->l('Lifetime of the Back Office cookie'), 'desc' => $this->l('Indicate the number of hours'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text', 'default' => '480', 'visibility' => Shop::CONTEXT_ALL),
'PS_ORDER_PROCESS_TYPE' => array('title' => $this->l('Order process type'), 'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $order_process_type, 'identifier' => 'value'),
'PS_GUEST_CHECKOUT_ENABLED' => array('title' => $this->l('Enable guest checkout'), 'desc' => $this->l('Your guest can make an order without registering'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_CONDITIONS' => array('title' => $this->l('Terms of service'), 'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'js' => array('on' => 'onchange="changeCMSActivationAuthorization()"', 'off' => 'onchange="changeCMSActivationAuthorization()"')),
@@ -171,15 +172,8 @@ class AdminPreferences extends AdminTab
{
$context = Context::getContext();
$languages = Language::getLanguages(false);
if (!Configuration::get('PS_FORCE_SMARTY_2'))
{
$files = scandir(_PS_THEME_DIR_);
foreach ($files AS $file)
if (!preg_match('/^\..*/', $file))
$context->smarty->clearCache($file);
}
else
$context->smarty->clear_all_cache();
Tools::clearCache($smarty);
/* Check required fields */
foreach ($fields AS $field => $values)
+92 -36
View File
@@ -248,7 +248,7 @@ class AdminProducts extends AdminTab
$attachment->file = $uniqid;
$attachment->mime = $_FILES['attachment_file']['type'];
$attachment->file_name = pSQL($_FILES['attachment_file']['name']);
if (empty($attachment->mime) OR Tools::strlen($attachment->mime) > 64)
if (empty($attachment->mime) OR Tools::strlen($attachment->mime) > 128)
$this->_errors[] = Tools::displayError('Invalid file extension');
if (!Validate::isGenericName($attachment->file_name))
$this->_errors[] = Tools::displayError('Invalid file name');
@@ -306,7 +306,7 @@ class AdminProducts extends AdminTab
else
{
Hook::addProduct($product);
Search::indexation(false);
Search::indexation(false, $product->id);
Tools::redirectAdmin(self::$currentIndex.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&conf=19&token='.($token ? $token : $this->token));
}
}
@@ -745,7 +745,7 @@ class AdminProducts extends AdminTab
if (!$specificPrice->add())
$this->_errors = Tools::displayError('An error occurred while updating the specific price.');
else
Tools::redirectAdmin(self::$currentIndex.'&id_product='.$id_product.'&add'.$this->table.'&tabs=2&conf=3&token='.($token ? $token : $this->token));
Tools::redirectAdmin(self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.$id_product.'&add'.$this->table.'&tabs=2&conf=3&token='.($token ? $token : $this->token));
}
}
else
@@ -765,7 +765,7 @@ class AdminProducts extends AdminTab
if (!$specificPrice->delete())
$this->_errors[] = Tools::displayError('An error occurred while deleting the specific price');
else
Tools::redirectAdmin(self::$currentIndex.'&id_product='.$obj->id.'&add'.$this->table.'&tabs=2&conf=1&token='.($token ? $token : $this->token));
Tools::redirectAdmin(self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.$obj->id.'&add'.$this->table.'&tabs=2&conf=1&token='.($token ? $token : $this->token));
}
}
else
@@ -787,7 +787,7 @@ class AdminProducts extends AdminTab
elseif (!SpecificPrice::setSpecificPriority((int)($obj->id), $priorities))
$this->_errors[] = Tools::displayError('An error occurred while setting priorities.');
else
Tools::redirectAdmin(self::$currentIndex.'&id_product='.$obj->id.'&add'.$this->table.'&tabs=2&conf=4&token='.($token ? $token : $this->token));
Tools::redirectAdmin(self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.$obj->id.'&add'.$this->table.'&tabs=2&conf=4&token='.($token ? $token : $this->token));
}
/* Customization management */
elseif (Tools::isSubmit('submitCustomizationConfiguration'))
@@ -1015,9 +1015,9 @@ class AdminProducts extends AdminTab
throw new Exception(Tools::displayError('Image format not recognized, allowed formats are: .gif, .jpg, .png'));
}
if (!$image->createImgFolder())
if (!$new_path = $image->getPathForCreation())
throw new Exception(Tools::displayError('An error occurred during new folder creation'));
if (!imageResize($subdir.$file, _PS_PROD_IMG_DIR_.$image->getImgPath().'.jpg'))
if (!imageResize($subdir.$file, $new_path.'.'.$image->image_format))
{
$image->delete();
throw new Exception(Tools::displayError('An error occurred while resizing image.'));
@@ -1060,17 +1060,18 @@ class AdminProducts extends AdminTab
else
{
$image = new Image($id_image);
if (!(Configuration::get('PS_LEGACY_IMAGES') && file_exists(_PS_PROD_IMG_DIR_.$id_product.'-'.$id_image.'.jpg')))
$image->createImgFolder();
if (!$new_path = $image->getPathForCreation())
$this->_errors[] = Tools::displayError('An error occurred during new folder creation');
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName))
$this->_errors[] = Tools::displayError('An error occurred during the image upload');
elseif (!imageResize($tmpName, _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.'.$image->image_format))
elseif (!imageResize($tmpName, $new_path.'.'.$image->image_format))
$this->_errors[] = Tools::displayError('An error occurred while copying image.');
elseif($method == 'auto')
{
$imagesTypes = ImageType::getImagesTypes('products');
foreach ($imagesTypes AS $k => $imageType)
if (!imageResize($tmpName, _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'-'.stripslashes($imageType['name']).'.'.$image->image_format, $imageType['width'], $imageType['height'], $image->image_format))
if (!imageResize($tmpName, $new_path.'-'.stripslashes($imageType['name']).'.'.$image->image_format, $imageType['width'], $imageType['height'], $image->image_format))
$this->_errors[] = Tools::displayError('An error occurred while copying image:').' '.stripslashes($imageType['name']);
}
@@ -1187,9 +1188,9 @@ class AdminProducts extends AdminTab
$this->_errors[] = Tools::displayError('An error occurred while adding tags.');
elseif ($id_image = $this->addProductImage($object, Tools::getValue('resizer')))
{
$currentIndex .= '&image_updated='.(int)(Tools::getValue('id_image'));
$currentIndex .= '&image_updated='.(int)Tools::getValue('id_image');
Hook::updateProduct($object);
Search::indexation(false);
Search::indexation(false, $object->id);
if (Tools::getValue('resizer') == 'man' && isset($id_image) AND is_int($id_image) AND $id_image)
Tools::redirectAdmin(self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&edit='.strval(Tools::getValue('productCreated')).'&id_image='.$id_image.'&imageresize&toconf=4&submitAddAndStay='.((Tools::isSubmit('submitAdd'.$this->table.'AndStay') OR Tools::getValue('productCreated') == 'on') ? 'on' : 'off').'&token='.(($token ? $token : $this->token)));
@@ -1202,7 +1203,11 @@ class AdminProducts extends AdminTab
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
$token = Tools::encrypt('PreviewProduct'.$object->id);
$preview_url .= $object->active ? '' : '?adtoken='.$token.'&ad='.$admin_dir;
if(strpos($preview_url, '?') === false)
$preview_url .= '?';
else
$preview_url .= '&';
$preview_url .= 'adtoken='.$token.'&ad='.$admin_dir;
}
Tools::redirectAdmin($preview_url);
} else if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') OR ($id_image AND $id_image !== true)) // Save and stay on same form
@@ -1243,18 +1248,18 @@ class AdminProducts extends AdminTab
elseif ($id_image = $this->addProductImage($object))
{
Hook::addProduct($object);
Search::indexation(false);
Search::indexation(false, $object->id);
// Save and preview
if (Tools::isSubmit('submitAddProductAndPreview'))
{
$preview_url = ($context->link->getProductLink($this->getFieldValue($object, 'id'), $this->getFieldValue($object, 'link_rewrite', $context->language->id), Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), $context->language->id)));
if (!$obj->active)
if (!$object->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
$token = Tools::encrypt('PreviewProduct'.$object->id);
$preview_url .= $object->active ? '' : '?adtoken='.$token.'&ad='.$admin_dir;
$preview_url .= '&adtoken='.$token.'&ad='.$admin_dir;
}
Tools::redirectAdmin($preview_url);
@@ -1729,7 +1734,7 @@ class AdminProducts extends AdminTab
<td class="cell border">'.$period.'</td>
<td class="cell border">'.$specificPrice['from_quantity'].'</th>
<td class="cell border"><b>'.Tools::displayPrice(Tools::ps_round((float)($this->_getFinalPrice($specificPrice, (float)($obj->price), $taxRate)), 2), $current_specific_currency).'</b></td>
<td class="cell border"><a href="'.self::$currentIndex.'&id_product='.(int)(Tools::getValue('id_product')).'&updateproduct&deleteSpecificPrice&id_specific_price='.(int)($specificPrice['id_specific_price']).'&token='.Tools::getValue('token').'"><img src="../img/admin/delete.gif" alt="'.$this->l('Delete').'" /></a></td>
<td class="cell border"><a href="'.self::$currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&id_product='.(int)(Tools::getValue('id_product')).'&updateproduct&deleteSpecificPrice&id_specific_price='.(int)($specificPrice['id_specific_price']).'&token='.Tools::getValue('token').'"><img src="../img/admin/delete.gif" alt="'.$this->l('Delete').'" /></a></td>
</tr>';
$i++;
}
@@ -2610,6 +2615,11 @@ class AdminProducts extends AdminTab
</td>
</tr>
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>';
if ((int)Configuration::get('PS_STOCK_MANAGEMENT'))
{
if (!$has_attribute)
{
if ($obj->id)
@@ -2662,6 +2672,12 @@ class AdminProducts extends AdminTab
<div class="hint clear" style="display: block;width: 70%;">'.$this->l('You used combinations, for this reason you can\'t edit your stock quantity here, but in the Combinations tab').'</div>
</td>
</tr>';
}
else
echo '<tr>
<td colspan="2">'.$this->l('The stock management is disabled').'</td>
</tr>';
echo '
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
<tr>
@@ -2709,8 +2725,48 @@ class AdminProducts extends AdminTab
<br /><input type="radio" name="out_of_stock" id="out_of_stock_3" value="2" '.($this->getFieldValue($obj, 'out_of_stock') == 2 ? 'checked="checked"' : '').'/> <label for="out_of_stock_3" class="t" id="label_out_of_stock_3">'.$this->l('Default:').' <i>'.$this->l(((int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')) ? 'Allow orders' : 'Deny orders')).'</i> ('.$this->l('as set in').' <a href="index.php?tab=AdminPPreferences&token='.Tools::getAdminToken('AdminPPreferences'.(int)(Tab::getIdFromClassName('AdminPPreferences')).(int)$context->employee->id).'" onclick="return confirm(\''.$this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false).'\');">'.$this->l('Preferences').'</a>)</label>
</td>
</tr>
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
<tr id="tr_categories"></tr>
<tr>
<td colspan="2" style="padding-bottom:5px;">
<hr style="width:100%;" />
</td>
</tr>
<tr>
<td class="col-left"><label for="id_category_default" class="t">'.$this->l('Default category:').'</label></td>
<td>
<div id="no_default_category" style="color: red;font-weight: bold;display: none;">'.$this->l('Please check a category in order to select the default category.').'</div>
<script>var post_selected_cat;</script>';
if (Tools::isSubmit('categoryBox'))
{
$postCat = Tools::getValue('categoryBox');
$selectedCat = Category::getSimpleCategories($this->_defaultFormLanguage, false, true, 'AND c.`id_category` IN ('.(empty($postCat) ? '1' : implode(',', $postCat)).')');
echo '<script>post_selected_cat = \''.implode(',', $postCat).'\';</script>';
}
if ($obj->id)
$selectedCat = Product::getProductCategoriesFull($obj->id, $this->_defaultFormLanguage);
else if(!Tools::isSubmit('categoryBox'))
$selectedCat[] = array('id_category' => 1, 'name' => $this->l('Home'));
echo '<select id="id_category_default" name="id_category_default">';
foreach($selectedCat AS $cat)
echo '<option value="'.$cat['id_category'].'" '.($obj->id_category_default == $cat['id_category'] ? 'selected' : '').'>'.$cat['name'].'</option>';
echo '</select>
</td>
</tr>
<tr id="tr_categories">
<td colspan="2">
';
// Translations are not automatic for the moment ;)
$trads = array(
'Home' => $this->l('Home'),
'selected' => $this->l('selected'),
'Collapse All' => $this->l('Collapse All'),
'Expand All' => $this->l('Expand All'),
'Check All' => $this->l('Check All'),
'Uncheck All' => $this->l('Uncheck All')
);
echo Helper::renderAdminCategorieTree($trads, $selectedCat).'
</td>
</tr>
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
<tr><td colspan="2">
<span onclick="$(\'#seo\').slideToggle();" style="cursor: pointer"><img src="../img/admin/arrow.gif" alt="'.$this->l('SEO').'" title="'.$this->l('SEO').'" style="float:left; margin-right:5px;"/>'.$this->l('Click here to improve product\'s rank in search engines (SEO)').'</span><br />
@@ -2719,7 +2775,7 @@ class AdminProducts extends AdminTab
<tr>
<td class="col-left">'.$this->l('Meta title:').'</td>
<td class="translatable">';
foreach ($this->_languages as $language)
foreach ($this->_languages AS $language)
echo ' <div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input size="55" type="text" id="meta_title_'.$language['id_lang'].'" name="meta_title_'.$language['id_lang'].'"
value="'.htmlentities($this->getFieldValue($obj, 'meta_title', $language['id_lang']), ENT_COMPAT, 'UTF-8').'" />
@@ -2894,18 +2950,10 @@ class AdminProducts extends AdminTab
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script>
<script type="text/javascript">
toggleVirtualProduct(getE(\'is_virtual_good\'));
unitPriceWithTax(\'unit\');';
unitPriceWithTax(\'unit\');
</script>';
$categoryBox = Tools::getValue('categoryBox', array());
echo '
$(function() {
$.ajax({
type: \'POST\',
url: \'ajax_category_list.php\',
data: \''.(sizeof($categoryBox) > 0 ? 'categoryBox='.serialize($categoryBox).'&' : '').'id_product='.$obj->id.'&id_category_default='.($this->getFieldValue($obj, 'id_category_default') ? $this->getFieldValue($obj, 'id_category_default') : Tools::getValue('id_category', 1)).'&id_category='.(int)(Tools::getValue('id_category')).'&token='.$this->token.'\',
async : true,
success: function(msg) { $(\'#tr_categories\').replaceWith(msg); }
});
});</script>';
}
function displayFormImages($obj, $token = NULL)
@@ -3128,6 +3176,7 @@ class AdminProducts extends AdminTab
$attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name'];
$currency = $context->currency;
$attributes_groups = AttributeGroup::getAttributesGroups($context->language->id);
$default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
$images = Image::getImages($context->language->id, $obj->id);
@@ -3667,11 +3716,18 @@ class AdminProducts extends AdminTab
private function addPackItem()
{
return '
function addPackItem()
{
if ($(\'#curPackItemId\').val() == \'\' || $(\'#curPackItemName\').val() == \'\') return false;
if ($(\'#curPackItemId\').val() == \'\' || $(\'#curPackItemName\').val() == \'\')
{
alert(\''.$this->l('Thanks to select at least one product.').'\');
return false;
}
else if ($(\'#curPackItemId\').val() == \'\' || $(\'#curPackItemQty\').val() == \'\')
{
alert(\''.$this->l('Thanks to set a quantity to add a product.').'\');
return false;
}
var lineDisplay = $(\'#curPackItemQty\').val()+ \'x \' +$(\'#curPackItemName\').val();
@@ -3685,7 +3741,7 @@ class AdminProducts extends AdminTab
$(\'#inputPackItems\').val($(\'#inputPackItems\').val() + line + \'-\');
$(\'#divPackItems\').html(divContent);
$(\'#namePackItems\').val($(\'#namePackItems\').val() + lineDisplay + \'¤\');
$(\'#namePackItems\').val($(\'#namePackItems\').val() + lineDisplay + \'¤\');
$(\'#curPackItemId\').val(\'\');
$(\'#curPackItemName\').val(\'\');
+6 -3
View File
@@ -91,6 +91,7 @@ class AdminReturn extends AdminTab
if (($id_order_return = (int)(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return))
{
$orderReturn = new OrderReturn($id_order_return);
$order = new Order($orderReturn->id_order);
$customer = new Customer($orderReturn->id_customer);
$orderReturn->state = (int)(Tools::getValue('state'));
if ($orderReturn->save())
@@ -100,9 +101,11 @@ class AdminReturn extends AdminTab
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{id_order_return}' => $id_order_return,
'{state_order_return}' => $orderReturnState->name[(int)(Configuration::get('PS_LANG_DEFAULT'))]);
Mail::Send(clan, 'order_return_state', Mail::l('Your order return state has changed'), $vars, $customer->email, $customer->firstname.' '.$customer->lastname);
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
'{state_order_return}' => (isset($orderReturnState->name[(int)$order->id_lang]) ? $orderReturnState->name[(int)$order->id_lang] : $orderReturnState->name[(int)Configuration::get('PS_LANG_DEFAULT')]));
Mail::Send((int)$order->id_lang, 'order_return_state', Mail::l('Your order return state has changed', $order->id_lang),
$vars, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
NULL, _PS_MAIL_DIR_, true);
Tools::redirectAdmin($currentIndex.'&conf=4&token='.$this->token);
}
}
else
+4 -7
View File
@@ -57,17 +57,14 @@ class AdminSearchConf extends AdminPreferences
parent::__construct();
}
public function postProcess()
{
if (isset($_POST['submitSearch'.$this->table]))
{
if ($this->tabAccess['edit'] === '1')
$this->_postConfig($this->_fieldsSearch);
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
{ if ($this->tabAccess['edit'] === '1') $this->_postConfig($this->_fieldsSearch); else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); }
if (isset($_POST['submitWeight'.$this->table]))
{ if ($this->tabAccess['edit'] === '1') $this->_postConfig($this->_fieldsWeight); else $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); }
}
}
public function display()
{
+6
View File
@@ -112,6 +112,11 @@ class AdminStores extends AdminTab
if ((int)($country->contains_states) AND !$id_state)
$this->_errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
$latitude = (int)(Tools::getValue('latitude'));
$longitude = (int)(Tools::getValue('longitude'));
if(empty($latitude) OR empty($longitude))
$this->_errors[] = Tools::displayError('Latitude and longitude are required.');
/* Check zip code */
if ($country->need_zip_code)
{
@@ -227,6 +232,7 @@ class AdminStores extends AdminTab
<label>'.$this->l('Latitude / Longitude:').'</label>
<div class="margin-form">
<input type="text" size="8" maxlength="10" name="latitude" value="'.htmlentities($this->getFieldValue($obj, 'latitude'), ENT_COMPAT, 'UTF-8').'" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> / <input type="text" size="8" maxlength="10" name="longitude" value="'.htmlentities($this->getFieldValue($obj, 'longitude'), ENT_COMPAT, 'UTF-8').'" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />
<sup>*</sup>
<p class="clear">'.$this->l('Store coords, eg. 45.265469 / -47.226478').'</p>
</div>
<label>'.$this->l('Phone:').'</label>
+2 -1
View File
@@ -252,8 +252,9 @@ class AdminTaxRulesGroup extends AdminTab
<td>'.$this->renderTaxesSelect($id_lang, $id_tax, array('class' => 'tax_'.$id_zone, 'id' => 'tax_'.$country['id_country'].'_0', 'name' => 'tax_'.$country['id_country'].'_0' )).'</td>
</tr>
';
if ($country['contains_states'])
if ($country['contains_states']) {
$html .= $this->renderStates($tax_rules, (int)$id_zone, (int)$country['id_country'], (int)$id_lang);
}
$i++;
}
+19 -1
View File
@@ -41,12 +41,16 @@ class AdminTaxes extends AdminTab
'rate' => array('title' => $this->l('Rate'), 'align' => 'center', 'suffix' => '%', 'width' => 50),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
$ecotax_desc = '';
if (Configuration::get('PS_USE_ECOTAX'))
$ecotax_desc = $this->l('If you disable the ecotax, the ecotax for all your products will be set to 0');
$this->optionTitle = $this->l('Tax options');
$this->_fieldsOptions = array(
'PS_TAX' => array('title' => $this->l('Enable tax:'), 'desc' => $this->l('Select whether or not to include tax on purchases'), 'cast' => 'intval', 'type' => 'bool'),
'PS_TAX_DISPLAY' => array('title' => $this->l('Display tax in cart:'), 'desc' => $this->l('Select whether or not to display tax on a distinct line in the cart'), 'cast' => 'intval', 'type' => 'bool'),
'PS_TAX_ADDRESS_TYPE' => array('title' => $this->l('Base on:'), 'cast' => 'pSQL', 'type' => 'select', 'list' => array(array('name' => $this->l('Invoice Address'), 'id' => 'id_address_invoice'), array('name' => $this->l('Delivery Address'), 'id' => 'id_address_delivery')), 'identifier' => 'id'),
'PS_USE_ECOTAX' => array('title' => $this->l('Use ecotax'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_USE_ECOTAX' => array('title' => $this->l('Use ecotax'), 'desc' => $ecotax_desc, 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
);
if (Configuration::get('PS_USE_ECOTAX'))
@@ -181,5 +185,19 @@ class AdminTaxes extends AdminTab
<img src="../img/admin/'.($value ? 'enabled.gif' : 'disabled.gif').'"
alt="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" title="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" /></a>';
}
public function updateOptionPsUseEcotax($value)
{
$old_value = (int)Configuration::get('PS_USE_ECOTAX');
if ($old_value != $value)
{
// Reset ecotax
if ($value == 0)
Product::resetEcoTax();
Configuration::updateValue('PS_USE_ECOTAX', (int)$value);
}
}
}
+4 -2
View File
@@ -34,13 +34,13 @@ class AdminThemes extends AdminPreferences
* @since 1.4.0.11, check theme compatibility 1.4
* @static
*/
static public $check_features_version = '1.4';
public static $check_features_version = '1.4';
/** $check_features is a multidimensional array used to check [theme]/config.xml values,
* and also checks prestashop current configuration if not match.
* @static
*/
static public $check_features = array(
public static $check_features = array(
'ccc' => array( // feature key name
'attributes' => array(
'available' => array(
@@ -261,11 +261,13 @@ class AdminThemes extends AdminPreferences
*/
public function postProcess()
{
global $smarty;
// new check compatibility theme feature (1.4) :
$val = Tools::getValue('PS_THEME');
Configuration::updateValue('PS_IMG_UPDATE_TIME', time());
if (!empty($val) AND !$this->_isThemeCompatible($val)) // don't submit if errors
unset($_POST['submitThemes'.$this->table]);
Tools::clearCache($smarty);
parent::postProcess();
}
}
+3 -3
View File
@@ -157,7 +157,7 @@ class AdminTranslations extends AdminTab
}
}
if ($bool)
Tools::redirectLink(self::$currentIndex.'&conf=14&token='.$this->token);
Tools::redirectAdmin(self::$currentIndex.'&conf=14&token='.$this->token);
$this->_errors[] = $this->l('a part of the data has been copied but some language files could not be found or copied');
}
@@ -1715,7 +1715,7 @@ class AdminTranslations extends AdminTab
{
if ($module{0} != '.' AND is_dir($root_dir.$module))
{
@include_once($root_dir.$module.'/'.$lang.'.php');
@include($root_dir.$module.'/'.$lang.'.php');
self::getModuleTranslations($is_default);
$this->recursiveGetModuleFiles($root_dir.$module.'/', $array_files, $module, $root_dir.$module.'/'.$lang.'.php', $is_default);
}
@@ -1891,7 +1891,7 @@ class AdminTranslations extends AdminTab
*
* @return array
*/
static public function getThemesList()
public static function getThemesList()
{
$dir = opendir(_PS_ALL_THEMES_DIR_);
while ($folder = readdir($dir))
+1798
View File
File diff suppressed because it is too large Load Diff
+9 -1
View File
@@ -37,7 +37,6 @@ class AdminWebservice extends AdminTab
$this->lang = false;
$this->edit = true;
$this->delete = true;
$this->id_lang_default = Configuration::get('PS_LANG_DEFAULT');
$this->fieldsDisplay = array(
@@ -93,6 +92,13 @@ class AdminWebservice extends AdminTab
$warnings[] = $this->l('If possible, it is preferable to use SSL (https) for webservice calls, as it avoids the security issues of type "man in the middle".');
$this->displayWarning($warnings);
foreach ($this->_list as $k => $item)
if ($item['is_module'] && $item['class_name'] && $item['module_name'] &&
($instance = Module::getInstanceByName($item['module_name'])) &&
!$instance->useNormalPermissionBehaviour())
unset($this->_list[$k]);
parent::displayList();
}
public function displayForm($isMainTab = true)
@@ -221,6 +227,8 @@ echo '
{
if (Tools::getValue('key') && strlen(Tools::getValue('key')) < 32)
$this->_errors[] = Tools::displayError($this->l('Key length must be 32 character long'));
if (WebserviceKey::keyExists(Tools::getValue('key')) && !Tools::getValue('id_webservice_account'))
$this->_errors[] = Tools::displayError($this->l('Key already exists'));
return parent::postProcess();
}
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+7
View File
@@ -59,3 +59,10 @@ a.action_module{color: #488C40;text-decoration: underline;}
a.header_module_toggle{font-weight: bold;color: #812143;display:block;}
a.module_toggle_all{color:#FFF;text-decoration:none;display:inherit;}
.nbr_module{float:right;margin-right:10px;font-style:italic;font-size:12px;color: #812143;}
.autoupgradeSteps div { line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.processing {overflow: auto;}
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+8 -1
View File
@@ -53,4 +53,11 @@ select {border: 1px solid #E0D0B1}
a.action_module{color: #268CCD;text-decoration: underline;}
a.header_module_toggle{font-weight: bold;color: #268CCD;display:block;}
a.module_toggle_all{color: #268CCD;}
.nbr_module{float:right;margin-right:10px;font-style:italic;font-size:12px;color: #268CCD;}
.nbr_module{float:right;margin-right:10px;font-style:italic;font-size:12px;color: #268CCD;}
.autoupgradeSteps div { line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.processing {overflow: auto;}
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+6
View File
@@ -57,3 +57,9 @@ a.header_module_toggle{font-weight: bold;color: #268CCD;display:block;}
a.module_toggle_all{color: #268CCD;}
.nbr_module{float:right;margin-right:10px;font-style:italic;font-size:12px;color: #268CCD;}
.autoupgradeSteps div { line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.processing {overflow: auto;}
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 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;
+3 -3
View File
@@ -276,7 +276,7 @@ class AddressCore extends ObjectModel
return isset($result['used']) ? $result['used'] : false;
}
static public function getCountryAndState($id_address)
public static function getCountryAndState($id_address)
{
if (isset(self::$_idCountries[$id_address]))
return self::$_idCountries[$id_address];
@@ -293,7 +293,7 @@ class AddressCore extends ObjectModel
* @param $id_address Address id
* @return boolean
*/
static public function addressExists($id_address)
public static function addressExists($id_address)
{
$row = Db::getInstance()->getRow('
SELECT `id_address`
@@ -303,7 +303,7 @@ class AddressCore extends ObjectModel
return isset($row['id_address']);
}
static public function getFirstCustomerAddressId($id_customer, $active = true)
public static function getFirstCustomerAddressId($id_customer, $active = true)
{
return Db::getInstance()->getValue('
SELECT `id_address`
+110 -33
View File
@@ -45,7 +45,7 @@ class AddressFormatCore extends ObjectModel
protected $table = 'address_format';
protected $identifier = 'id_country';
static public $requireFormFieldsList = array(
public static $requireFormFieldsList = array(
'firstname',
'name',
'address1',
@@ -54,7 +54,7 @@ class AddressFormatCore extends ObjectModel
'Country:name',
'State:name');
static public $forbiddenProperyList = array(
public static $forbiddenPropertyList = array(
'deleted',
'date_add',
'other',
@@ -85,10 +85,12 @@ class AddressFormatCore extends ObjectModel
'call_prefixes',
'call_prefix');
static public $forbiddenClassList = array(
public static $forbiddenClassList = array(
'Manufacturer',
'Supplier');
const _CLEANING_REGEX_ = '#([^\w:_]+)#i';
public function getFields()
{
parent::validateFields();
@@ -124,7 +126,7 @@ class AddressFormatCore extends ObjectModel
{
$propertyName = $property->getName();
if (($propertyName == $fieldName) && ($isIdField ||
(!preg_match('#id|id_\w#', $propertyName, $match))))
(!preg_match('#id|id_\w#', $propertyName))))
$isValide = true;
}
@@ -148,7 +150,6 @@ class AddressFormatCore extends ObjectModel
private function _checkLiableAssociation($patternName, $fieldsValidate)
{
$patternName = trim($patternName);
$cleanedLine = '';
if ($associationName = explode(':', $patternName))
{
@@ -158,8 +159,7 @@ class AddressFormatCore extends ObjectModel
else if ($totalNameUsed == 1)
{
$associationName[0] = strtolower($associationName[0]);
$cleanedLine = $associationName[0];
if (in_array($associationName[0], self::$forbiddenProperyList) ||
if (in_array($associationName[0], self::$forbiddenPropertyList) ||
!$this->_checkValidateClassField('Address', $associationName[0], false))
$this->_errorFormatList[] = Tools::displayError('This name isn\'t allowed').': '.
$associationName[0];
@@ -183,12 +183,10 @@ class AddressFormatCore extends ObjectModel
// Check if the field name exist in the class write by the user
$this->_checkValidateClassField($associationName[0], $associationName[1], false);
$cleanedLine = $associationName[0].':'.$associationName[1];
}
}
}
}
return (strlen($cleanedLine)) ? $cleanedLine.' ' : '';
}
/*
@@ -196,27 +194,30 @@ class AddressFormatCore extends ObjectModel
*/
public function checkFormatFields()
{
$cleanedContent = '';
$this->_errorFormatList = array();
$fieldsValidate = Address::getFieldsValidate();
$usedKeyList = array();
$multipleLineFields = explode("\n", $this->format);
if ($multipleLineFields && is_array($multipleLineFields))
foreach($multipleLineFields as $lineField)
{
$lineField = str_replace(array("\n", "\t", "\r\n", "\r"), '', $lineField);
if (strlen($lineField))
if (($patternsName = preg_split(self::_CLEANING_REGEX_, $lineField, -1, PREG_SPLIT_NO_EMPTY)))
if (is_array($patternsName))
{
$patternsName = explode(' ', trim($lineField));
if ($patternsName && is_array($patternsName))
{
foreach($patternsName as $patternName)
$cleanedContent .= $this->_checkLiableAssociation($patternName, $fieldsValidate);
$cleanedContent = trim($cleanedContent)."\r\n";
{
if (!in_array($patternName, $usedKeyList))
{
$this->_checkLiableAssociation($patternName, $fieldsValidate);
$usedKeyList[] = $patternName;
}
else
$this->_errorFormatList[] = Tools::displayError('This key is used too many times (once allowed').
': '.$patternName;
}
}
$this->format = $cleanedContent;
}
return (count($this->_errorFormatList)) ? false : true;
}
@@ -228,6 +229,61 @@ class AddressFormatCore extends ObjectModel
return $this->_errorFormatList;
}
/*
** Set the layout key with the liable value
** example : (firstname) => 'Presta' will result (Presta)
** : (firstname-lastname) => 'Presta' and 'Shop' result '(Presta-Shop)'
*/
private static function _setOriginalDisplayFormat(&$formattedValueList, $currentLine, $currentKeyList)
{
if ($currentKeyList && is_array($currentKeyList))
if ($originalFormattedPatternList = explode(' ', $currentLine))
// Foreach the available pattern
foreach($originalFormattedPatternList as $patternNum => $pattern)
{
// Var allows to modify the good formatted key value when multiple key exist into the same pattern
$mainFormattedKey = '';
// Multiple key can be found in the same pattern
foreach($currentKeyList as $key)
{
// Check if we need to use an older modified pattern if a key has already be matched before
$replacedValue = empty($mainFormattedKey) ? $pattern : $formattedValueList[$mainFormattedKey];
if (($formattedValue = preg_replace('/'.$key.'/', $formattedValueList[$key], $replacedValue, -1, $count)))
if ($count)
{
// Allow to check multiple key in the same pattern,
if (empty($mainFormattedKey))
$mainFormattedKey = $key;
// Set the pattern value to an empty string if an older key has already been matched before
if ($mainFormattedKey != $key)
$formattedValueList[$key] = '';
// Store the new pattern value
$formattedValueList[$mainFormattedKey] = $formattedValue;
unset($originalFormattedPatternList[$patternNum]);
}
}
}
}
/*
** Cleaned the layout set by the user
*/
public static function cleanOrderedAddress(&$orderedAddressField)
{
foreach($orderedAddressField as &$line)
{
$cleanedLine = '';
if (($keyList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)))
{
foreach($keyList as $key)
$cleanedLine .= $key.' ';
$cleanedLine = trim($cleanedLine);
$line = $cleanedLine;
}
}
}
/*
* Returns the formatted fields with associated values
*
@@ -244,9 +300,10 @@ class AddressFormatCore extends ObjectModel
// Check if $address exist and it's an instanciate object of Address
if ($address && ($address instanceof Address))
foreach($addressFormat as $lineNum => $line)
foreach($addressFormat as $line)
{
if (($keyList = explode(' ', $line)) && is_array($keyList))
if (($keyList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)) && is_array($keyList))
{
foreach($keyList as $pattern)
if ($associateName = explode(':', $pattern))
{
@@ -274,9 +331,12 @@ class AddressFormatCore extends ObjectModel
}
}
}
self::_setOriginalDisplayFormat($tab, $line, $keyList);
}
}
self::cleanOrderedAddress($addressFormat);
// Free the instanciate objects
foreach($temporyObject as $objectName => &$object)
foreach($temporyObject as &$object)
unset($object);
return $tab;
}
@@ -295,7 +355,7 @@ class AddressFormatCore extends ObjectModel
$addressText = '';
foreach ($addressFields as $line)
if (($patternsList = explode(' ', $line)))
if (($patternsList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY)))
{
$tmpText = '';
foreach($patternsList as $pattern)
@@ -328,8 +388,8 @@ class AddressFormatCore extends ObjectModel
foreach($publicProperties as $property)
{
$propertyName = $property->getName();
if ((!in_array($propertyName, AddressFormat::$forbiddenProperyList)) &&
(!preg_match('#id|id_\w#', $propertyName, $match)))
if ((!in_array($propertyName, AddressFormat::$forbiddenPropertyList)) &&
(!preg_match('#id|id_\w#', $propertyName)))
$propertyList[] = $propertyName;
}
unset($object);
@@ -355,7 +415,7 @@ class AddressFormatCore extends ObjectModel
foreach($publicProperties as $property)
{
$propertyName = $property->getName();
if (preg_match('#id_\w#', $propertyName, $match) && strlen($propertyName) > 3)
if (preg_match('#id_\w#', $propertyName) && strlen($propertyName) > 3)
{
$nameObject = ucfirst(substr($propertyName, 3));
if (!in_array($nameObject, self::$forbiddenClassList) &&
@@ -375,19 +435,41 @@ class AddressFormatCore extends ObjectModel
* @param Integer PS_COUNTRY.id if null using default country
* @return Array String field address format
*/
public static function getOrderedAddressFields($id_country = 0, $split_all = false)
public static function getOrderedAddressFields($id_country = 0, $split_all = false, $cleaned = false)
{
$out = array();
$field_set = explode("\n", self::getAddressCountryFormat($id_country));
foreach ($field_set as $field_item)
if ($split_all)
foreach(explode(' ',$field_item) as $word_item)
{
if ($cleaned)
$keyList = ($cleaned) ? preg_split(self::_CLEANING_REGEX_, $field_item, -1, PREG_SPLIT_NO_EMPTY) :
explode(' ', $field_item);
foreach($keyList as $word_item)
$out[] = trim($word_item);
}
else
$out[] = trim($field_item);
$out[] = ($cleaned) ? implode(' ', preg_split(self::_CLEANING_REGEX_, trim($field_item), -1, PREG_SPLIT_NO_EMPTY))
: trim($field_item);
return $out;
}
/*
** Return a data array containing ordered, formatedValue and object fields
*/
public static function getFormattedLayoutData($address)
{
$layoutData = array();
if ($address && $address instanceof Address)
{
$layoutData['ordered'] = AddressFormat::getOrderedAddressFields((int)$address->id_country);
$layoutData['formated'] = AddressFormat::getFormattedAddressFieldsValues($address, $layoutData['ordered']);
$layoutData['object'] = get_object_vars($address);
}
return $layoutData;
}
/**
* Returns address format by country if not defined using default country
*
@@ -399,11 +481,6 @@ class AddressFormatCore extends ObjectModel
$out = '';
$id_country = (int) $id_country;
if ($id_country <= 0)
{
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
}
$tmp_obj = new AddressFormat();
$tmp_obj->id_country = $id_country;
$out = $tmp_obj->getFormat($tmp_obj->id_country);
+40 -9
View File
@@ -159,10 +159,11 @@ abstract class AdminTabCore
protected $_includeVars = false;
protected $_includeContainer = true;
public $ajax = false;
public static $tabParenting = array(
'AdminProducts' => 'AdminCatalog',
'AdminCategories' => 'AdminCatalog',
'AdminImageResize' => 'AdminImages',
'AdminCMS' => 'AdminCMSContent',
'AdminCMSCategories' => 'AdminCMSContent',
'AdminOrdersStates' => 'AdminStatuses',
@@ -233,6 +234,14 @@ abstract class AdminTabCore
return str_replace('"', '&quot;', ($addslashes ? addslashes($str) : stripslashes($str)));
}
/**
* ajaxDisplay is the default ajax return sytem
*
* @return void
*/
public function displayAjax()
{
}
/**
* Manage page display (form, list...)
*/
@@ -433,7 +442,7 @@ abstract class AdminTabCore
/* Checking for multilingual required fields */
foreach ($rules['requiredLang'] AS $fieldLang)
if (($empty = Tools::getValue($fieldLang.'_'.$defaultLanguage->id)) === false OR empty($empty))
if (($empty = Tools::getValue($fieldLang.'_'.$defaultLanguage->id)) === false OR $empty !== '0' AND empty($empty))
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $fieldLang, $className).'</b> '.$this->l('is required at least in').' '.$defaultLanguage->name;
/* Checking for maximum fields sizes */
@@ -506,6 +515,24 @@ abstract class AdminTabCore
return true;
}
/**
* ajaxPreProcess is a method called in ajax-tab.php before displayConf().
*
* @return void
*/
public function ajaxPreProcess()
{
}
/**
* ajaxProcess is the default handle method for request with ajax-tab.php
*
* @return void
*/
public function ajaxProcess()
{
}
/**
* Manage page processing
*/
@@ -1013,7 +1040,7 @@ abstract class AdminTabCore
{
$languages = Language::getLanguages(false);
foreach ($languages AS $language)
foreach ($rules['validateLang'] AS $field => $validation)
foreach (array_keys($rules['validateLang']) AS $field)
if (isset($_POST[$field.'_'.(int)($language['id_lang'])]))
$object->{$field}[(int)($language['id_lang'])] = $_POST[$field.'_'.(int)($language['id_lang'])];
}
@@ -1107,9 +1134,9 @@ abstract class AdminTabCore
public function displayConf()
{
if ($conf = Tools::getValue('conf'))
echo '<div class="conf">
<img src="../img/admin/ok2.png" />
'.$this->_conf[(int)($conf)].'
echo '
<div class="conf">
<img src="../img/admin/ok2.png" alt="" /> '.$this->_conf[(int)($conf)].'
</div>';
}
@@ -1259,6 +1286,7 @@ abstract class AdminTabCore
echo '<form method="post" action="'.self::$currentIndex;
if(Tools::getIsset($this->identifier))
echo '&'.$this->identifier.'='.(int)(Tools::getValue($this->identifier));
echo '&token='.$token;
if (Tools::getIsset($this->table.'Orderby'))
echo '&'.$this->table.'Orderby='.urlencode($this->_orderBy).'&'.$this->table.'Orderway='.urlencode(strtolower($this->_orderWay));
echo '#'.$this->table.'" class="form">
@@ -1313,7 +1341,7 @@ abstract class AdminTabCore
<script type="text/javascript" src="../js/admin-dnd.js"></script>
';
}
echo '<table'.(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="'.(($id_category = (int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? substr($this->identifier,3,strlen($this->identifier)) : '').'"' : '' ).' class="table'.((array_key_exists($this->identifier,$this->identifiersDnd) AND ($this->_orderBy != 'position 'AND $this->_orderWay != 'DESC')) ? ' tableDnD' : '' ).'" cellpadding="0" cellspacing="0">
echo '<table'.(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="'.(((int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? substr($this->identifier,3,strlen($this->identifier)) : '').'"' : '' ).' class="table'.((array_key_exists($this->identifier,$this->identifiersDnd) AND ($this->_orderBy != 'position 'AND $this->_orderWay != 'DESC')) ? ' tableDnD' : '' ).'" cellpadding="0" cellspacing="0">
<thead>
<tr class="nodrag nodrop">
<th>';
@@ -1485,7 +1513,7 @@ abstract class AdminTabCore
if (preg_match('/cms/Ui', $this->identifier))
$isCms = true;
$keyToGet = 'id_'.($isCms ? 'cms_' : '').'category'.(in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : '');
foreach ($this->_list AS $i => $tr)
foreach ($this->_list AS $tr)
{
$id = $tr[$this->identifier];
echo '<tr'.(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'>
@@ -1934,7 +1962,6 @@ abstract class AdminTabCore
{
if (sizeof($languages) == 1)
return false;
$defaultIso = Language::getIsoById($defaultLanguage);
$output = '
<div class="displayed_flag">
<img src="../img/l/'.$defaultLanguage.'.jpg" class="pointer" id="language_current_'.$id.'" onclick="toggleLanguageFlags(this);" alt="" />
@@ -2162,6 +2189,10 @@ abstract class AdminTabCore
if ($this->validateField(Tools::getValue($key), $options))
{
// check if a method updateOptionFieldName is available
$method_name = 'updateOption'.Tools::toCamelCase($key, true);
if (method_exists($this, $method_name))
$this->$method_name(Tools::getValue($key));
if (isset($options['type']) && in_array($options['type'], array('textLang', 'textareaLang')))
{
$list = array();
-8
View File
@@ -63,14 +63,6 @@ class AliasCore extends ObjectModel
}
}
static public function deleteAliases($search)
{
return Db::getInstance()->Execute('
DELETE
FROM `'._DB_PREFIX_.'alias`
WHERE `search` LIKE \''.pSQL($search).'\'');
}
public function getAliases()
{
$aliases = Db::getInstance()->ExecuteS('
+20 -1
View File
@@ -37,7 +37,7 @@ class AttachmentCore extends ObjectModel
public $position;
protected $fieldsRequired = array('file', 'mime');
protected $fieldsSize = array('file' => 40, 'mime' => 64, 'file_name' => 128);
protected $fieldsSize = array('file' => 40, 'mime' => 128, 'file_name' => 128);
protected $fieldsValidate = array('file' => 'isGenericName', 'mime' => 'isCleanHtml', 'file_name' => 'isGenericName');
protected $fieldsRequiredLang = array('name');
@@ -102,5 +102,24 @@ class AttachmentCore extends ObjectModel
}
return $result1;
}
public static function getProductAttached($id_lang, $list)
{
$ids_attachements = array();
if (is_array($list))
{
foreach($list as $attachement)
$ids_attachements[] = $attachement['id_attachment'];
$tmp = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'product_attachment` pa
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pa.`id_product` = pl.`id_product`)
WHERE `id_attachment` IN ('.implode(',', array_map('intval', $ids_attachements)).') AND pl.`id_lang` = '.(int)$id_lang.';');
$productAttachements = array();
foreach($tmp as $t)
$productAttachements[$t['id_attachment']][] = $t['name'];
return $productAttachements;
}
else
return false;
}
}
+4 -4
View File
@@ -98,7 +98,7 @@ class AttributeCore extends ObjectModel
* @param boolean $notNull Get only not null fields if true
* @return array Attributes
*/
static public function getAttributes($id_lang, $notNull = false)
public static function getAttributes($id_lang, $notNull = false)
{
return Db::getInstance()->ExecuteS('
SELECT ag.*, agl.*, a.`id_attribute`, al.`name`, agl.`name` AS `attribute_group`
@@ -139,7 +139,7 @@ class AttributeCore extends ObjectModel
* @param integer $id_product
* @return mixed Quantity or false
*/
static public function getAttributeQty($id_product)
public static function getAttributeQty($id_product)
{
Tools::displayAsDeprecated();
@@ -160,7 +160,7 @@ class AttributeCore extends ObjectModel
* @param array &$arr
* return bool
*/
static public function updateQtyProduct(&$arr)
public static function updateQtyProduct(&$arr)
{
Tools::displayAsDeprecated();
@@ -192,7 +192,7 @@ class AttributeCore extends ObjectModel
* @param integer $id_product_attribute
* @return mixed Minimal Quantity or false
*/
static public function getAttributeMinimalQty($id_product_attribute)
public static function getAttributeMinimalQty($id_product_attribute)
{
$minimal_quantity = Db::getInstance()->getValue('
SELECT `minimal_quantity`
+3 -3
View File
@@ -81,7 +81,7 @@ class AttributeGroupCore extends ObjectModel
return parent::getTranslationsFields(array('name', 'public_name'));
}
static public function cleanDeadCombinations()
public static function cleanDeadCombinations()
{
$attributeCombinations = Db::getInstance()->ExecuteS('SELECT pac.`id_attribute`, pa.`id_product_attribute` FROM `'._DB_PREFIX_.'product_attribute` pa LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pa.`id_product_attribute` = pac.`id_product_attribute`)');
$toRemove = array();
@@ -121,7 +121,7 @@ class AttributeGroupCore extends ObjectModel
* @param boolean $id_attribute_group Attribute group id
* @return array Attributes
*/
static public function getAttributes($id_lang, $id_attribute_group)
public static function getAttributes($id_lang, $id_attribute_group)
{
return Db::getInstance()->ExecuteS('
SELECT *
@@ -137,7 +137,7 @@ class AttributeGroupCore extends ObjectModel
* @param integer $id_lang Language id
* @return array Attributes groups
*/
static public function getAttributesGroups($id_lang)
public static function getAttributesGroups($id_lang)
{
return Db::getInstance()->ExecuteS('
SELECT *
+49 -4
View File
@@ -31,6 +31,10 @@ class BackupCore
public $id;
/** @var string Last error messages */
public $error;
/** @var string default backup directory. */
public static $backupDir = '/backups/';
/** @var string custom backup directory. */
public $customBackupDir = NULL;
/**
* Creates a new backup object
@@ -40,24 +44,65 @@ class BackupCore
public function __construct($filename = NULL)
{
if ($filename)
$this->id = self::getBackupPath($filename);
$this->id = $this->getRealBackupPath($filename);
}
/**
* you can set a different path with that function
*
* @TODO include the prefix name
* @param string $dir
* @return boolean bo
*/
public function setCustomBackupPath($dir)
{
$customDir = DIRECTORY_SEPARATOR.trim($dir,'/').DIRECTORY_SEPARATOR;
if(is_dir(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.$customDir.DIRECTORY_SEPARATOR))
$this->customBackupDir = $customDir;
else
return false;
return true;
}
/**
* get the path to use for backup (customBackupDir if specified, or default)
*
* @param string $filename filename to use
* @return string full path
*/
public function getRealBackupPath($filename = NULL)
{
$backupDir = Backup::getBackupPath($filename);
if (!empty($this->customBackupDir))
{
$backupDir = str_replace(_PS_ADMIN_DIR_.self::$backupDir, _PS_ADMIN_DIR_.$this->customBackupDir, $backupDir);
if(strrpos($backupDir,DIRECTORY_SEPARATOR))
$backupDir .= DIRECTORY_SEPARATOR;
}
return $backupDir;
}
/**
* Get the full path of the backup file
*
* @param string $filename Filename of the backup file
* @param string $filename prefix of the backup file (datetime will be the second part)
* @return The full path of the backup file, or false if the backup file does not exists
*/
public static function getBackupPath($filename)
{
$backupdir = realpath(PS_ADMIN_DIR.'/backups/');
$backupdir = realpath(_PS_ADMIN_DIR_.self::$backupDir);
if ($backupdir === false)
die(Tools::displayError('Backups directory does not exist.'));
// Check the realpath so we can validate the backup file is under the backup directory
if(!empty($filename))
$backupfile = realpath($backupdir.'/'.$filename);
else
$backupfile = $backupdir.DIRECTORY_SEPARATOR;
if ($backupfile === false OR strncmp($backupdir, $backupfile, strlen($backupdir)) != 0)
die (Tools::displayError());
@@ -132,7 +177,7 @@ class BackupCore
// Generate some random number, to make it extra hard to guess backup file names
$rand = dechex ( mt_rand(0, min(0xffffffff, mt_getrandmax() ) ) );
$date = time();
$backupfile = PS_ADMIN_DIR . '/backups/' . $date . '-' . $rand . '.sql';
$backupfile = $this->getRealBackupPath().$date.'-'.$rand.'.sql';
// Figure out what compression is available and open the file
if (function_exists('bzopen'))
+3 -3
View File
@@ -175,7 +175,7 @@ class CMSCore extends ObjectModel
AND `id_cms_category`='.(int)($movedCms['id_cms_category'])));
}
static public function cleanPositions($id_category)
public static function cleanPositions($id_category)
{
$result = Db::getInstance()->ExecuteS('
SELECT `id_cms`
@@ -194,12 +194,12 @@ class CMSCore extends ObjectModel
return true;
}
static public function getLastPosition($id_category)
public static function getLastPosition($id_category)
{
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'cms` WHERE `id_cms_category` = '.(int)($id_category)));
}
static public function getCMSPages($id_lang = NULL, $id_cms_category = NULL, $active = true)
public static function getCMSPages($id_lang = NULL, $id_cms_category = NULL, $active = true)
{
return Db::getInstance()->ExecuteS('
SELECT *
+32 -11
View File
@@ -218,14 +218,14 @@ class CMSCategoryCore extends ObjectModel
return $category;
}
static public function recurseCMSCategory($categories, $current, $id_cms_category = 1, $id_selected = 1, $is_html = 0)
public static function recurseCMSCategory($categories, $current, $id_cms_category = 1, $id_selected = 1, $is_html = 0)
{
$html = '<option value="'.$id_cms_category.'"'.(($id_selected == $id_cms_category) ? ' selected="selected"' : '').'>'.
str_repeat('&nbsp;', $current['infos']['level_depth'] * 5).self::hideCMSCategoryPosition(stripslashes($current['infos']['name'])).'</option>';
if ($is_html == 0)
echo $html;
if (isset($categories[$id_cms_category]))
foreach ($categories[$id_cms_category] AS $key => $row)
foreach (array_keys($categories[$id_cms_category]) AS $key)
$html .= self::recurseCMSCategory($categories, $categories[$id_cms_category][$key], $key, $id_selected, $is_html);
return $html;
}
@@ -247,7 +247,7 @@ class CMSCategoryCore extends ObjectModel
SELECT `id_cms_category`
FROM `'._DB_PREFIX_.'cms_category`
WHERE `id_parent` = '.(int)($id_cms_category));
foreach ($result AS $k => $row)
foreach ($result AS $row)
{
$toDelete[] = (int)($row['id_cms_category']);
$this->recursiveDelete($toDelete, (int)($row['id_cms_category']));
@@ -322,7 +322,7 @@ class CMSCategoryCore extends ObjectModel
* @param boolean $active return only active categories
* @return array Categories
*/
static public function getCategories($id_lang, $active = true, $order = true)
public static function getCategories($id_lang, $active = true, $order = true)
{
if (!Validate::isBool($active))
die(Tools::displayError());
@@ -344,7 +344,7 @@ class CMSCategoryCore extends ObjectModel
return $categories;
}
static public function getSimpleCategories($id_lang)
public static function getSimpleCategories($id_lang)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.`id_cms_category`, cl.`name`
@@ -389,7 +389,7 @@ class CMSCategoryCore extends ObjectModel
* @param string $name CMSCategory name
* @return string Name without position
*/
static public function hideCMSCategoryPosition($name)
public static function hideCMSCategoryPosition($name)
{
return preg_replace('/^[0-9]+\./', '', $name);
}
@@ -401,12 +401,12 @@ class CMSCategoryCore extends ObjectModel
* @param boolean $active return only active categories
* @return array categories
*/
static public function getHomeCategories($id_lang, $active = true)
public static function getHomeCategories($id_lang, $active = true)
{
return self::getChildren(1, $id_lang, $active);
}
static public function getChildren($id_parent, $id_lang, $active = true)
public static function getChildren($id_parent, $id_lang, $active = true)
{
if (!Validate::isBool($active))
die(Tools::displayError());
@@ -500,7 +500,7 @@ class CMSCategoryCore extends ObjectModel
* @param boolean $unrestricted allows search without lang and includes first CMSCategory and exact match
* @return array Corresponding categories
*/
static public function searchByName($id_lang, $query, $unrestricted = false)
public static function searchByName($id_lang, $query, $unrestricted = false)
{
if ($unrestricted === true)
return Db::getInstance()->getRow('
@@ -516,6 +516,27 @@ class CMSCategoryCore extends ObjectModel
WHERE `name` LIKE \'%'.pSQL($query).'%\' AND c.`id_cms_category` != 1');
}
/**
* Retrieve CMSCategory by name and parent CMSCategory id
*
* @param integer $id_lang Language ID
* @param string $CMSCategory_name Searched CMSCategory name
* @param integer $id_parent_CMSCategory parent CMSCategory ID
* @return array Corresponding CMSCategory
* @deprecated
*/
public static function searchByNameAndParentCMSCategoryId($id_lang, $CMSCategory_name, $id_parent_CMSCategory)
{
Tools::displayAsDeprecated();
return Db::getInstance()->getRow('
SELECT c.*, cl.*
FROM `'._DB_PREFIX_.'cms_category` c
LEFT JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category` AND `id_lang` = '.(int)($id_lang).')
WHERE `name` LIKE \''.pSQL($CMSCategory_name).'\'
AND c.`id_cms_category` != 1
AND c.`id_parent` = '.(int)($id_parent_CMSCategory));
}
/**
* Get Each parent CMSCategory of this CMSCategory until the root CMSCategory
*
@@ -578,7 +599,7 @@ class CMSCategoryCore extends ObjectModel
AND `id_cms_category`='.(int)($movedCategory['id_cms_category'])));
}
static public function cleanPositions($id_category_parent)
public static function cleanPositions($id_category_parent)
{
$result = Db::getInstance()->ExecuteS('
SELECT `id_cms_category`
@@ -597,7 +618,7 @@ class CMSCategoryCore extends ObjectModel
return true;
}
static public function getLastPosition($id_category_parent)
public static function getLastPosition($id_category_parent)
{
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'cms_category` WHERE `id_parent` = '.(int)($id_category_parent)));
}
+1 -1
View File
@@ -133,7 +133,7 @@ class CacheFSCore extends Cache {
foreach ($res[1] AS $table)
if (isset($this->_tablesCached[$table]))
{
foreach ($this->_tablesCached[$table] AS $fsKey => $foo)
foreach (array_keys($this->_tablesCached[$table]) AS $fsKey)
{
$this->delete($fsKey);
$this->delete($fsKey.'_nrows');
+2 -2
View File
@@ -143,7 +143,7 @@ class CarrierCore extends ObjectModel
{
if (!parent::add($autodate, $nullValues) OR !Validate::isLoadedObject($this))
return false;
if (!$result = Db::getInstance()->ExecuteS('SELECT `id_carrier` FROM `'._DB_PREFIX_.$this->table.'` WHERE `deleted` = 0'))
if (!Db::getInstance()->ExecuteS('SELECT `id_carrier` FROM `'._DB_PREFIX_.$this->table.'` WHERE `deleted` = 0'))
return false;
if (!$numRows = Db::getInstance()->NumRows())
return false;
@@ -432,7 +432,7 @@ class CarrierCore extends ObjectModel
{
// Get id zone
if (!$id_zone)
$id_zone = (int)$defaultCountry->id_zone;
$id_zone = Country::getIdZone(Country::getDefaultCountryId());
// Get only carriers that have a range compatible with cart
if (($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT AND (!Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone)))
+51 -32
View File
@@ -219,7 +219,7 @@ class CartCore extends ObjectModel
return parent::delete();
}
static public function getTaxesAverageUsed($id_cart)
public static function getTaxesAverageUsed($id_cart)
{
$cart = new Cart((int)($id_cart));
if (!Validate::isLoadedObject($cart))
@@ -357,7 +357,7 @@ class CartCore extends ObjectModel
pl.`description_short`, pl.`available_now`, pl.`available_later`, p.`id_product`, p.`id_category_default`, p.`id_supplier`, p.`id_manufacturer`, p.`on_sale`, p.`ecotax`, p.`additional_shipping_cost`, p.`available_for_order`,
p.`price`, p.`weight`, p.`width`, p.`height`, p.`depth`, p.`out_of_stock`, p.`active`, p.`date_add`, p.`date_upd`, IFNULL(pa.`minimal_quantity`, p.`minimal_quantity`) as minimal_quantity,
t.`id_tax`, tl.`name` AS tax, t.`rate`, pa.`price` AS price_attribute, stock.quantity,
pa.`ecotax` AS ecotax_attr, i.`id_image`, il.`legend`, pl.`link_rewrite`, cl.`link_rewrite` AS category, CONCAT(cp.`id_product`, cp.`id_product_attribute`) AS unique_id,
pa.`ecotax` AS ecotax_attr, pl.`link_rewrite`, cl.`link_rewrite` AS category, CONCAT(cp.`id_product`, cp.`id_product_attribute`) AS unique_id,
IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
IF (IFNULL(pa.`supplier_reference`, \'\') = \'\', p.`supplier_reference`, pa.`supplier_reference`) AS supplier_reference,
(p.`weight`+ pa.`weight`) weight_attribute,
@@ -374,17 +374,6 @@ class CartCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$this->id_lang.')
LEFT JOIN `'._DB_PREFIX_.'customization` cu ON (p.`id_product` = cu.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` pai ON (pai.`id_product_attribute` = pa.`id_product_attribute`)
LEFT JOIN `'._DB_PREFIX_.'image` i ON (IF(pai.`id_image`,
i.`id_image` =
(SELECT i2.`id_image`
FROM `'._DB_PREFIX_.'image` i2
INNER JOIN `'._DB_PREFIX_.'product_attribute_image` pai2 ON (pai2.`id_image` = i2.`id_image`)
WHERE i2.`id_product` = p.`id_product` AND pai2.`id_product_attribute` = pa.`id_product_attribute`
ORDER BY i2.`position`
LIMIT 1),
i.`id_product` = p.`id_product` AND i.`cover` = 1)
)
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$this->id_lang.')
'.Product::sqlStock('cp', 'cp').'
WHERE cp.`id_cart` = '.(int)$this->id.'
@@ -409,7 +398,7 @@ class CartCore extends ObjectModel
$this->_products = array();
if (empty($result))
return array();
foreach ($result AS $k => $row)
foreach ($result AS $row)
{
if (isset($row['ecotax_attr']) AND $row['ecotax_attr'] > 0)
$row['ecotax'] = (float)($row['ecotax_attr']);
@@ -439,7 +428,27 @@ class CartCore extends ObjectModel
$row['total_wt'] = $row['price_wt'] * (int)($row['cart_quantity']);
$row['total'] = Tools::ps_round($row['price'] * (int)($row['cart_quantity']), 2);
}
$row['reduction_applies'] = $specificPriceOutput AND (float)($specificPriceOutput['reduction']);
$row2 = Db::getInstance()->getRow('
SELECT i.`id_image`, il.`legend`
FROM `'._DB_PREFIX_.'image` i
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
WHERE '.((isset($row['`pai_id_image`']) AND $row['`pai_id_image`'])
? 'i.`id_image` = (
SELECT i2.`id_image`
FROM `'._DB_PREFIX_.'image` i2
INNER JOIN `'._DB_PREFIX_.'product_attribute_image` pai2 ON (pai2.`id_image` = i2.`id_image`)
WHERE i2.`id_product` = p.`id_product` AND pai2.`id_product_attribute` = pa.`id_product_attribute`
ORDER BY i2.`position`
LIMIT 1
)'
: 'i.`id_product` = '.(int)$row['id_product'].' AND i.`cover` = 1').'
');
if (!$row2)
$row2 = array('id_image' => false, 'legend' => false);
$row = array_merge($row, $row2);
$row['reduction_applies'] = ($specificPriceOutput AND (float)$specificPriceOutput['reduction']);
$row['id_image'] = Product::defineProductImage($row,$this->id_lang);
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
$row['features'] = Product::getFeaturesStatic((int)$row['id_product']);
@@ -454,8 +463,6 @@ class CartCore extends ObjectModel
public static function cacheSomeAttributesLists($ipaList, $id_lang)
{
$paImplode = array();
$attributesList = array();
$attributesListSmall = array();
foreach ($ipaList as $id_product_attribute)
if ((int)$id_product_attribute AND !array_key_exists($id_product_attribute.'-'.$id_lang, self::$_attributesLists))
{
@@ -608,7 +615,7 @@ class CartCore extends ObjectModel
else
Db::getInstance()->Execute('
UPDATE `'._DB_PREFIX_.'cart_product`
SET `quantity` = `quantity` '.$qty.'
SET `quantity` = `quantity` '.$qty.', `date_add` = NOW()
WHERE `id_product` = '.(int)$id_product.
(!empty($id_product_attribute) ? ' AND `id_product_attribute` = '.(int)$id_product_attribute : '').'
AND `id_cart` = '.(int)$this->id.'
@@ -748,7 +755,7 @@ class CartCore extends ObjectModel
$query = 'INSERT INTO `'._DB_PREFIX_.'customized_data` (`id_customization`, `type`, `index`, `value`) VALUES ('.(int)$id_customization.', '.(int)$type.', '.(int)$index.', \''.pSql($field).'\')';
if (!$result = Db::getInstance()->Execute($query))
if (!Db::getInstance()->Execute($query))
return false;
return true;
}
@@ -874,7 +881,7 @@ class CartCore extends ObjectModel
return true;
}
static public function getTotalCart($id_cart, $use_tax_display = false)
public static function getTotalCart($id_cart, $use_tax_display = false)
{
$cart = new Cart((int)($id_cart));
if (!Validate::isLoadedObject($cart))
@@ -1103,7 +1110,6 @@ class CartCore extends ObjectModel
else
$result = Carrier::getCarriers((int)(Configuration::get('PS_LANG_DEFAULT')), true, false, (int)($id_zone));
$resultsArray = array();
foreach ($result AS $k => $row)
{
if ($row['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT'))
@@ -1232,7 +1238,10 @@ class CartCore extends ObjectModel
{
$moduleName = $carrier->external_module_name;
$module = Module::getInstanceByName($moduleName);
if (key_exists('id_carrier', $module))
if (Validate::isLoadedObject($module))
{
if (array_key_exists('id_carrier', $module))
$module->id_carrier = $carrier->id;
if($carrier->need_range)
$shipping_cost = $module->getOrderShippingCost($this, $shipping_cost);
@@ -1243,6 +1252,9 @@ class CartCore extends ObjectModel
if ($shipping_cost === false)
return false;
}
else
return false;
}
// Apply tax
if (isset($carrierTax))
@@ -1327,13 +1339,13 @@ class CartCore extends ObjectModel
$groups = Customer::getGroupsStatic($this->id_customer);
if (($discountObj->id_customer OR $discountObj->id_group) AND ($this->id_customer != $discountObj->id_customer AND !in_array($discountObj->id_group, $groups)))
if (($discountObj->id_customer OR $discountObj->id_group) AND ((($this->id_customer != $discountObj->id_customer) OR ($this->id_customer == 0)) AND !in_array($discountObj->id_group, $groups)))
{
if (!$customer->isLogged())
return Tools::displayError('You cannot use this voucher.').' - '.Tools::displayError('Please log in.');
return Tools::displayError('You cannot use this voucher.');
}
$currentDate = date('Y-m-d');
$onlyProductWithDiscount = true;
if (!$discountObj->cumulable_reduction)
{
@@ -1376,6 +1388,10 @@ class CartCore extends ObjectModel
$delivery = new Address((int)($this->id_address_delivery));
$invoice = new Address((int)($this->id_address_invoice));
// New layout system with personalization fields
$formattedAddresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice);
$formattedAddresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
$total_tax = $this->getOrderTotal() - $this->getOrderTotal(false);
if ($total_tax < 0)
@@ -1399,6 +1415,7 @@ class CartCore extends ObjectModel
'delivery_state' => State::getNameById($delivery->id_state),
'invoice' => $invoice,
'invoice_state' => State::getNameById($invoice->id_state),
'formattedAddresses' => $formattedAddresses,
'carrier' => new Carrier($this->id_carrier, $id_lang),
'products' => $this->getProducts(false),
'discounts' => $this->getDiscounts(false, true),
@@ -1427,7 +1444,7 @@ class CartCore extends ObjectModel
return true;
}
static public function lastNoneOrderedCart($id_customer)
public static function lastNoneOrderedCart($id_customer)
{
$sql = 'SELECT c.`id_cart`
FROM '._DB_PREFIX_.'cart c
@@ -1470,7 +1487,7 @@ class CartCore extends ObjectModel
return self::$_isVirtualCart[$this->id];
}
static public function getCartByOrderId($id_order)
public static function getCartByOrderId($id_order)
{
if ($id_cart = self::getCartIdByOrderId($id_order))
return new Cart((int)($id_cart));
@@ -1478,7 +1495,7 @@ class CartCore extends ObjectModel
return false;
}
static public function getCartIdByOrderId($id_order)
public static function getCartIdByOrderId($id_order)
{
$result = Db::getInstance()->getRow('SELECT `id_cart` FROM '._DB_PREFIX_.'orders WHERE `id_order` = '.(int)$id_order);
if (!$result OR empty($result) OR !key_exists('id_cart', $result))
@@ -1563,7 +1580,7 @@ class CartCore extends ObjectModel
return $result;
}
static public function getCustomerCarts($id_customer)
public static function getCustomerCarts($id_customer)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT *
@@ -1573,7 +1590,7 @@ class CartCore extends ObjectModel
return $result;
}
static public function replaceZeroByShopName($echo, $tr)
public static function replaceZeroByShopName($echo, $tr)
{
return ($echo == '0' ? Configuration::get('PS_SHOP_NAME') : $echo);
}
@@ -1657,8 +1674,8 @@ class CartCore extends ObjectModel
{
$query = 'INSERT INTO `'._DB_PREFIX_.'cart_product`(`id_cart`, `id_product`, `id_product_attribute`, `quantity`, `date_add`) VALUES ';
foreach ($values as $value)
$query .= '('.(int)$this->id.', '.(int)$value['id_product'].', '.(int)$value['id_product_attribute'].', '.(int)$value['quantity'].', NOW()),';
$result = Db::getInstance()->Execute(rtrim($query, ','));
$query .= '('.(int)$this->id.', '.(int)$value['id_product'].', '.(isset($value['id_product_attribute']) ? (int)$value['id_product_attribute'] : 'NULL').', '.(int)$value['quantity'].', NOW()),';
Db::getInstance()->Execute(rtrim($query, ','));
}
return true;
}
@@ -1676,7 +1693,7 @@ class CartCore extends ObjectModel
* @param int $id_cart
* @return bool true if cart has been made by a guest customer
*/
static public function isGuestCartByCartId($id_cart)
public static function isGuestCartByCartId($id_cart)
{
if (!(int)$id_cart)
return false;
@@ -1699,6 +1716,8 @@ class CartCore extends ObjectModel
{
$carrier = new Carrier((int)$id_carrier, Configuration::get('PS_LANG_DEFAULT'));
$shippingMethod = $carrier->getShippingMethod();
if (!$carrier->range_behavior)
return true;
if ($shippingMethod == Carrier::SHIPPING_METHOD_FREE)
return true;
+32 -37
View File
@@ -179,6 +179,16 @@ class CategoryCore extends ObjectModel
return $ret;
}
/**
* @see ObjectModel::toggleStatus()
*/
public function toggleStatus()
{
$result = parent::toggleStatus();
Module::hookExec('categoryUpdate');
return $result;
}
/**
* Recursive scan of subcategories
*
@@ -186,14 +196,16 @@ class CategoryCore extends ObjectModel
* @param integer $currentDepth specify the current depth in the tree (don't use it, only for rucursivity!)
* @param integer $id_lang Specify the id of the language used
* @param array $excludedIdsArray specify a list of ids to exclude of results
* @param Link $link
*
* @return array Subcategories lite tree
*/
function recurseLiteCategTree($maxDepth = 3, $currentDepth = 0, $id_lang = NULL, $excludedIdsArray = NULL, Link $link = NULL)
public function recurseLiteCategTree($maxDepth = 3, $currentDepth = 0, $id_lang = NULL, $excludedIdsArray = NULL)
{
$id_lang = is_null($id_lang) ? Context::getContext()->language->id : (int)$id_lang;
if (!(int)$id_lang)
$id_lang = _USER_ID_LANG_;
$children = array();
if (($maxDepth == 0 OR $currentDepth < $maxDepth) AND $subcats = $this->getSubCategories($id_lang, true) AND sizeof($subcats))
foreach ($subcats AS &$subcat)
@@ -202,7 +214,7 @@ class CategoryCore extends ObjectModel
break;
elseif (!is_array($excludedIdsArray) || !in_array($subcat['id_category'], $excludedIdsArray))
{
$categ = new Category((int)$subcat['id_category'], $id_lang);
$categ = new Category($subcat['id_category'], $id_lang);
$children[] = $categ->recurseLiteCategTree($maxDepth, $currentDepth + 1, $id_lang, $excludedIdsArray);
}
}
@@ -216,12 +228,12 @@ class CategoryCore extends ObjectModel
);
}
static public function recurseCategory($categories, $current, $id_category = 1, $id_selected = 1)
public static function recurseCategory($categories, $current, $id_category = 1, $id_selected = 1)
{
echo '<option value="'.$id_category.'"'.(($id_selected == $id_category) ? ' selected="selected"' : '').'>'.
str_repeat('&nbsp;', $current['infos']['level_depth'] * 5).stripslashes($current['infos']['name']).'</option>';
if (isset($categories[$id_category]))
foreach ($categories[$id_category] AS $key => $row)
foreach (array_keys($categories[$id_category]) AS $key)
self::recurseCategory($categories, $categories[$id_category][$key], $key, $id_selected);
}
@@ -241,7 +253,7 @@ class CategoryCore extends ObjectModel
SELECT `id_category`
FROM `'._DB_PREFIX_.'category`
WHERE `id_parent` = '.(int)($id_category));
foreach ($result AS $k => $row)
foreach ($result AS $row)
{
$toDelete[] = (int)($row['id_category']);
$this->recursiveDelete($toDelete, (int)($row['id_category']));
@@ -353,7 +365,7 @@ class CategoryCore extends ObjectModel
{
$left = (int)$n++;
if (isset($categories[(int)$id_category]['subcategories']))
foreach ($categories[(int)$id_category]['subcategories'] AS $id_subcategory => $value)
foreach (array_keys($categories[(int)$id_category]['subcategories']) AS $id_subcategory)
self::_subTree($categories, (int)$id_subcategory, $n);
$right = (int)$n++;
@@ -367,7 +379,7 @@ class CategoryCore extends ObjectModel
* @param boolean $active return only active categories
* @return array Categories
*/
static public function getCategories($id_lang = false, $active = true, $order = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
public static function getCategories($id_lang = false, $active = true, $order = true, $sql_filter = '', $sql_sort = '',$sql_limit = '')
{
if (!Validate::isBool($active))
die(Tools::displayError());
@@ -392,7 +404,7 @@ class CategoryCore extends ObjectModel
return $categories;
}
static public function getSimpleCategories($id_lang)
public static function getSimpleCategories($id_lang)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.`id_category`, cl.`name`
@@ -594,37 +606,19 @@ class CategoryCore extends ObjectModel
* @param int $id_lang
* @return array
*/
public static function getChildrenWithNbSelectedSubCatForProduct($id_parent, $id_product = 0, $ids_categories = null, $id_lang)
public static function getChildrenWithNbSelectedSubCat($id_parent, $selectedCat, $id_lang)
{
$categories_product_str = '';
if ($id_product)
{
$categories_product = Db::getInstance()->ExecuteS('
SELECT `id_category`
FROM `'._DB_PREFIX_.'category_product`
WHERE `id_product` = '.(int)$id_product);
if (sizeof($categories_product))
foreach ($categories_product as $category_product)
$categories_product_str .= $category_product['id_category'].',';
}
else
{
$categories_product = array();
$categories_product_str = $ids_categories;
}
$categories_product_str = rtrim($categories_product_str, ',');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.`id_category`, cl.`name`, IF((
SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF((
SELECT COUNT(*)
FROM `'._DB_PREFIX_.'category` c2
WHERE c2.`id_parent` = c.`id_category`
) > 0, 1, 0) AS has_children, '.($categories_product_str ? '(
) > 0, 1, 0) AS has_children, '.($selectedCat ? '(
SELECT count(c3.`id_category`)
FROM `'._DB_PREFIX_.'category` c3
WHERE c3.`nleft` > c.`nleft`
AND c3.`nright` < c.`nright`
AND c3.`id_category` IN ('.$categories_product_str.')
AND c3.`id_category` IN ('.$selectedCat.')
)' : '0').' AS nbSelectedSubCat
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`
@@ -725,7 +719,7 @@ class CategoryCore extends ObjectModel
* @param boolean $unrestricted allows search without lang and includes first category and exact match
* @return array Corresponding categories
*/
static public function searchByName($id_lang, $query, $unrestricted = false)
public static function searchByName($id_lang, $query, $unrestricted = false)
{
if ($unrestricted === true)
return Db::getInstance()->getRow('
@@ -749,7 +743,7 @@ class CategoryCore extends ObjectModel
* @param integer $id_parent_category parent category ID
* @return array Corresponding category
*/
static public function searchByNameAndParentCategoryId($id_lang, $category_name, $id_parent_category)
public static function searchByNameAndParentCategoryId($id_lang, $category_name, $id_parent_category)
{
return Db::getInstance()->getRow('
SELECT c.*, cl.*
@@ -794,7 +788,7 @@ class CategoryCore extends ObjectModel
* @param $id_category Category id
* @return boolean
*/
static public function categoryExists($id_category)
public static function categoryExists($id_category)
{
$row = Db::getInstance()->getRow('
SELECT `id_category`
@@ -867,7 +861,7 @@ class CategoryCore extends ObjectModel
$this->addGroups(array(1));
}
static public function setNewGroupForHome($id_group)
public static function setNewGroupForHome($id_group)
{
if (!(int)($id_group))
return false;
@@ -920,7 +914,7 @@ class CategoryCore extends ObjectModel
* @param mixed $id_category_parent
* @return boolean true if succeed
*/
static public function cleanPositions($id_category_parent)
public static function cleanPositions($id_category_parent)
{
$return = true;
@@ -941,7 +935,7 @@ class CategoryCore extends ObjectModel
return $return;
}
static public function getLastPosition($id_category_parent)
public static function getLastPosition($id_category_parent)
{
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'category` WHERE `id_parent` = '.(int)($id_category_parent)));
}
@@ -1022,3 +1016,4 @@ class CategoryCore extends ObjectModel
return $result[0]['nb_product_recursive'];
}
}
+1 -1
View File
@@ -169,7 +169,7 @@ class CombinationCore extends ObjectModel
$sqlValues = array();
foreach ($values as $value)
$sqlValues[] = '('.(int)$this->id.', '.(int)$value['id'].')';
$result = Db::getInstance()->Execute('
Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'product_attribute_image` (`id_product_attribute`, `id_image`)
VALUES '.implode(',', $sqlValues)
);
+198
View File
@@ -0,0 +1,198 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class CompareProduct extends ObjectModel
{
public $id;
public $id_product;
public $id_guest;
public $id_customer;
public $date_add;
public $date_upd;
protected $fieldRequired = array(
'id_product',
'id_guest',
'id_customer');
protected $fieldsValidate = array(
'id_product' => 'isUnsignedInt',
'id_guest' => 'isUnsignedInt',
'id_customer' => 'isUnsignedInt'
);
protected $table = 'compare_product';
protected $identifier = 'id_compare_product';
/**
* Get all compare products of the guest
* @param int $id_guest
* @return array
*/
public static function getGuestCompareProducts($id_guest)
{
$results = Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_product`
FROM `'._DB_PREFIX_.'compare_product`
WHERE `id_guest` = '.(int)($id_guest));
$compareProducts = null;
foreach($results as $result)
$compareProducts[] = $result['id_product'];
return $compareProducts;
}
/**
* Add a compare product for the guest
* @param int $id_guest, int $id_product
* @return boolean
*/
public static function addGuestCompareProduct($id_guest, $id_product)
{
return Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'compare_product` (`id_product`, `id_guest`, `date_add`, `date_upd`)
VALUES ('.(int)($id_product).', '.(int)($id_guest).', NOW(), NOW())
');
}
/**
* Remove a compare product for the guest
* @param int $id_guest, int $id_product
* @return boolean
*/
public static function removeGuestCompareProduct($id_guest, $id_product)
{
return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'compare_product` WHERE `id_guest` = '.(int)($id_guest).' AND `id_product` = '.(int)($id_product));
}
/**
* Get the number of compare products of the guest
* @param int $id_guest
* @return int
*/
public static function getGuestNumberProducts($id_guest)
{
return (int)(Db::getInstance()->getValue('
SELECT count(`id_compare_product`)
FROM `'._DB_PREFIX_.'compare_product`
WHERE `id_guest` = '.(int)($id_guest)));;
}
/**
* Get all comapare products of the customer
* @param int $id_customer
* @return array
*/
public static function getCustomerCompareProducts($id_customer)
{
$results = Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_product`
FROM `'._DB_PREFIX_.'compare_product`
WHERE `id_customer` = '.(int)($id_customer));
$compareProducts = null;
foreach($results as $result)
$compareProducts[] = $result['id_product'];
return $compareProducts;
}
/**
* Add a compare product for the customer
* @param int $id_customer, int $id_product
* @return boolean
*/
public static function addCustomerCompareProduct($id_customer, $id_product)
{
return Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'compare_product` (`id_product`, `id_customer`, `date_add`, `date_upd`) VALUES ('.(int)($id_product).', '.(int)($id_customer).', NOW(), NOW())');
}
/**
* Remove a compare product for the customer
* @param int $id_customer, int $id_product
* @return boolean
*/
public static function removeCustomerCompareProduct($id_customer, $id_product)
{
return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'compare_product` WHERE `id_customer` = '.(int)($id_customer).' AND `id_product` = '.(int)($id_product));
}
/**
* Get the number of compare products of the customer
* @param int $id_customer
* @return int
*/
public static function getCustomerNumberProducts($id_customer)
{
return (int)(Db::getInstance()->getValue('
SELECT count(`id_compare_product`)
FROM `'._DB_PREFIX_.'compare_product`
WHERE `id_customer` = '.(int)($id_customer)));
}
/**
* Clean entries which are older than the period
* @param string $period
* @return void
*/
public static function cleanCompareProducts($period = 'week')
{
if ($period === 'week')
$interval = '1 WEEK';
elseif ($period === 'month')
$interval = '1 MONTH';
elseif ($period === 'year')
$interval = '1 YEAR';
else
return;
if ($interval != null)
{
Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'compare_product`
WHERE date_upd < DATE_SUB(NOW(), INTERVAL '.pSQL($interval).')');
}
}
}
@@ -20,14 +20,14 @@
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7040 $
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class ConfigurationTest
class ConfigurationTestCore
{
static function check($tests)
static function check($tests)
{
$res = array();
foreach ($tests AS $key => $test)
@@ -35,7 +35,7 @@ class ConfigurationTest
return $res;
}
static function run($ptr, $arg = 0)
static function run($ptr, $arg = 0)
{
if (call_user_func(array('ConfigurationTest', 'test_'.$ptr), $arg))
return ('ok');
@@ -43,32 +43,32 @@ class ConfigurationTest
}
// Misc functions
static function test_phpversion()
static function test_phpversion()
{
return version_compare(substr(phpversion(), 0, 3), '5.0', '>=');
}
static function test_mysql_support()
static function test_mysql_support()
{
return function_exists('mysql_connect');
}
static function test_magicquotes()
static function test_magicquotes()
{
return !ini_get('magic_quotes_gpc');
}
static function test_upload()
static function test_upload()
{
return ini_get('file_uploads');
}
static function test_fopen()
static function test_fopen()
{
return ini_get('allow_url_fopen');
}
static function test_system($funcs)
static function test_system($funcs)
{
foreach ($funcs AS $func)
if (!function_exists($func))
@@ -76,17 +76,17 @@ class ConfigurationTest
return true;
}
static function test_gd()
static function test_gd()
{
return function_exists('imagecreatetruecolor');
}
static function test_register_globals()
static function test_register_globals()
{
return !ini_get('register_globals');
}
static function test_gz()
static function test_gz()
{
if (function_exists('gzencode'))
return !(@gzencode('dd') === false);
@@ -94,7 +94,7 @@ class ConfigurationTest
}
// is_writable dirs
static function test_dir($dir, $recursive = false)
static function test_dir($dir, $recursive = false)
{
if (!file_exists($dir) OR !$dh = opendir($dir))
return false;
@@ -119,107 +119,112 @@ class ConfigurationTest
}
// is_writable files
static function test_file($file)
static function test_file($file)
{
return (file_exists($file) AND is_writable($file));
}
static function test_config_dir($dir)
static function test_config_dir($dir)
{
return self::test_dir($dir);
}
static function test_sitemap($dir)
static function test_sitemap($dir)
{
return self::test_file($dir);
}
static function test_root_dir($dir)
static function test_root_dir($dir)
{
return self::test_dir($dir);
}
static function test_log_dir($dir)
static function test_log_dir($dir)
{
return self::test_dir($dir);
}
static function test_admin_dir($dir)
static function test_admin_dir($dir)
{
return self::test_dir($dir);
}
static function test_img_dir($dir)
static function test_img_dir($dir)
{
return self::test_dir($dir, true);
}
static function test_module_dir($dir)
static function test_module_dir($dir)
{
return self::test_dir($dir, true);
}
static function test_tools_dir($dir)
static function test_tools_dir($dir)
{
return self::test_dir($dir);
}
static function test_cache_dir($dir)
static function test_cache_dir($dir)
{
return self::test_dir($dir);
}
static function test_tools_v2_dir($dir)
static function test_tools_v2_dir($dir)
{
return self::test_dir($dir);
}
static function test_cache_v2_dir($dir)
static function test_cache_v2_dir($dir)
{
return self::test_dir($dir);
}
static function test_download_dir($dir)
static function test_download_dir($dir)
{
return self::test_dir($dir);
}
static function test_mails_dir($dir)
static function test_mails_dir($dir)
{
return self::test_dir($dir, true);
}
static function test_translations_dir($dir)
static function test_translations_dir($dir)
{
return self::test_dir($dir, true);
}
static function test_theme_lang_dir($dir)
static function test_theme_lang_dir($dir)
{
if (!file_exists($dir))
return true;
return self::test_dir($dir, true);
}
static function test_theme_cache_dir($dir)
static function test_theme_cache_dir($dir)
{
if (!file_exists($dir))
return true;
return self::test_dir($dir, true);
}
static function test_customizable_products_dir($dir)
static function test_customizable_products_dir($dir)
{
return self::test_dir($dir);
}
static function test_virtual_products_dir($dir)
static function test_virtual_products_dir($dir)
{
return self::test_dir($dir);
}
static function test_mcrypt()
static function test_mcrypt()
{
return function_exists('mcrypt_encrypt');
}
static function test_dom()
{
return extension_loaded('Dom');
}
}
+1 -1
View File
@@ -339,7 +339,7 @@ class CookieCore
public function unsetFamily($origin)
{
$family = $this->getFamily($origin);
foreach ($family AS $member => $value)
foreach (array_keys($family) AS $member)
unset($this->$member);
}
+9 -9
View File
@@ -157,7 +157,7 @@ class CountryCore extends ObjectModel
* @param string $iso_code Country iso code
* @return integer Country ID
*/
static public function getByIso($iso_code)
public static function getByIso($iso_code)
{
if (!Validate::isLanguageIsoCode($iso_code))
die(Tools::displayError());
@@ -169,7 +169,7 @@ class CountryCore extends ObjectModel
return $result['id_country'];
}
static public function getIdZone($id_country)
public static function getIdZone($id_country)
{
if (!Validate::isUnsignedId($id_country))
die(Tools::displayError());
@@ -193,7 +193,7 @@ class CountryCore extends ObjectModel
* @param integer $id_country Country ID
* @return string Country name
*/
static public function getNameById($id_lang, $id_country)
public static function getNameById($id_lang, $id_country)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `name`
@@ -210,7 +210,7 @@ class CountryCore extends ObjectModel
* @param integer $id_country Country ID
* @return string Country iso
*/
static public function getIsoById($id_country)
public static function getIsoById($id_country)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `iso_code`
@@ -227,7 +227,7 @@ class CountryCore extends ObjectModel
* @param string $country Country Name
* @return intval Country id
*/
static public function getIdByName($id_lang = NULL, $country)
public static function getIdByName($id_lang = NULL, $country)
{
$sql = '
SELECT `id_country`
@@ -241,7 +241,7 @@ class CountryCore extends ObjectModel
return ((int)($result['id_country']));
}
static public function getNeedZipCode($id_country)
public static function getNeedZipCode($id_country)
{
if (!(int)($id_country))
return false;
@@ -252,7 +252,7 @@ class CountryCore extends ObjectModel
WHERE `id_country` = '.(int)($id_country));
}
static public function getZipCodeFormat($id_country)
public static function getZipCodeFormat($id_country)
{
if (!(int)($id_country))
return false;
@@ -303,7 +303,7 @@ class CountryCore extends ObjectModel
return (bool)self::isNeedDniByCountryId($this->id);
}
static public function isNeedDniByCountryId($id_country)
public static function isNeedDniByCountryId($id_country)
{
return (bool)Db::getInstance()->getValue('
SELECT `need_identification_number`
@@ -311,7 +311,7 @@ class CountryCore extends ObjectModel
WHERE `id_country` = '.(int)$id_country);
}
static public function containsStates($id_country)
public static function containsStates($id_country)
{
return (bool)Db::getInstance()->getValue('
SELECT `contains_states`
+6 -7
View File
@@ -127,7 +127,6 @@ class CurrencyCore extends ObjectModel
{
if (!is_array($selection) OR !Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table))
die(Tools::displayError());
$result = true;
foreach ($selection AS $id)
{
$obj = new Currency((int)($id));
@@ -238,7 +237,7 @@ class CurrencyCore extends ObjectModel
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
}
static public function getCurrency($id_currency)
public static function getCurrency($id_currency)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT *
@@ -247,7 +246,7 @@ class CurrencyCore extends ObjectModel
AND `id_currency` = '.(int)($id_currency));
}
static public function getIdByIsoCode($iso_code)
public static function getIdByIsoCode($iso_code)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `id_currency`
@@ -319,10 +318,10 @@ class CurrencyCore extends ObjectModel
return new Currency($id_currency);
}
static public function refreshCurrencies()
public static function refreshCurrencies()
{
// Parse
if (!$feed = @simplexml_load_file('http://www.prestashop.com/xml/currencies.xml'))
if (!$feed = Tools::simplexml_load_file('http://www.prestashop.com/xml/currencies.xml'))
return Tools::displayError('Cannot parse feed.');
// Default feed currency (EUR)
@@ -343,13 +342,13 @@ class CurrencyCore extends ObjectModel
* @deprecated as of 1.5 use $context->currency instead
* @return Currency
*/
static public function getCurrent()
public static function getCurrent()
{
Tools::displayAsDeprecated();
return Context::getContext()->currency;
}
static public function getCurrencyInstance($id)
public static function getCurrencyInstance($id)
{
if (!array_key_exists($id, self::$currencies))
self::$currencies[(int)($id)] = new Currency($id);
+8 -8
View File
@@ -306,7 +306,7 @@ class CustomerCore extends ObjectModel
* @param integer $id_address Address ID
* @return boolean result
*/
static public function customerHasAddress($id_customer, $id_address)
public static function customerHasAddress($id_customer, $id_address)
{
if (!array_key_exists($id_customer, self::$_customerHasAddress))
{
@@ -320,7 +320,7 @@ class CustomerCore extends ObjectModel
return self::$_customerHasAddress[$id_customer];
}
static public function resetAddressCache($id_customer)
public static function resetAddressCache($id_customer)
{
if (array_key_exists($id_customer, self::$_customerHasAddress))
unset(self::$_customerHasAddress[$id_customer]);
@@ -364,7 +364,7 @@ class CustomerCore extends ObjectModel
* @param string $passwd Password
* @return boolean result
*/
static public function checkPassword($id_customer, $passwd)
public static function checkPassword($id_customer, $passwd)
{
if (!Validate::isUnsignedId($id_customer) OR !Validate::isMd5($passwd))
die (Tools::displayError());
@@ -452,7 +452,7 @@ class CustomerCore extends ObjectModel
return self::customerIdExistsStatic((int)($id_customer));
}
static public function customerIdExistsStatic($id_customer)
public static function customerIdExistsStatic($id_customer)
{
$row = Db::getInstance()->getRow('
SELECT `id_customer`
@@ -506,10 +506,10 @@ class CustomerCore extends ObjectModel
WHERE o.valid = 1 AND o.`id_customer` = '.(int)($this->id));
}
static public function getDefaultGroupId($id_customer)
public static function getDefaultGroupId($id_customer)
{
if (!isset(self::$_defaultGroupId[(int)($id_customer)]))
self::$_defaultGroupId[(int)($id_customer)] = Db::getInstance()->getValue('SELECT `id_default_group` FROM `'._DB_PREFIX_.'customer` WHERE `id_customer` = '.(int)($id_customer));
self::$_defaultGroupId[(int)($id_customer)] = Db::getInstance()->getValue('SELECT `id_default_group` FROM `'._DB_PREFIX_.'customer` WHERE `id_customer` = '.(int)$id_customer);
return self::$_defaultGroupId[(int)($id_customer)];
}
@@ -568,7 +568,7 @@ class CustomerCore extends ObjectModel
return false;
}
static public function printNewsIcon($id_customer, $tr)
public static function printNewsIcon($id_customer, $tr)
{
$customer = new Customer($tr['id_customer']);
if (!Validate::isLoadedObject($customer))
@@ -578,7 +578,7 @@ class CustomerCore extends ObjectModel
'</a>';
}
static public function printOptinIcon($id_customer, $tr)
public static function printOptinIcon($id_customer, $tr)
{
$customer = new Customer($tr['id_customer']);
if (!Validate::isLoadedObject($customer))
+4 -4
View File
@@ -28,7 +28,7 @@
class CustomizationCore
{
static public function getReturnedCustomizations($id_order)
public static function getReturnedCustomizations($id_order)
{
if (($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT ore.`id_order_return`, ord.`id_order_detail`, ord.`id_customization`, ord.`product_quantity`
@@ -42,7 +42,7 @@ class CustomizationCore
return $customizations;
}
static public function getOrderedCustomizations($id_cart)
public static function getOrderedCustomizations($id_cart)
{
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT `id_customization`, `quantity` FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.(int)($id_cart)))
return false;
@@ -52,7 +52,7 @@ class CustomizationCore
return $customizations;
}
static public function countCustomizationQuantityByProduct($customizations)
public static function countCustomizationQuantityByProduct($customizations)
{
$total = array();
foreach ($customizations AS $customization)
@@ -60,7 +60,7 @@ class CustomizationCore
return $total;
}
static public function getLabel($id_customization, $id_lang)
public static function getLabel($id_customization, $id_lang)
{
if (!$id_customization || !$id_lang)
return false;
+1 -1
View File
@@ -353,7 +353,7 @@ abstract class DbCore
Cache::getInstance()->setQuery($sql, $resultArray);
return $resultArray;
}
/**
* getRow return an associative array containing the first row of the query
* This function automatically add "limit 1" to the query
+9 -10
View File
@@ -190,7 +190,7 @@ class DiscountCore extends ObjectModel
*
* @return array Discount types
*/
static public function getDiscountTypes($id_lang)
public static function getDiscountTypes($id_lang)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT *
@@ -294,7 +294,6 @@ class DiscountCore extends ObjectModel
return 0;
$products = $cart->getProducts();
$categories = Discount::getCategories((int)$this->id);
$in_category = false;
foreach ($products AS $product)
if (count($categories) AND Product::idIsOnCategoryId($product['id_product'], $categories))
@@ -341,7 +340,7 @@ class DiscountCore extends ObjectModel
return 0;
}
static public function getCategories($id_discount)
public static function getCategories($id_discount)
{
return Db::getInstance()->ExecuteS('
SELECT `id_category`
@@ -376,12 +375,12 @@ class DiscountCore extends ObjectModel
}
}
static public function discountExists($discountName, $id_discount = 0)
public static function discountExists($discountName, $id_discount = 0)
{
return Db::getInstance()->getRow('SELECT `id_discount` FROM '._DB_PREFIX_.'discount WHERE `name` LIKE \''.pSQL($discountName).'\' AND `id_discount` != '.(int)($id_discount));
}
static public function createOrderDiscount($order, $productList, $qtyList, $name, $shipping_cost = false, $id_category = 0, $subcategory = 0)
public static function createOrderDiscount($order, $productList, $qtyList, $name, $shipping_cost = false, $id_category = 0, $subcategory = 0)
{
$languages = Language::getLanguages($order);
$products = $order->getProducts(false, $productList, $qtyList);
@@ -430,7 +429,7 @@ class DiscountCore extends ObjectModel
return $voucher;
}
static public function display($discountValue, $discountType, $currency = false)
public static function display($discountValue, $discountType, $currency = false)
{
if ((float)($discountValue) AND (int)($discountType))
{
@@ -442,7 +441,7 @@ class DiscountCore extends ObjectModel
return ''; // return a string because it's a display method
}
static public function getVouchersToCartDisplay($id_lang, $id_customer)
public static function getVouchersToCartDisplay($id_lang, $id_customer)
{
return Db::getInstance()->ExecuteS('
SELECT d.`name`, dl.`description`, d.`id_discount`
@@ -456,7 +455,7 @@ class DiscountCore extends ObjectModel
OR d.`id_group` IN (SELECT `id_group` FROM `'._DB_PREFIX_.'customer_group` WHERE `id_customer` = '.(int)($id_customer).')))' : 'OR d.`id_group` = 1)'));
}
static public function deleteByIdCustomer($id_customer)
public static function deleteByIdCustomer($id_customer)
{
$discounts = Db::getInstance()->ExecuteS('SELECT `id_discount` FROM `'._DB_PREFIX_.'discount` WHERE `id_customer` = '.(int)($id_customer));
foreach ($discounts as $discount)
@@ -468,7 +467,7 @@ class DiscountCore extends ObjectModel
return true;
}
static public function deleteByIdGroup($id_group)
public static function deleteByIdGroup($id_group)
{
$discounts = Db::getInstance()->ExecuteS('SELECT `id_discount` FROM `'._DB_PREFIX_.'discount` WHERE `id_group` = '.(int)($id_group));
foreach ($discounts as $discount)
@@ -480,7 +479,7 @@ class DiscountCore extends ObjectModel
return true;
}
static public function getDiscount($id_discount)
public static function getDiscount($id_discount)
{
return Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'discount` WHERE `id_discount` = '.(int)$id_discount);
}
+4 -4
View File
@@ -116,7 +116,7 @@ class EmployeeCore extends ObjectModel
return $fields;
}
public function add($autodate = true, $nullValues = true)
{
$this->last_passwd_gen = date('Y-m-d H:i:s', strtotime('-'.Configuration::get('PS_PASSWD_TIME_BACK').'minutes'));
@@ -151,7 +151,7 @@ class EmployeeCore extends ObjectModel
return $this;
}
static public function employeeExists($email)
public static function employeeExists($email)
{
if (!Validate::isEmail($email))
die (Tools::displayError());
@@ -168,7 +168,7 @@ class EmployeeCore extends ObjectModel
* @param string $passwd Password
* @return boolean result
*/
static public function checkPassword($id_employee, $passwd)
public static function checkPassword($id_employee, $passwd)
{
if (!Validate::isUnsignedId($id_employee) OR !Validate::isPasswd($passwd, 8))
die (Tools::displayError());
@@ -181,7 +181,7 @@ class EmployeeCore extends ObjectModel
AND active = 1');
}
static public function countProfile($id_profile, $activeOnly = false)
public static function countProfile($id_profile, $activeOnly = false)
{
return Db::getInstance()->getValue('
SELECT COUNT(*)
+5 -5
View File
@@ -67,7 +67,7 @@ class FeatureCore extends ObjectModel
* @return array Array with feature's data
* @static
*/
static public function getFeature($id_lang, $id_feature)
public static function getFeature($id_lang, $id_feature)
{
return Db::getInstance()->getRow('
SELECT *
@@ -83,7 +83,7 @@ class FeatureCore extends ObjectModel
* @return array Multiple arrays with feature's data
* @static
*/
static public function getFeatures($id_lang)
public static function getFeatures($id_lang)
{
return Db::getInstance()->ExecuteS('
SELECT *
@@ -132,7 +132,7 @@ class FeatureCore extends ObjectModel
$fields = $this->getTranslationsFieldsChild();
foreach ($fields as $field)
{
foreach ($field as $key => $value)
foreach (array_keys($field) as $key)
if (!Validate::isTableOrIdentifier($key))
die(Tools::displayError());
$mode = Db::getInstance()->getRow('SELECT `id_lang` FROM `'.pSQL(_DB_PREFIX_.$this->table).'_lang` WHERE `'.pSQL($this->identifier).
@@ -151,7 +151,7 @@ class FeatureCore extends ObjectModel
* @return int Number of feature
* @static
*/
static public function nbFeatures($id_lang)
public static function nbFeatures($id_lang)
{
$result = Db::getInstance()->getRow('
SELECT COUNT(ag.`id_feature`) as nb
@@ -168,7 +168,7 @@ class FeatureCore extends ObjectModel
* @param integer $id_product Product id
* @param array $value Feature Value
*/
static public function addFeatureImport($name)
public static function addFeatureImport($name)
{
$rq = Db::getInstance()->getRow('SELECT `id_feature` FROM '._DB_PREFIX_.'feature_lang WHERE `name` = \''.pSQL($name).'\' GROUP BY `id_feature`');
if (!empty($rq))
+5 -5
View File
@@ -81,7 +81,7 @@ class FeatureValueCore extends ObjectModel
* @return array Array with feature's values
* @static
*/
static public function getFeatureValues($id_feature)
public static function getFeatureValues($id_feature)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT *
@@ -97,7 +97,7 @@ class FeatureValueCore extends ObjectModel
* @return array Array with feature's values
* @static
*/
static public function getFeatureValuesWithLang($id_lang, $id_feature)
public static function getFeatureValuesWithLang($id_lang, $id_feature)
{
return Db::getInstance()->ExecuteS('
SELECT *
@@ -114,7 +114,7 @@ class FeatureValueCore extends ObjectModel
* @return array Array with value's languages
* @static
*/
static public function getFeatureValueLang($id_feature_value)
public static function getFeatureValueLang($id_feature_value)
{
return Db::getInstance()->ExecuteS('
SELECT *
@@ -131,14 +131,14 @@ class FeatureValueCore extends ObjectModel
* @return string String value name selected
* @static
*/
static public function selectLang($lang, $id_lang)
public static function selectLang($lang, $id_lang)
{
foreach ($lang as $tab)
if ($tab['id_lang'] == $id_lang)
return $tab['value'];
}
static public function addFeatureValueImport($id_feature, $name)
public static function addFeatureValueImport($id_feature, $name)
{
$rq = Db::getInstance()->ExecuteS('
SELECT fv.`id_feature_value`
+13 -5
View File
@@ -115,6 +115,8 @@ class FrontControllerCore
ob_start();
$defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
// Switch language if needed and init cookie language
if ($iso = Tools::getValue('isolang') AND Validate::isLanguageIsoCode($iso) AND ($id_lang = (int)(Language::getIdByIso($iso))))
$_GET['id_lang'] = $id_lang;
@@ -122,7 +124,7 @@ class FrontControllerCore
Tools::switchLanguage();
Tools::setCookieLanguage($cookie);
$currency = Tools::setCurrency($cookie);
if (Validate::isLoadedObject($currency))
$smarty->ps_currency = $currency;
if (!Validate::isLoadedObject($language = new Language($cookie->id_lang)))
@@ -159,6 +161,7 @@ class FrontControllerCore
}
$_MODULES = array();
/* Cart already exists */
if ((int)$cookie->id_cart)
{
@@ -232,9 +235,11 @@ class FrontControllerCore
$smarty->ps_language = $language;
/* get page name to display it in body id */
// @todo check here
$pathinfo = pathinfo(__FILE__);
$page_name = Dispatcher::getInstance()->getController();
$page_name = (preg_match('/^[0-9]/', $page_name)) ? 'page_'.$page_name : $page_name;
$smarty->assign(Tools::getMetaTags($language->id, $page_name));
$smarty->assign('request_uri', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
@@ -285,8 +290,6 @@ class FrontControllerCore
'vat_management' => (int)Configuration::get('VATNUMBER_MANAGEMENT'),
'opc' => (bool)Configuration::get('PS_ORDER_PROCESS_TYPE'),
'PS_CATALOG_MODE' => (bool)Configuration::get('PS_CATALOG_MODE'),
'id_current_shop' => $this->id_current_shop,
'id_current_group_shop' => (int)$this->id_current_group_shop
));
// Deprecated
@@ -473,7 +476,7 @@ class FrontControllerCore
{
$this->addCSS(_THEME_CSS_DIR_.'global.css', 'all');
$this->addJS(array(_PS_JS_DIR_.'jquery/jquery-1.4.4.min.js', _PS_JS_DIR_.'jquery/jquery.easing.1.3.js', _PS_JS_DIR_.'tools.js'));
if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
if (Tools::isSubmit('live_edit') AND Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
{
$this->addJS(array(
_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js',
@@ -482,6 +485,9 @@ class FrontControllerCore
);
$this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css');
}
$language = new Language($this->context->language->id);
if ($language->is_rtl)
Tools::addCSS(_THEME_CSS_DIR_.'rtl.css');
}
public function process()
@@ -538,6 +544,8 @@ class FrontControllerCore
{
if (!$this->context)
$this->context = Context::getContext();
if (!self::$initialized)
$this->init();
$this->context->smarty->assign(array(
'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => $this->context->cart)),
@@ -702,7 +710,7 @@ class FrontControllerCore
*/
public function addJS($js_uri)
{
if(!isset($this->js_files))
if (!isset($this->js_files))
$this->js_files = array();
// avoid useless operation...
if (in_array($js_uri, $this->js_files))
+8 -14
View File
@@ -82,7 +82,7 @@ class GroupCore extends ObjectModel
return parent::getTranslationsFields(array('name'));
}
static public function getGroups($id_lang)
public static function getGroups($id_lang)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT g.`id_group`, g.`reduction`, g.`price_display_method`, gl.`name`
@@ -110,21 +110,15 @@ class GroupCore extends ObjectModel
'.($limit > 0 ? 'LIMIT '.(int)$start.', '.(int)$limit : ''));
}
static public function getReduction($id_customer = NULL)
public static function getReduction($id_customer = NULL)
{
if ($id_customer === NULL)
$id_customer = 0;
if (!isset(self::$_cacheReduction['customer'][$id_customer]))
{
if ($id_customer)
$customer = new Customer((int)($id_customer));
self::$_cacheReduction['customer'][$id_customer] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
if (!isset(self::$_cacheReduction['customer'][(int)$id_customer]))
self::$_cacheReduction['customer'][(int)$id_customer] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `reduction`
FROM `'._DB_PREFIX_.'group`
WHERE `id_group` = '.((isset($customer) AND Validate::isLoadedObject($customer)) ? (int)($customer->id_default_group) : 1));
WHERE `id_group` = '.((int)$id_customer ? Customer::getDefaultGroupId((int)$id_customer) : 1));
return self::$_cacheReduction['customer'][(int)$id_customer];
}
return self::$_cacheReduction['customer'][$id_customer];
}
public static function getReductionByIdGroup($id_group)
{
@@ -138,7 +132,7 @@ class GroupCore extends ObjectModel
return self::$_cacheReduction['group'][$id_group];
}
static public function getPriceDisplayMethod($id_group)
public static function getPriceDisplayMethod($id_group)
{
if (!isset(self::$_groupPriceDisplayMethod[$id_group]))
self::$_groupPriceDisplayMethod[$id_group] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
@@ -148,7 +142,7 @@ class GroupCore extends ObjectModel
return self::$_groupPriceDisplayMethod[$id_group];
}
static public function getDefaultPriceDisplayMethod()
public static function getDefaultPriceDisplayMethod()
{
return self::getPriceDisplayMethod(1);
}

Some files were not shown because too many files have changed in this diff Show More