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

This commit is contained in:
djfm
2013-07-22 08:25:26 +00:00
61 changed files with 454 additions and 253 deletions

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>

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;

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>';
}

View File

@@ -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">
@@ -313,12 +313,13 @@
{
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(/[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){
@@ -326,8 +327,10 @@
line = line.replace('id="' + key + '' + id + '"','id="' + key + '' + id + '" checked=checked');
});
}
$("#imageList").append(line);
}
$('.fancybox').fancybox();
});
{/literal}

View File

@@ -234,10 +234,10 @@
{/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">
{$fields_value.image}
<p align="center">{l s='File size'} {$fields_value.size}kb</p>
{$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'}
</a>

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),
),
);

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.')

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),

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);

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 = '';

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,19 +113,26 @@ 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 `ps_hook_alias` ha
INNER JOIN `ps_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 Cache::retrieve($cache_id);
return (isset($hook_ids[$hook_name]) ? $hook_ids[$hook_name] : false);
}
/**

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(
@@ -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;

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

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();
}
}
/**
@@ -901,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
@@ -939,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;
@@ -969,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)
@@ -1015,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(
@@ -1125,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();
@@ -1152,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)
{

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;

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),
),
@@ -2699,8 +2699,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);
}

View File

@@ -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))

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`

View File

@@ -2430,7 +2430,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';
@@ -2516,6 +2516,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;
}
}
/**

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;
}
/**

View File

@@ -803,7 +803,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)$this->object->id, true, (int)$this->context->employee->id);
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.').
@@ -3013,4 +3013,4 @@ class AdminControllerCore extends Controller
return $return;
}
}
}

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;

View File

@@ -25,8 +25,6 @@
*/
/**
* This class is currently only here for tests
*
* @since 1.5.0
*/
class DbPDOCore extends Db

View File

@@ -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));

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;
}
}
@@ -1350,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'));
}
@@ -1373,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');
}
@@ -1511,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);
@@ -1525,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)

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,

View File

