// Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap

Conflicts:
	.gitignore
	admin-dev/themes/default/css/admin.css
	admin-dev/themes/default/template/controllers/categories/helpers/list/list_header.tpl
	admin-dev/themes/default/template/controllers/customers/helpers/list/list_header.tpl
	admin-dev/themes/default/template/controllers/modules/list.tpl
	admin-dev/themes/default/template/controllers/modules/page.tpl
	admin-dev/themes/default/template/controllers/modules/tab_module_line.tpl
	admin-dev/themes/default/template/controllers/orders/_documents.tpl
	admin-dev/themes/default/template/controllers/orders/_shipping.tpl
	admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl
	admin-dev/themes/default/template/controllers/payment/helpers/view/view.tpl
	admin-dev/themes/default/template/controllers/payment/restrictions.tpl
	admin-dev/themes/default/template/controllers/products/images.tpl
	admin-dev/themes/default/template/controllers/products/informations.tpl
	admin-dev/themes/default/template/header.tpl
	admin-dev/themes/default/template/helpers/form/form.tpl
	admin-dev/themes/default/template/helpers/modules_list/list.tpl
	classes/Tools.php
	controllers/admin/AdminCartRulesController.php
	controllers/admin/AdminProductsController.php
	css/admin.css
This commit is contained in:
Kevin Granger
2013-07-24 17:01:23 +02:00
603 changed files with 14577 additions and 11364 deletions
+71 -1
View File
@@ -5,8 +5,18 @@
.idea
.svn
.DS_Store
.sass-cache
robots.txt
sitemap.xml
cache/cachefs/*
!cache/cachefs/index.php
download/*
!download/index.php
upload/*
!upload/index.php
admin-dev/autoupgrade/*
admin-dev/backups/*
!admin-dev/backups/index.php
cache/smarty/cache/*
!cache/smarty/cache/index.php
cache/smarty/compile/*
@@ -16,6 +26,7 @@ cache/tcpdf/*
!cache/tcpdf/index.php
config/xml/*.xml
config/settings.inc.php
config/settings.old.php
log/*.log
img/*
!img/index.php
@@ -27,6 +38,10 @@ tools/smarty*/compile/*.php
override/classes/*.php
themes/default/cache/*.js
themes/default/cache/*.css
themes/default/modules/*/*.php
!themes/default/modules/*/index.php
themes/default/lang/*.php
!themes/default/lang/index.php
modules/*/translations/*.php
!modules/*/translations/index.php
mails/*
@@ -35,4 +50,59 @@ modules/*/mails/*
!modules/*/mails/en
translations/*
!translations/*.gzip
.sass-cache
modules/atos/*
modules/addshoppers
modules/alliedwallet
modules/authorizeaim
modules/autoupgrade
modules/avalaratax
modules/backwardcompatibility
modules/canadapost
modules/cloudcache
modules/ebay
modules/fedexcarrier
modules/fianetfraud
modules/fianetsceau
modules/fidbag
modules/firstdata
modules/gadwords
modules/gamification
modules/ganalytics
modules/gsitemap
modules/hipay
modules/iadvize
modules/itembase
modules/jirafe
modules/kiala
modules/kialasmall
modules/klarnaprestashop
modules/kwixo
modules/livezilla
modules/mailjet
modules/merchantware
modules/mobile_theme
modules/mondialrelay
modules/moneybookers
modules/nqgatewayneteven
modules/ogone
modules/pagseguro
modules/paypal
modules/payulatam
modules/prediggo
modules/prestafraud
modules/shipwire
modules/shoppingfeedexport
modules/shoppingfluxexport
modules/socolissimo
modules/stripejs
modules/themeinstallator
modules/tntcarrier
modules/treepodia
modules/trustedshops
modules/trustly
modules/twenga
modules/upscarrier
modules/uspscarrier
modules/wexpay
modules/yotpo
modules/zingaya
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=address'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=address'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=addresses'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=addresses'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+45 -2
View File
@@ -37,7 +37,6 @@ $height = Tools::getValue('height');
$id_employee = Tools::getValue('id_employee');
$id_lang = Tools::getValue('id_lang');
if (!isset($cookie->id_employee) || !$cookie->id_employee || $cookie->id_employee != $id_employee)
die(Tools::displayError());
@@ -47,6 +46,51 @@ if (!Validate::isModuleName($module))
if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php'))
die(Tools::displayError());
$shop_id = '';
Shop::setContext(Shop::CONTEXT_ALL);
if (Context::getContext()->cookie->shopContext)
{
$split = explode('-', Context::getContext()->cookie->shopContext);
if (count($split) == 2)
{
if ($split[0] == 'g')
{
if (Context::getContext()->employee->hasAuthOnShopGroup($split[1]))
Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
else
{
$shop_id = Context::getContext()->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
}
else if (Shop::getShop($split[1]) && Context::getContext()->employee->hasAuthOnShop($split[1]))
{
$shop_id = $split[1];
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
else
{
$shop_id = Context::getContext()->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
}
}
// Check multishop context and set right context if need
if (Shop::getContext())
{
if (Shop::getContext() == Shop::CONTEXT_SHOP && !Shop::CONTEXT_SHOP)
Shop::setContext(Shop::CONTEXT_GROUP, Shop::getContextShopGroupID());
if (Shop::getContext() == Shop::CONTEXT_GROUP && !Shop::CONTEXT_GROUP)
Shop::setContext(Shop::CONTEXT_ALL);
}
// Replace existing shop if necessary
if (!$shop_id)
Context::getContext()->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
elseif (Context::getContext()->shop->id != $shop_id)
Context::getContext()->shop = new Shop($shop_id);
require_once($module_path);
$graph = new $module();
@@ -57,4 +101,3 @@ if ($option)
$graph->create($render, $type, $width, $height, $layers);
$graph->draw();
+4 -4
View File
@@ -30,14 +30,14 @@ echo ' </div>
<div id="footer">
<div style="float:left;margin-left:10px;padding-top:6px">
<a href="http://www.prestashop.com/" target="_blank" style="font-weight:700;color:#666666">PrestaShop&trade; '._PS_VERSION_.'</a><br />
<span style="font-size:10px">'.translate('Load time:').' '.number_format(microtime(true) - $timerStart, 3, '.', '').'s</span>
<span style="font-size:10px">'.Translate::getAdminTranslation('Load time:').' '.number_format(microtime(true) - $timerStart, 3, '.', '').'s</span>
</div>
<div style="float:right;height:40px;margin-right:10px;line-height:38px;vertical-align:middle">';
if (strtoupper(Context::getContext()->language->iso_code) == 'FR') echo '<span style="color: #812143; font-weight: bold;">Questions / Renseignements / Formations :</span> <strong>+33 (0)1.40.18.30.04</strong> de 09h &agrave; 18h ';
echo ' | <a href="http://www.prestashop.com/en/contact_us/" target="_blank" class="footer_link">'.translate('Contact').'</a>
| <a href="http://forge.prestashop.com" target="_blank" class="footer_link">'.translate('Bug Tracker').'</a>
| <a href="http://www.prestashop.com/forums/" target="_blank" class="footer_link">'.translate('Forum').'</a>
echo ' | <a href="http://www.prestashop.com/en/contact_us/" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Contact').'</a>
| <a href="http://forge.prestashop.com" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Bug Tracker').'</a>
| <a href="http://www.prestashop.com/forums/" target="_blank" class="footer_link">'.Translate::getAdminTranslation('Forum').'</a>
</div>
</div>
</div>
+16 -9
View File
@@ -223,8 +223,16 @@ function checkPSVersion()
return $upgrader->checkPSVersion();
}
/**
* Deprecated since > 1.5.4.1
* Use Translate::getAdminTranslation($string) instead
*
* @param string $string
*/
function translate($string)
{
Tools::displayAsDeprecated();
global $_LANGADM;
if (!is_array($_LANGADM))
return str_replace('"', '&quot;', $string);
@@ -233,7 +241,6 @@ function translate($string)
return str_replace('"', '&quot;', stripslashes($str));
}
/**
* Returns a new Tab object
*
@@ -461,7 +468,7 @@ function runAdminTab($tab, $ajaxMode = false)
echo '<div class="path_bar">
<div id="help-button" class="floatr" style="display: none; font-family: Verdana; font-size: 10px; margin-right: 4px; margin-top: 4px;">
</div>
<a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).(int)Context::getContext()->employee->id).'">'.translate('Back Office').'</a>
<a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).(int)Context::getContext()->employee->id).'">'.Translate::getAdminTranslation('Back Office').'</a>
'.$bread.'</div>';
if (!$ajaxMode && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL)
@@ -470,10 +477,10 @@ function runAdminTab($tab, $ajaxMode = false)
if (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$shop_group = new ShopGroup((int)Shop::getContextShopGroupID());
printf(translate('You are configuring your store for group shop %s'), '<b>'.$shop_group->name.'</b>');
printf(Translate::getAdminTranslation('You are configuring your store for group shop %s'), '<b>'.$shop_group->name.'</b>');
}
elseif (Shop::getContext() == Shop::CONTEXT_SHOP)
printf(translate('You are configuring your store for shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
printf(Translate::getAdminTranslation('You are configuring your store for shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
echo '</div>';
}
if (Validate::isLoadedObject($adminObj))
@@ -546,8 +553,8 @@ function runAdminTab($tab, $ajaxMode = false)
// we can display the correct url
// die(Tools::jsonEncode(array(translate('Invalid security token'),$url)));
die(Tools::jsonEncode(translate('Invalid security token')));
// die(Tools::jsonEncode(array(Translate::getAdminTranslation('Invalid security token'),$url)));
die(Tools::jsonEncode(Translate::getAdminTranslation('Invalid security token')));
}
else
{
@@ -559,17 +566,17 @@ function runAdminTab($tab, $ajaxMode = false)
if (false === strpos($url, '?token=') AND false === strpos($url, '&token='))
$url .= '&token='.$adminObj->token;
$message = translate('Invalid security token');
$message = Translate::getAdminTranslation('Invalid security token');
echo '<html><head><title>'.$message.'</title></head><body style="font-family:Arial,Verdana,Helvetica,sans-serif;background-color:#EC8686">
<div style="background-color:#FAE2E3;border:1px solid #000000;color:#383838;font-weight:700;line-height:20px;margin:0 0 10px;padding:10px 15px;width:500px">
<img src="../img/admin/error2.png" style="margin:-4px 5px 0 0;vertical-align:middle">
'.$message.'
</div>';
echo '<a href="'.htmlentities($url).'" method="get" style="float:left;margin:10px">
<input type="button" value="'.Tools::htmlentitiesUTF8(translate('I understand the risks and I really want to display this page')).'" style="height:30px;margin-top:5px" />
<input type="button" value="'.Tools::htmlentitiesUTF8(Translate::getAdminTranslation('I understand the risks and I really want to display this page')).'" style="height:30px;margin-top:5px" />
</a>
<a href="index.php" method="get" style="float:left;margin:10px">
<input type="button" value="'.Tools::htmlentitiesUTF8(translate('Take me out of here!')).'" style="height:40px" />
<input type="button" value="'.Tools::htmlentitiesUTF8(Translate::getAdminTranslation('Take me out of here!')).'" style="height:40px" />
</a>
</body></html>';
die;
+48 -1
View File
@@ -50,6 +50,53 @@ if (!Validate::isModuleName($module))
if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php'))
die(Tools::displayError());
$shop_id = '';
Shop::setContext(Shop::CONTEXT_ALL);
if (Context::getContext()->cookie->shopContext)
{
$split = explode('-', Context::getContext()->cookie->shopContext);
if (count($split) == 2)
{
if ($split[0] == 'g')
{
if (Context::getContext()->employee->hasAuthOnShopGroup($split[1]))
Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
else
{
$shop_id = Context::getContext()->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
}
else if (Shop::getShop($split[1]) && Context::getContext()->employee->hasAuthOnShop($split[1]))
{
$shop_id = $split[1];
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
else
{
$shop_id = Context::getContext()->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
}
}
}
// Check multishop context and set right context if need
if (Shop::getContext())
{
if (Shop::getContext() == Shop::CONTEXT_SHOP && !Shop::CONTEXT_SHOP)
Shop::setContext(Shop::CONTEXT_GROUP, Shop::getContextShopGroupID());
if (Shop::getContext() == Shop::CONTEXT_GROUP && !Shop::CONTEXT_GROUP)
Shop::setContext(Shop::CONTEXT_ALL);
}
// Replace existing shop if necessary
if (!$shop_id)
Context::getContext()->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
elseif (Context::getContext()->shop->id != $shop_id)
Context::getContext()->shop = new Shop($shop_id);
require_once($module_path);
$grid = new $module();
@@ -59,4 +106,4 @@ if ($option)
$grid->setOption($option);
$grid->create($render, $type, $width, $height, $start, $limit, $sort, $dir);
$grid->render();
$grid->render();
+35 -35
View File
@@ -41,7 +41,7 @@ echo '
<link type="text/css" rel="stylesheet" href="'._PS_JS_DIR_.'jquery/plugins/cluetip/jquery.cluetip.css" />
<link type="text/css" rel="stylesheet" href="themes/'.Context::getContext()->employee->bo_theme.'/css/admin.css" />
<link type="text/css" rel="stylesheet" href="'._PS_JS_DIR_.'jquery/plugins/chosen/jquery.chosen.css" />
<title>PrestaShop&trade; - '.translate('Administration panel').'</title>
<title>PrestaShop&trade; - '.Translate::getAdminTranslation('Administration panel').'</title>
<script type="text/javascript">
var helpboxes = '.Configuration::get('PS_HELPBOX').';
var roundMode = '.Configuration::get('PS_PRICE_ROUND_MODE').';
@@ -78,7 +78,7 @@ echo '
html = "";
nb_notifs = 0;
$.each(json.order, function(property, value) {
html += "<li>'.translate('A new order has been made on your shop.').'<br />'.translate('Order number : ').'<strong>#" + parseInt(value.id_order) + "</strong><br />'.translate('Total : ').'<strong>" + value.total_paid_real + "</strong><br />'.translate('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'&vieworder&id_order=" + parseInt(value.id_order) + "\">'.translate('Click here to see that order').'</a></li>";
html += "<li>'.Translate::getAdminTranslation('A new order has been made on your shop.').'<br />'.Translate::getAdminTranslation('Order number : ').'<strong>#" + parseInt(value.id_order) + "</strong><br />'.Translate::getAdminTranslation('Total : ').'<strong>" + value.total_paid_real + "</strong><br />'.Translate::getAdminTranslation('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'&vieworder&id_order=" + parseInt(value.id_order) + "\">'.Translate::getAdminTranslation('Click here to see that order').'</a></li>";
});
if (html != "")
@@ -99,7 +99,7 @@ echo '
html = "";
nb_notifs = 0;
$.each(json.customer, function(property, value) {
html += "<li>'.translate('A new customer registered on your shop.').'<br />'.translate('Customer name : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'&viewcustomer&id_customer=" + parseInt(value.id_customer) + "\">'.translate('Click here to see that customer').'</a></li>";
html += "<li>'.Translate::getAdminTranslation('A new customer registered on your shop.').'<br />'.Translate::getAdminTranslation('Customer name : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'&viewcustomer&id_customer=" + parseInt(value.id_customer) + "\">'.Translate::getAdminTranslation('Click here to see that customer').'</a></li>";
});
if (html != "")
{
@@ -121,7 +121,7 @@ echo '
html = "";
nb_notifs = 0;
$.each(json.customer_message, function(property, value) {
html += "<li>'.translate('A new message posted on your shop.').'<br />'.translate('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'&viewcustomer_thread&id_customer_thread=" + parseInt(value.id_customer_thread) + "\">'.translate('Click here to see that message').'</a></li>";
html += "<li>'.Translate::getAdminTranslation('A new message posted on your shop.').'<br />'.Translate::getAdminTranslation('From : ').'<strong>" + value.customer_name + "</strong><br /><a href=\"index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'&viewcustomer_thread&id_customer_thread=" + parseInt(value.id_customer_thread) + "\">'.Translate::getAdminTranslation('Click here to see that message').'</a></li>";
});
if (html != "")
@@ -149,14 +149,14 @@ echo '
if (Shop::isFeatureActive())
{
if (Shop::getContext() == Shop::CONTEXT_ALL)
$youEditFieldFor = translate('A modification of this field will be applied for all shops');
$youEditFieldFor = Translate::getAdminTranslation('A modification of this field will be applied for all shops');
elseif (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$shop_group = new ShopGroup((int)Shop::getContextShopGroupID());
$youEditFieldFor = sprintf(translate('A modification of this field will be applied for all shops of group %s'), '<b>'.$shop_group->name.'</b>');
$youEditFieldFor = sprintf(Translate::getAdminTranslation('A modification of this field will be applied for all shops of group %s'), '<b>'.$shop_group->name.'</b>');
}
else
$youEditFieldFor = sprintf(translate('A modification of this field will be applied for the shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
$youEditFieldFor = sprintf(Translate::getAdminTranslation('A modification of this field will be applied for the shop %s'), '<b>'.Context::getContext()->shop->name.'</b>');
echo 'hints.html(hints.html()+\'<br /><span class="red">'.addslashes($youEditFieldFor).'</span>\');';
}
@@ -202,10 +202,10 @@ echo ' var html = "";
{
echo '<div id="orders_notif" class="notifs"><span id="orders_notif_number_wrapper" class="number_wrapper"><span id="orders_notif_value">0</span></span>
<div id="orders_notif_wrapper" class="notifs_wrapper">
<h3>'.translate('Last orders').'</h3>
<p class="no_notifs">'.translate('No new orders has been made on your shop').'</p>
<h3>'.Translate::getAdminTranslation('Last orders').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new orders has been made on your shop').'</p>
<ul id="list_orders_notif"></ul>
<p><a href="index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'">'.translate('Show all orders').'</a></p>
<p><a href="index.php?tab=AdminOrders&token='.Tools::getAdminTokenLite('AdminOrders').'">'.Translate::getAdminTranslation('Show all orders').'</a></p>
</div>
</div>';
}
@@ -213,10 +213,10 @@ echo ' var html = "";
{
echo '<div id="customers_notif" class="notifs notifs_alternate"><span id="customers_notif_number_wrapper" class="number_wrapper"><span id="customers_notif_value">0</span></span>
<div id="customers_notif_wrapper" class="notifs_wrapper">
<h3>'.translate('Last customers').'</h3>
<p class="no_notifs">'.translate('No new customers registered on your shop').'</p>
<h3>'.Translate::getAdminTranslation('Last customers').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new customers registered on your shop').'</p>
<ul id="list_customers_notif"></ul>
<p><a href="index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'">'.translate('Show all customers').'</a></p>
<p><a href="index.php?tab=AdminCustomers&token='.Tools::getAdminTokenLite('AdminCustomers').'">'.Translate::getAdminTranslation('Show all customers').'</a></p>
</div>
</div>';
}
@@ -224,26 +224,26 @@ echo ' var html = "";
{
echo '<div id="customer_messages_notif" class="notifs"><span id="customer_messages_notif_number_wrapper" class="number_wrapper"><span id="customer_messages_notif_value">0</span></span>
<div id="customer_messages_notif_wrapper" class="notifs_wrapper">
<h3>'.translate('Last messages').'</h3>
<p class="no_notifs">'.translate('No new messages posted on your shop').'</p>
<h3>'.Translate::getAdminTranslation('Last messages').'</h3>
<p class="no_notifs">'.Translate::getAdminTranslation('No new messages posted on your shop').'</p>
<ul id="list_customer_messages_notif"></ul>
<p><a href="index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'">'.translate('Show all messages').'</a></p>
<p><a href="index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'">'.Translate::getAdminTranslation('Show all messages').'</a></p>
</div>
</div>';
}
echo '</div>
echo '</div>
<div id="employee_box">
<div id="employee_infos">
<div class="employee_name">'.translate('Welcome,').' <strong>'.Context::getContext()->employee->firstname.'&nbsp'.Context::getContext()->employee->lastname.'</strong></div>
<div class="employee_name">'.Translate::getAdminTranslation('Welcome,').' <strong>'.Context::getContext()->employee->firstname.'&nbsp'.Context::getContext()->employee->lastname.'</strong></div>
<div class="clear"></div>
<ul id="employee_links">
<li><a href="'.htmlentities(Context::getContext()->link->getAdminLink('AdminEmployees'), ENT_COMPAT, 'UTF-8').'&id_employee={$employee->id}&amp;updateemployee">'.translate('My preferences').'</a></li>
<li><a href="'.htmlentities(Context::getContext()->link->getAdminLink('AdminEmployees'), ENT_COMPAT, 'UTF-8').'&id_employee={$employee->id}&amp;updateemployee">'.Translate::getAdminTranslation('My preferences').'</a></li>
<li class="separator">&nbsp;</li>
<li><a id="header_logout" href="index.php?logout">'.translate('logout').'</a></li>
<li><a id="header_logout" href="index.php?logout">'.Translate::getAdminTranslation('logout').'</a></li>
</ul>';
if (defined(_PS_BASE_URL_))
echo '<a href="'._PS_BASE_URL_.'" id="header_foaccess" target="_blank" title="'.translate('View my shop').'">'.translate('View my shop').'</a>';
echo '<a href="'._PS_BASE_URL_.'" id="header_foaccess" target="_blank" title="'.Translate::getAdminTranslation('View my shop').'">'.Translate::getAdminTranslation('View my shop').'</a>';
echo '</div>
</div>
@@ -252,18 +252,18 @@ echo ' var html = "";
<form method="post" action="index.php?controller=AdminSearch&amp;token='.Tools::getAdminTokenLite('AdminSearch').'">
<input type="text" name="bo_query" id="bo_query" value="'.Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))).'" />
<select name="bo_search_type" id="bo_search_type" class="chosen no-search">
<option value="0">'.translate('everywhere').'</option>
<option value="1" '.(Tools::getValue('bo_search_type') == 1 ? 'selected="selected"' : '').'>'.translate('catalog').'</option>
<optgroup label="'.translate('customers').':">
<option value="2" '.(Tools::getValue('bo_search_type') == 2 ? 'selected="selected"' : '').'>'.translate('by name').'</option>
<option value="6" '.(Tools::getValue('bo_search_type') == 6 ? 'selected="selected"' : '').'>'.translate('by ip address').'</option>
<option value="0">'.Translate::getAdminTranslation('everywhere').'</option>
<option value="1" '.(Tools::getValue('bo_search_type') == 1 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('catalog').'</option>
<optgroup label="'.Translate::getAdminTranslation('customers').':">
<option value="2" '.(Tools::getValue('bo_search_type') == 2 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('by name').'</option>
<option value="6" '.(Tools::getValue('bo_search_type') == 6 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('by ip address').'</option>
</optgroup>
<option value="3" '.(Tools::getValue('bo_search_type') == 3 ? 'selected="selected"' : '').'>'.translate('orders').'</option>
<option value="4" '.(Tools::getValue('bo_search_type') == 4 ? 'selected="selected"' : '').'>'.translate('invoices').'</option>
<option value="5" '.(Tools::getValue('bo_search_type') == 5 ? 'selected="selected"' : '').'>'.translate('carts').'</option>
<option value="7" '.(Tools::getValue('bo_search_type') == 7 ? 'selected="selected"' : '').'>'.translate('modules').'</option>
<option value="3" '.(Tools::getValue('bo_search_type') == 3 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('orders').'</option>
<option value="4" '.(Tools::getValue('bo_search_type') == 4 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('invoices').'</option>
<option value="5" '.(Tools::getValue('bo_search_type') == 5 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('carts').'</option>
<option value="7" '.(Tools::getValue('bo_search_type') == 7 ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('modules').'</option>
</select>
<input type="submit" id="bo_search_submit" class="button" value="'.translate('Search').'"/>
<input type="submit" id="bo_search_submit" class="button" value="'.Translate::getAdminTranslation('Search').'"/>
</form>
</div>
<div id="header_quick">
@@ -277,7 +277,7 @@ echo ' var html = "";
}
</script>
<select onchange="quickSelect(this);" id="quick_select">
<option value="0">'.translate('Quick Access').'</option>';
<option value="0">'.Translate::getAdminTranslation('Quick Access').'</option>';
foreach (QuickAccess::getQuickAccesses(Context::getContext()->language->id) AS $quick)
{
preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $adminTab);
@@ -342,8 +342,8 @@ echo '
<div id="main">
<div id="content">'
.(file_exists(_PS_ADMIN_DIR_.'/../install') ? '<div style="background-color: #FFEBCC;border: 1px solid #F90;line-height: 20px;margin: 0px 0px 10px;padding: 10px 20px;">'
.translate('For security reasons, you must also:').' '.
translate('delete the /install folder').
.Translate::getAdminTranslation('For security reasons, you must also:').' '.
Translate::getAdminTranslation('delete the /install folder').
'</div>' : '').'
';
if(defined('_PS_MODE_DEV_') && _PS_MODE_DEV_)
@@ -352,7 +352,7 @@ echo '
if (Shop::isFeatureActive() && Context::getContext()->controller->multishop_context != Shop::CONTEXT_ALL)
{
echo '<div class="multishop_toolbar">
<span class="text_multishop">'.translate('Multistore configuration for').'</span>'.
<span class="text_multishop">'.Translate::getAdminTranslation('Multistore configuration for').'</span>'.
Helper::renderShopList();
echo '</div>';
}
+352 -15
View File
@@ -2,6 +2,10 @@
/*LIST*/
/*FORM*/
/*BUTTON*/
/*HEADER*/
/* Portrait orientation targeting */
/* Portrait orientation targeting */
/*MENU*/
/*SEPARATION*/
/*TABLE*/
/*UI ACCORDEON*/
@@ -23,10 +27,14 @@
/*TAB MODULES LIST*/
/******** ie7 ******/
/*MODULE POSITION*/
/*FOOTER*/
/*DASHBOARD*/
/******** CREATE AN ORDER **************/
/************** SCENE *****************/ }
#nobootstrap body {
font-family: Arial, Helvetica, sans-serif; }
#nobootstrap h1, #nobootstrap h2, #nobootstrap h3, #nobootstrap h4 {
font-family: Arial, Helvetica, sans-serif;
margin-bottom: .5em;
line-height: 1.4em; }
#nobootstrap h2 {
@@ -98,7 +106,11 @@
color: #123456;
margin: 2px;
padding: 2px; }
#nobootstrap .button, #nobootstrap .btn {
#nobootstrap .icon {
vertical-align: middle; }
#nobootstrap .icon-top {
vertical-align: top; }
#nobootstrap .button {
background: #e3e3e3 url("../img/bg-button-degrade.png") repeat-x scroll left top;
background: -moz-linear-gradient(center top, #f9f9f9, #e3e3e3) repeat scroll 0 0 transparent;
background: -webkit-gradient(linear, center top, center bottom, from(#f9f9f9), to(#e3e3e3)) repeat scroll 0 0 transparent;
@@ -116,22 +128,321 @@
vertical-align: middle;
white-space: nowrap;
text-shadow: 0 1px 0 #fff; }
#nobootstrap .button[disabled=disabled], #nobootstrap .btn[disabled=disabled] {
#nobootstrap .button[disabled=disabled] {
color: #8C8C8C; }
#nobootstrap .button.bt-icon, #nobootstrap .btn.bt-icon {
#nobootstrap .button.bt-icon {
display: inline-block;
margin-bottom: 7px; }
#nobootstrap .button.bt-icon span, #nobootstrap .btn.bt-icon span {
#nobootstrap .button.bt-icon span {
padding-left: 5px; }
#nobootstrap input.button[disabled=disabled]:hover, #nobootstrap input.btn[disabled=disabled]:hover {
#nobootstrap input.button[disabled=disabled]:hover {
background-color: #FFF6D3; }
#nobootstrap .button:hover, #nobootstrap .btn:hover {
#nobootstrap .button:hover {
border: 1px solid #939393; }
#nobootstrap .button:active, #nobootstrap .btn:active {
#nobootstrap .button:active {
border: 1px solid #939393; }
#nobootstrap .button.export-csv span, #nobootstrap .btn.export-csv {
#nobootstrap .button.export-csv span {
background: transparent url("../img/export-csv.png") no-repeat scroll left top;
padding: 1px 0 1px 20px; }
#nobootstrap #top_container {
margin: 0;
padding: 0; }
#nobootstrap #header {
background-color: #394049;
height: 90px; }
@media screen and (orientation: portrait) {
#nobootstrap #header {
min-width: 1250px; } }
@media screen and (orientation: landscape) {
#nobootstrap #header {
min-width: 1250px; } }
#nobootstrap #header #header_infos {
position: relative;
margin: 0;
padding: 0;
height: 60px; }
#nobootstrap #header #header_shopname {
float: left;
margin: 10px 15px 0 10px; }
#nobootstrap #header #employee_box {
float: right;
display: block; }
#nobootstrap #header #employee_infos {
display: block;
margin: 5px 15px 0 10px; }
#nobootstrap #header #employee_infos a {
color: #BABABA;
text-transform: capitalize;
margin-right: 5px; }
#nobootstrap #header #employee_infos a:hover {
color: #fff; }
#nobootstrap #header #employee_infos .employee_name {
float: left;
color: #fff;
padding: 0 20px 0 0; }
#nobootstrap #header .separator {
background: transparent url("../img/separator.png") no-repeat scroll center top;
height: 19px;
width: 16px;
margin-right: 5px; }
#nobootstrap #header ul#employee_links {
list-style: none;
display: block;
text-align: left; }
#nobootstrap #header ul#employee_links li {
display: inline;
line-height: 20px; }
#nobootstrap #header #header_infos #header_shopname span {
display: block;
font-size: 24px;
height: 28px;
overflow: hidden;
margin: 0;
color: #fff;
text-shadow: 0 1px 0 #000000; }
#nobootstrap #header #header_infos a#header_logout {
background: transparent url("../img/logout.png") no-repeat scroll left top;
padding-left: 20px;
color: #bababa; }
#nobootstrap #header #header_infos a#header_logout:hover {
color: #fff; }
#nobootstrap #header #header_infos #header_logout a span {
color: #bababa; }
#nobootstrap #header #header_infos #header_foaccess {
text-decoration: none;
color: #bababa; }
#nobootstrap #header #header_infos #header_foaccess a {
color: #bababa !important; }
#nobootstrap #header #header_infos a#header_foaccess:hover {
color: #fff; }
#nobootstrap #header #header_search {
background-color: #fff;
border: 2px solid #000;
float: left;
margin-top: 15px;
position: relative;
height: 25px;
box-shadow: 0 1px 0 #666666; }
#nobootstrap #header #header_search #bo_query {
font: 13px Arial,sans-serif;
float: left;
background: none repeat scroll 0 0 transparent;
border: none;
box-shadow: none;
padding: 5px 0px 5px 4px;
width: 160px; }
#nobootstrap #header #header_search #bo_search_type_chzn {
font-size: 13px;
float: left;
margin: 0 23px 0 0;
padding: 0 4px;
vertical-align: middle;
width: 80px !important;
height: 27px;
border: none; }
#nobootstrap #header #header_search #bo_search_type_chzn.chzn-container-single .chzn-single {
box-shadow: none;
border-radius: 0px;
border: none;
border-left: 1px dotted #ccc; }
#nobootstrap #header #header_search #bo_search_submit {
background: url("../img/icon-search2.png") no-repeat scroll center;
border: none;
width: 27px;
height: 25px;
float: left;
font-weight: normal;
margin: 0;
padding: 0;
cursor: pointer;
text-indent: -9999em;
position: absolute;
right: 0;
display: block;
border-left: 1px solid #3079ED;
border-radius: 0px;
/*hacking ie7font-size: 0!ie7; color: transparent!ie;*/ }
#nobootstrap #header #header_quick {
float: right;
display: block;
margin-top: 15px; }
#nobootstrap #header #header_quick #quick_select_chzn {
font-size: 13px;
margin: 0 10px 0 0;
padding: 0px 0 4px; }
#nobootstrap #header #header_myaccount {
background: url("../img/bg-lang.png") no-repeat;
display: block;
float: right;
height: 16px;
margin: 8px 1px 0 0;
width: 16px; }
#nobootstrap .path_bar {
display: none; }
#nobootstrap #notifs_icon_wrapper {
float: left;
position: relative;
margin: 15px 10px 0;
width: 95px; }
#nobootstrap .notifs {
float: left;
position: relative;
cursor: pointer;
margin: 0;
padding: 5px;
width: 18px;
height: 16px; }
#nobootstrap #orders_notif {
background: url("../img/notif_order.png") no-repeat center top; }
#nobootstrap #customers_notif {
background: url("../img/notif_customer.png") no-repeat center top; }
#nobootstrap #customer_messages_notif {
background: url("../img/notif_message.png") no-repeat center top; }
#nobootstrap #orders_notif.open_notifs,
#nobootstrap #customers_notif.open_notifs,
#nobootstrap #customer_messages_notif.open_notifs {
background-color: #FFFFFF;
border: 1px solid #000000;
position: relative;
display: block;
background-position: center bottom; }
#nobootstrap .number_wrapper {
color: white;
display: none;
font-size: 13px;
font-weight: bold;
position: absolute;
right: -8px;
top: -10px;
z-index: 101;
padding: 2px 5px; }
#nobootstrap .number_wrapper span {
background-color: #F03D25;
font-size: 11px;
display: block;
padding: 1px 3px;
border-color: -moz-use-text-color #DD3822 #DD3822;
border-radius: 2px 2px 2px 2px;
border-right: 1px solid #DD3822;
border-style: none solid solid;
border-width: 0 0px; }
#nobootstrap .notifs_wrapper {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #000;
border-top: none;
display: none;
cursor: auto;
position: absolute;
top: 25px;
left: -1px;
width: 300px;
padding: 10px;
color: black;
z-index: 9999; }
#nobootstrap .notifs_wrapper h3 {
font-size: 14px;
padding-bottom: 8px;
margin: 0;
border-bottom: 1px solid #E5E5E5; }
#nobootstrap .notifs_wrapper ul {
padding: 6px 0;
margin: 0; }
#nobootstrap .notifs_wrapper ul li {
text-decoration: none;
list-style: none;
font-size: 12px;
padding: 5px 0; }
#nobootstrap #header_infos .notifs_wrapper a {
font-weight: bold;
font-size: 11px;
color: black;
float: right; }
#nobootstrap .notifs_wrapper p {
font-size: 12px;
padding-top: 8px;
margin: 0;
border-top: 1px solid #E5E5E5; }
#nobootstrap .notifs_wrapper p.no_notifs {
border: none; }
#nobootstrap #header #menu {
background-color: #f8f8f8;
border-bottom: 1px solid #e5e5e5;
float: left;
line-height: normal;
margin: 0;
padding: 0;
width: 100%; }
#nobootstrap #header #menu li.maintab {
float: left;
height: 29px;
list-style: none;
list-style: none;
display: block;
border-left: 1px solid #fff;
border-right: 1px solid #ccc; }
#nobootstrap #header #menu li.submenu_size .title {
cursor: default;
color: #000;
display: block;
padding: 8px 3px 4px 0;
font-weight: normal;
font-size: 12px; }
#nobootstrap #header #menu li.submenu_size .title {
_display: inline;
_padding: 6px 5px 4px 0; }
#nobootstrap #header #menu li {
_height: 32px;
_padding-top: 3px; }
#nobootstrap #header #menu img {
display: inline;
padding: 0 3px 0 6px;
margin-top: -4px;
vertical-align: middle;
width: 16px;
height: 16px; }
#nobootstrap #header #menu li.active, #nobootstrap #header #menu li:hover {
background-position: 0 -38px;
white-space: nowrap; }
#nobootstrap #header #menu li:hover, #nobootstrap #header #menu li.active {
background-color: #49B2FF; }
#nobootstrap #header #menu li.maintab:hover, #nobootstrap #header #menu li.active {
border-left: 1px solid #49B2FF;
border-right: 1px solid #49B2FF; }
#nobootstrap #header #menu li.active a.title, #nobootstrap #header #menu li:hover a.title {
color: #fff;
text-shadow: -1px -1px 0 #3293D6; }
#nobootstrap #header #menu .withLeftBorder {
background: transparent url("../img/separator_subnav.png") no-repeat 0 5px; }
#nobootstrap #header #menu .submenu {
background: #f8f8f8;
clear: both;
margin: 0;
padding: 0;
border: 1px solid #d9d9d9;
z-index: 9999;
box-shadow: 1px 5px 5px #CCCCCC;
-moz-box-shadow: 1px 5px 10px #CCCCCC;
-webkit-box-shadow: 1px 5px 10px #CCCCCC; }
#nobootstrap #header #menu .submenu li {
list-style: none;
margin: 0;
padding: 0;
display: block;
min-width: 150px; }
#nobootstrap #header #menu .submenu li a {
font-size: 12px;
display: block;
padding: 5px 15px 5px 10px;
color: #666666;
border-top: 1px solid #fff;
border-bottom: 1px solid #ccc; }
#nobootstrap #header #menu .submenu li a:hover {
background-color: #eee;
text-shadow: 0 1px 0 #fff; }
#nobootstrap #header #menu .submenu li.active a {
color: #fff; }
#nobootstrap #header #menu .submenu li.active a:hover {
color: #666666; }
#nobootstrap .separation {
background-color: #ccc;
border-bottom: 1px solid #fff;
@@ -222,6 +533,7 @@
#nobootstrap .path_bar {
background-color: #E2EBEE;
border: 1px solid #999999;
font-family: Trebuchet,Arial,Helvetica,sans-serif;
font-size: 13px;
margin-bottom: 20px;
padding: 5px; }
@@ -230,6 +542,7 @@
#nobootstrap .cat_bar {
background-color: #F4E8CD;
border: 1px solid #999999;
font-family: Trebuchet,Arial,Helvetica,sans-serif;
font-size: 12px;
font-weight: 700;
margin-bottom: 20px;
@@ -344,6 +657,14 @@
#nobootstrap .toolbar-placeholder {
position: relative; }
#nobootstrap .toolbarBox {
background-color: #F8F8F8;
border: 1px solid #CCCCCC;
margin-bottom: 10px;
padding: 5px 0;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
position: relative; }
#nobootstrap .toolbarBox .pageTitle {
margin-left: 10px;
@@ -389,7 +710,8 @@
float: none;
height: 32px;
margin: 0 auto;
width: 32px; }
width: 32px;
/*hacking ie7margin:0 !ie; position:relative !ie;*/ }
#nobootstrap .toolbarBox .process-icon-delete {
background-image: url("../img/process-icon-delete.png"); }
#nobootstrap .toolbarBox .process-icon-duplicate {
@@ -892,7 +1214,8 @@
font-weight: bold; }
#nobootstrap #statsContainer .blocStats .blocConversion {
display: block;
display: inline-table; }
display: inline-table;
min-height: 80px; }
#nobootstrap #moduleContainer {
margin-left: 220px;
padding: 13px 0 0 20px; }
@@ -996,7 +1319,7 @@
margin: 0;
white-space: nowrap;
overflow: auto;
height: 335px; }
height: 370px; }
#nobootstrap #modules_list_container_tab #modules_list_container_content li {
display: inline-block; }
#nobootstrap #modules_list_container_tab table tr th {
@@ -1050,7 +1373,7 @@
font-size: 10px;
color: #fff;
text-transform: uppercase;
padding: 2px 10px;
padding: 0 10px;
display: inline-block;
border-radius: 3px; }
#nobootstrap #modules_list_container_tab .row-actions-module {
@@ -1093,11 +1416,11 @@
border: none; }
#nobootstrap .default_modules_list_display_type #modules_list_container_content li table {
border: solid 1px #ccc;
height: 140px;
height: 105px;
width: 100%;
margin-bottom: 15px; }
margin-bottom: 10px; }
#nobootstrap #modules_list_container_tab ul li {
height: 140px; }
height: 105px; }
#nobootstrap .ie7 #modules_list_container_tab #modules_list_container_content li {
zoom: 1;
display: inline; }
@@ -1165,6 +1488,20 @@
margin: 0 1em 0 0.25em; }
#nobootstrap ul.listForm li {
padding-bottom: 3px; }
#nobootstrap #footer {
height: 40px;
font-size: 12px;
clear: both;
font-size: 0.9em;
color: #666666; }
#nobootstrap #footer .footerLeft {
float: left;
margin-left: 10px; }
#nobootstrap #footer .footerRight {
float: right;
margin-right: 10px; }
#nobootstrap #footer .footer_link, #nobootstrap #footer .footer_link:hover {
color: #268CCD; }
#nobootstrap .pageTitleHome {
font-size: 1.6em;
font-weight: normal;
@@ -302,7 +302,7 @@
{assign var=is_child value=true}
{assign var=result_accesses value=0}
<tr class="child-{$child.id_parent}">
<td{if !$is_child} class="bold"{/if}>{if $is_child} &raquo; {/if}<strong>{$child.name}</strong></td>
<td{if !$is_child} class="bold"{/if}>{if $is_child} &raquo; {/if}{$child.name}</td>
{foreach $perms as $perm}
{if $access_edit == 1}
<td>
@@ -27,13 +27,7 @@
{block name="label"}
{if $input.name == 'vat_number'}
{if $vat == 'is_applicable'}
<div id="vat_area" style="display: visible">
{else if $vat == 'management'}
<div id="vat_area" style="display: hidden">
{else}
<div style="display: none;">
{/if}
<div id="vat_area" style="display: visible">
{/if}
{if $input.type == 'text_customer' && !isset($customer)}
@@ -33,7 +33,7 @@
<li><i class="icon-home"></i>
{assign var=params_url value=""}
{else}
<li>{assign var=params_url value="&id_category={$category.id_category}&viewcategory"}
{assign var=params_url value="&id_category={$category.id_category|intval}&viewcategory"}
{/if}
{if $category.id_category == $categories_tree_current_id}
{$category.name}</li>
@@ -75,10 +75,10 @@
{if $key != 'deleteMode'}
{if is_array($value)}
{foreach $value as $val}
<input type="hidden" name="{$key}[]" value="{$val}" />
<input type="hidden" name="{$key|escape:'htmlall':'UTF-8'}[]" value="{$val|escape:'htmlall':'UTF-8'}" />
{/foreach}
{else}
<input type="hidden" name="{$key}" value="{$value}" />
<input type="hidden" name="{$key|escape:'htmlall':'UTF-8'}" value="{$value|escape:'htmlall':'UTF-8'}" />
{/if}
{/if}
{/foreach}
@@ -35,7 +35,7 @@
{/block}
{block name=leadin}
{if isset($delete_customer) && $delete_customer}
<form action="{$REQUEST_URI}" method="post">
<form action="{$REQUEST_URI|escape:'htmlall':'UTF-8'}" method="post">
<div class="alert alert-block">
<h2>{l s='How do you want to delete these customer(s)?'}</h2>
<p>{l s='There are two ways of deleting a customer. Please choose your preferred method.'}</p>
@@ -52,10 +52,10 @@
{foreach $POST as $key => $value}
{if is_array($value)}
{foreach $value as $val}
<input type="hidden" name="{$key}[]" value="{$val}" />
<input type="hidden" name="{$key|escape:'htmlall':'UTF-8'}[]" value="{$val|escape:'htmlall':'UTF-8'}" />
{/foreach}
{else}
<input type="hidden" name="{$key}" value="{$value}" />
<input type="hidden" name="{$key|escape:'htmlall':'UTF-8'}" value="{$value|escape:'htmlall':'UTF-8'}" />
{/if}
{/foreach}
<br /><input type="submit" class="button" value="{l s='Delete'}" />
@@ -106,63 +106,61 @@
if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']')
{
exist = true;
jAlert('{l s='This category already exists for this group.'}');
jAlert('{l s='This category already exists for this group.' js=1}');
return false;
}
});
if (exist)
return;
$.ajax({
type:"POST",
url: "ajax-tab.php",
async: true,
dataType: "json",
data : {
ajax: "1",
token: "{getAdminToken tab='AdminGroups'}",
controller: "AdminGroups",
action: "addCategoryReduction",
category_reduction: $('#category_reduction_fancybox').val() ,
id_category: $('[name="id_category"]:checked').val()
},
success : function(jsonData)
type:"POST",
url: "ajax-tab.php",
async: true,
dataType: "json",
data : {
ajax: "1",
token: "{getAdminToken tab='AdminGroups'}",
controller: "AdminGroups",
action: "addCategoryReduction",
category_reduction: $('#category_reduction_fancybox').val() ,
id_category: $('[name="id_category"]:checked').val()
},
success : function(jsonData) {
if (jsonData.hasError)
{
if (jsonData.hasError)
{
var errors = '';
for(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
jAlert(errors);
}
else
{
$('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}'+jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
var input_hidden = document.createElement("input");
input_hidden.setAttribute('type', 'hidden');
input_hidden.setAttribute('value', jsonData.discount);
input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
input_hidden.setAttribute('class', 'category_reduction');
$('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
$.fancybox.close();
}
var errors = '';
for (error in jsonData.errors)
//IE6 bug fix
if (error != 'indexOf')
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
jAlert(errors);
}
});
else
{
$('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}'+jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
var input_hidden = document.createElement("input");
input_hidden.setAttribute('type', 'hidden');
input_hidden.setAttribute('value', jsonData.discount);
input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
input_hidden.setAttribute('class', 'category_reduction');
$('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
$.fancybox.close();
}
}
});
return false;
}
function initFancyBox()
{
$('[name="id_category"]:checked').removeAttr('checked');
collapseAllCategories();
$('#category_reduction_fancybox').val('0.00');
}
function initFancyBox()
{
$('[name="id_category"]:checked').removeAttr('checked');
collapseAllCategories();
$('#category_reduction_fancybox').val('0.00');
}
</script>
<div class="margin-form">
<a class="button" href="#group_discount_category_fancybox" id="group_discount_category">{l s='Add a category discount'}</a>
@@ -270,4 +268,4 @@
{else}
{$smarty.block.parent}
{/if}
{/block}
{/block}
@@ -50,14 +50,14 @@
console.log(truncateAuthorized);
if (truncateAuthorized)
{
if (!confirm('{l s='Are you sure that you would like to delete this' js=1}' + ' ' + $.trim($('#entity > option:selected').text().toLowerCase()) + '{l s='?' js=1}'))
if (!confirm('{l s='Are you sure that you would like to delete this' js=1}' + ' ' + $.trim($('#entity > option:selected').text().toLowerCase()) + '?'))
{
e.preventDefault();
}
}
else
{
jAlert('{l s='You do not have permission to delete here. When the multistore is enabled, only a SuperAdmin can delete all items before an import.'}');
jAlert('{l s='You do not have permission to delete here. When the multistore is enabled, only a SuperAdmin can delete all items before an import.' js=1}');
return false;
}
}
@@ -49,14 +49,14 @@
<form action="#" id="login_form" method="post">
<div class="field">
<label for="email">{l s='Email address:'}</label>
<input type="text" id="email" name="email" class="input email_field" value="{if isset($email)}{$email|escape:'htmlall':'UTF-8'}{/if}" />
<input type="text" id="email" name="email" class="input email_field" tabindex="1" value="{if isset($email)}{$email|escape:'htmlall':'UTF-8'}{/if}" />
</div>
<div class="field">
<label for="passwd">{l s='Password:'}</label>
<input id="passwd" type="password" name="passwd" class="input password_field" value="{if isset($password)}{$password}{/if}"/>
<input id="passwd" type="password" name="passwd" class="input password_field" tabindex="2" value="{if isset($password)}{$password}{/if}"/>
</div>
<div class="field">
<input type="submit" name="submitLogin" value="{l s='Log in'}" class="button fl margin-right-5" />
<input type="submit" name="submitLogin" value="{l s='Log in'}" tabindex="3" class="button fl margin-right-5" />
<p class="fl no-margin hide ajax-loader">
<img src="../img/loader.gif" alt="" />
</p>
@@ -92,8 +92,11 @@
{/if}
</dl>
</div>
{if isset($module->message)}<div class="alert">{$module->message}</div>{/if}
<p class="desc">{if isset($module->description) && $module->description ne ''}{l s='Description'} : {$module->description}{else}&nbsp;{/if}</p>
{if isset($module->message) && (!isset($module->type) || ($module->type != 'addonsMustHave' || $module->type !== 'addonsNative'))}<div class="alert">{$module->message}</div>{/if}
<div class="row-fluid">
{if !isset($module->not_on_disk)}
{$module->optionsHtml}
{if isset($module->preferences) && isset($module->preferences['favorite']) && $module->preferences['favorite'] == 1}
@@ -36,7 +36,6 @@
</ul>
</div>
{/if}
<div class="row">
<div class="col-lg-12">
<span class="pull-right">
@@ -50,7 +49,6 @@
</a>
</span>
</div>
<div id="container">
<!--start sidebar module-->
<div class="row-fluid">
@@ -83,4 +81,4 @@
</div>
</div>
</div>
</div>
</div>
@@ -77,9 +77,9 @@
{/if}
{if get_class($document) eq 'OrderInvoice'}
{if isset($document->is_delivery)}
#{Configuration::get('PS_DELIVERY_PREFIX', $current_id_lang)}{'%06d'|sprintf:$document->delivery_number}
#{Configuration::get('PS_DELIVERY_PREFIX', $current_id_lang, null, $order->id_shop)}{'%06d'|sprintf:$document->delivery_number}
{else}
{$document->getInvoiceNumberFormatted($current_id_lang)}
{$document->getInvoiceNumberFormatted($current_id_lang, $order->id_shop)}
{/if}
{elseif get_class($document) eq 'OrderSlip'}
#{Configuration::get('PS_CREDIT_SLIP_PREFIX', $current_id_lang)}{'%06d'|sprintf:$document->id}
@@ -123,7 +123,7 @@
{if !isset($document->is_delivery)}
<tr id="invoiceNote{$document->id}" style="display:none">
<td colspan="5">
<form action="{$current_index}&viewOrder&id_order={$order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}" method="post">
<form action="{$current_index}&viewOrder&id_order={$order->id}{if isset($smarty.get.token)}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}{/if}" method="post">
<p>
<label for="editNote{$document->id}" class="t">{l s='Note'}</label>
<input type="hidden" name="id_order_invoice" value="{$document->id}" />
@@ -149,7 +149,7 @@
<td colspan="5" class="center">
<h4>{l s='No documents are available'}</h4>
{if isset($invoice_management_active) && $invoice_management_active}
<a class="btn btn-default" href="{$current_index}&viewOrder&submitGenerateInvoice&id_order={$order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">
<a class="button" href="{$current_index}&viewOrder&submitGenerateInvoice&id_order={$order->id}{if isset($smarty.get.token)}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}{/if}">{l s='Generate invoice'}</a>
<i class="icon-repeat"></i>
{l s='Generate invoice'}
</a>
@@ -158,4 +158,4 @@
</tr>
{/foreach}
</tbody>
</table>
</table>
@@ -22,14 +22,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" id="shipping_table">
<colgroup>
<col width="15%">
<col width="15%">
<col width="">
<col width="20%">
<col width="1%">
</colgroup>
<table class="table" id="shipping_table">
<thead>
<tr>
<th>
@@ -58,7 +51,7 @@
<td>{dateFormat date=$line.date_add full=true}</td>
<td>{$line.type}</td>
<td>{$line.carrier_name}</td>
<td>{$line.weight|string_format:"%.3f"} {Configuration::get('PS_WEIGHT_UNIT')}</td>
<td class="weight">{$line.weight|string_format:"%.3f"} {Configuration::get('PS_WEIGHT_UNIT')}</td>
<td class="center">
{if $order->getTaxCalculationMethod() == $smarty.const.PS_TAX_INC}
{displayPrice price=$line.shipping_cost_tax_incl currency=$currency->id}
@@ -90,4 +83,4 @@
</tr>
{/foreach}
</tbody>
</table>
</table>
@@ -33,8 +33,8 @@
var currencies = new Array();
var id_currency = '';
var id_lang = '';
var txt_show_carts = '{l s='Show carts and orders for this customer.' js='1'}';
var txt_hide_carts = '{l s='Hide carts and orders for this customer.' js='1'}';
var txt_show_carts = '{l s='Show carts and orders for this customer.' js=1}';
var txt_hide_carts = '{l s='Hide carts and orders for this customer.' js=1}';
var defaults_order_state = new Array();
var customization_errors = false;
var pic_dir = '{$pic_dir}';
@@ -100,7 +100,7 @@
$('#show_old_carts').click();
$('#payment_module_name').change();
$.ajaxSetup({ type:"post" });
$("#voucher").autocomplete('{$link->getAdminLink('AdminCartRules')|escape:'html'}', {
$("#voucher").autocomplete('{$link->getAdminLink('AdminCartRules')|addslashes}', {
minChars: 3,
max: 15,
width: 250,
@@ -468,7 +468,7 @@
$('#new_address').attr('href', address_link.replace(/id_customer=[0-9]+/, 'id_customer='+id_customer));
$.ajax({
type:"POST",
url : "{$link->getAdminLink('AdminCarts')|escape:'html'}",
url : "{$link->getAdminLink('AdminCarts')|addslashes}",
async: false,
dataType: "json",
data : {
@@ -27,7 +27,7 @@
{block name="override_tpl"}
<script type="text/javascript">
var admin_order_tab_link = "{$link->getAdminLink('AdminOrders')|escape:'html'}";
var admin_order_tab_link = "{$link->getAdminLink('AdminOrders')|addslashes}";
var id_order = {$order->id};
var id_lang = {$current_id_lang};
var id_currency = {$order->id_currency};
@@ -134,11 +134,9 @@
</label>
<div class="col-lg-10">
<select id="id_order_state" name="id_order_state">
{foreach from=$states item=state}
{if $state['id_order_state'] != $currentState->id}
<option value="{$state['id_order_state']}">{$state['name']|stripslashes}</option>
{/if}
{/foreach}
{foreach from=$states item=state}
<option value="{$state['id_order_state']}"{if $state['id_order_state'] == $currentState->id} selected="selected" disabled="disabled"{/if}>{$state['name']|stripslashes}</option>
{/foreach}
</select>
</div>
<input type="hidden" name="id_order" value="{$order->id}" />
@@ -561,7 +559,7 @@
<td>{displayPrice price=$payment->amount currency=$payment->id_currency}</td>
<td>
{if $invoice = $payment->getOrderInvoice($order->id)}
{$invoice->getInvoiceNumberFormatted($current_id_lang)}
{$invoice->getInvoiceNumberFormatted($current_id_lang, $order->id_shop)}
{else}
{l s='No invoice'}
{/if}
@@ -644,7 +642,7 @@
<td>
<select name="payment_invoice" id="payment_invoice">
{foreach from=$invoices_collection item=invoice}
<option value="{$invoice->id}" selected="selected">{$invoice->getInvoiceNumberFormatted($current_id_lang)}</option>
<option value="{$invoice->id}" selected="selected">{$invoice->getInvoiceNumberFormatted($current_id_lang, $order->id_shop)}</option>
{/foreach}
</select>
</td>
@@ -25,13 +25,12 @@
{extends file="helpers/view/view.tpl"}
{block name="override_tpl"}
{if !$shop_context}
<div class="alert alert-block">{l s='You have more than one shop and must select one to configure payment.'}</div>
{else}
{if !$shop_context}
<div class="alert alert-block">{l s='You have more than one shop and must select one to configure payment.'}</div>
{else}
{if isset($modules_list)}
{$modules_list}
{/if}
{if $display_restrictions}
<legend>{l s='Payment module restrictions'}</legend>
{foreach $lists as $list}
@@ -40,5 +39,5 @@
{else}
<div class="alert alert-block">{l s='No payment module installed'}</div>
{/if}
{/if}
{/block}
{/if}
{/block}
@@ -34,10 +34,10 @@
{if $module->active}
<th class="center">
{if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'}
<input type="hidden" id="checkedBox_{$list['name_id']}_{$module->name}" value="checked">
<input type="hidden" id="checkedBox_{$list['name_id']}_{$module->name}" value="checked"/>
<a href="javascript:checkPaymentBoxes('{$list['name_id']}', '{$module->name}')" style="text-decoration:none;">
{/if}
&nbsp;<img src="{$ps_base_uri}modules/{$module->name}/logo.gif" alt="{$module->name}" title="{$module->displayName}" />
&nbsp;<img src="{$ps_base_uri}modules/{$module->name}/logo.gif" alt="{$module->name}" title="{$module->displayName}"/>
{if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'}
</a>
{/if}
@@ -66,11 +66,9 @@
{$type = 'checkbox'}
{/if}
{if $type != 'null'}
<input type="checkbox" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}"
{if $item['check_list'][$key_module] == 'checked'}checked="checked"{/if}
/>
<input type="{$type}" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}" {if $item['check_list'][$key_module] == 'checked'}checked="checked"{/if}/>
{else}
--
<input type="hidden" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}"/>--
{/if}
</td>
{/if}
@@ -122,4 +120,4 @@
</button>
</p>
</fieldset>
</form>
</form>
@@ -78,7 +78,7 @@
<tr id="image_id">
<td style="padding: 4px;">
<a href="{$smarty.const._THEME_PROD_DIR_}image_path.jpg" class="fancybox">
<img src="{$smarty.const._THEME_PROD_DIR_}en-default-small_default.jpg" alt="image_id" title="image_id" />
<img src="{$smarty.const._THEME_PROD_DIR_}{$iso_lang}-default-small_default.jpg" alt="image_id" title="image_id" />
</a>
</td>
<td id="td_image_id" class="pointer dragHandle center positionImage">
@@ -291,41 +291,28 @@
{
doAdminAjax(
{
"action":"updateImagePosition",
"json":json,
"token" : "{/literal}{$token}{literal}",
"tab" : "AdminProducts",
"ajax" : 1
});
}
function delQueue(id)
{
$("#img" + id).fadeOut("slow");
$("#img" + id).remove();
}
function imageLine(id, path, position, cover, shops)
{
line = $("#lineType").html();
line = line.replace(/image_id/g, id);
line = line.replace(/en-default/g, path);
line = line.replace(/image_path/g, path);
line = line.replace(/image_position/g, position);
line = line.replace(/icon-check-empty/g, cover);
line = line.replace(/<tbody>/gi, "");
line = line.replace(/<\/tbody>/gi, "");
if (shops != false)
{
$.each(shops, function(key, value){
if (value == 1)
line = line.replace('id="' + key + '' + id + '"','id="' + key + '' + id + '" checked=checked');
});
line = $("#lineType").html();
line = line.replace(/image_id/g, id);
line = line.replace(/[a-z]{2}-default/g, path);
line = line.replace(/image_path/g, path);
line = line.replace(/image_position/g, position);
line = line.replace(/blank/g, cover);
line = line.replace(/<tbody>/gi, "");
line = line.replace(/<\/tbody>/gi, "");
if (shops != false)
{
$.each(shops, function(key, value){
if (value == 1)
line = line.replace('id="' + key + '' + id + '"','id="' + key + '' + id + '" checked=checked');
});
}
$("#imageList").append(line);
}
$("#imageList").append(line);
}
$('.fancybox').fancybox();
});
{/literal}
</script>
$('.fancybox').fancybox();
});
{/literal}
</script>
{/if}
@@ -43,7 +43,7 @@
$('document').ready( function() {
$(".check_product_name")
.autocomplete(
'{$link->getAdminLink('AdminProducts', true)|escape:'html'}', {
'{$link->getAdminLink('AdminProducts', true)|addslashes}', {
minChars: 3,
max: 10,
width: $(".check_product_name").width(),
@@ -90,7 +90,7 @@
var table = $('#selectTables select').val();
if (!table)
jAlert("{l s='Please choose a table.'}");
jAlert("{l s='Please choose a table.' js=1}");
else
AddRequestSql(table);
});
@@ -24,9 +24,9 @@
*}
<a href="{$href}" class="delete"
{if in_array($id_shop, $shops_having_dependencies)}
onclick="jAlert('{l s='You cannot delete this shop\'s (customer and/or order dependency)'}'); return false;"
onclick="jAlert('{l s='You cannot delete this shop\'s (customer and/or order dependency)' js=1}'); return false;"
{elseif isset($confirm)}
onclick="if (confirm('{$confirm}')){ return true; }else{ event.stopPropagation(); event.preventDefault();};"
onclick="if (confirm('{$confirm}')){ return true; } else { event.stopPropagation(); event.preventDefault();};"
{/if} title="{$action}">
<img src="../img/admin/delete.gif" alt="{$action}" />
</a>
@@ -138,7 +138,7 @@
// check if it's possible to add the product
if (product_infos == null || $('#cur_product_name').val() == '')
{
jAlert('{l s='Please select at least one product.'}');
jAlert('{l s='Please select at least one product.' js=1}');
return false;
}
+5 -3
View File
@@ -75,6 +75,8 @@
var token_admin_customer_threads = '{getAdminToken tab='AdminCustomerThreads' slashes=1}';
var currentIndex = '{$currentIndex}';
var default_language = '{$default_language|intval}';
var choose_language_translate = "{l s='Choose language' slashes=1}";
</script>
{/if}
@@ -201,7 +203,7 @@
</button>
</span>
</div>
<!-- // Search in section
<!-- //todo Search in section
<select name="bo_search_type" id="bo_search_type" class="chosen no-search">
<option value="0">{l s='everywhere'}</option>
<option value="1" {if {$search_type} == 1} selected="selected" {/if}>{l s='catalog'}</option>
@@ -251,7 +253,7 @@
<i class="icon-AdminDashboard"></i> {l s='Dashboard'}
</a>
</li>
{foreach $tabs AS $t}
{foreach $tabs as $t}
{if $t.active}
<li class="maintab {if $t.current}active{/if}" id="maintab{$t.id_tab}">
<a href="javascript:adminNav('#maintab{$t.id_tab}');" class="title">
@@ -289,4 +291,4 @@
<div class="multishop_toolbar">
<span class="text_multishop">{l s='Multistore configuration for'}</span> {$shop_list}
</div>
{/if}
{/if}
@@ -295,13 +295,20 @@
{/foreach}
{elseif $input.type == 'file'}
{if isset($input.display_image) && $input.display_image}
{if isset($fields_value.image) && $fields_value.image}
{if isset($fields_value[$input.name].image) && $fields_value[$input.name].image}
<div id="image">
<<<<<<< HEAD
{$fields_value.image}
<p align="center">{l s='File size'} {$fields_value.size}kb</p>
<a class="btn btn-default" href="{$current}&{$identifier}={$form_id}&token={$token}&deleteImage=1">
<i class="icon-trash"></i> {l s='Delete'}
=======
{$fields_value[$input.name].image}
<p align="center">{l s='File size'} {$fields_value[$input.name].size}kb</p>
<a href="{$current}&{$identifier}={$form_id}&token={$token}&deleteImage=1">
<img src="../img/admin/delete.gif" alt="{l s='Delete'}" /> {l s='Delete'}
>>>>>>> 6ac3f1133ae7547ff92964c47ec141c3ab5bf5c4
</a>
</div><br />
@@ -405,13 +412,13 @@
{/if}
</div>
{/foreach}
{hook h='displayAdminForm'}
{hook h='displayAdminForm' fieldset=$f}
{if isset($name_controller)}
{capture name=hookName assign=hookName}display{$name_controller|ucfirst}Form{/capture}
{hook h=$hookName}
{hook h=$hookName fieldset=$f}
{elseif isset($smarty.get.controller)}
{capture name=hookName assign=hookName}display{$smarty.get.controller|ucfirst|htmlentities}Form{/capture}
{hook h=$hookName}
{hook h=$hookName fieldset=$f}
{/if}
{elseif $key == 'submit'}
<div class="margin-form">
@@ -29,9 +29,18 @@
{if count($modules_list)}
<table border="0" cellpadding="0" cellspacing="5" class="table table-striped table-hover">
{counter start=1 assign="count"}
<<<<<<< HEAD
{foreach from=$modules_list item=module}
{include file='controllers/modules/tab_module_line.tpl' class_row={cycle values=",row alt"}}
{if $count %2 == 0}{/if}
=======
{foreach from=$modules_list item=module}
<div style="width:400px">{include file='controllers/modules/tab_module_line.tpl' class_row={cycle values=",row alt"}}</div>
{if $count %3 == 0}
</li>
<li>
{/if}
>>>>>>> 6ac3f1133ae7547ff92964c47ec141c3ab5bf5c4
{counter}
{/foreach}
</table>
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=attachment'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=attachment'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=authentication'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=authentication'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=best-sales'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=best-sales'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=category'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=category'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=change-currency'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=change-currency'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+6 -2
View File
@@ -137,9 +137,13 @@ class Autoload
else
{
$filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE) {
if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE)
{
rename($filename_tmp, $filename);
} else {
@chmod($filename, 0664);
}
else
{
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated),
// no need to die.
error_log('Cannot write temporary file '.$filename_tmp);
+1 -1
View File
@@ -53,7 +53,7 @@ class CMSCore extends ObjectModel
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
'content' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString', 'size' => 3999999999999),
'content' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 3999999999999),
),
);
+3 -4
View File
@@ -567,8 +567,8 @@ class CarrierCore extends ObjectModel
}
$row['name'] = (strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME'));
$row['price'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier'], true, null, null, $id_zone));
$row['price_tax_exc'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier'], false, null, null, $id_zone));
$row['price'] = (($shipping_method == Carrier::SHIPPING_METHOD_FREE) ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier'], true, null, null, $id_zone));
$row['price_tax_exc'] = (($shipping_method == Carrier::SHIPPING_METHOD_FREE) ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier'], false, null, null, $id_zone));
$row['img'] = file_exists(_PS_SHIP_IMG_DIR_.(int)$row['id_carrier']).'.jpg' ? _THEME_SHIP_DIR_.(int)$row['id_carrier'].'.jpg' : '';
// If price is false, then the carrier is unavailable (carrier module)
@@ -852,8 +852,7 @@ class CarrierCore extends ObjectModel
(SELECT '.(int)$this->id.', `id_tax_rules_group`, `id_shop`
FROM `'._DB_PREFIX_.'carrier_tax_rules_group_shop`
WHERE `id_carrier`='.(int)$old_id.')');
// Update warehouse_carriers
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'warehouse_carrier SET id_carrier='.(int)$this->id.' WHERE id_carrier='.(int)$old_id);
}
/**
+63 -79
View File
@@ -424,9 +424,10 @@ class CartCore extends ObjectModel
// Build SELECT
$sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`,
pl.`description_short`, pl.`available_now`, pl.`available_later`, p.`id_product`, product_shop.`id_category_default`, p.`id_supplier`,
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`, product_shop.`available_for_order`, product_shop.`price`, p.`weight`,
stock.`quantity` quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, product_shop.`active`, p.`date_add`,
p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`,
product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
stock.`quantity` AS quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`weight`,
p.`date_add`, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
CONCAT(cp.`id_product`, IFNULL(cp.`id_product_attribute`, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
product_shop.`wholesale_price`, product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference');
@@ -2542,6 +2543,7 @@ class CartCore extends ObjectModel
if (empty($id_carrier) && $this->isCarrierInRange((int)Configuration::get('PS_CARRIER_DEFAULT'), (int)$id_zone))
$id_carrier = (int)Configuration::get('PS_CARRIER_DEFAULT');
$total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
if (empty($id_carrier))
{
if ((int)$this->id_customer)
@@ -2576,7 +2578,7 @@ class CartCore extends ObjectModel
{
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int)$id_zone);
$total_order = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
$total_order = $total_package_without_shipping_tax_inc;
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int)$id_zone, (int)$this->id_currency);
// Get only carriers that have a range compatible with cart
@@ -2679,26 +2681,8 @@ class CartCore extends ObjectModel
$id_zone = (int)$default_country->id_zone;
}
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int)$carrier->id, $this->getTotalWeight(), (int)$id_zone);
// Code Review V&V TO FINISH
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice(
$carrier->id,
$this->getOrderTotal(
true,
Cart::BOTH_WITHOUT_SHIPPING,
$product_list
),
$id_zone,
(int)$this->id_currency
);
if ((
$carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT
&& !$check_delivery_price_by_weight
) || (
$carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE
&& !$check_delivery_price_by_price
if (($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int)$id_zone))
|| ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $id_zone, (int)$this->id_currency)
))
$shipping_cost += 0;
else
@@ -2845,7 +2829,10 @@ class CartCore extends ObjectModel
$formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
$formatted_addresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice);
$total_tax = $this->getOrderTotal() - $this->getOrderTotal(false);
$base_total_tax_inc = $this->getOrderTotal(true);
$base_total_tax_exc = $this->getOrderTotal(false);
$total_tax = $base_total_tax_inc - $base_total_tax_exc;
if ($total_tax < 0)
$total_tax = 0;
@@ -2943,9 +2930,9 @@ class CartCore extends ObjectModel
'total_shipping_tax_exc' => $total_shipping_tax_exc,
'total_products_wt' => $total_products_wt,
'total_products' => $total_products,
'total_price' => $this->getOrderTotal(),
'total_price' => $base_total_tax_inc,
'total_tax' => $total_tax,
'total_price_without_tax' => $this->getOrderTotal(false),
'total_price_without_tax' => $base_total_tax_exc,
'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int)Tools::getValue('multi-shipping') == 1),
'free_ship' => $total_shipping ? 0 : 1,
'carrier' => new Carrier($this->id_carrier, $id_lang),
@@ -3423,62 +3410,59 @@ class CartCore extends ObjectModel
*/
public function setNoMultishipping()
{
// Upgrading quantities
$sql = 'SELECT sum(`quantity`) as quantity, id_product, id_product_attribute, count(*) as count
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
GROUP BY id_product, id_product_attribute
HAVING count > 1';
foreach (Db::getInstance()->executeS($sql) as $product)
if (Configuration::get('PS_ALLOW_MULTISHIPPING'))
{
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
SET `quantity` = '.$product['quantity'].'
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
AND id_product = '.$product['id_product'].'
AND id_product_attribute = '.$product['id_product_attribute'];
Db::getInstance()->execute($sql);
// Upgrading quantities
$sql = 'SELECT sum(`quantity`) as quantity, id_product, id_product_attribute, count(*) as count
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
GROUP BY id_product, id_product_attribute
HAVING count > 1';
foreach (Db::getInstance()->executeS($sql) as $product)
{
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
SET `quantity` = '.$product['quantity'].'
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
AND id_product = '.$product['id_product'].'
AND id_product_attribute = '.$product['id_product_attribute'];
Db::getInstance()->execute($sql);
}
// Merging multiple lines
$sql = 'DELETE cp1
FROM `'._DB_PREFIX_.'cart_product` cp1
INNER JOIN `'._DB_PREFIX_.'cart_product` cp2
ON (
(cp1.id_cart = cp2.id_cart)
AND (cp1.id_product = cp2.id_product)
AND (cp1.id_product_attribute = cp2.id_product_attribute)
AND (cp1.id_address_delivery <> cp2.id_address_delivery)
AND (cp1.date_add > cp2.date_add)
)';
Db::getInstance()->execute($sql);
}
// Merging multiple lines
$sql = 'DELETE cp1
FROM `'._DB_PREFIX_.'cart_product` cp1
INNER JOIN `'._DB_PREFIX_.'cart_product` cp2
ON (
(cp1.id_cart = cp2.id_cart)
AND (cp1.id_product = cp2.id_product)
AND (cp1.id_product_attribute = cp2.id_product_attribute)
AND (cp1.id_address_delivery <> cp2.id_address_delivery)
AND (cp1.date_add > cp2.date_add)
)';
Db::getInstance()->execute($sql);
// Upgrading address delivery
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
SET `id_address_delivery` =
(
SELECT `id_address_delivery`
FROM `'._DB_PREFIX_.'cart`
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
)
WHERE `id_cart` = '.(int)$this->id.'
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '');
Db::getInstance()->execute($sql);
$sql = 'UPDATE `'._DB_PREFIX_.'customization`
SET `id_address_delivery` =
(
SELECT `id_address_delivery`
FROM `'._DB_PREFIX_.'cart`
// Update delivery address for each product line
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'cart_product`
SET `id_address_delivery` = (
SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart`
WHERE `id_cart` = '.(int)$this->id.' AND `id_shop` = '.(int)$this->id_shop.'
)
WHERE `id_cart` = '.(int)$this->id.'
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : ''));
if (Customization::isFeatureActive())
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'customization`
SET `id_address_delivery` = (
SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart`
WHERE `id_cart` = '.(int)$this->id.'
)
WHERE `id_cart` = '.(int)$this->id;
Db::getInstance()->execute($sql);
WHERE `id_cart` = '.(int)$this->id);
}
/**
+14 -13
View File
@@ -1104,29 +1104,30 @@ class CartRuleCore extends ObjectModel
'.($context->customer->id ? 'OR cr.id_customer = '.(int)$context->cart->id_customer : '').'
)
AND (
cr.carrier_restriction = 0
cr.`carrier_restriction` = 0
'.($context->cart->id_carrier ? 'OR c.id_carrier = '.(int)$context->cart->id_carrier : '').'
)
AND (
cr.shop_restriction = 0
cr.`shop_restriction` = 0
'.((Shop::isFeatureActive() && $context->shop->id) ? 'OR crs.id_shop = '.(int)$context->shop->id : '').'
)
AND (
cr.group_restriction = 0
cr.`group_restriction` = 0
'.($context->customer->id ? 'OR 0 < (
SELECT cg.id_group
FROM '._DB_PREFIX_.'customer_group cg
LEFT JOIN '._DB_PREFIX_.'cart_rule_group crg ON (cg.id_group = crg.id_group AND cg.id_group = '.(int)$context->customer->id_default_group.')
WHERE cr.id_cart_rule = crg.id_cart_rule
AND cg.id_customer = '.(int)$context->customer->id.' LIMIT 1
SELECT cg.`id_group`
FROM `'._DB_PREFIX_.'customer_group` cg
INNER JOIN `'._DB_PREFIX_.'cart_rule_group` crg ON cg.id_group = crg.id_group
WHERE cr.`id_cart_rule` = crg.`id_cart_rule`
AND cg.`id_customer` = '.(int)$context->customer->id.'
LIMIT 1
)' : '').'
)
AND (
cr.reduction_product <= 0
OR cr.reduction_product IN (
SELECT id_product
FROM '._DB_PREFIX_.'cart_product
WHERE id_cart = '.(int)$context->cart->id.'
cr.`reduction_product` <= 0
OR cr.`reduction_product` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_cart` = '.(int)$context->cart->id.'
)
)
AND cr.id_cart_rule NOT IN (SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$context->cart->id.')
+12 -18
View File
@@ -109,7 +109,7 @@ class CategoryCore extends ObjectModel
// Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
@@ -796,7 +796,7 @@ class CategoryCore extends ObjectModel
)).')';
$flag = Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'category_product` (`id_product`, `id_category`, `position`)
INSERT IGNORE INTO `'._DB_PREFIX_.'category_product` (`id_product`, `id_category`, `position`)
VALUES '.implode(',', $row)
);
return $flag;
@@ -831,20 +831,15 @@ class CategoryCore extends ObjectModel
if (!Validate::isUnsignedId($id_category) || !Validate::isUnsignedId($id_lang))
return false;
if (isset(self::$_links[$id_category.'-'.$id_lang]))
return self::$_links[$id_category.'-'.$id_lang];
$result = Db::getInstance()->getRow('
SELECT cl.`link_rewrite`
FROM `'._DB_PREFIX_.'category_lang` cl
WHERE `id_lang` = '.(int)$id_lang.'
'.Shop::addSqlRestrictionOnLang('cl').'
AND cl.`id_category` = '.(int)$id_category
);
self::$_links[$id_category.'-'.$id_lang] = $result['link_rewrite'];
return $result['link_rewrite'];
if (!isset(self::$_links[$id_category.'-'.$id_lang]))
self::$_links[$id_category.'-'.$id_lang] = Db::getInstance()->getValue('
SELECT cl.`link_rewrite`
FROM `'._DB_PREFIX_.'category_lang` cl
WHERE `id_lang` = '.(int)$id_lang.'
'.Shop::addSqlRestrictionOnLang('cl').'
AND cl.`id_category` = '.(int)$id_category
);
return self::$_links[$id_category.'-'.$id_lang];
}
public function getLink(Link $link = null)
@@ -1395,8 +1390,7 @@ class CategoryCore extends ObjectModel
SELECT DISTINCT c.*
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.')
WHERE `level_depth` = 1
');
WHERE `level_depth` = 1');
}
public function isRootCategoryForAShop()
+8 -1
View File
@@ -102,7 +102,14 @@ class CombinationCore extends ObjectModel
// Removes the product from StockAvailable, for the current shop
StockAvailable::removeProductFromStockAvailable((int)$this->id_product, (int)$this->id);
if ($specific_prices = SpecificPrice::getByProductId((int)$this->id_product, (int)$this->id))
foreach ($specific_prices as $specific_price)
{
$price = new SpecificPrice((int)$specific_price['id_specific_price']);
$price->delete();
}
if (!$this->hasMultishopEntries() && !$this->deleteAssociations())
return false;
return true;
+2 -2
View File
@@ -505,9 +505,9 @@ class ConfigurationCore extends ObjectModel
if ($id_shop)
return ' AND id_shop = '.(int)$id_shop;
elseif ($id_shop_group)
return ' AND id_shop_group = '.(int)$id_shop_group.' AND id_shop IS NULL';
return ' AND id_shop_group = '.(int)$id_shop_group.' AND (id_shop IS NULL OR id_shop = 0)';
else
return ' AND id_shop_group IS NULL AND id_shop IS NULL';
return ' AND (id_shop_group IS NULL OR id_shop_group = 0) AND (id_shop IS NULL OR id_shop = 0)';
}
/**
+4
View File
@@ -82,8 +82,12 @@ class ConnectionCore extends ObjectModel
// The connection is created if it does not exist yet and we get the current page id
if (!isset($cookie->id_connections) || !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false)))
$id_page = Connection::setNewConnection($cookie);
// If we do not track the pages, no need to get the page id
if (!Configuration::get('PS_STATSDATA_PAGESVIEWS') && !Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
return array();
if (!isset($id_page) || !$id_page)
$id_page = Page::getCurrentId();
// If we do not track the page views by customer, the id_page is the only information needed
if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
return array('id_page' => $id_page);
+22 -13
View File
@@ -121,20 +121,23 @@ class CountryCore extends ObjectModel
public static function getCountries($id_lang, $active = false, $contain_states = false, $list_states = true)
{
$countries = array();
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT cl.*,c.*, cl.`name` country, z.`name` zone
FROM `'._DB_PREFIX_.'country` c '.Shop::addSqlAssociation('country', 'c').'
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = c.`id_zone`)
WHERE 1'.($active ? ' AND c.active = 1' : '').($contain_states ? ' AND c.`contains_states` = '.(int)$contain_states : '').'
ORDER BY cl.name ASC') as $country)
$countries[$country['id_country']] = $country;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT cl.*,c.*, cl.`name` country, z.`name` zone
FROM `'._DB_PREFIX_.'country` c '.Shop::addSqlAssociation('country', 'c').'
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = c.`id_zone`)
WHERE 1'.($active ? ' AND c.active = 1' : '').($contain_states ? ' AND c.`contains_states` = '.(int)$contain_states : '').'
ORDER BY cl.name ASC');
foreach ($result as $row)
$countries[$row['id_country']] = $row;
if ($list_states)
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'state` ORDER BY `name` ASC') as $state)
if (isset($countries[$state['id_country']])) /* Does not keep the state if its country has been disabled and not selected */
if ($state['active'] == 1)
$countries[$state['id_country']]['states'][] = $state;
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'state` ORDER BY `name` ASC');
foreach ($result as $row)
if (isset($countries[$row['id_country']]) && $row['active'] == 1) /* Does not keep the state if its country has been disabled and not selected */
$countries[$row['id_country']]['states'][] = $row;
}
return $countries;
}
@@ -370,4 +373,10 @@ class CountryCore extends ObjectModel
else
return true;
}
}
public function add($autodate = true, $null_values = false)
{
$return = parent::add($autodate, $null_values) && self::addModuleRestrictions(array(), array(array('id_country' => $this->id)), array());
return $return;
}
}
+8 -8
View File
@@ -43,7 +43,7 @@ class CurrencyCore extends ObjectModel
/** @var int bool used for displaying blank between sign and price */
public $blank;
/** @var string Conversion rate from euros */
/** @var string exchange rate from euros */
public $conversion_rate;
/** @var boolean True if currency has been deleted (staying in database as deleted) */
@@ -326,23 +326,23 @@ class CurrencyCore extends ObjectModel
}
/**
* Refresh the currency conversion rate
* The XML file define conversion rate for each from a default currency ($isoCodeSource).
* Refresh the currency exchange rate
* The XML file define exchange rate for each from a default currency ($isoCodeSource).
*
* @param $data XML content which contains all the conversion rates
* @param $data XML content which contains all the exchange rates
* @param $isoCodeSource The default currency used in the XML file
* @param $defaultCurrency The default currency object
*/
public function refreshCurrency($data, $isoCodeSource, $defaultCurrency)
{
// fetch the conversion rate of the default currency
$conversion_rate = 1;
// fetch the exchange rate of the default currency
$exchange_rate = 1;
if ($defaultCurrency->iso_code != $isoCodeSource)
{
foreach ($data->currency as $currency)
if ($currency['iso_code'] == $defaultCurrency->iso_code)
{
$conversion_rate = round((float)$currency['rate'], 6);
$exchange_rate = round((float)$currency['rate'], 6);
break;
}
}
@@ -364,7 +364,7 @@ class CurrencyCore extends ObjectModel
}
if (isset($rate))
$this->conversion_rate = round($rate / $conversion_rate, 6);
$this->conversion_rate = round($rate / $exchange_rate, 6);
}
$this->update();
}
+54 -31
View File
@@ -379,12 +379,12 @@ class DispatcherCore
/**
* Load default routes group by languages
*/
protected function loadRoutes()
protected function loadRoutes($id_shop = null)
{
$context = Context::getContext();
// Load custom routes from modules
$modules_routes = Hook::exec('moduleRoutes', array(), null, true, false);
$modules_routes = Hook::exec('moduleRoutes', array('id_shop' => $id_shop), null, true, false);
if (is_array($modules_routes) && count($modules_routes))
foreach($modules_routes as $module_route)
foreach($module_route as $route => $route_details)
@@ -405,7 +405,8 @@ class DispatcherCore
$route['controller'],
$lang['id_lang'],
$route['keywords'],
isset($route['params']) ? $route['params'] : array()
isset($route['params']) ? $route['params'] : array(),
$id_shop
);
// Load the custom routes prior the defaults to avoid infinite loops
@@ -420,13 +421,13 @@ class DispatcherCore
// Load routes from meta table
$sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang
FROM `'._DB_PREFIX_.'meta` m
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml').')
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml', $id_shop).')
ORDER BY LENGTH(ml.url_rewrite) DESC';
if ($results = Db::getInstance()->executeS($sql))
foreach ($results as $row)
{
if ($row['url_rewrite'])
$this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang']);
$this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang'], array(), array(), $id_shop);
}
// Set default empty route if no empty route (that's weird I know)
@@ -439,7 +440,7 @@ class DispatcherCore
// Load custom routes
foreach ($this->default_routes as $route_id => $route_data)
if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id))
if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id, null, null, $id_shop))
foreach (Language::getLanguages() as $lang)
$this->addRoute(
$route_id,
@@ -447,7 +448,8 @@ class DispatcherCore
$route_data['controller'],
$lang['id_lang'],
$route_data['keywords'],
isset($route_data['params']) ? $route_data['params'] : array()
isset($route_data['params']) ? $route_data['params'] : array(),
$id_shop
);
}
}
@@ -458,11 +460,15 @@ class DispatcherCore
* @param string $rule Url rule
* @param string $controller Controller to call if request uri match the rule
* @param int $id_lang
* @param int $id_shop
*/
public function addRoute($route_id, $rule, $controller, $id_lang = null, array $keywords = array(), array $params = array())
public function addRoute($route_id, $rule, $controller, $id_lang = null, array $keywords = array(), array $params = array(), $id_shop = null)
{
if (is_null($id_lang))
$id_lang = Context::getContext()->language->id;
if ($id_lang === null)
$id_lang = (int)Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
$regexp = preg_quote($rule, '#');
if ($keywords)
@@ -497,10 +503,12 @@ class DispatcherCore
}
$regexp = '#^/'.$regexp.'(\?.*)?$#u';
if (!isset($this->routes[$id_lang]))
$this->routes[$id_lang] = array();
if (!isset($this->routes[$id_shop]))
$this->routes[$id_shop] = array();
if (!isset($this->routes[$id_shop][$id_lang]))
$this->routes[$id_shop][$id_lang] = array();
$this->routes[$id_lang][$route_id] = array(
$this->routes[$id_shop][$id_lang][$route_id] = array(
'rule' => $rule,
'regexp' => $regexp,
'controller' => $controller,
@@ -514,14 +522,17 @@ class DispatcherCore
*
* @param string $route_id
* @param int $id_lang
* @param int $id_shop
* @return bool
*/
public function hasRoute($route_id, $id_lang = null)
public function hasRoute($route_id, $id_lang = null, $id_shop = null)
{
if (is_null($id_lang))
$id_lang = Context::getContext()->language->id;
if ($id_lang === null)
$id_lang = (int)Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
return isset($this->routes[$id_lang]) && isset($this->routes[$id_lang][$route_id]);
return isset($this->routes[$id_shop]) && isset($this->routes[$id_shop][$id_lang]) && isset($this->routes[$id_shop][$id_lang][$route_id]);
}
/**
@@ -530,14 +541,18 @@ class DispatcherCore
* @param string $route_id
* @param int $id_lang
* @param string $keyword
* @param int $id_shop
* @return bool
*/
public function hasKeyword($route_id, $id_lang, $keyword)
public function hasKeyword($route_id, $id_lang, $keyword, $id_shop = null)
{
if (!isset($this->routes[$id_lang]) && !isset($this->routes[$id_lang][$route_id]))
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
if (!isset($this->routes[$id_shop]) || !isset($this->routes[$id_shop][$id_lang]) || !isset($this->routes[$id_shop][$id_lang][$route_id]))
return false;
return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_lang][$route_id]['rule']);
return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_shop][$id_lang][$route_id]['rule']);
}
/**
@@ -569,18 +584,23 @@ class DispatcherCore
* @param bool $use_routes If false, don't use to create this url
* @param string $anchor Optional anchor to add at the end of this url
*/
public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '')
public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '', $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if ($id_lang === null)
$id_lang = (int)Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
if (!isset($this->routes[$id_lang][$route_id]))
if ($this->use_routes && !isset($this->routes[$id_shop]))
$this->loadRoutes($id_shop);
if (!isset($this->routes[$id_shop][$id_lang][$route_id]))
{
$query = http_build_query($params, '', '&');
$index_link = $this->use_routes ? '' : 'index.php';
return ($route_id == 'index') ? $index_link.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '').$anchor;
}
$route = $this->routes[$id_lang][$route_id];
$route = $this->routes[$id_shop][$id_lang][$route_id];
// Check required fields
$query_params = isset($route['params']) ? $route['params'] : array();
foreach ($route['keywords'] as $key => $data)
@@ -646,7 +666,7 @@ class DispatcherCore
*
* @return string
*/
public function getController()
public function getController($id_shop = null)
{
if (defined('_PS_ADMIN_DIR_'))
$_GET['controllerUri'] = Tools::getvalue('controller');
@@ -655,7 +675,10 @@ class DispatcherCore
$_GET['controller'] = $this->controller;
return $this->controller;
}
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
$controller = Tools::getValue('controller');
if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m))
@@ -682,10 +705,10 @@ class DispatcherCore
{
// Add empty route as last route to prevent this greedy regexp to match request uri before right time
if ($this->empty_route)
$this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id);
$this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id, array(), array(), $id_shop);
if (isset($this->routes[Context::getContext()->language->id]))
foreach ($this->routes[Context::getContext()->language->id] as $route)
if (isset($this->routes[$id_shop][Context::getContext()->language->id]))
foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route)
if (preg_match($route['regexp'], $this->request_uri, $m))
{
// Route found ! Now fill $_GET with parameters of uri
@@ -771,4 +794,4 @@ class DispatcherCore
return $controllers;
}
}
}
+9 -6
View File
@@ -244,12 +244,15 @@ class EmployeeCore extends ObjectModel
*/
public function isLoggedBack()
{
/* Employee is valid only if it can be load and if cookie password is the same as database one */
return ($this->id
&& Validate::isUnsignedId($this->id)
&& Employee::checkPassword($this->id, $this->passwd)
&& (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP'))
);
if (!Cache::isStored('isLoggedBack'.$this->id))
{
/* Employee is valid only if it can be load and if cookie password is the same as database one */
Cache::store('isLoggedBack'.$this->id, (
$this->id && Validate::isUnsignedId($this->id) && Employee::checkPassword($this->id, $this->passwd)
&& (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP'))
));
}
return Cache::retrieve('isLoggedBack'.$this->id);
}
/**
+7
View File
@@ -70,6 +70,13 @@ class GroupCore extends ObjectModel
protected $webserviceParameters = array();
public function __construct($id = null, $id_lang = null, $id_shop = null)
{
parent::__construct($id, $id_lang, $id_shop);
if ($this->id && !isset(Group::$group_price_display_method[$this->id]))
self::$group_price_display_method[$this->id] = $this->price_display_method;
}
public static function getGroups($id_lang, $id_shop = false)
{
$shop_criteria = '';
+7 -2
View File
@@ -216,13 +216,18 @@ class GroupReductionCore extends ObjectModel
FROM `'._DB_PREFIX_.'product_group_reduction_cache` pgr
WHERE pgr.`id_product` = '.(int)$id_product_old
);
if (!$res)
return true;
$query = '';
foreach ($res as $row)
{
$query = 'INSERT INTO `'._DB_PREFIX_.'product_group_reduction_cache` (`id_product`, `id_group`, `reduction`) VALUES ';
$query .= '('.(int)$id_product.', '.(int)$row['id_group'].', '.(float)$row['reduction'].')';
$query .= 'INSERT INTO `'._DB_PREFIX_.'product_group_reduction_cache` (`id_product`, `id_group`, `reduction`) VALUES ';
$query .= '('.(int)$id_product.', '.(int)$row['id_group'].', '.(float)$row['reduction'].') ON DUPLICATE KEY UPDATE `reduction` = '.(float)$row['reduction'].';';
}
return Db::getInstance()->execute($query);
}
+36 -13
View File
@@ -64,10 +64,10 @@ class HookCore extends ObjectModel
'primary' => 'id_hook',
'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isHookName', 'required' => true, 'size' => 64),
'title' => array('type' => self::TYPE_STRING),
'description' => array('type' => self::TYPE_HTML),
'position' => array('type' => self::TYPE_BOOL),
'live_edit' => array('type' => self::TYPE_BOOL),
'title' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'description' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'),
'position' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'live_edit' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
),
);
@@ -83,7 +83,7 @@ class HookCore extends ObjectModel
public function add($autodate = true, $null_values = false)
{
Cache::clean('hook_idbyname_'.$this->name);
Cache::clean('hook_idsbyname');
return parent::add($autodate, $null_values);
}
@@ -113,17 +113,40 @@ class HookCore extends ObjectModel
if (!Validate::isHookName($hook_name))
return false;
$cache_id = 'hook_idbyname_'.$hook_name;
$cache_id = 'hook_idsbyname';
if (!Cache::isStored($cache_id))
{
$retro_hook_name = Hook::getRetroHookName($hook_name);
Cache::store($cache_id, Db::getInstance()->getValue('
SELECT `id_hook`
FROM `'._DB_PREFIX_.'hook`
WHERE `name` = \''.pSQL($hook_name).'\'
OR `name` = \''.pSQL($retro_hook_name).'\'
'));
// Get all hook ID by name and alias
$hook_ids = array();
$result = Db::getInstance()->ExecuteS('
SELECT `id_hook`, `name`
FROM `'._DB_PREFIX_.'hook`
UNION
SELECT `id_hook`, ha.`alias` as name
FROM `'._DB_PREFIX_.'hook_alias` ha
INNER JOIN `'._DB_PREFIX_.'hook` h ON ha.name = h.name');
foreach ($result as $row)
$hook_ids[$row['name']] = $row['id_hook'];
Cache::store($cache_id, $hook_ids);
}
else
$hook_ids = Cache::retrieve($cache_id);
return (isset($hook_ids[$hook_name]) ? $hook_ids[$hook_name] : false);
}
/**
* Return hook ID from name
*/
public static function getNameById($hook_id)
{
$cache_id = 'hook_namebyid_'.$hook_id;
if (!Cache::isStored($cache_id))
Cache::store($cache_id, Db::getInstance()->getValue('
SELECT `name`
FROM `'._DB_PREFIX_.'hook`
WHERE `id_hook` = '.(int)$hook_id)
);
return Cache::retrieve($cache_id);
}
+3 -5
View File
@@ -262,7 +262,7 @@ class LanguageCore extends ObjectModel
$mPath_to = _PS_MAIL_DIR_.(string)$iso_to.'/';
}
$lFiles = array('admin.php', 'errors.php', 'fields.php', 'pdf.php', 'tabs.php', 'index.php');
$lFiles = array('admin.php', 'errors.php', 'fields.php', 'pdf.php', 'tabs.php');
// Added natives mails files
$mFiles = array(
@@ -273,7 +273,7 @@ class LanguageCore extends ObjectModel
'contact.html', 'contact.txt',
'contact_form.html', 'contact_form.txt',
'credit_slip.html', 'credit_slip.txt',
'download_product.html', 'download_product.txt', 'download-product.tpl',
'download_product.html', 'download_product.txt',
'employee_password.html', 'employee_password.txt',
'forward_msg.html', 'forward_msg.txt',
'guest_to_customer.html', 'guest_to_customer.txt',
@@ -297,7 +297,7 @@ class LanguageCore extends ObjectModel
'test.html', 'test.txt',
'voucher.html', 'voucher.txt',
'voucher_new.html', 'voucher_new.txt',
'order_changed.html', 'order_changed.txt', 'index.php'
'order_changed.html', 'order_changed.txt'
);
$number = -1;
@@ -704,10 +704,8 @@ class LanguageCore extends ObjectModel
$lang->name = $lang_pack->name;
}
elseif ($params_lang !== null && is_array($params_lang))
{
foreach ($params_lang as $key => $value)
$lang->$key = $value;
}
else
return false;
+107 -50
View File
@@ -91,7 +91,7 @@ class LinkCore
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if (!$id_shop)
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
@@ -101,9 +101,9 @@ class LinkCore
if (!is_object($product))
{
if (is_array($product) && isset($product['id_product']))
$product = new Product($product['id_product'], false, $id_lang);
else if (is_numeric($product) || !$product)
$product = new Product($product, false, $id_lang);
$product = new Product($product['id_product'], false, $id_lang);
elseif ((int)$product)
$product = new Product((int)$product, false, $id_lang);
else
throw new PrestaShopException('Invalid product vars');
}
@@ -112,29 +112,30 @@ class LinkCore
$params = array();
$params['id'] = $product->id;
$params['rewrite'] = (!$alias) ? $product->getFieldByLang('link_rewrite') : $alias;
$params['ean13'] = (!$ean13) ? $product->ean13 : $ean13;
$params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords'));
$params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title'));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'manufacturer'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'manufacturer', $id_shop))
$params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'supplier'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'supplier', $id_shop))
$params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'price'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'price', $id_shop))
$params['price'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specificPrice);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'tags'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'tags', $id_shop))
$params['tags'] = Tools::str2url($product->getTags($id_lang));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category'))
$params['category'] = !is_null($product->category) ? Tools::str2url($product->category) : Tools::str2url($category);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category', $id_shop))
$params['category'] = (!is_null($product->category) && !empty($product->category)) ? Tools::str2url($product->category) : Tools::str2url($category);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'reference'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'reference', $id_shop))
$params['reference'] = Tools::str2url($product->reference);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories', $id_shop))
{
$params['category'] = (!$category) ? $product->category : $category;
$cats = array();
@@ -145,7 +146,7 @@ class LinkCore
}
$anchor = $ipa ? $product->getAnchor($ipa) : '';
return $url.$dispatcher->createUrl('product_rule', $id_lang, $params, $force_routes, $anchor);
return $url.$dispatcher->createUrl('product_rule', $id_lang, $params, $force_routes, $anchor, $id_shop);
}
/**
@@ -157,11 +158,16 @@ class LinkCore
* @param string $selected_filters Url parameter to autocheck filters of the module blocklayered
* @return string
*/
public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null)
public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
if (!is_object($category))
$category = new Category($category, $id_lang);
@@ -184,7 +190,7 @@ class LinkCore
$params['selected_filters'] = $selected_filters;
}
return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow);
return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -195,24 +201,33 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getCMSCategoryLink($category, $alias = null, $id_lang = null)
public function getCMSCategoryLink($cms_category, $alias = null, $id_lang = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if (!is_object($category))
$category = new CMSCategory($category, $id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
$dispatcher = Dispatcher::getInstance();
if (!is_object($cms_category))
{
if ($alias !== null && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, array('id' => (int)$cms_category, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$cms_category = new CMSCategory($cms_category, $id_lang);
}
// Set available keywords
$params = array();
$params['id'] = $category->id;
$params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias;
$params['meta_keywords'] = Tools::str2url($category->meta_keywords);
$params['meta_title'] = Tools::str2url($category->meta_title);
$params['id'] = $cms_category->id;
$params['rewrite'] = (!$alias) ? $cms_category->link_rewrite : $alias;
$params['meta_keywords'] = Tools::str2url($cms_category->meta_keywords);
$params['meta_title'] = Tools::str2url($cms_category->meta_title);
return $url.Dispatcher::getInstance()->createUrl('cms_category_rule', $id_lang, $params, $this->allow);
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -224,33 +239,42 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null, $id_shop = null)
{
$base = (($ssl && $this->ssl_enable) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://');
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
$dispatcher = Dispatcher::getInstance();
if (!is_object($cms))
{
if ($alias !== null && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('cms_rule', $id_lang, array('id' => (int)$cms, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$cms = new CMS($cms, $id_lang);
}
// Set available keywords
$params = array();
$params['id'] = $cms->id;
$params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias;
$params['meta_keywords'] = '';
if (isset($cms->meta_keywords) && !empty($cms->meta_keywords))
$params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int)$id_lang]) : Tools::str2url($cms->meta_keywords);
else
$params['meta_keywords'] = '';
$params['meta_title'] = '';
if (isset($cms->meta_title) && !empty($cms->meta_title))
$params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int)$id_lang]) : Tools::str2url($cms->meta_title);
else
$params['meta_title'] = '';
return $url.Dispatcher::getInstance()->createUrl('cms_rule', $id_lang, $params, $this->allow);
return $url.$dispatcher->createUrl('cms_rule', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -261,14 +285,24 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getSupplierLink($supplier, $alias = null, $id_lang = null)
public function getSupplierLink($supplier, $alias = null, $id_lang = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
$dispatcher = Dispatcher::getInstance();
if (!is_object($supplier))
{
if ($alias !== null && !$dispatcher->hasKeyword('supplier_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('supplier_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('supplier_rule', $id_lang, array('id' => (int)$supplier, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$supplier = new Supplier($supplier, $id_lang);
}
// Set available keywords
$params = array();
@@ -277,7 +311,7 @@ class LinkCore
$params['meta_keywords'] = Tools::str2url($supplier->meta_keywords);
$params['meta_title'] = Tools::str2url($supplier->meta_title);
return $url.Dispatcher::getInstance()->createUrl('supplier_rule', $id_lang, $params, $this->allow);
return $url.$dispatcher->createUrl('supplier_rule', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -288,14 +322,24 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getManufacturerLink($manufacturer, $alias = null, $id_lang = null)
public function getManufacturerLink($manufacturer, $alias = null, $id_lang = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
$dispatcher = Dispatcher::getInstance();
if (!is_object($manufacturer))
{
if ($alias !== null && !$dispatcher->hasKeyword('manufacturer_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('manufacturer_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('manufacturer_rule', $id_lang, array('id' => (int)$manufacturer, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$manufacturer = new Manufacturer($manufacturer, $id_lang);
}
// Set available keywords
$params = array();
@@ -304,7 +348,7 @@ class LinkCore
$params['meta_keywords'] = Tools::str2url($manufacturer->meta_keywords);
$params['meta_title'] = Tools::str2url($manufacturer->meta_title);
return $url.Dispatcher::getInstance()->createUrl('manufacturer_rule', $id_lang, $params, $this->allow);
return $url.$dispatcher->createUrl('manufacturer_rule', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -316,23 +360,28 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null)
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null, $id_shop = null)
{
$base = (($ssl && $this->ssl_enable) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://');
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
// Set available keywords
$params['module'] = $module;
$params['controller'] = $controller ? $controller : 'default';
// If the module has its own route ... just use it !
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang))
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop))
return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params);
else
return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow);
return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -403,7 +452,7 @@ class LinkCore
*
* @return string Page link
*/
public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false)
public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
{
$controller = Tools::strReplaceFirst('.php', '', $controller);
@@ -419,16 +468,24 @@ class LinkCore
parse_str($request, $request);
}
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request);
$url = ($ssl && $this->ssl_enable) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true);
$url .= __PS_BASE_URI__.$this->getLangLink($id_lang).ltrim($uri_path, '/');
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request, false, '', $id_shop);
$url = ($ssl && $this->ssl_enable) ? 'https://' : 'http://';
$url .= $shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang).ltrim($uri_path, '/');
return $url;
}
public function getCatImageLink($name, $id_category, $type = null)
{
$uri_path = ($this->allow == 1) ? (__PS_BASE_URI__.'c/'.$id_category.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_CAT_DIR_.$id_category.($type ? '-'.$type : '').'.jpg');
if($this->allow == 1 && $type)
$uri_path = __PS_BASE_URI__.'c/'.$id_category.'-'.$type.'/'.$name.'.jpg';
else
$uri_path = _THEME_CAT_DIR_.$id_category.($type ? '-'.$type : '').'.jpg';
return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
}
+12 -1
View File
@@ -43,6 +43,9 @@ class LoggerCore extends ObjectModel
/** @var integer Object ID */
public $object_id;
/** @var integer Object ID */
public $id_employee;
/** @var string Object creation date */
public $date_add;
@@ -61,6 +64,7 @@ class LoggerCore extends ObjectModel
'error_code' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
'object_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'object_type' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
@@ -98,7 +102,7 @@ class LoggerCore extends ObjectModel
* @param boolean $allow_duplicate if set to true, can log several time the same information (not recommended)
* @return boolean true if succeed
*/
public static function addLog($message, $severity = 1, $error_code = null, $object_type = null, $object_id = null, $allow_duplicate = false)
public static function addLog($message, $severity = 1, $error_code = null, $object_type = null, $object_id = null, $allow_duplicate = false, $id_employee = null)
{
$log = new Logger();
$log->severity = intval($severity);
@@ -106,6 +110,13 @@ class LoggerCore extends ObjectModel
$log->message = pSQL($message);
$log->date_add = date('Y-m-d H:i:s');
$log->date_upd = date('Y-m-d H:i:s');
if ($id_employee === null && isset(Context::getContext()->employee) && Validate::isLoadedObject(Context::getContext()->employee))
$id_employee = Context::getContext()->employee->id;
if ($id_employee !== null)
$log->id_employee = (int)$id_employee;
if (!empty($object_type) && !empty($object_id))
{
$log->object_type = pSQL($object_type);
+3
View File
@@ -249,6 +249,9 @@ class MailCore
if (isset($logo))
$template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($logo)));
if ((Context::getContext()->link instanceof Link) === false)
Context::getContext()->link = new Link();
$template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
$template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id);
$template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id);
+3 -2
View File
@@ -78,8 +78,8 @@ class ManufacturerCore extends ObjectModel
'date_upd' => array('type' => self::TYPE_DATE),
// Lang fields
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
'short_description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString', 'size' => 254),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
'short_description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 254),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'),
@@ -198,6 +198,7 @@ class ManufacturerCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'manufacturer` as m ON (m.`id_manufacturer`= p.`id_manufacturer`)
WHERE m.`id_manufacturer` = '.(int)$manufacturer['id_manufacturer'].
($active ? ' AND product_shop.`active` = 1 ' : '').
' AND product_shop.`visibility` NOT IN ("none")'.
($all_group ? '' : ' AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `'._DB_PREFIX_.'category_group` cg
+30 -29
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2012 PrestaShop
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -30,36 +30,37 @@ class MediaCore
'ui.core' => array('fileName' => 'jquery.ui.core.min.js', 'dependencies' => array(), 'theme' => true),
'ui.widget' => array('fileName' => 'jquery.ui.widget.min.js', 'dependencies' => array(), 'theme' => false),
'ui.mouse' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => false),
'ui.position' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array(), 'theme' => false),
'ui.draggable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => false),
'ui.droppable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false),
'ui.resizable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.selectable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.sortable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.accordion' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.autocomplete' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
'ui.button' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.dialog' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
'ui.slider' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.tabs' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.datepicker' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core'), 'theme' => true),
'ui.progressbar' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'effects.core' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array(), 'theme' => false),
'effects.blind' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.bounce' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.clip' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.drop' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.explode' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.fade' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.fold' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.highlight' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.pulsate' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.scale' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.shake' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.slide' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.transfer' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false)
'ui.position' => array('fileName' => 'jquery.ui.position.min.js', 'dependencies' => array(), 'theme' => false),
'ui.draggable' => array('fileName' => 'jquery.ui.draggable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => false),
'ui.droppable' => array('fileName' => 'jquery.ui.droppable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false),
'ui.resizable' => array('fileName' => 'jquery.ui.resizable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.selectable' => array('fileName' => 'jquery.ui.selectable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.sortable' => array('fileName' => 'jquery.ui.sortable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.accordion' => array('fileName' => 'jquery.ui.accordion.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.autocomplete' => array('fileName' => 'jquery.ui.autocomplete.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
'ui.button' => array('fileName' => 'jquery.ui.button.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
'ui.slider' => array('fileName' => 'jquery.ui.slider.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.tabs' => array('fileName' => 'jquery.ui.tabs.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.datepicker' => array('fileName' => 'jquery.ui.datepicker.min.js', 'dependencies' => array('ui.core'), 'theme' => true),
'ui.progressbar' => array('fileName' => 'jquery.ui.progressbar.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'effects.core' => array('fileName' => 'jquery.effects.core.min.js', 'dependencies' => array(), 'theme' => false),
'effects.blind' => array('fileName' => 'jquery.effects.blind.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.bounce' => array('fileName' => 'jquery.effects.bounce.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.clip' => array('fileName' => 'jquery.effects.clip.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.drop' => array('fileName' => 'jquery.effects.drop.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.explode' => array('fileName' => 'jquery.effects.explode.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.fade' => array('fileName' => 'jquery.effects.fade.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.fold' => array('fileName' => 'jquery.effects.fold.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.highlight' => array('fileName' => 'jquery.effects.highlight.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.pulsate' => array('fileName' => 'jquery.effects.pulsate.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.scale' => array('fileName' => 'jquery.effects.scale.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.shake' => array('fileName' => 'jquery.effects.shake.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.slide' => array('fileName' => 'jquery.effects.slide.min.js', 'dependencies' => array('effects.core'), 'theme' => false),
'effects.transfer' => array('fileName' => 'jquery.effects.transfer.min.js', 'dependencies' => array('effects.core'), 'theme' => false)
);
public static function minifyHTML($html_content)
{
if (strlen($html_content) > 0)
+42 -18
View File
@@ -242,16 +242,6 @@ abstract class ObjectModelCore
$this->{$key} = $value;
}
}
if (!is_array(self::$fieldsRequiredDatabase))
{
$fields = $this->getfieldsRequiredDatabase(true);
if ($fields)
foreach ($fields as $row)
self::$fieldsRequiredDatabase[$row['object_name']][(int)$row['id_required_field']] = pSQL($row['field_name']);
else
self::$fieldsRequiredDatabase = array();
}
}
/**
@@ -546,7 +536,7 @@ abstract class ObjectModelCore
$object_id = Db::getInstance()->Insert_ID();
if ($definition['multilang'])
if (isset($definition['multilang']) && $definition['multilang'])
{
$res = Db::getInstance()->executeS('
SELECT *
@@ -763,6 +753,9 @@ abstract class ObjectModelCore
if (!array_key_exists('active', $this))
throw new PrestaShopException('property "active" is missing in object '.get_class($this));
// Update only active field
$this->setFieldsToUpdate(array('active' => true));
// Update active status on object
$this->active = !(int)$this->active;
@@ -898,6 +891,7 @@ abstract class ObjectModelCore
*/
public function validateField($field, $value, $id_lang = null)
{
$this->cacheFieldsRequiredDatabase();
$data = $this->def['fields'][$field];
// Check if field is required
@@ -936,8 +930,22 @@ abstract class ObjectModelCore
if (!method_exists('Validate', $data['validate']))
throw new PrestaShopException('Validation function not found. '.$data['validate']);
if (!empty($value) && !call_user_func(array('Validate', $data['validate']), $value))
return 'Property '.get_class($this).'->'.$field.' is not valid';
if (!empty($value))
{
$res = true;
if (Tools::strtolower($data['validate']) == 'iscleanhtml')
{
if (!call_user_func(array('Validate', $data['validate']), $value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
$res = false;
}
else
{
if (!call_user_func(array('Validate', $data['validate']), $value))
$res = false;
}
if (!$res)
return 'Property '.get_class($this).'->'.$field.' is not valid';
}
}
return true;
@@ -966,6 +974,7 @@ abstract class ObjectModelCore
public function validateController($htmlentities = true)
{
$this->cacheFieldsRequiredDatabase();
$errors = array();
$required_fields_database = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array();
foreach ($this->def['fields'] as $field => $data)
@@ -977,11 +986,11 @@ abstract class ObjectModelCore
// Checking for required fields
if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
if (!$this->id || $field != 'passwd')
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
// Checking for maximum fields sizes
if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size'])
$errors[] = sprintf(
$errors[$field] = sprintf(
Tools::displayError('%1$s is too long. Maximum length: %2$d'),
self::displayFieldName($field, get_class($this), $htmlentities),
$data['size']
@@ -992,7 +1001,7 @@ abstract class ObjectModelCore
if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0'))
{
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required']))
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
else
{
if (isset($data['copy_post']) && !$data['copy_post'])
@@ -1012,6 +1021,7 @@ abstract class ObjectModelCore
public function getWebserviceParameters($ws_params_attribute_name = null)
{
$this->cacheFieldsRequiredDatabase();
$default_resource_parameters = array(
'objectSqlId' => $this->def['primary'],
'retrieveData' => array(
@@ -1122,6 +1132,7 @@ abstract class ObjectModelCore
public function validateFieldsRequiredDatabase($htmlentities = true)
{
$this->cacheFieldsRequiredDatabase();
$errors = array();
$required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array();
@@ -1136,7 +1147,7 @@ abstract class ObjectModelCore
$value = Tools::getValue($field);
if (empty($value))
$errors[] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities));
$errors[$field] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities));
}
return $errors;
@@ -1149,6 +1160,19 @@ abstract class ObjectModelCore
FROM '._DB_PREFIX_.'required_field
'.(!$all ? 'WHERE object_name = \''.pSQL(get_class($this)).'\'' : ''));
}
public function cacheFieldsRequiredDatabase()
{
if (!is_array(self::$fieldsRequiredDatabase))
{
$fields = $this->getfieldsRequiredDatabase(true);
if ($fields)
foreach ($fields as $row)
self::$fieldsRequiredDatabase[$row['object_name']][(int)$row['id_required_field']] = pSQL($row['field_name']);
else
self::$fieldsRequiredDatabase = array();
}
}
public function addFieldsRequiredDatabase($fields)
{
@@ -1608,4 +1632,4 @@ abstract class ObjectModelCore
{
$this->update_fields = $fields;
}
}
}
+3 -3
View File
@@ -386,7 +386,7 @@ abstract class PaymentModuleCore extends Module
'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td>
<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod((int)$this->context->customer->id) == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
<td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['cart_quantity'] - $customization_quantity).'</td>
<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['cart_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
</tr>';
@@ -431,9 +431,9 @@ abstract class PaymentModuleCore extends Module
// Set the new voucher value
if ($voucher->reduction_tax)
$voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt - $order->total_shipping_tax_incl;
$voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_incl : 0);
else
$voucher->reduction_amount = $values['tax_excl'] - $order->total_products - $order->total_shipping_tax_excl;
$voucher->reduction_amount = $values['tax_excl'] - $order->total_products - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_excl : 0);
$voucher->id_customer = $order->id_customer;
$voucher->quantity = 1;
+11 -9
View File
@@ -297,8 +297,8 @@ class ProductCore extends ObjectModel
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
'available_now' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'available_later' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'IsGenericName', 'size' => 255),
),
@@ -868,12 +868,13 @@ class ProductCore extends ObjectModel
AND cp.id_product = '.$this->id
);
foreach ($result as $categ_to_delete)
$this->deleteCategory($categ_to_delete['id_category']);
// if none are found, it's an error
if (!is_array($result))
return false;
foreach ($result as $categ_to_delete)
$this->deleteCategory($categ_to_delete['id_category']);
if (!$this->addToCategories($categories))
return false;
@@ -2699,8 +2700,10 @@ class ProductCore extends ObjectModel
// Group reduction
if ($use_group_reduction)
{
if ($reduction_from_category = (float)GroupReduction::getValueForProduct($id_product, $id_group))
$price -= $price * $reduction_from_category;
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
if (!empty($reduction_from_category) && (float)$reduction_from_category == 0)
$price -= $price * (float)$reduction_from_category;
else // apply group reduction if there is no group reduction for this category
$price *= ((100 - Group::getReductionByIdGroup($id_group)) / 100);
}
@@ -3794,15 +3797,14 @@ class ProductCore extends ObjectModel
isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null
);
$row['quantity_all_versions'] = $row['quantity'];
if ($row['id_product_attribute'])
{
$row['quantity_all_versions'] = $row['quantity'];
$row['quantity'] = Product::getQuantity(
(int)$row['id_product'],
$row['id_product_attribute'],
isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null
);
}
$row['id_image'] = Product::defineProductImage($row, $id_lang);
$row['features'] = Product::getFrontFeaturesStatic((int)$id_lang, $row['id_product']);
+6 -2
View File
@@ -71,7 +71,11 @@ class ProductSaleCore
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
$interval = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
$prefix = '';
if ($order_by == 'date_add')
$prefix = 'p.';
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
@@ -104,7 +108,7 @@ class ProductSaleCore
WHERE cg.`id_group` '.$sql_groups.'
)
GROUP BY product_shop.id_product
ORDER BY `'.pSQL($order_by).'` '.pSQL($order_way).'
ORDER BY '.$prefix.'`'.pSQL($order_by).'` '.pSQL($order_way).'
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+6 -2
View File
@@ -208,9 +208,10 @@ class ProductSupplierCore extends ObjectModel
*
* @param int $id_product
* @param int $id_product_attribute Optional
* @param bool $converted_price Optional
* @return Array keys: price_te, id_currency
*/
public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0)
public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0, $converted_price = false)
{
if (is_null($id_supplier) || is_null($id_product))
return;
@@ -222,6 +223,9 @@ class ProductSupplierCore extends ObjectModel
$query->where('id_supplier = '.(int)$id_supplier);
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
if ($converted_price)
return Tools::convertPrice($row['price_te'], $row['id_currency']);
return $row['price_te'];
}
}
}
+1 -3
View File
@@ -37,7 +37,7 @@ class RequestSqlCore extends ObjectModel
'primary' => 'id_request_sql',
'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 200),
'sql' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 1000),
'sql' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true),
),
);
@@ -232,8 +232,6 @@ class RequestSqlCore extends ObjectModel
{
if ($attribut = $this->cutAttribute(trim($attr), $from))
$tab[] = $attribut;
else
return false;
}
return $tab;
}
+5 -12
View File
@@ -116,19 +116,12 @@ class SceneCore extends ObjectModel
}
public function deleteImage($force_delete = false)
{
// Hack to prevent the main scene image from being deleted in AdminController::uploadImage() when a thumb image is uploaded
if (isset($_FILES['thumb']) && (!isset($_FILES['image']) || empty($_FILES['image']['name'])))
return true;
if (parent::deleteImage())
{
if (file_exists($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format)
&& !unlink($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format))
return false;
}
else
{
if (file_exists($this->image_dir.'thumbs/'.$this->id.'-m_scene_default.'.$this->image_format)
&& !unlink($this->image_dir.'thumbs/'.$this->id.'-m_scene_default.'.$this->image_format))
return false;
if (!(isset($_FILES) && count($_FILES)))
return parent::deleteImage();
return true;
}
+13 -5
View File
@@ -102,11 +102,11 @@ class SearchCore
$string = preg_replace('/['.PREG_CLASS_SEARCH_EXCLUDE.']+/u', ' ', $string);
if ($indexation)
$string = preg_replace('/[._-]+/', '', $string);
$string = preg_replace('/[._-]+/', ' ', $string);
else
{
$string = preg_replace('/[._]+/', '', $string);
$string = ltrim(preg_replace('/([^ ])-/', '$1', ' '.$string));
$string = ltrim(preg_replace('/([^ ])-/', '$1 ', ' '.$string));
$string = preg_replace('/[._]+/', '', $string);
$string = preg_replace('/[^\s]-+/', '', $string);
}
@@ -224,7 +224,7 @@ class SearchCore
AND product_shop.`active` = 1
AND product_shop.`visibility` IN ("both", "search")
AND product_shop.indexed = 1
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
AND cg.`id_group` '.(!$id_customer ? '= '.(int)Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.'
)');
@@ -571,6 +571,14 @@ class SearchCore
return true;
}
public static function removeProductsSearchIndex($products)
{
if (count($products)) {
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'search_index WHERE id_product IN ('.implode(',', $products).')');
ObjectModel::updateMultishopTable('Product', array('indexed' => 0), 'a.id_product IN ('.implode(',', $products).')');
}
}
protected static function setProductsAsIndexed(&$products)
{
if (count($products))
@@ -622,7 +630,7 @@ class SearchCore
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
WHERE product_shop.`active` = 1
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
AND cg.`id_group` '.(!$id_customer ? '= '.(int)Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').'
AND t.`name` LIKE \'%'.pSQL($tag).'%\'';
@@ -656,7 +664,7 @@ class SearchCore
'.Product::sqlStock('p', 0).'
WHERE product_shop.`active` = 1
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
AND cg.`id_group` '.(!$id_customer ? '= '.(int)Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').'
AND t.`name` LIKE \'%'.pSQL($tag).'%\'
+1 -1
View File
@@ -135,7 +135,7 @@ class SpecificPriceCore extends ObjectModel
SELECT *
FROM `'._DB_PREFIX_.'specific_price`
WHERE `id_product` = '.(int)$id_product.
($id_product_attribute ? 'AND id_product_attribute = '.(int)$id_product_attribute : '').'
($id_product_attribute ? ' AND id_product_attribute = '.(int)$id_product_attribute : '').'
AND id_cart = '.(int)$id_cart);
}
+1
View File
@@ -140,6 +140,7 @@ class SupplierCore extends ObjectModel
WHERE ps.`id_supplier` = '.(int)$supplier['id_supplier'].'
AND ps.id_product_attribute = 0'.
($active ? ' AND product_shop.`active` = 1' : '').
' AND product_shop.`visibility` NOT IN ("none")'.
($all_groups ? '' :'
AND ps.`id_product` IN (
SELECT cp.`id_product`
+15 -10
View File
@@ -169,12 +169,18 @@ class TabCore extends ObjectModel
*/
public static function getCurrentParentId()
{
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `id_parent`
FROM `'._DB_PREFIX_.'tab`
WHERE LOWER(class_name) = \''.pSQL(Tools::strtolower(Tools::getValue('controller'))).'\''))
return $result['id_parent'];
return -1;
$cache_id = 'getCurrentParentId_'.Tools::strtolower(Tools::getValue('controller'));
if (!Cache::isStored($cache_id))
{
$value = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_parent`
FROM `'._DB_PREFIX_.'tab`
WHERE LOWER(class_name) = \''.pSQL(Tools::strtolower(Tools::getValue('controller'))).'\'');
if (!$value)
$value = -1;
Cache::store($cache_id, $value);
}
return Cache::retrieve($cache_id);
}
/**
@@ -538,11 +544,10 @@ class TabCore extends ObjectModel
foreach($tab->attributes() as $key => $value)
if ($key == 'display_type')
$display_type = (string)$value;
foreach ($tab->children() as $module)
foreach ($module->attributes() as $k => $v)
if ($k == 'name')
$modules_list[$display_type][] = (string)$v;
$modules_list[$display_type][(int)$module['position']] = (string)$module['name'];
ksort($modules_list[$display_type]);
}
}
+102 -58
View File
@@ -338,11 +338,9 @@ class ToolsCore
/* If language does not exist or is disabled, erase it */
if ($cookie->id_lang)
{
//echo $cookie->id_lang;exit;
$lang = new Language((int)$cookie->id_lang);
if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop())
$cookie->id_lang = null;
}
/* Automatically detect language if not already defined */
@@ -399,7 +397,7 @@ class ToolsCore
{
$context->cookie->id_lang = $id_lang;
$language = new Language($id_lang);
if (Validate::isLoadedObject($language))
if (Validate::isLoadedObject($language) && $language->active)
$context->language = $language;
$params = $_GET;
@@ -433,8 +431,11 @@ class ToolsCore
{
// get currency from context
$currency = Shop::getEntityIds('currency', Context::getContext()->shop->id);
$cookie->id_currency = $currency[0]['id_currency'];
return Currency::getCurrencyInstance((int)$cookie->id_currency);
if (isset($currency[0]) && $currency[0]['id_currency'])
{
$cookie->id_currency = $currency[0]['id_currency'];
return Currency::getCurrencyInstance((int)$cookie->id_currency);
}
}
}
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
@@ -681,17 +682,21 @@ class ToolsCore
if ($files = scandir($dirname))
{
foreach ($files as $file)
if ($file != '.' && $file != '..' && $file != '.svn')
{
if (is_dir($dirname.$file))
Tools::deleteDirectory($dirname.$file, true);
elseif (file_exists($dirname.$file))
unlink($dirname.$file);
}
if ($file != '.' && $file != '..' && $file != '.svn')
{
if (is_dir($dirname.$file))
Tools::deleteDirectory($dirname.$file, true);
elseif (file_exists($dirname.$file))
unlink($dirname.$file);
}
if ($delete_self)
rmdir($dirname);
if (!rmdir($dirname))
return false;
return true;
}
}
return false;
}
/**
* Display an error according to an error code
@@ -1023,47 +1028,66 @@ class ToolsCore
*/
public static function replaceAccentedChars($str)
{
/* One source among others:
http://www.tachyonsoft.com/uc0000.htm
http://www.tachyonsoft.com/uc0001.htm
*/
$patterns = array(
/* Lowercase */
'/[\x{0105}\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}]/u',
'/[\x{00E7}\x{010D}\x{0107}]/u',
'/[\x{010F}]/u',
'/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{011B}\x{0119}]/u',
'/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}]/u',
'/[\x{011F}]/u',
'/[\x{0142}\x{013E}\x{013A}]/u',
'/[\x{00F1}\x{0148}]/u',
'/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}]/u',
'/[\x{0159}\x{0155}]/u',
'/[\x{015B}\x{0161}\x{015F}]/u',
'/[\x{00DF}]/u',
'/[\x{0165}]/u',
'/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{016F}]/u',
'/[\x{00FD}\x{00FF}]/u',
'/[\x{017C}\x{017A}\x{017E}]/u',
'/[\x{00E6}]/u',
'/[\x{0153}]/u',
/* a */ '/[\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}\x{0101}\x{0103}\x{0105}]/u',
/* c */ '/[\x{00E7}\x{0107}\x{0109}\x{010D}]/u',
/* d */ '/[\x{010F}\x{0111}]/u',
/* e */ '/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{0113}\x{0115}\x{0117}\x{0119}\x{011B}]/u',
/* g */ '/[\x{011F}\x{0121}\x{0123}]/u',
/* h */ '/[\x{0125}\x{0127}]/u',
/* i */ '/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}\x{0129}\x{012B}\x{012D}\x{012F}\x{0131}]/u',
/* j */ '/[\x{0135}]/u',
/* k */ '/[\x{0137}\x{0138}]/u',
/* l */ '/[\x{013A}\x{013C}\x{013E}\x{0140}\x{0142}]/u',
/* n */ '/[\x{00F1}\x{0144}\x{0146}\x{0148}\x{0149}\x{014B}]/u',
/* o */ '/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}\x{014D}\x{014F}\x{0151}]/u',
/* r */ '/[\x{0155}\x{0157}\x{0159}]/u',
/* s */ '/[\x{015B}\x{015D}\x{015F}\x{0161}]/u',
/* ss*/ '/[\x{00DF}]/u',
/* t */ '/[\x{0163}\x{0165}\x{0167}]/u',
/* u */ '/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{0169}\x{016B}\x{016D}\x{016F}\x{0171}\x{0173}]/u',
/* w */ '/[\x{0175}]/u',
/* y */ '/[\x{00FF}\x{0177}\x{00FD}]/u',
/* z */ '/[\x{017A}\x{017C}\x{017E}]/u',
/* ae*/ '/[\x{00E6}]/u',
/* oe*/ '/[\x{0153}]/u',
/* Uppercase */
'/[\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
'/[\x{00C7}\x{010C}\x{0106}]/u',
'/[\x{010E}]/u',
'/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{011A}\x{0118}]/u',
'/[\x{011E}]/u',
'/[\x{0141}\x{013D}\x{0139}]/u',
'/[\x{00D1}\x{0147}]/u',
'/[\x{00D3}]/u',
'/[\x{0158}\x{0154}]/u',
'/[\x{015A}\x{0160}\x{015E}]/u',
'/[\x{0164}]/u',
'/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{016E}]/u',
'/[\x{017B}\x{0179}\x{017D}]/u',
'/[\x{00C6}]/u',
'/[\x{0152}]/u');
/* A */ '/[\x{0100}\x{0102}\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
/* C */ '/[\x{00C7}\x{0106}\x{0108}\x{010A}\x{010C}]/u',
/* D */ '/[\x{010E}\x{0110}]/u',
/* E */ '/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{0112}\x{0114}\x{0116}\x{0118}\x{011A}]/u',
/* G */ '/[\x{011C}\x{011E}\x{0120}\x{0122}]/u',
/* H */ '/[\x{0124}\x{0126}]/u',
/* I */ '/[\x{0128}\x{012A}\x{012C}\x{012E}\x{0130}]/u',
/* J */ '/[\x{0134}]/u',
/* K */ '/[\x{0136}]/u',
/* L */ '/[\x{0139}\x{013B}\x{013D}\x{0139}\x{0141}]/u',
/* N */ '/[\x{00D1}\x{0143}\x{0145}\x{0147}\x{014A}]/u',
/* O */ '/[\x{00D3}\x{014C}\x{014E}\x{0150}]/u',
/* R */ '/[\x{0154}\x{0156}\x{0158}]/u',
/* S */ '/[\x{015A}\x{015C}\x{015E}\x{0160}]/u',
/* T */ '/[\x{0162}\x{0164}\x{0166}]/u',
/* U */ '/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{0168}\x{016A}\x{016C}\x{016E}\x{0170}\x{0172}]/u',
/* W */ '/[\x{0174}]/u',
/* Y */ '/[\x{0176}]/u',
/* Z */ '/[\x{0179}\x{017B}\x{017D}]/u',
/* AE*/ '/[\x{00C6}]/u',
/* OE*/ '/[\x{0152}]/u');
// ö to oe
// å to aa
// ä to ae
$replacements = array(
'a', 'c', 'd', 'e', 'i', 'g', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'z', 'ae', 'oe',
'A', 'C', 'D', 'E', 'G', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE'
'a', 'c', 'd', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'w', 'z', 'ae', 'oe',
'A', 'C', 'D', 'E', 'G', 'H', 'I', 'J', 'K', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE'
);
return preg_replace($patterns, $replacements, $str);
@@ -1304,14 +1328,16 @@ class ToolsCore
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, $curl_timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$opts = stream_context_get_options($stream_context);
if (isset($opts['http']['method']) && Tools::strtolower($opts['http']['method']) == 'post')
{
curl_setopt($curl, CURLOPT_POST, true);
if (isset($opts['http']['content']))
if ($stream_context != null) {
$opts = stream_context_get_options($stream_context);
if (isset($opts['http']['method']) && Tools::strtolower($opts['http']['method']) == 'post')
{
parse_str($opts['http']['content'], $datas);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
curl_setopt($curl, CURLOPT_POST, true);
if (isset($opts['http']['content']))
{
parse_str($opts['http']['content'], $datas);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
}
}
}
$content = curl_exec($curl);
@@ -1564,7 +1590,7 @@ class ToolsCore
}
// Write .htaccess data
if (!$write_fd = @fopen($path, 'w'))
if (!$write_fd = fopen($path, 'w'))
return false;
fwrite($write_fd, trim($specific_before)."\n\n");
@@ -2102,6 +2128,9 @@ exit;
}
}
/**
* @deprecated as of 1.5 use Controller::getController('PageNotFoundController')->run();
*/
public static function display404Error()
{
header('HTTP/1.1 404 Not Found');
@@ -2402,7 +2431,7 @@ exit;
return $pattern;
return preg_replace('/\\\[px]\{[a-z]\}{1,2}|(\/[a-z]*)u([a-z]*)$/i', "$1$2", $pattern);
}
public static function addonsRequest($request, $params = array())
{
$addons_url = 'api.addons.prestashop.com';
@@ -2488,6 +2517,21 @@ exit;
// No content, return false
return false;
}
public static function fileAttachment($input = 'fileUpload')
{
$fileAttachment = null;
if (isset($_FILES[$input]['name']) && !empty($_FILES[$input]['name']) && !empty($_FILES[$input]['tmp_name']))
{
$fileAttachment['rename'] = uniqid(). self::strtolower(substr($_FILES[$input]['name'], -5));
$fileAttachment['content'] = file_get_contents($_FILES[$input]['tmp_name']);
$fileAttachment['tmp_name'] = $_FILES[$input]['tmp_name'];
$fileAttachment['name'] = $_FILES[$input]['name'];
$fileAttachment['mime'] = $_FILES[$input]['type'];
$fileAttachment['error'] = $_FILES[$input]['error'];
}
return $fileAttachment;
}
}
/**
+7 -1
View File
@@ -180,7 +180,13 @@ class TranslateCore
if ($js)
$ret = addslashes($ret);
$lang_cache[$cache_key] = str_replace('"', '&quot;', $ret);
$ret = str_replace('"', '&quot;', $ret);
if ($sprintf === null)
$lang_cache[$cache_key] = $ret;
else
return $ret;
}
return $lang_cache[$cache_key];
}
+10 -3
View File
@@ -380,7 +380,7 @@ class ValidateCore
*/
public static function isGenericName($name)
{
return empty($name) || preg_match('/^[^<>=#{}]*$/u', $name);
return empty($name) || preg_match('/^[^<>={}]*$/u', $name);
}
/**
@@ -389,7 +389,7 @@ class ValidateCore
* @param string $html HTML field to validate
* @return boolean Validity is ok or not
*/
public static function isCleanHtml($html)
public static function isCleanHtml($html, $allow_iframe = false)
{
$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
$events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
@@ -398,7 +398,14 @@ class ValidateCore
$events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
$events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
$events .= '|onselectstart|onstart|onstop';
return (!preg_match('/<[ \t\n]*script/ims', $html) && !preg_match('/('.$events.')[ \t\n]*=/ims', $html) && !preg_match('/.*script\:/ims', $html) && !preg_match('/<[ \t\n]*i?frame/ims', $html));
if (preg_match('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
return false;
if (!$allow_iframe && preg_match('/<[ \t\n]*(i?frame|form|input|embed|object)/ims', $html))
return false;
return true;
}
/**
+1 -1
View File
@@ -144,7 +144,7 @@ abstract class CacheCore
*/
public function set($key, $value, $ttl = 0)
{
if ($this->_set($key, $value))
if ($this->_set($key, $value, $ttl))
{
if ($ttl < 0)
$ttl = 0;
+1
View File
@@ -149,6 +149,7 @@ class CacheFsCore extends Cache
*/
protected function getFilename($key)
{
$key = md5($key);
$path = _PS_CACHEFS_DIRECTORY_;
for ($i = 0; $i < $this->depth; $i++)
$path .= $key[$i].'/';
+3 -2
View File
@@ -65,8 +65,9 @@ class CacheMemcacheCore extends Cache
{
foreach ($dump as $entries)
{
if ($entries)
$this->keys = array_merge($this->keys, array_keys($entries));
if($entries)
foreach ($entries as $key => $data)
$this->keys[$key] = $data[1];
}
}
}
+42 -37
View File
@@ -314,7 +314,7 @@ class AdminControllerCore extends Controller
19 => $this->l('Duplication was completed successfully.'), 20 => $this->l('The translation was added successfully, but the language has not been created.'),
21 => $this->l('Module reset successfully.'), 22 => $this->l('Module deleted successfully.'),
23 => $this->l('Localization pack imported successfully.'), 24 => $this->l('Localization pack imported successfully.'),
25 => $this->l('The selcted images have successfully been moved.'),
25 => $this->l('The selected images have successfully been moved.'),
26 => $this->l('Your cover selection has been saved.'),
27 => $this->l('The image shop association has been modified.'),
28 => $this->l('A zone has been assigned to the selection successfully.'),
@@ -648,12 +648,14 @@ class AdminControllerCore extends Controller
$this->errors[] = Tools::displayError('Unable to delete associated images.');
$object->deleted = 1;
if ($object->update())
if ($res = $object->update())
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
}
elseif ($object->delete())
elseif ($res = $object->delete())
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
$this->errors[] = Tools::displayError('An error occurred during deletion.');
if ($res)
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
}
}
else
@@ -702,6 +704,7 @@ class AdminControllerCore extends Controller
/* voluntary do affectation here */
elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect)
{
Logger::addLog(sprintf($this->l('%s addition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
$parent_id = (int)Tools::getValue('id_parent', 1);
$this->afterAdd($this->object);
$this->updateAssoShop($this->object->id);
@@ -736,7 +739,6 @@ class AdminControllerCore extends Controller
{
/* Checking fields validity */
$this->validateRules();
if (empty($this->errors))
{
$id = (int)Tools::getValue($this->identifier);
@@ -802,6 +804,7 @@ class AdminControllerCore extends Controller
if (empty($this->redirect_after))
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=4&token='.$this->token;
}
Logger::addLog(sprintf($this->l('%s edition'), $this->className), 1, null, $this->className, (int)$object->id, true, (int)$this->context->employee->id);
}
else
$this->errors[] = Tools::displayError('An error occurred while updating an object.').
@@ -956,7 +959,8 @@ class AdminControllerCore extends Controller
continue;
// Check if field is required
if (isset($values['required']) && $values['required'] && !empty($_POST['multishopOverrideOption'][$field]))
if ((!Shop::isFeatureActive() && isset($values['required']) && $values['required'])
|| (Shop::isFeatureActive() && isset($_POST['multishopOverrideOption'][$field]) && isset($values['required']) && $values['required']))
if (isset($values['type']) && $values['type'] == 'textLang')
{
foreach ($languages as $language)
@@ -1194,8 +1198,7 @@ class AdminControllerCore extends Controller
$tpl_action = $this->tpl_folder.$this->display.'.tpl';
// Check if action template has been override
// Check if action template has been overriden
foreach ($this->context->smarty->getTemplateDir() as $template_dir)
if (file_exists($template_dir.DIRECTORY_SEPARATOR.$tpl_action) && $this->display != 'view' && $this->display != 'options')
{
@@ -1214,27 +1217,15 @@ class AdminControllerCore extends Controller
$page = $this->content;
if ($conf = Tools::getValue('conf'))
if ($this->json)
$this->context->smarty->assign('conf', Tools::jsonEncode($this->_conf[(int)$conf]));
else
$this->context->smarty->assign('conf', $this->_conf[(int)$conf]);
$notifications_type = array('errors', 'warnings', 'informations', 'confirmations');
foreach($notifications_type as $type)
if ($this->json)
$this->context->smarty->assign($type, Tools::jsonEncode(array_unique($this->$type)));
else
$this->context->smarty->assign($type, array_unique($this->$type));
$this->context->smarty->assign('conf', $this->json ? Tools::jsonEncode($this->_conf[(int)$conf]) : $this->_conf[(int)$conf]);
if ($this->json)
$this->context->smarty->assign('page', Tools::jsonEncode($page));
else
$this->context->smarty->assign('page', $page);
foreach (array('errors', 'warnings', 'informations', 'confirmations') as $type)
$this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type));
$this->context->smarty->assign('page', $this->json ? Tools::jsonEncode($page) : $page);
$this->smartyOutputContent($this->layout);
}
/**
* add a warning message to display at the top of the page
*
@@ -1536,7 +1527,6 @@ class AdminControllerCore extends Controller
public function renderModulesList()
{
if ($this->getModulesList($this->filter_modules_list))
{
$helper = new Helper();
@@ -2218,9 +2208,9 @@ class AdminControllerCore extends Controller
}
else
$this->_listsql .= ($this->lang ? 'b.*,' : '').' a.*';
$this->_listsql .= '
'.(isset($this->_select) ? ', '.$this->_select : '').$select_shop.'
'.(isset($this->_select) ? ', '.rtrim($this->_select, ', ') : '').$select_shop.'
FROM `'._DB_PREFIX_.$sql_table.'` a
'.$lang_join.'
'.(isset($this->_join) ? $this->_join.' ' : '').'
@@ -2249,7 +2239,7 @@ class AdminControllerCore extends Controller
$all_modules = Module::getModulesOnDisk(true);
$this->modules_list = array();
foreach($all_modules as $module)
foreach ($all_modules as $module)
{
$perm = true;
if ($module->id)
@@ -2265,9 +2255,11 @@ class AdminControllerCore extends Controller
if (in_array($module->name, $filter_modules_list) && $perm)
{
$this->fillModuleData($module, 'select');
$this->modules_list[] = $module;
$this->modules_list[array_search($module->name, $filter_modules_list)] = $module;
}
}
ksort($this->modules_list);
if (count($this->modules_list))
return true;
@@ -2726,18 +2718,31 @@ class AdminControllerCore extends Controller
else
{
$result = true;
if ($this->deleted)
foreach ($this->boxes as $id)
{
foreach ($this->boxes as $id)
$to_delete = new $this->className($id);
$delete_ok = true;
if ($this->deleted)
{
$to_delete = new $this->className($id);
$to_delete->deleted = 1;
$result = $result && $to_delete->update();
if (!$to_delete->update())
{
$result = false;
$delete_ok = false;
}
}
else
if (!$to_delete->delete())
{
$result = false;
$delete_ok = false;
}
if ($delete_ok)
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$to_delete->id, true, (int)$this->context->employee->id);
else
$this->errors[] = sprintf(Tools::displayError('Can\'t delete #%d'), $id);
}
else
$result = $object->deleteSelection(Tools::getValue($this->table.'Box'));
if ($result)
$this->redirect_after = self::$currentIndex.'&conf=2&token='.$this->token;
$this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
@@ -3018,4 +3023,4 @@ class AdminControllerCore extends Controller
return $return;
}
}
}
+7 -5
View File
@@ -775,9 +775,11 @@ class FrontControllerCore extends Controller
public function checkLiveEditAccess()
{
$live_token = Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee'));
$ad = Tools::getValue('ad');
return Tools::isSubmit('live_edit') && $ad && Tools::getValue('liveToken') == $live_token && is_dir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$ad);
if (!Tools::isSubmit('live_edit') || !Tools::getValue('ad') || !Tools::getValue('liveToken'))
return false;
if (Tools::getValue('liveToken') != Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee')))
return false;
return is_dir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.Tools::getValue('ad'));
}
public function getLiveEditFooter()
@@ -847,8 +849,8 @@ class FrontControllerCore extends Controller
$range = 2; /* how many pages around page selected */
if ($this->p < 0)
$this->p = 0;
if ($this->p < 1)
$this->p = 1;
if (isset($this->context->cookie->nb_item_per_page) && $this->n != $this->context->cookie->nb_item_per_page && in_array($this->n, $nArray))
$this->context->cookie->nb_item_per_page = $this->n;
Regular → Executable
+13 -7
View File
@@ -79,12 +79,7 @@ abstract class DbCore
/**
* @var array Object instance for singleton
*/
protected static $_servers = array(
array('server' => _DB_SERVER_, 'user' => _DB_USER_, 'password' => _DB_PASSWD_, 'database' => _DB_NAME_), /* MySQL Master server */
// Add here your slave(s) server(s)
// array('server' => '192.168.0.15', 'user' => 'rep', 'password' => '123456', 'database' => 'rep'),
// array('server' => '192.168.0.3', 'user' => 'myuser', 'password' => 'mypassword', 'database' => 'mydatabase'),
);
protected static $_servers = array();
/**
* Store last executed query
@@ -169,6 +164,8 @@ abstract class DbCore
/* do not remove, useful for some modules */
abstract public function set_db($db_name);
abstract public function getBestEngine();
/**
* Get Db object instance
@@ -180,6 +177,15 @@ abstract class DbCore
{
static $id = 0;
// This MUST not be declared with the class members because some defines (like _DB_SERVER_) may not exist yet (the constructor can be called directly with params)
if (!self::$_servers)
self::$_servers = array(
array('server' => _DB_SERVER_, 'user' => _DB_USER_, 'password' => _DB_PASSWD_, 'database' => _DB_NAME_), /* MySQL Master server */
// Add here your slave(s) server(s)
// array('server' => '192.168.0.15', 'user' => 'rep', 'password' => '123456', 'database' => 'rep'),
// array('server' => '192.168.0.3', 'user' => 'myuser', 'password' => 'mypassword', 'database' => 'mydatabase'),
);
$total_servers = count(self::$_servers);
if ($master || $total_servers == 1)
$id_server = 0;
@@ -674,7 +680,7 @@ abstract class DbCore
return call_user_func_array(array(Db::getClass(), 'hasTableWithSamePrefix'), array($server, $user, $pwd, $db, $prefix));
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine));
}
+43 -12
View File
@@ -52,6 +52,21 @@ class DbMySQLiCore extends Db
return $this->link;
}
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
if (strpos($host, ':') !== false)
{
list($host, $port) = explode(':', $host);
$link = @new mysqli($host, $this->user, $this->password, null, $port);
}
else
$link = @new mysqli($host, $user, $password);
$success = $link->query('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`');
if ($dropit && ($link->query('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`') !== false))
return true;
return $success;
}
/**
* @see DbCore::disconnect()
@@ -169,24 +184,40 @@ class DbMySQLiCore extends Db
if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout))
return 1;
if (!$link->real_connect($server, $user, $pwd, $db))
// There is an @ because mysqli throw a warning when the database does not exists
if (!@$link->real_connect($server, $user, $pwd, $db))
return (mysqli_connect_errno() == 1049) ? 2 : 1;
if (strtolower($engine) == 'innodb')
{
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
return 4;
$row = $result->fetch_assoc();
if (!$row || strtolower($row['Value']) != 'yes')
return 4;
}
$link->close();
return 0;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $this->link->query($sql);
if (!$result)
$value = 'MyISAM';
$row = $result->fetch_assoc();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $this->link->query($sql);
while ($row = $result->fetch_assoc())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
$link = @new mysqli($server, $user, $pwd, $db);
if (mysqli_connect_error())
+264 -253
View File
@@ -1,253 +1,264 @@
<?php
/*
* 2007-2013 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-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* This class is currently only here for tests
*
* @since 1.5.0
*/
class DbPDOCore extends Db
{
protected static function _getPDO($host, $user, $password, $dbname, $timeout = 5)
{
$dsn = 'mysql:';
if ($dbname)
$dsn .= 'dbname='.$dbname.';';
if (preg_match('/^(.*):([0-9]+)$/', $host, $matches))
$dsn .= 'host='.$matches[1].';port='.$matches[2];
elseif (preg_match('#^.*:(/.*)$#', $host, $matches))
$dsn .= 'unix_socket='.$matches[1];
else
$dsn .= 'host='.$host;
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
}
/**
* @see DbCore::connect()
*/
public function connect()
{
try {
$this->link = $this->_getPDO($this->server, $this->user, $this->password, $this->database, 5);
} catch (PDOException $e) {
die(sprintf(Tools::displayError('Link to database cannot be established: %s'), utf8_encode($e->getMessage())));
}
// UTF-8 support
if ($this->link->exec('SET NAMES \'utf8\'') === false)
die(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.'));
return $this->link;
}
/**
* @see DbCore::disconnect()
*/
public function disconnect()
{
unset($this->link);
}
/**
* @see DbCore::_query()
*/
protected function _query($sql)
{
return $this->link->query($sql);
}
/**
* @see DbCore::nextRow()
*/
public function nextRow($result = false)
{
if (!$result)
$result = $this->result;
return $result->fetch(PDO::FETCH_ASSOC);
}
/**
* @see DbCore::_numRows()
*/
protected function _numRows($result)
{
return $result->rowCount();
}
/**
* @see DbCore::Insert_ID()
*/
public function Insert_ID()
{
return $this->link->lastInsertId();
}
/**
* @see DbCore::Affected_Rows()
*/
public function Affected_Rows()
{
return $this->result->rowCount();
}
/**
* @see DbCore::getMsgError()
*/
public function getMsgError($query = false)
{
$error = $this->link->errorInfo();
return ($error[0] == '00000') ? '' : $error[2];
}
/**
* @see DbCore::getNumberError()
*/
public function getNumberError()
{
$error = $this->link->errorInfo();
return isset($error[1]) ? $error[1] : 0;
}
/**
* @see DbCore::getVersion()
*/
public function getVersion()
{
return $this->getValue('SELECT VERSION()');
}
/**
* @see DbCore::_escape()
*/
public function _escape($str)
{
$search = array("\\", "\0", "\n", "\r", "\x1a", "'", '"');
$replace = array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"');
return str_replace($search, $replace, $str);
}
/**
* @see DbCore::set_db()
*/
public function set_db($db_name)
{
return $this->link->exec('USE '.pSQL($db_name));
}
/**
* @see Db::hasTableWithSamePrefix()
*/
public static function hasTableWithSamePrefix($server, $user, $pwd, $db, $prefix)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
} catch (PDOException $e) {
return false;
}
$sql = 'SHOW TABLES LIKE \''.$prefix.'%\'';
$result = $link->query($sql);
return (bool)$result->fetch();
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
} catch (PDOException $e) {
return false;
}
$sql = '
CREATE TABLE `'.$prefix.'test` (
`test` tinyint(1) unsigned NOT NULL
) ENGINE=MyISAM';
$result = $link->query($sql);
if (!$result)
{
$error = $link->errorInfo();
return $error[2];
}
$link->query('DROP TABLE `'.$prefix.'test`');
return true;
}
/**
* @see Db::checkConnection()
*/
public static function tryToConnect($server, $user, $pwd, $db, $newDbLink = true, $engine = null, $timeout = 5)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, $timeout);
} catch (PDOException $e) {
return ($e->getCode() == 1049) ? 2 : 1;
}
if (strtolower($engine) == 'innodb')
{
$value = 0;
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
$value = 4;
$row = $result->fetch();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 4;
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $link->query($sql);
while ($row = $result->fetch())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 0;
break;
}
return $value;
}
unset($link);
return 0;
}
/**
* @see Db::checkEncoding()
*/
public static function tryUTF8($server, $user, $pwd)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, false, 5);
} catch (PDOException $e) {
return false;
}
$result = $link->exec('SET NAMES \'utf8\'');
unset($link);
return ($result === false) ? false : true;
}
}
<?php
/*
* 2007-2013 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-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* @since 1.5.0
*/
class DbPDOCore extends Db
{
protected static function _getPDO($host, $user, $password, $dbname, $timeout = 5)
{
$dsn = 'mysql:';
if ($dbname)
$dsn .= 'dbname='.$dbname.';';
if (preg_match('/^(.*):([0-9]+)$/', $host, $matches))
$dsn .= 'host='.$matches[1].';port='.$matches[2];
elseif (preg_match('#^.*:(/.*)$#', $host, $matches))
$dsn .= 'unix_socket='.$matches[1];
else
$dsn .= 'host='.$host;
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
}
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
try {
$link = DbPDO::_getPDO($host, $user, $password, false);
$success = $link->exec('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`');
if ($dropit && ($link->exec('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`') !== false))
return true;
} catch (PDOException $e) {
return false;
}
return $success;
}
/**
* @see DbCore::connect()
*/
public function connect()
{
try {
$this->link = $this->_getPDO($this->server, $this->user, $this->password, $this->database, 5);
} catch (PDOException $e) {
die(sprintf(Tools::displayError('Link to database cannot be established: %s'), utf8_encode($e->getMessage())));
}
// UTF-8 support
if ($this->link->exec('SET NAMES \'utf8\'') === false)
die(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.'));
return $this->link;
}
/**
* @see DbCore::disconnect()
*/
public function disconnect()
{
unset($this->link);
}
/**
* @see DbCore::_query()
*/
protected function _query($sql)
{
return $this->link->query($sql);
}
/**
* @see DbCore::nextRow()
*/
public function nextRow($result = false)
{
if (!$result)
$result = $this->result;
return $result->fetch(PDO::FETCH_ASSOC);
}
/**
* @see DbCore::_numRows()
*/
protected function _numRows($result)
{
return $result->rowCount();
}
/**
* @see DbCore::Insert_ID()
*/
public function Insert_ID()
{
return $this->link->lastInsertId();
}
/**
* @see DbCore::Affected_Rows()
*/
public function Affected_Rows()
{
return $this->result->rowCount();
}
/**
* @see DbCore::getMsgError()
*/
public function getMsgError($query = false)
{
$error = $this->link->errorInfo();
return ($error[0] == '00000') ? '' : $error[2];
}
/**
* @see DbCore::getNumberError()
*/
public function getNumberError()
{
$error = $this->link->errorInfo();
return isset($error[1]) ? $error[1] : 0;
}
/**
* @see DbCore::getVersion()
*/
public function getVersion()
{
return $this->getValue('SELECT VERSION()');
}
/**
* @see DbCore::_escape()
*/
public function _escape($str)
{
$search = array("\\", "\0", "\n", "\r", "\x1a", "'", '"');
$replace = array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"');
return str_replace($search, $replace, $str);
}
/**
* @see DbCore::set_db()
*/
public function set_db($db_name)
{
return $this->link->exec('USE '.pSQL($db_name));
}
/**
* @see Db::hasTableWithSamePrefix()
*/
public static function hasTableWithSamePrefix($server, $user, $pwd, $db, $prefix)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
} catch (PDOException $e) {
return false;
}
$sql = 'SHOW TABLES LIKE \''.$prefix.'%\'';
$result = $link->query($sql);
return (bool)$result->fetch();
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
} catch (PDOException $e) {
return false;
}
$sql = '
CREATE TABLE `'.$prefix.'test` (
`test` tinyint(1) unsigned NOT NULL
) ENGINE=MyISAM';
$result = $link->query($sql);
if (!$result)
{
$error = $link->errorInfo();
return $error[2];
}
$link->query('DROP TABLE `'.$prefix.'test`');
return true;
}
/**
* @see Db::checkConnection()
*/
public static function tryToConnect($server, $user, $pwd, $db, $newDbLink = true, $engine = null, $timeout = 5)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, $timeout);
} catch (PDOException $e) {
return ($e->getCode() == 1049) ? 2 : 1;
}
unset($link);
return 0;
}
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $this->link->query($sql);
if (!$result)
$value = 'MyISAM';
$row = $result->fetch();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $this->link->query($sql);
while ($row = $result->fetch())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
/**
* @see Db::checkEncoding()
*/
public static function tryUTF8($server, $user, $pwd)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, false, 5);
} catch (PDOException $e) {
return false;
}
$result = $link->exec('SET NAMES \'utf8\'');
unset($link);
return ($result === false) ? false : true;
}
}
+35 -26
View File
@@ -46,6 +46,15 @@ class MySQLCore extends Db
return $this->link;
}
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
$link = mysql_connect($host, $user, $password);
$success = mysql_query('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`', $link);
if ($dropit && (mysql_query('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`', $link) !== false))
return true;
return $success;
}
/**
* @see DbCore::disconnect()
@@ -165,36 +174,36 @@ class MySQLCore extends Db
return 1;
if (!@mysql_select_db($db, $link))
return 2;
if (strtolower($engine) == 'innodb')
{
$value = 0;
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result)
$value = 4;
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes')
$value = 4;
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 0;
break;
}
return $value;
}
@mysql_close($link);
return 0;
}
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result)
$value = 'MyISAM';
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
ini_set('mysql.connect_timeout', 5);
if (!$link = @mysql_connect($server, $user, $pwd, true))
-1
View File
@@ -361,7 +361,6 @@ class HelperCore
public function renderModulesList($modules_list)
{
$this->tpl_vars = array('modules_list' => $modules_list);
$tpl = $this->createTemplate('helpers/modules_list/list.tpl');
$tpl->assign($this->tpl_vars);
+8 -8
View File
@@ -173,13 +173,13 @@ class HelperListCore extends Helper
public function displayListContent()
{
if ($this->position_identifier)
$id_category = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category', ($this->is_cms ? '1' : Category::getRootCategory()->id ));
else
$id_category = Category::getRootCategory()->id;
if (isset($this->fields_list['position']))
{
if ($this->position_identifier)
$id_category = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category', ($this->is_cms ? '1' : Category::getRootCategory()->id ));
else
$id_category = Category::getRootCategory()->id;
$positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list);
sort($positions);
}
@@ -307,7 +307,7 @@ class HelperListCore extends Helper
'table' => $this->table,
'token' => $this->token,
'color_on_bg' => $this->colorOnBackground,
'id_category' => $id_category,
'id_category' => isset($id_category) ? $id_category : false,
'bulk_actions' => $this->bulk_actions,
'positions' => isset($positions) ? $positions : null,
'order_by' => $this->orderBy,
@@ -456,7 +456,7 @@ class HelperListCore extends Helper
);
if ($this->specificConfirmDelete !== false)
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : self::$cache_lang['DeleteItem'].$name;
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : addcslashes(Tools::htmlentitiesDecodeUTF8(self::$cache_lang['DeleteItem'].$name), '\'');
$tpl->assign(array_merge($this->tpl_delete_link_vars, $data));
@@ -535,7 +535,7 @@ class HelperListCore extends Helper
{
if (!isset($params['type']))
$params['type'] = 'text';
$value = Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.(array_key_exists('filter_key', $params) ? $params['filter_key'] : $key)};
$value = Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.(array_key_exists('filter_key', $params) && $key != 'active' ? $params['filter_key'] : $key)};
switch ($params['type'])
{
case 'bool':
+46 -32
View File
@@ -153,18 +153,22 @@ abstract class ModuleCore
// If cache is not generated, we generate it
if (self::$modules_cache == null && !is_array(self::$modules_cache))
{
// Join clause is done to check if the module is activated in current shop context
$sql_limit_shop = 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'module_shop` ms WHERE m.`id_module` = ms.`id_module` AND ms.`id_shop` = '.((is_object(Context::getContext()->shop) && $id = (int)Context::getContext()->shop->id) ? $id : 1);
$sql = 'SELECT m.`id_module`, m.`name`, ('.$sql_limit_shop.') as total FROM `'._DB_PREFIX_.'module` m';
// Result is cached
$id_shop = (Validate::isLoadedObject($this->context->shop) ? $this->context->shop->id : 1);
self::$modules_cache = array();
$result = Db::getInstance()->executeS($sql);
// Join clause is done to check if the module is activated in current shop context
$result = Db::getInstance()->executeS('
SELECT m.`id_module`, m.`name`, (
SELECT id_module
FROM `'._DB_PREFIX_.'module_shop` ms
WHERE m.`id_module` = ms.`id_module`
AND ms.`id_shop` = '.(int)$id_shop.'
LIMIT 1
) as mshop
FROM `'._DB_PREFIX_.'module` m');
foreach ($result as $row)
{
self::$modules_cache[$row['name']] = $row;
self::$modules_cache[$row['name']]['active'] = ($row['total'] > 0) ? 1 : 0;
self::$modules_cache[$row['name']]['active'] = ($row['mshop'] > 0) ? 1 : 0;
}
}
@@ -668,6 +672,7 @@ abstract class ModuleCore
if ($alias = Hook::getRetroHookName($hook_name))
$hook_name = $alias;
Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
// Get hook id
$id_hook = Hook::getIdByName($hook_name);
@@ -714,6 +719,7 @@ abstract class ModuleCore
));
}
Hook::exec('actionModuleRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
return $return;
}
@@ -729,11 +735,16 @@ abstract class ModuleCore
// Get hook id if a name is given as argument
if (!is_numeric($hook_id))
{
$hook_name = (int)$hook_id;
// Retrocompatibility
$hook_id = Hook::getIdByName($hook_id);
if (!$hook_id)
return false;
}
else
$hook_name = Hook::getNameById((int)$hook_id);
Hook::exec('actionModuleUnRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
// Unregister module on hook by id
$sql = 'DELETE FROM `'._DB_PREFIX_.'hook_module`
@@ -744,6 +755,8 @@ abstract class ModuleCore
// Clean modules position
$this->cleanPositions($hook_id, $shop_list);
Hook::exec('actionModuleUnRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
return $result;
}
@@ -1341,7 +1354,7 @@ abstract class ModuleCore
elseif (isset($context->customer))
{
$groups = $context->customer->getGroups();
if (empty($groups))
if (!count($groups))
$groups = array(Configuration::get('PS_UNIDENTIFIED_GROUP'));
}
@@ -1364,7 +1377,7 @@ abstract class ModuleCore
'.(isset($billing) && $frontend ? 'AND mc.id_country = '.(int)$billing->id_country : '').'
AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).'
AND hm.id_shop IN('.implode(', ', $list).')
'.(count($groups) && $frontend ? 'AND (mg.`id_group` IN('.implode(', ', $groups).'))' : '').$paypal_condition.'
'.((count($groups) && $frontend) ? 'AND (mg.`id_group` IN ('.implode(', ', $groups).'))' : '').$paypal_condition.'
GROUP BY hm.id_hook, hm.id_module
ORDER BY hm.`position`, m.`name` DESC');
}
@@ -1502,12 +1515,12 @@ abstract class ModuleCore
* @param int $id_hook Hook ID
* @return array Exceptions
*/
protected static $exceptionsCache = null;
public function getExceptions($hookID, $dispatch = false)
public function getExceptions($id_hook, $dispatch = false)
{
if (self::$exceptionsCache === null)
$cache_id = 'exceptionsCache';
if (!Cache::isStored($cache_id))
{
self::$exceptionsCache = array();
$exceptionsCache = array();
$sql = 'SELECT * FROM `'._DB_PREFIX_.'hook_module_exceptions`
WHERE `id_shop` IN ('.implode(', ', Shop::getContextListShopID()).')';
$result = Db::getInstance()->executeS($sql);
@@ -1516,33 +1529,34 @@ abstract class ModuleCore
if (!$row['file_name'])
continue;
$key = $row['id_hook'].'-'.$row['id_module'];
if (!isset(self::$exceptionsCache[$key]))
self::$exceptionsCache[$key] = array();
if (!isset(self::$exceptionsCache[$key][$row['id_shop']]))
self::$exceptionsCache[$key][$row['id_shop']] = array();
self::$exceptionsCache[$key][$row['id_shop']][] = $row['file_name'];
if (!isset($exceptionsCache[$key]))
$exceptionsCache[$key] = array();
if (!isset($exceptionsCache[$key][$row['id_shop']]))
$exceptionsCache[$key][$row['id_shop']] = array();
$exceptionsCache[$key][$row['id_shop']][] = $row['file_name'];
}
Cache::store($cache_id, $exceptionsCache);
}
else
$exceptionsCache = !Cache::retrieve($cache_id);
$key = $hookID.'-'.$this->id;
if (!$dispatch)
$key = $id_hook.'-'.$this->id;
$array_return = array();
if ($dispatch)
{
$files = array();
foreach (Shop::getContextListShopID() as $shop_id)
if (isset(self::$exceptionsCache[$key], self::$exceptionsCache[$key][$shop_id]))
foreach (self::$exceptionsCache[$key][$shop_id] as $file)
if (!in_array($file, $files))
$files[] = $file;
return $files;
if (isset($exceptionsCache[$key], $exceptionsCache[$key][$shop_id]))
$array_return[$shop_id] = $exceptionsCache[$key][$shop_id];
}
else
{
$list = array();
foreach (Shop::getContextListShopID() as $shop_id)
if (isset(self::$exceptionsCache[$key], self::$exceptionsCache[$key][$shop_id]))
$list[$shop_id] = self::$exceptionsCache[$key][$shop_id];
return $list;
if (isset($exceptionsCache[$key], $exceptionsCache[$key][$shop_id]))
foreach ($exceptionsCache[$key][$shop_id] as $file)
if (!in_array($file, $array_return))
$array_return[] = $file;
}
return $array_return;
}
public static function isInstalled($module_name)
@@ -1603,7 +1617,7 @@ abstract class ModuleCore
{
if ($name === null)
$name = $this->name;
return $name.'|'.(int)Tools::usingSecureMode().'|'.(int)$this->context->shop->id.'|'.(int)Group::getCurrent()->id.'|'.(int)$this->context->language->id;
return $name.'|'.(int)Tools::usingSecureMode().'|'.(int)$this->context->shop->id.'|'.(int)Group::getCurrent()->id.'|'.(int)$this->context->language->id.'|'.(int)$this->context->currency->id;
}
public function display($file, $template, $cacheId = null, $compileId = null)
+35 -11
View File
@@ -63,7 +63,7 @@ class OrderCore extends ObjectModel
/** @var string Payment module */
public $module;
/** @var float Currency conversion rate */
/** @var float Currency exchange rate */
public $conversion_rate;
/** @var boolean Customer is ok for a recyclable package */
@@ -254,10 +254,12 @@ class OrderCore extends ObjectModel
public function __construct($id = null, $id_lang = null)
{
parent::__construct($id, $id_lang);
if ($this->id_customer)
$is_admin = (is_object(Context::getContext()->controller) && Context::getContext()->controller->controller_type == 'admin');
if ($this->id_customer && !$is_admin)
{
$customer = new Customer((int)($this->id_customer));
$this->_taxCalculationMethod = Group::getPriceDisplayMethod((int)($customer->id_default_group));
$this->_taxCalculationMethod = Group::getPriceDisplayMethod((int)$customer->id_default_group);
}
else
$this->_taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
@@ -290,7 +292,7 @@ class OrderCore extends ObjectModel
/* Does NOT delete a product but "cancel" it (which means return/refund/delete it depending of the case) */
public function deleteProduct($order, $orderDetail, $quantity)
{
if (!(int)($this->getCurrentState()))
if (!(int)($this->getCurrentState()) || !validate::isLoadedObject($orderDetail))
return false;
if ($this->hasBeenDelivered())
@@ -1146,13 +1148,14 @@ class OrderCore extends ObjectModel
if ($use_existing_payment)
{
$id_order_payments = Db::getInstance()->executeS('
SELECT op.id_order_payment
SELECT DISTINCT op.id_order_payment
FROM `'._DB_PREFIX_.'order_payment` op
INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.reference = op.order_reference)
LEFT JOIN `'._DB_PREFIX_.'order_invoice_payment` oip ON (oip.id_order_payment = op.id_order_payment)
WHERE oip.id_order_payment IS NULL AND o.id_order = '.(int)$order_invoice->id_order);
WHERE (oip.id_order != '.(int)$order_invoice->id_order.' OR oip.id_order IS NULL) AND o.id_order = '.(int)$order_invoice->id_order);
if (count($id_order_payments))
{
foreach ($id_order_payments as $order_payment)
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
@@ -1160,6 +1163,9 @@ class OrderCore extends ObjectModel
`id_order_invoice` = '.(int)$order_invoice->id.',
`id_order_payment` = '.(int)$order_payment['id_order_payment'].',
`id_order` = '.(int)$order_invoice->id_order);
// Clear cache
Cache::clean('order_invoice_paid_*');
}
}
// Update order cart rule
@@ -1237,12 +1243,11 @@ class OrderCore extends ObjectModel
public function getTotalWeight()
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT SUM(product_weight * product_quantity) weight
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(product_weight * product_quantity)
FROM '._DB_PREFIX_.'order_detail
WHERE id_order = '.(int)($this->id));
return (float)($result['weight']);
return (float)($result);
}
/**
@@ -1466,6 +1471,9 @@ class OrderCore extends ObjectModel
$res = Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
VALUES('.(int)$order_invoice->id.', '.(int)$order_payment->id.', '.(int)$this->id.')');
// Clear cache
Cache::clean('order_invoice_paid_*');
}
return $res;
@@ -1881,5 +1889,21 @@ class OrderCore extends ObjectModel
$order = new Order($id_order);
return $order->getUniqReference();
}
/**
* Return a unique reference like : GWJTHMZUN#2
*
* With multishipping, order reference are the same for all orders made with the same cart
* in this case this method suffix the order reference by a # and the order number
*
* @since 1.5.5.0
*/
public function getIdOrderCarrier()
{
return (int)Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `'._DB_PREFIX_.'order_carrier`
WHERE `id_order` = '.(int)$this->id);
}
}
+1 -1
View File
@@ -508,7 +508,7 @@ class OrderDetailCore extends ObjectModel
$this->purchase_supplier_price = (float)$product['wholesale_price'];
if ($product['id_supplier'] > 0)
$this->purchase_supplier_price = (float)ProductSupplier::getProductPrice((int)$product['id_supplier'], $product['id_product'], $product['id_product_attribute']);
$this->purchase_supplier_price = (float)ProductSupplier::getProductPrice((int)$product['id_supplier'], $product['id_product'], $product['id_product_attribute'], true);
$this->setSpecificPrice($order, $product);
+8 -4
View File
@@ -142,7 +142,7 @@ class OrderHistoryCore extends ObjectModel
$links .= '&nbsp;'.Tools::htmlentitiesUTF8(sprintf(Tools::displayError('downloadable %d time(s)'), (int)$product['downloadable']));
$links .= '</li>';
}
$links .= '<ul>';
$links .= '</ul>';
$data = array(
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
@@ -161,6 +161,9 @@ class OrderHistoryCore extends ObjectModel
$manager = null;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
$manager = StockManagerFactory::getManager();
$errorOrCanceledStatuses = array(Configuration::get('PS_OS_ERROR'), Configuration::get('PS_OS_CANCELED'));
// foreach products of the order
if (Validate::isLoadedObject($old_os))
foreach ($order->getProductsDetail() as $product)
@@ -171,7 +174,7 @@ class OrderHistoryCore extends ObjectModel
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
// @since 1.5.0 - Stock Management
if (!Pack::isPack($product['product_id']) &&
($old_os->id == Configuration::get('PS_OS_ERROR') || $old_os->id == Configuration::get('PS_OS_CANCELED')) &&
in_array($old_os->id, $errorOrCanceledStatuses) &&
!StockAvailable::dependsOnStock($product['id_product'], (int)$order->id_shop))
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop);
}
@@ -182,13 +185,14 @@ class OrderHistoryCore extends ObjectModel
// @since 1.5.0 - Stock Management
if (!Pack::isPack($product['product_id']) &&
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
in_array($new_os->id, $errorOrCanceledStatuses) &&
!StockAvailable::dependsOnStock($product['id_product']))
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
}
// if waiting for payment => payment error/canceled
elseif (!$new_os->logable && !$old_os->logable &&
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
in_array($new_os->id, $errorOrCanceledStatuses) &&
!in_array($old_os->id, $errorOrCanceledStatuses) &&
!StockAvailable::dependsOnStock($product['id_product']))
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
// @since 1.5.0 : if the order is being shipped and this products uses the advanced stock management :
+6 -4
View File
@@ -522,14 +522,16 @@ class OrderInvoiceCore extends ObjectModel
*/
public function getTotalPaid()
{
if (!array_key_exists($this->id, self::$_total_paid_cache))
$cache_id = 'order_invoice_paid_'.(int)$this->id;
if (!Cache::isStored($cache_id))
{
self::$_total_paid_cache[$this->id] = 0;
$amount = 0;
$payments = OrderPayment::getByInvoiceId($this->id);
foreach ($payments as $payment)
self::$_total_paid_cache[$this->id] += $payment->amount;
$amount += $payment->amount;
Cache::store($cache_id, $amount);
}
return self::$_total_paid_cache[$this->id];
return Cache::retrieve($cache_id);
}
/**
+6 -3
View File
@@ -60,13 +60,16 @@ class HTMLTemplateDeliverySlipCore extends HTMLTemplate
$invoice_address = new Address((int)$this->order->id_address_invoice);
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
}
$carrier = new Carrier($this->order->id_carrier);
$carrier->name = ($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name);
$this->smarty->assign(array(
'order' => $this->order,
'order_details' => $this->order_invoice->getProducts(),
'delivery_address' => $formatted_delivery_address,
'invoice_address' => $formatted_invoice_address,
'order_invoice' => $this->order_invoice
'order_invoice' => $this->order_invoice,
'carrier' => $carrier
));
return $this->smarty->fetch($this->getTemplate('delivery-slip'));
@@ -87,7 +90,7 @@ class HTMLTemplateDeliverySlipCore extends HTMLTemplate
*/
public function getFilename()
{
return Configuration::get('PS_DELIVERY_PREFIX').sprintf('%06d', $this->order->invoice_number).'.pdf';
return Configuration::get('PS_DELIVERY_PREFIX', Context::getContext()->language->id, null, $this->order->id_shop).sprintf('%06d', $this->order->invoice_number).'.pdf';
}
}
+5 -3
View File
@@ -89,7 +89,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$tax_exempt = Configuration::get('VATNUMBER_MANAGEMENT')
&& !empty($address->vat_number)
&& $address->id_country != Configuration::get('VATNUMBER_COUNTRY');
$carrier = new Carrier($this->order->id_carrier);
$this->smarty->assign(array(
'tax_exempt' => $tax_exempt,
'use_one_after_another_method' => $this->order_invoice->useOneAfterAnotherTaxComputationMethod(),
@@ -98,7 +99,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
'ecotax_tax_breakdown' => $this->order_invoice->getEcoTaxTaxesBreakdown(),
'wrapping_tax_breakdown' => $this->order_invoice->getWrappingTaxesBreakdown(),
'order' => $this->order,
'order_invoice' => $this->order_invoice
'order_invoice' => $this->order_invoice,
'carrier' => $carrier
));
return $this->smarty->fetch($this->getTemplate('invoice.tax-tab'));
@@ -137,7 +139,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
*/
public function getFilename()
{
return Configuration::get('PS_INVOICE_PREFIX').sprintf('%06d', $this->order_invoice->number).'.pdf';
return Configuration::get('PS_INVOICE_PREFIX', Context::getContext()->language->id, null, $this->order->id_shop).sprintf('%06d', $this->order_invoice->number).'.pdf';
}
}
+12 -1
View File
@@ -153,4 +153,15 @@ class ShopGroupCore extends ObjectModel
return false;
}
}
public function shopNameExists($name, $id_shop = false)
{
return Db::getInstance()->getValue('
SELECT id_shop
FROM '._DB_PREFIX_.'shop
WHERE name = "'.pSQL($name).'"
AND id_shop_group = '.(int)$this->id.'
'.($id_shop ? 'AND id_shop != '.(int)$id_shop : '')
);
}
}
+21 -27
View File
@@ -34,8 +34,8 @@ class ShopUrlCore extends ObjectModel
public $main;
public $active;
protected static $main_domain = null;
protected static $main_domain_ssl = null;
protected static $main_domain = array();
protected static $main_domain_ssl = array();
/**
* @see ObjectModel::$definition
@@ -143,41 +143,35 @@ class ShopUrlCore extends ObjectModel
return Db::getInstance()->getValue($sql);
}
public static function getMainShopDomain($id_shop = null)
{
if (!self::$main_domain || $id_shop !== null)
self::$main_domain = Db::getInstance()->getValue('SELECT domain
FROM '._DB_PREFIX_.'shop_url
WHERE main=1 AND id_shop = '.($id_shop !== null ? (int)$id_shop : Context::getContext()->shop->id));
return self::$main_domain;
}
public static function cacheMainDomainForShop($id_shop)
{
if (!Validate::isUnsignedId($id_shop))
return false;
ShopUrl::getMainShopDomain($id_shop);
ShopUrl::getMainShopDomainSSL($id_shop);
if (!isset(self::$main_domain_ssl[(int)$id_shop]) || !isset(self::$main_domain[(int)$id_shop]))
{
$row = Db::getInstance()->getRow('
SELECT domain, domain_ssl
FROM '._DB_PREFIX_.'shop_url
WHERE main = 1
AND id_shop = '.($id_shop !== null ? (int)$id_shop : Context::getContext()->shop->id));
self::$main_domain[(int)$id_shop] = $row['domain'];
self::$main_domain_ssl[(int)$id_shop] = $row['domain_ssl'];
}
}
public static function resetMainDomainCache()
{
self::$main_domain = null;
self::$main_domain_ssl = null;
self::$main_domain = array();
self::$main_domain_ssl = array();
}
public static function getMainShopDomain($id_shop = null)
{
ShopUrl::cacheMainDomainForShop($id_shop);
return self::$main_domain[(int)$id_shop];
}
public static function getMainShopDomainSSL($id_shop = null)
{
if (!self::$main_domain_ssl || $id_shop !== null)
{
$sql = 'SELECT domain_ssl
FROM '._DB_PREFIX_.'shop_url
WHERE main = 1
AND id_shop = '.($id_shop !== null ? (int)$id_shop : Context::getContext()->shop->id);
self::$main_domain_ssl = Db::getInstance()->getValue($sql);
}
return self::$main_domain_ssl;
ShopUrl::cacheMainDomainForShop($id_shop);
return self::$main_domain_ssl[(int)$id_shop];
}
}
+1 -1
View File
@@ -236,7 +236,7 @@ class StockMvtCore extends ObjectModel
$query->innerJoin('stock', 's', 's.id_stock = sm.id_stock');
$query->innerJoin('warehouse', 'w', 'w.id_warehouse = s.id_warehouse');
$query->where('sm.sign = 1');
$query->where('s.id_product = '.(int)$id_product.' AND s.id_product_attribute = '.(int)$id_product_attribute);
$query->where('s.id_product = '.(int)$id_product.' OR s.id_product_attribute = '.(int)$id_product_attribute);
$query->orderBy('date_add DESC');
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
+17 -8
View File
@@ -53,13 +53,22 @@ class TaxRulesGroupCore extends ObjectModel
protected static $_taxes = array();
public static function getTaxRulesGroups($only_active = true)
public static function getTaxRulesGroups($only_active = true, $multiShop = false)
{
return Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'tax_rules_group` g'
.($only_active ? ' WHERE g.`active` = 1' : '').'
ORDER BY name ASC');
if ((bool)$multiShop) {
return Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'tax_rules_group` g'
.Shop::addSqlAssociation('tax_rules_group', 'g')
.($only_active ? ' WHERE g.`active` = 1' : '').'
ORDER BY name ASC');
} else {
return Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'tax_rules_group` g'
.($only_active ? ' WHERE g.`active` = 1' : '').'
ORDER BY name ASC');
}
}
/**
@@ -113,11 +122,11 @@ class TaxRulesGroupCore extends ObjectModel
);
}
public function hasUniqueTaxRuleForCountry($id_country, $id_state)
public function hasUniqueTaxRuleForCountry($id_country, $id_state, $id_tax_rule = false)
{
$rules = TaxRule::getTaxRulesByGroupId((int)Context::getContext()->language->id, (int)$this->id);
foreach ($rules as $rule)
if ($rule['id_country'] == $id_country && $id_state == $rule['id_state'] && !$rule['behavior'])
if ($rule['id_country'] == $id_country && $id_state == $rule['id_state'] && !$rule['behavior'] && (int)$id_tax_rule != $rule['id_tax_rule'])
return true;
return false;
+21 -6
View File
@@ -47,6 +47,8 @@ class WebserviceOutputBuilderCore
protected $virtualFields = array();
protected $statusInt;
protected $wsParamOverrides;
protected static $_cache_ws_parameters = array();
// Header properties
protected $headerParams = array(
@@ -283,7 +285,7 @@ class WebserviceOutputBuilderCore
if (is_null($this->wsResource))
throw new WebserviceException ('You must set web service resource for get the resources list.', array(82, 500));
$output = '';
$more_attr = array('shop_name' => htmlentities(Configuration::get('PS_SHOP_NAME')));
$more_attr = array('shop_name' => htmlspecialchars(Configuration::get('PS_SHOP_NAME')));
$output .= $this->objectRender->renderNodeHeader('api', array(), $more_attr);
foreach ($this->wsResource as $resourceName => $resource)
{
@@ -359,7 +361,11 @@ class WebserviceOutputBuilderCore
$type_of_view = self::VIEW_DETAILS;
}
$ws_params = $objects['empty']->getWebserviceParameters();
$class = get_class($objects['empty']);
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $objects['empty']->getWebserviceParameters();
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
foreach ($this->wsParamOverrides AS $p)
{
$object = $p['object'];
@@ -376,7 +382,7 @@ class WebserviceOutputBuilderCore
{
if ($key !== 'empty')
{
if ($this->fieldsToDisplay === 'minimum')
if ($this->fieldsToDisplay === 'minimum')
$output .= $this->renderEntityMinimum($object, $depth);
else
$output .= $this->renderEntity($object, $depth);
@@ -406,7 +412,11 @@ class WebserviceOutputBuilderCore
*/
public function renderEntityMinimum($object, $depth)
{
$ws_params = $object->getWebserviceParameters();
$class = get_class($object);
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $object->getWebserviceParameters();
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
$more_attr['id'] = $object->id;
$more_attr['xlink_resource'] = $this->wsUrl.$ws_params['objectsNodeName'].'/'.$object->id;
$output = $this->setIndent($depth).$this->objectRender->renderNodeHeader($ws_params['objectNodeName'], $ws_params, $more_attr, false);
@@ -446,7 +456,12 @@ class WebserviceOutputBuilderCore
public function renderEntity($object, $depth)
{
$output = '';
$ws_params = $object->getWebserviceParameters();
$class = get_class($object);
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $object->getWebserviceParameters();
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
foreach ($this->wsParamOverrides AS $p)
{
$o = $p['object'];
@@ -792,4 +807,4 @@ class WebserviceOutputBuilderCore
{
$this->fieldsToDisplay = $fields;
}
}
}
+15 -6
View File
@@ -530,9 +530,10 @@ class WebserviceRequestCore
}
}
}
return $this->returnOutput();
$return = $this->returnOutput();
unset($webservice_call);
unset ($display_errors);
unset($display_errors);
return $return;
}
protected function webserviceChecks()
@@ -1158,6 +1159,7 @@ class WebserviceRequestCore
$sorts = array($this->urlFragments['sort']);
$sql_sort .= ' ORDER BY ';
foreach ($sorts as $sort)
{
$delimiterPosition = strrpos($sort, '_');
@@ -1219,15 +1221,13 @@ class WebserviceRequestCore
return $filters;
}
public function getFilteredObjectList()
{
$objects = array();
$filters = $this->manageFilters();
/* If we only need to display the synopsis, analyzing the first row is sufficient */
if (isset($this->urlFragments['schema']) && $this->urlFragments['schema'] == 'synopsis')
if (isset($this->urlFragments['schema']) && in_array($this->urlFragments['schema'], array('blank', 'synopsis')))
$filters = array('sql_join' => '', 'sql_filter' => '', 'sql_sort' => '', 'sql_limit' => ' LIMIT 1');
$this->resourceConfiguration['retrieveData']['params'][] = $filters['sql_join'];
@@ -1241,7 +1241,16 @@ class WebserviceRequestCore
if ($sqlObjects)
{
foreach ($sqlObjects as $sqlObject)
$objects[] = new $this->resourceConfiguration['retrieveData']['className']((int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']]);
{
if ($this->fieldsToDisplay == 'minimum')
{
$obj = new $this->resourceConfiguration['retrieveData']['className']();
$obj->id = (int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']];
$objects[] = $obj;
}
else
$objects[] = new $this->resourceConfiguration['retrieveData']['className']((int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']]);
}
return $objects;
}
}
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=cms'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=cms'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+15 -1
View File
@@ -90,7 +90,21 @@ if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
$context = Context::getContext();
/* Initialize the current Shop */
$context->shop = Shop::initialize();
try
{
$context->shop = Shop::initialize();
}
catch(Exception $e)
{
header('HTTP/1.1 503 temporarily overloaded');
define('_PS_SMARTY_DIR_', _PS_TOOL_DIR_.'smarty/');
require_once(_PS_SMARTY_DIR_.'Smarty.class.php');
$context->smarty = new Smarty();
$context->smarty->display('error500.html');
exit;
}
define('_THEME_NAME_', $context->shop->getTheme());
define('__PS_BASE_URI__', $context->shop->getBaseURI());
+1 -1
View File
@@ -36,7 +36,7 @@ function smartyTranslate($params, &$smarty)
{
$htmlentities = !isset($params['js']);
$pdf = isset($params['pdf']);
$addslashes = isset($params['slashes']);
$addslashes = (isset($params['slashes']) || isset($params['js']));
$sprintf = isset($params['sprintf']) ? $params['sprintf'] : false;
if ($pdf)

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