@@ -143,22 +143,21 @@ 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 (!self::$main_domain_ssl || !self::$main_domain || $id_shop !== null)
{
$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 = $row['domain'];
self::$main_domain_ssl = $row['domain_ssl'];
}
}
public static function resetMainDomainCache()
@@ -167,17 +166,15 @@ class ShopUrlCore extends ObjectModel
self::$main_domain_ssl = null;
}
public static function getMainShopDomain($id_shop = null)
{
ShopUrl::cacheMainDomainForShop($id_shop);
return self::$main_domain;
}
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);
}
ShopUrl::cacheMainDomainForShop($id_shop);
return self::$main_domain_ssl;
}
}

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');
}
}
/**

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());

View File

@@ -231,7 +231,7 @@ class AdminCategoriesControllerCore extends AdminController
{
if (empty($this->display))
{
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE'))
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops()) > 1)
$this->toolbar_btn['new-url'] = array(
'href' => self::$currentIndex.'&amp;add'.$this->table.'root&amp;token='.$this->token,
'desc' => $this->l('Add new root category')

View File

@@ -433,10 +433,10 @@ class AdminCountriesControllerCore extends AdminController
public function processStatus()
{
$return = parent::processStatus();
parent::processStatus();
if (Validate::isLoadedObject($object = $this->loadObject()) && $object->active == 1)
$return &= Country::addModuleRestrictions(array(), array(array('id_country' => $object->id)), array());
return $return;
return Country::addModuleRestrictions(array(), array(array('id_country' => $object->id)), array());
return false;
}
public function processBulkStatusSelection($way)

View File

@@ -38,7 +38,7 @@ class AdminCurrenciesControllerCore extends AdminController
'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 80),
'iso_code_num' => array('title' => $this->l('ISO code number'), 'align' => 'center', 'width' => 120),
'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false),
'conversion_rate' => array('title' => $this->l('Exchange rate'), 'type' => 'float', 'align' => 'center', 'width' => 130, 'search' => false),
'conversion_rate' => array('title' => $this->l('Exchange rate'), 'type' => 'float', 'align' => 'center', 'width' => 130, 'search' => false, 'filter_key' => 'currency_shop!conversion_rate'),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
);

View File

@@ -377,12 +377,13 @@ class AdminHomeControllerCore extends AdminController
$chart = new Chart();
$chart->getCurve(1)->setType('bars');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT total_paid / conversion_rate as total_converted, left(invoice_date, 10) as invoice_date
SELECT SUM(total_paid / conversion_rate) as total_converted, left(invoice_date, 10) as invoice_date
FROM '._DB_PREFIX_.'orders o
WHERE valid = 1
AND total_paid > 0
AND invoice_date BETWEEN \''.date('Y-m-d', strtotime('-7 DAYS', time())).' 00:00:00\' AND \''.date('Y-m-d H:i:s').'\'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER).'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER).'
GROUP BY DATE(invoice_date)
');
foreach ($result as $row)
$chart->getCurve(1)->setPoint(strtotime($row['invoice_date'].' 02:00:00'), $row['total_converted']);

View File

@@ -375,6 +375,7 @@ class AdminImagesControllerCore extends AdminController
|| !Configuration::updateValue('PS_PNG_QUALITY', Tools::getValue('PS_PNG_QUALITY')))
$this->errors[] = Tools::displayError('Unknown error.');
else
$this->confirmations[] = $this->_conf[6];
return parent::postProcess();
}
else

View File

@@ -511,7 +511,7 @@ class AdminManufacturersControllerCore extends AdminController
$this->fields_value = array(
'name' => Manufacturer::getNameById($address->id_manufacturer),
'alias' => 'manufacturer',
'id_country' => Configuration::get('PS_COUNTRY_DEFAULT')
'id_country' => $address->id_country
);
$this->initToolbar();
@@ -671,6 +671,8 @@ class AdminManufacturersControllerCore extends AdminController
if (Tools::isSubmit('editaddresses'))
$this->display = 'editaddresses';
else if (Tools::isSubmit('updateaddress'))
$this->display = 'editaddresses';
else if (Tools::isSubmit('addaddress'))
$this->display = 'addaddress';
else if (Tools::isSubmit('submitAddaddress'))

View File

@@ -95,6 +95,14 @@ class AdminPreferencesControllerCore extends AdminController
'default' => '0',
'visibility' => Shop::CONTEXT_ALL
),
'PS_ALLOW_HTML_IFRAME' => array(
'title' => $this->l('Allow iframes on html fields'),
'desc' => $this->l('Allow iframes on fields like product description. We recommend that you leave this option disabled'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'default' => '0'
),
'PS_PRICE_ROUND_MODE' => array(
'title' => $this->l('Round mode'),
'desc' => $this->l('You can choose how to round prices: Always round superior, always round inferior or classic rounding.'),

View File

@@ -2058,17 +2058,28 @@ class AdminProductsControllerCore extends AdminController
// Check fields validity
foreach ($rules['validate'] as $field => $function)
if ($this->isProductFieldUpdated($field) && ($value = Tools::getValue($field)))
if (!Validate::$function($value))
{
$res = true;
if (Tools::strtolower($function) == 'iscleanhtml')
{
if (!Validate::$function($value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
$res = false;
}
else
if (!Validate::$function($value))
$res = false;
if (!$res)
$this->errors[] = sprintf(
Tools::displayError('The %s field is invalid.'),
call_user_func(array($className, 'displayFieldName'), $field, $className)
);
}
// Check multilingual fields validity
foreach ($rules['validateLang'] as $fieldLang => $function)
foreach ($languages as $language)
if ($this->isProductFieldUpdated('description_short', $language['id_lang']) && ($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])))
if (!Validate::$function($value))
if (!Validate::$function($value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
$this->errors[] = sprintf(
Tools::displayError('The %1$s field (%2$s) is invalid.'),
call_user_func(array($className, 'displayFieldName'), $fieldLang, $className),
@@ -2543,7 +2554,7 @@ class AdminProductsControllerCore extends AdminController
$this->tpl_form_vars['currentIndex'] = self::$currentIndex;
$this->tpl_form_vars['display_multishop_checkboxes'] = (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP && $this->display == 'edit');
$this->fields_form = array('');
$this->display = 'edit';
$this->tpl_form_vars['token'] = $this->token;
$this->tpl_form_vars['combinationImagesJs'] = $this->getCombinationImagesJs();
$this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int)Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
@@ -2573,8 +2584,8 @@ class AdminProductsControllerCore extends AdminController
$this->tpl_form_vars['upload_max_filesize'] = $upload_max_filesize;
$this->tpl_form_vars['country_display_tax_label'] = $this->context->country->display_tax_label;
$this->tpl_form_vars['has_combinations'] = $this->object->hasAttributes();
$this->product_exists_in_shop = true;
if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id))
{
$this->product_exists_in_shop = false;
@@ -2602,12 +2613,14 @@ class AdminProductsControllerCore extends AdminController
$this->initPack($this->object);
$this->{'initForm'.$this->tab_display}($this->object);
$this->tpl_form_vars['product'] = $this->object;
if ($this->ajax)
if (!isset($this->tpl_form_vars['custom_form']))
throw new PrestaShopException('custom_form empty for action '.$this->tab_display);
else
return $this->tpl_form_vars['custom_form'];
}
$parent = parent::renderForm();
$this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
return $parent;
@@ -2999,7 +3012,7 @@ class AdminProductsControllerCore extends AdminController
$data->assign(array(
'link' => $this->context->link,
'currency' => $currency = $this->context->currency,
'tax_rules_groups' => TaxRulesGroup::getTaxRulesGroups(true),
'tax_rules_groups' => TaxRulesGroup::getTaxRulesGroups(true, true),
'taxesRatesByGroup' => TaxRulesGroup::getAssociatedTaxRatesByIdCountry($this->context->country->id),
'ecotaxTaxRate' => Tax::getProductEcotaxRate(),
'tax_exclude_taxe_option' => Tax::excludeTaxeOption(),
@@ -3490,7 +3503,7 @@ class AdminProductsControllerCore extends AdminController
$data->assign('languages', $this->_languages);
$data->assign('currency', $currency);
$this->object = $product;
$this->display = 'edit';
//$this->display = 'edit';
$data->assign('product_name_redirected', Product::getProductName((int)$product->id_product_redirected, null, (int)$this->context->language->id));
/*
* Form for adding a virtual product like software, mp3, etc...
@@ -3646,12 +3659,15 @@ class AdminProductsControllerCore extends AdminController
$current_shop_id = (int)$this->context->shop->id;
else
$current_shop_id = 0;
$languages = Language::getLanguages(true);
$data->assign(array(
'countImages' => $count_images,
'id_product' => (int)Tools::getValue('id_product'),
'id_category_default' => (int)$this->_category->id,
'images' => $images,
'iso_lang' => $languages[0]['iso_code'],
'token' => $this->token,
'table' => $this->table,
'max_image_size' => $this->max_image_size / 1024 / 1024,

View File

@@ -181,11 +181,13 @@ class AdminStockInstantStateControllerCore extends AdminController
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
if (Tools::isSubmit('csv') && (int)Tools::getValue('id_warehouse') != -1)
if ((Tools::isSubmit('csv_quantities') || Tools::isSubmit('csv_prices')) &&
(int)Tools::getValue('id_warehouse') != -1)
$limit = false;
$order_by_valuation = false;
$order_by_real_quantity = false;
if ($this->context->cookie->{$this->table.'Orderby'} == 'valuation')
{
unset($this->context->cookie->{$this->table.'Orderby'});
@@ -200,6 +202,7 @@ class AdminStockInstantStateControllerCore extends AdminController
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
$nb_items = count($this->_list);
for ($i = 0; $i < $nb_items; ++$i)
{
$item = &$this->_list[$i];

View File

@@ -296,8 +296,12 @@ class AdminStoresControllerCore extends AdminController
if (!($obj = $this->loadObject(true)))
return;
if (file_exists(_PS_TMP_IMG_DIR_.$this->table.'_'.(int)$obj->id.'.'.$this->imageType)) {
@unlink(_PS_TMP_IMG_DIR_.$this->table.'_'.(int)$obj->id.'.'.$this->imageType);
}
$image = ImageManager::thumbnail(_PS_STORE_IMG_DIR_.'/'.$obj->id.'.jpg', $this->table.'_'.(int)$obj->id.'.'.$this->imageType, 350, $this->imageType, true);
$image = ImageManager::thumbnail(_PS_STORE_IMG_DIR_.DIRECTORY_SEPARATOR.$obj->id.'.jpg', $this->table.'_'.(int)$obj->id.'.'.$this->imageType, 350, $this->imageType, true, true);
$days = array();
$days[1] = $this->l('Monday');
@@ -316,7 +320,7 @@ class AdminStoresControllerCore extends AdminController
'latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'),
'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'),
'image' => $image ? $image : false,
'size' => $image ? filesize(_PS_STORE_IMG_DIR_.'/'.$obj->id.'.jpg') / 1000 : false,
'size' => $image ? filesize(_PS_STORE_IMG_DIR_.DIRECTORY_SEPARATOR.$obj->id.'.jpg') / 1000 : false,
'days' => $days,
'hours' => isset($hours_unserialized) ? $hours_unserialized : false
);

View File

@@ -77,8 +77,23 @@ class AdminTagsControllerCore extends AdminController
public function postProcess()
{
if ($this->tabAccess['edit'] === '1' && Tools::getValue('submitAdd'.$this->table))
{
if (($id = (int)Tools::getValue($this->identifier)) && ($obj = new $this->className($id)) && Validate::isLoadedObject($obj))
{
$previousProducts = $obj->getProducts();
$removedProducts = array();
foreach ($previousProducts as $product)
if (!in_array($product['id_product'], $_POST['products']))
$removedProducts[] = $product['id_product'];
if (Configuration::get('PS_SEARCH_INDEXATION'))
Search::removeProductsSearchIndex($removedProducts);
$obj->setProducts($_POST['products']);
}
}
return parent::postProcess();
}

View File

@@ -614,7 +614,7 @@ class AdminThemesControllerCore extends AdminController
$ext = ($field_name == 'PS_STORES_ICON') ? '.gif' : '.jpg';
$logo_name = $logo_prefix.'-'.(int)$id_shop.$ext;
if (Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL || $id_shop == 0 || Shop::isFeatureActive()==false)
if (Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL || $id_shop == 0 || Shop::isFeatureActive() == false)
$logo_name = $logo_prefix.$ext;
if ($field_name == 'PS_STORES_ICON')

View File

@@ -353,13 +353,15 @@ class AdminTranslationsControllerCore extends AdminController
$items = Language::getFilesList($from_lang, $from_theme, $to_lang, $to_theme, false, false, true);
foreach ($items as $source => $dest)
{
$bool &= $this->checkDirAndCreate($dest);
$bool &= @copy($source, $dest);
if (strpos($dest, 'modules') && basename($source) === $from_lang.'.php' && $bool !== false)
$bool &= $this->changeModulesKeyTranslation($dest, $from_theme, $to_theme);
if (!$this->checkDirAndCreate($dest))
$this->errors[] = sprintf($this->l('Impossible to create the directory "%s".'), $dest);
elseif (!copy($source, $dest))
$this->errors[] = sprintf($this->l('Impossible to copy "%s" to "%s".'), $source, $dest);
elseif (strpos($dest, 'modules') && basename($source) === $from_lang.'.php' && $bool !== false)
if (!$this->changeModulesKeyTranslation($dest, $from_theme, $to_theme))
$this->errors[] = sprintf($this->l('Impossible to translate "$dest".'), $dest);
}
if ($bool)
if (!count($this->errors))
$this->redirect(false, 14);
$this->errors[] = $this->l('A part of the data has been copied but some of the language files could not be found.');
}
@@ -1072,7 +1074,7 @@ class AdminTranslationsControllerCore extends AdminController
if ($type_file == 'php')
$regex = '/this->l\(\''._PS_TRANS_PATTERN_.'\'[\)|\,]/U';
else if ($type_file == 'specific')
$regex = '/translate\(\''._PS_TRANS_PATTERN_.'\'\)/U';
$regex = '/Translate::getAdminTranslation\(\''._PS_TRANS_PATTERN_.'\'\)/U';
else
$regex = '/\{l\s*s\s*=[\'\"]'._PS_TRANS_PATTERN_.'[\'\"](\s*sprintf=.*)?(\s*js=1)?(\s*slashes=1)?\s*\}/U';
break;

View File

@@ -37,15 +37,8 @@ class ContactControllerCore extends FrontController
{
if (Tools::isSubmit('submitMessage'))
{
$fileAttachment = null;
if (isset($_FILES['fileUpload']['name']) && !empty($_FILES['fileUpload']['name']) && !empty($_FILES['fileUpload']['tmp_name']))
{
$extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
$filename = uniqid().substr($_FILES['fileUpload']['name'], -5);
$fileAttachment['content'] = file_get_contents($_FILES['fileUpload']['tmp_name']);
$fileAttachment['name'] = $_FILES['fileUpload']['name'];
$fileAttachment['mime'] = $_FILES['fileUpload']['type'];
}
$extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
$fileAttachment = Tools::fileAttachment('fileUpload');
$message = Tools::getValue('message'); // Html entities is not usefull, iscleanHtml check there is no bad html tags.
if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from))
$this->errors[] = Tools::displayError('Invalid email address.');
@@ -55,9 +48,9 @@ class ContactControllerCore extends FrontController
$this->errors[] = Tools::displayError('Invalid message');
else if (!($id_contact = (int)(Tools::getValue('id_contact'))) || !(Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))))
$this->errors[] = Tools::displayError('Please select a subject from the list provided. ');
else if (!empty($_FILES['fileUpload']['name']) && $_FILES['fileUpload']['error'] != 0)
else if (!empty($fileAttachment['name']) && $fileAttachment['error'] != 0)
$this->errors[] = Tools::displayError('An error occurred during the file-upload process.');
else if (!empty($_FILES['fileUpload']['name']) && !in_array(substr(Tools::strtolower($_FILES['fileUpload']['name']), -4), $extension) && !in_array(substr(Tools::strtolower($_FILES['fileUpload']['name']), -5), $extension))
else if (!empty($fileAttachment['name']) && !in_array( Tools::strtolower(substr($fileAttachment['name'], -4)), $extension) && !in_array( Tools::strtolower(substr($fileAttachment['name'], -5)), $extension))
$this->errors[] = Tools::displayError('Bad file extension');
else
{
@@ -152,8 +145,8 @@ class ContactControllerCore extends FrontController
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = Tools::htmlentitiesUTF8($message);
if (isset($filename) && rename($_FILES['fileUpload']['tmp_name'], _PS_MODULE_DIR_.'../upload/'.$filename))
$cm->file_name = $filename;
if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename'])))
$cm->file_name = $fileAttachment['rename'];
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!$cm->add())
@@ -173,8 +166,8 @@ class ContactControllerCore extends FrontController
'{product_name}' => '',
);
if (isset($filename))
$var_list['{attached_file}'] = $_FILES['fileUpload']['name'];
if (isset($fileAttachment['name']))
$var_list['{attached_file}'] = $fileAttachment['name'];
$id_order = (int)Tools::getValue('id_order');
@@ -197,10 +190,6 @@ class ContactControllerCore extends FrontController
$var_list['{product_name}'] = $product->name[Context::getContext()->language->id];
}
if (empty($contact->email))
Mail::Send($this->context->language->id, 'contact_form', ((isset($ct) && Validate::isLoadedObject($ct)) ? sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token) : Mail::l('Your message has been correctly sent')), $var_list, $from, null, null, null, $fileAttachment);
else
@@ -296,5 +285,4 @@ class ContactControllerCore extends FrontController
$this->context->smarty->assign('orderedProductList', $products);
}
}
}
}

View File

@@ -113,6 +113,9 @@ class ManufacturerControllerCore extends FrontController
{
$data = Manufacturer::getManufacturers(true, $this->context->language->id, true, false, false, false);
$nbProducts = count($data);
$this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
$this->p = abs((int)(Tools::getValue('p', 1)));
$data = Manufacturer::getManufacturers(true, $this->context->language->id, true, $this->p, $this->n, false);
$this->pagination($nbProducts);
foreach ($data as &$item)
@@ -129,4 +132,4 @@ class ManufacturerControllerCore extends FrontController
else
$this->context->smarty->assign('nbManufacturers', 0);
}
}
}

View File

@@ -158,7 +158,7 @@ class ProductControllerCore extends FrontController
$this->category = new Category($regs[5], (int)$this->context->cookie->id_lang);
}
}
else
if ( ! isset($this->category))
// Set default product category
$this->category = new Category($this->product->id_category_default, (int)$this->context->cookie->id_lang);
}

View File

@@ -567,6 +567,12 @@ select optgroup option {
background: url(../img/admin/warning.gif) no-repeat 0 0;
}
#blockNewVersionCheck .warn h3 {
padding: 0 0 0 5px;
margin: 0px;
background: none;
}
#content .error h3 {
padding: 0 0 0 20px;
background: url(../img/admin/warning.gif) no-repeat 0 0;

View File

@@ -86,7 +86,7 @@
<name>displayCustomerAccount</name><title>Customer account displayed in Front Office</title><description>This hook displays new elements on the customer account page</description>
</hook>
<hook id="actionOrderSlipAdd" live_edit="0">
<name>actionOrderSlipAdd</name><title>Order slip creation</title><description>This hook is called when a product's quantity is modified</description>
<name>actionOrderSlipAdd</name><title>Order slip creation</title><description>This hook is called when a new credit slip is added regarding client order</description>
</hook>
<hook id="displayProductTab" live_edit="0">
<name>displayProductTab</name><title>Tabs on product page</title><description>This hook is called on the product page's tab</description>

View File

@@ -24,3 +24,5 @@ ALTER TABLE `PREFIX_log` ADD `id_employee` INT(10) UNSIGNED NULL AFTER `object_i
SET @id_parent = (SELECT IFNULL(id_tab, 1) FROM `PREFIX_tab` WHERE `class_name` = 'AdminPriceRule' LIMIT 1);
UPDATE `PREFIX_tab` SET id_parent = @id_parent WHERE `id_parent` = 1 AND `class_name` = 'AdminMarketing' LIMIT 1;
UPDATE `PREFIX_hook` SET `description` = 'This hook is called when a new credit slip is added regarding client order' WHERE `name` = 'actionOrderSlipAdd';

View File

@@ -40,10 +40,6 @@
// if backspace is hit with no input, remove the last tag
if (pressed == 8) { // backspace
if ( $this.val() == "" ) {
self.remove();
return false;
}
return;
}
});

View File

@@ -20,7 +20,11 @@
<td>&nbsp;</td>
</tr>
<tr>
<td align="left">Customer e-mail address: <a href="mailto:{email}"><strong>{email}</strong></a> <br /><br /> Customer message: {message}</td>
<td align="left">Customer e-mail address: <a href="mailto:{email}"><strong>{email}</strong></a>
<br /><br />Customer message: {message}
<br /><br /> Order ID : {order_name}
<br /><br />Attached file : {attached_file}
</td>
</tr>
<tr>
<td>&nbsp;</td>

View File

@@ -8,4 +8,8 @@ Customer message:
{message}
Order reference : {order_name}
Attached file : {attached_file}
{shop_url} powered by PrestaShop™

View File

@@ -2,7 +2,7 @@
<module>
<name>blockmyaccountfooter</name>
<displayName><![CDATA[My account block for your website&#039;s footer]]></displayName>
<version><![CDATA[1.2]]></version>
<version><![CDATA[1.3]]></version>
<description><![CDATA[Displays a block with links relative to user accounts.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>cheque</name>
<displayName><![CDATA[Payments by check]]></displayName>
<displayName><![CDATA[Payment by check]]></displayName>
<version><![CDATA[2.3]]></version>
<description><![CDATA[This module allows you to accept payments by check.]]></description>
<author><![CDATA[PrestaShop]]></author>

View File

@@ -89,6 +89,7 @@ class LoyaltyDefaultModuleFrontController extends ModuleFrontController
$cart_rule->date_to = date('Y-m-d H:i:s', strtotime($cart_rule->date_from.' +1 year'));
$cart_rule->minimum_amount = (float)Configuration::get('PS_LOYALTY_MINIMAL');
$cart_rule->minimum_amount_currency = (int)$this->context->currency->id;
$cart_rule->active = 1;
$categories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY');

View File

@@ -540,8 +540,7 @@ class MailAlerts extends Module
$coverage = StockManagerFactory::getManager()->getProductCoverage($id_product, $id_product_attribute, $warning_coverage, $id_warehouse);
// if we need to send a notification
if ($product->active == 1 &&
($coverage < $warning_coverage) && !empty($this->_merchant_mails) &&
if ($product->active == 1 && $coverage !== -1 && ($coverage < $warning_coverage) && !empty($this->_merchant_mails) &&
Configuration::getGlobalValue('MA_MERCHANT_COVERAGE'))
{
$id_lang = (int)Context::getContext()->language->id;

View File

@@ -131,6 +131,31 @@ class PSCleaner extends Module
$db = Db::getInstance();
$logs = array();
// Remove doubles in the configuration
$filtered_configuration = array();
$result = $db->ExecuteS('SELECT * FROM '._DB_PREFIX_.'configuration');
foreach ($result as $row)
{
$key = $row['id_shop_group'].'-|-'.$row['id_shop'].'-|-'.$row['name'];
if (in_array($key, $filtered_configuration))
{
$query = 'DELETE FROM '._DB_PREFIX_.'configuration WHERE id_configuration = '.(int)$row['id_configuration'];
$db->Execute($query);
$logs[$query] = 1;
}
else
$filtered_configuration[] = $key;
}
unset($filtered_configuration);
// Remove inexisting or monolanguage configuration value from configuration_lang
$query = 'DELETE FROM `'._DB_PREFIX_.'configuration_lang`
WHERE `id_configuration` NOT IN (SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration`)
OR `id_configuration` IN (SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration` WHERE name IS NOT NULL AND name != "")';
if ($db->Execute($query))
if ($affected_rows = $db->Affected_Rows())
$logs[$query] = $affected_rows;
// Simple Cascade Delete
$queries = array(
// 0 => DELETE FROM __table__, 1 => WHERE __id__ NOT IN, 2 => NOT IN __table__, 3 => __id__ used in the "NOT IN" table, 4 => module_name
@@ -347,6 +372,7 @@ class PSCleaner extends Module
// @Todo: Remove attachment files, images...
Image::clearTmpDir();
$this->clearAllCaches();
return $logs;
}
@@ -534,6 +560,9 @@ class PSCleaner extends Module
protected function clearAllCaches()
{
$index = file_get_contents(_PS_TMP_IMG_DIR_.'index.php');
Tools::deleteDirectory(_PS_TMP_IMG_DIR_, false);
file_put_contents(_PS_TMP_IMG_DIR_.'index.php', $index);
Context::getContext()->smarty->clearAllCache();
}
}

View File

@@ -649,8 +649,7 @@ class ReferralProgram extends Module
{
$cartRule = new CartRule((int)$referralprogram->id_cart_rule_sponsor);
$currency = new Currency((int)$order->id_currency);
$discount_display = ReferralProgram::displayDiscount($cartRule->reduction_percent ? $cartRule->reduction_percent : $cartRule->reduction_amount, $cartRule->reduction_percent ? 1 : 2, $currency);
$data = array('{sponsored_firstname}' => $customer->firstname, '{sponsored_lastname}' => $customer->lastname, '{discount_display}' => $discount_display, '{discount_name}' => $cartRule->code);
$discount_display = ReferralProgram::displayDiscount( (float) $cartRule->reduction_percent ? (float) $cartRule->reduction_percent : (int) $cartRule->reduction_amount, (float) $cartRule->reduction_percent ? 1 : 2, $currency); $data = array('{sponsored_firstname}' => $customer->firstname, '{sponsored_lastname}' => $customer->lastname, '{discount_display}' => $discount_display, '{discount_name}' => $cartRule->code);
Mail::Send((int)$order->id_lang, 'referralprogram-congratulations', Mail::l('Congratulations!', (int)$order->id_lang), $data, $sponsor->email, $sponsor->firstname.' '.$sponsor->lastname, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
return true;
}

View File

@@ -470,7 +470,7 @@ class StatsForecast extends Module
$where = ' AND co.id_zone = '.(int)$this->context->cookie->stats_id_zone.' ';
}
$sql = 'SELECT SUM(od.`product_price` * od.`product_quantity` / o.conversion_rate) as orderSum, COUNT(*) AS orderQty, cl.name, AVG(od.`product_price` / o.conversion_rate) as priveAvg
$sql = 'SELECT SUM(od.`product_price` * od.`product_quantity` / o.conversion_rate) as orderSum, SUM(od.product_quantity) as orderQty, cl.name, AVG(od.`product_price` / o.conversion_rate) as priveAvg
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = od.product_id

View File

@@ -0,0 +1,9 @@
Hello,
Please read the documentation before trying to override something here.
http://doc.prestashop.com/display/PS15/Overriding+default+behaviors
Frequently Asked Questions
Q: I added an override file but it seems to be ignored by PrestaShop
A: You need to trigger the regeneration of the /cache/class_index.php file. This is done simply by deleting the file. It is the same when manually removing an override: in order to reinstate the default behavior, you must delete the /cache/class_index.php file.

View File

@@ -89,8 +89,8 @@
{/foreach}
</select>
{elseif !isset($customerThread.id_order) && !isset($isLogged)}
<input type="text" name="id_order" id="id_order" value="{if isset($customerThread.id_order) && $customerThread.id_order > 0}{$customerThread.id_order|intval}{else}{if isset($smarty.post.id_order)}{$smarty.post.id_order|intval}{/if}{/if}" />
{elseif $customerThread.id_order > 0}
<input type="text" name="id_order" id="id_order" value="{if isset($customerThread.id_order) && $customerThread.id_order|intval > 0}{$customerThread.id_order|intval}{else}{if isset($smarty.post.id_order) && !empty($smarty.post.id_order)}{$smarty.post.id_order|intval}{/if}{/if}" />
{elseif $customerThread.id_order|intval > 0}
<input type="text" name="id_order" id="id_order" value="{$customerThread.id_order|intval}" readonly="readonly" />
{/if}
</p>

View File

@@ -53,42 +53,42 @@
<ul class="pagination">
{if $p != 1}
{assign var='p_previous' value=$p-1}
<li id="pagination_previous"><a {$no_follow_text} href="{$link->goPage($requestPage, $p_previous)|escape:'html'}">&laquo;&nbsp;{l s='Previous'}</a></li>
<li id="pagination_previous"><a {$no_follow_text} href="{$link->goPage($requestPage, $p_previous)}">&laquo;&nbsp;{l s='Previous'}</a></li>
{else}
<li id="pagination_previous" class="disabled"><span>&laquo;&nbsp;{l s='Previous'}</span></li>
{/if}
{if $start==3}
<li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)|escape:'html'}">1</a></li>
<li><a {$no_follow_text} href="{$link->goPage($requestPage, 2)|escape:'html'}">2</a></li>
<li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li>
<li><a {$no_follow_text} href="{$link->goPage($requestPage, 2)}">2</a></li>
{/if}
{if $start==2}
<li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)|escape:'html'}">1</a></li>
<li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li>
{/if}
{if $start>3}
<li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)|escape:'html'}">1</a></li>
<li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li>
<li class="truncate">...</li>
{/if}
{section name=pagination start=$start loop=$stop+1 step=1}
{if $p == $smarty.section.pagination.index}
<li class="current"><span>{$p|escape:'htmlall':'UTF-8'}</span></li>
{else}
<li><a {$no_follow_text} href="{$link->goPage($requestPage, $smarty.section.pagination.index)|escape:'html'}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}</a></li>
<li><a {$no_follow_text} href="{$link->goPage($requestPage, $smarty.section.pagination.index)}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}</a></li>
{/if}
{/section}
{if $pages_nb>$stop+2}
<li class="truncate">...</li>
<li><a href="{$link->goPage($requestPage, $pages_nb)|escape:'html'}">{$pages_nb|intval}</a></li>
<li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li>
{/if}
{if $pages_nb==$stop+1}
<li><a href="{$link->goPage($requestPage, $pages_nb)|escape:'html'}">{$pages_nb|intval}</a></li>
<li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li>
{/if}
{if $pages_nb==$stop+2}
<li><a href="{$link->goPage($requestPage, $pages_nb-1)|escape:'html'}">{$pages_nb-1|intval}</a></li>
<li><a href="{$link->goPage($requestPage, $pages_nb)|escape:'html'}">{$pages_nb|intval}</a></li>
<li><a href="{$link->goPage($requestPage, $pages_nb-1)}">{$pages_nb-1|intval}</a></li>
<li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li>
{/if}
{if $pages_nb > 1 AND $p != $pages_nb}
{assign var='p_next' value=$p+1}
<li id="pagination_next"><a {$no_follow_text} href="{$link->goPage($requestPage, $p_next)|escape:'html'}">{l s='Next'}&nbsp;&raquo;</a></li>
<li id="pagination_next"><a {$no_follow_text} href="{$link->goPage($requestPage, $p_next)}">{l s='Next'}&nbsp;&raquo;</a></li>
{else}
<li id="pagination_next" class="disabled"><span>{l s='Next'}&nbsp;&raquo;</span></li>
{/if}