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

This commit is contained in:
djfm committed 2013-07-12 09:50:04 +00:00
commit e4173fbc98
444 files changed
+8651 -3220

No files matched your search

+70 -1
View File
@@ -7,6 +7,15 @@
.DS_Store .DS_Store
robots.txt robots.txt
sitemap.xml 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/*
!cache/smarty/cache/index.php !cache/smarty/cache/index.php
cache/smarty/compile/* cache/smarty/compile/*
@@ -16,6 +25,7 @@ cache/tcpdf/*
!cache/tcpdf/index.php !cache/tcpdf/index.php
config/xml/*.xml config/xml/*.xml
config/settings.inc.php config/settings.inc.php
config/settings.old.php
log/*.log log/*.log
img/* img/*
!img/index.php !img/index.php
@@ -27,6 +37,10 @@ tools/smarty*/compile/*.php
override/classes/*.php override/classes/*.php
themes/default/cache/*.js themes/default/cache/*.js
themes/default/cache/*.css 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/*.php
!modules/*/translations/index.php !modules/*/translations/index.php
mails/* mails/*
@@ -35,4 +49,59 @@ modules/*/mails/*
!modules/*/mails/en !modules/*/mails/en
translations/* translations/*
!translations/*.gzip !translations/*.gzip
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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); 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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); 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');
+3
View File
@@ -25,6 +25,9 @@ select[disabled="disabled"], input[disabled="disabled"],textarea[disabled="disab
.double_select select{width:300px;height:160px;} .double_select select{width:300px;height:160px;}
.double_select a{text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px} .double_select a{text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px}
.icon {vertical-align:middle}
.icon-top {vertical-align:top}
/*BUTTON*/ /*BUTTON*/
.button{ .button{
background: #e3e3e3 url('../img/bg-button-degrade.png') repeat-x scroll left top; background: #e3e3e3 url('../img/bg-button-degrade.png') repeat-x scroll left top;
@@ -27,13 +27,7 @@
{block name="label"} {block name="label"}
{if $input.name == 'vat_number'} {if $input.name == 'vat_number'}
{if $vat == 'is_applicable'} <div id="vat_area" style="display: visible">
<div id="vat_area" style="display: visible">
{else if $vat == 'management'}
<div id="vat_area" style="display: hidden">
{else}
<div style="display: none;">
{/if}
{/if} {/if}
{if $input.type == 'text_customer' && !isset($customer)} {if $input.type == 'text_customer' && !isset($customer)}
@@ -106,63 +106,61 @@
if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']') if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']')
{ {
exist = true; 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; return false;
} }
}); });
if (exist) if (exist)
return; return;
$.ajax({ $.ajax({
type:"POST", type:"POST",
url: "ajax-tab.php", url: "ajax-tab.php",
async: true, async: true,
dataType: "json", dataType: "json",
data : { data : {
ajax: "1", ajax: "1",
token: "{getAdminToken tab='AdminGroups'}", token: "{getAdminToken tab='AdminGroups'}",
controller: "AdminGroups", controller: "AdminGroups",
action: "addCategoryReduction", action: "addCategoryReduction",
category_reduction: $('#category_reduction_fancybox').val() , category_reduction: $('#category_reduction_fancybox').val() ,
id_category: $('[name="id_category"]:checked').val() id_category: $('[name="id_category"]:checked').val()
}, },
success : function(jsonData) success : function(jsonData) {
if (jsonData.hasError)
{ {
if (jsonData.hasError) var errors = '';
{ for (error in jsonData.errors)
var errors = ''; //IE6 bug fix
for(error in jsonData.errors) if (error != 'indexOf')
//IE6 bug fix errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
if(error != 'indexOf') jAlert(errors);
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();
}
} }
}); 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; return false;
} }
function initFancyBox() function initFancyBox()
{ {
$('[name="id_category"]:checked').removeAttr('checked'); $('[name="id_category"]:checked').removeAttr('checked');
collapseAllCategories(); collapseAllCategories();
$('#category_reduction_fancybox').val('0.00'); $('#category_reduction_fancybox').val('0.00');
} }
</script> </script>
<div class="margin-form"> <div class="margin-form">
<a class="button" href="#group_discount_category_fancybox" id="group_discount_category">{l s='Add a category discount'}</a> <a class="button" href="#group_discount_category_fancybox" id="group_discount_category">{l s='Add a category discount'}</a>
@@ -50,14 +50,14 @@
console.log(truncateAuthorized); console.log(truncateAuthorized);
if (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(); e.preventDefault();
} }
} }
else 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; return false;
} }
} }
@@ -77,7 +77,7 @@
</dl> </dl>
</div> </div>
<p class="desc">{if isset($module->description) && $module->description ne ''}{l s='Description'} : {$module->description}{else}&nbsp;{/if}</p> <p class="desc">{if isset($module->description) && $module->description ne ''}{l s='Description'} : {$module->description}{else}&nbsp;{/if}</p>
{if isset($module->message)}<div class="conf">{$module->message}</div>{/if} {if isset($module->message) && (!isset($module->type) || ($module->type != 'addonsMustHave' || $module->type !== 'addonsNative'))}<div class="conf">{$module->message}</div>{/if}
<div class="row-actions-module"> <div class="row-actions-module">
{if !isset($module->not_on_disk)} {if !isset($module->not_on_disk)}
{$module->optionsHtml} {$module->optionsHtml}
@@ -58,7 +58,7 @@
</li> </li>
{foreach from=$list_modules_categories item=module_category key=module_category_key} {foreach from=$list_modules_categories item=module_category key=module_category_key}
<li {if isset($categoryFiltered[$module_category_key])}style="background-color:#EBEDF4"{/if} class="categoryModuleFilterLink"> <li {if isset($categoryFiltered[$module_category_key])}style="background-color:#EBEDF4"{/if} class="categoryModuleFilterLink">
<div class="categorieWidth"><a href="{$currentIndex}&token={$token}&{if isset($categoryFiltered[$module_category_key])}un{/if}filterCategory={$module_category_key}"><span>{$module_category.name}</span></a></div> <div class="categorieWidth"><a href="{$currentIndex}&token={$token}&filterCategory={$module_category_key}"><span>{$module_category.name}</span></a></div>
<div class="count">{$module_category.nb}</div> <div class="count">{$module_category.nb}</div>
</li> </li>
{/foreach} {/foreach}
@@ -110,7 +110,7 @@
{if !isset($document->is_delivery)} {if !isset($document->is_delivery)}
<tr id="invoiceNote{$document->id}" style="display:none" class="current-edit"> <tr id="invoiceNote{$document->id}" style="display:none" class="current-edit">
<td colspan="5"> <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> <p>
<label for="editNote{$document->id}" class="t">{l s='Note'}</label> <label for="editNote{$document->id}" class="t">{l s='Note'}</label>
<input type="hidden" name="id_order_invoice" value="{$document->id}" /> <input type="hidden" name="id_order_invoice" value="{$document->id}" />
@@ -130,7 +130,7 @@
<td colspan="5" class="center"> <td colspan="5" class="center">
<h3>{l s='No documents are available'}</h3> <h3>{l s='No documents are available'}</h3>
{if isset($invoice_management_active) && $invoice_management_active} {if isset($invoice_management_active) && $invoice_management_active}
<p><a class="button" href="{$current_index}&viewOrder&submitGenerateInvoice&id_order={$order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">{l s='Generate invoice'}</a></p> <p><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></p>
{/if} {/if}
</td> </td>
</tr> </tr>
@@ -24,11 +24,11 @@
*} *}
<table class="table" width="100%" cellspacing="0" cellpadding="0" id="shipping_table"> <table class="table" width="100%" cellspacing="0" cellpadding="0" id="shipping_table">
<colgroup> <colgroup>
<col width="15%"> <col width="15%"/>
<col width="15%"> <col width="15%"/>
<col width=""> <col width=""/>
<col width="10%"> <col width="10%"/>
<col width="20%"> <col width="20%"/>
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
@@ -46,7 +46,7 @@
<td>{dateFormat date=$line.date_add full=true}</td> <td>{dateFormat date=$line.date_add full=true}</td>
<td>{$line.type}</td> <td>{$line.type}</td>
<td>{$line.carrier_name}</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> <td>
{if $order->getTaxCalculationMethod() == $smarty.const.PS_TAX_INC} {if $order->getTaxCalculationMethod() == $smarty.const.PS_TAX_INC}
{displayPrice price=$line.shipping_cost_tax_incl currency=$currency->id} {displayPrice price=$line.shipping_cost_tax_incl currency=$currency->id}
@@ -100,7 +100,7 @@
$('#show_old_carts').click(); $('#show_old_carts').click();
$('#payment_module_name').change(); $('#payment_module_name').change();
$.ajaxSetup({ type:"post" }); $.ajaxSetup({ type:"post" });
$("#voucher").autocomplete('{$link->getAdminLink('AdminCartRules')|escape:'html'}', { $("#voucher").autocomplete('{$link->getAdminLink('AdminCartRules')|addslashes}', {
minChars: 3, minChars: 3,
max: 15, max: 15,
width: 250, width: 250,
@@ -468,7 +468,7 @@
$('#new_address').attr('href', address_link.replace(/id_customer=[0-9]+/, 'id_customer='+id_customer)); $('#new_address').attr('href', address_link.replace(/id_customer=[0-9]+/, 'id_customer='+id_customer));
$.ajax({ $.ajax({
type:"POST", type:"POST",
url : "{$link->getAdminLink('AdminCarts')|escape:'html'}", url : "{$link->getAdminLink('AdminCarts')|addslashes}",
async: false, async: false,
dataType: "json", dataType: "json",
data : { data : {
@@ -27,7 +27,7 @@
{block name="override_tpl"} {block name="override_tpl"}
<script type="text/javascript"> <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_order = {$order->id};
var id_lang = {$current_id_lang}; var id_lang = {$current_id_lang};
var id_currency = {$order->id_currency}; var id_currency = {$order->id_currency};
@@ -264,8 +264,8 @@
{if (!$order->valid && sizeof($currencies) > 1)} {if (!$order->valid && sizeof($currencies) > 1)}
<form method="post" action="{$currentIndex}&vieworder&id_order={$order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}"> <form method="post" action="{$currentIndex}&vieworder&id_order={$order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">
<p class="warn">{l s='Don\'t forget to update your conversion rate before making this change.'}</p> <p class="warn">{l s='Do not forget to update your exchange rate before making this change.'}</p>
<label>{l s='Don\'t forget to update your conversion rate before making this change.'}</label> <label>{l s='Do not forget to update your exchange rate before making this change.'}</label>
<select name="new_currency"> <select name="new_currency">
{foreach from=$currencies item=currency_change} {foreach from=$currencies item=currency_change}
{if $currency_change['id_currency'] != $order->id_currency} {if $currency_change['id_currency'] != $order->id_currency}
@@ -34,10 +34,10 @@
{if $module->active} {if $module->active}
<th> <th>
{if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'} {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;"> <a href="javascript:checkPaymentBoxes('{$list['name_id']}', '{$module->name}')" style="text-decoration:none;">
{/if} {/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'} {if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'}
</a> </a>
{/if} {/if}
@@ -64,11 +64,9 @@
{$type = 'checkbox'} {$type = 'checkbox'}
{/if} {/if}
{if $type != 'null'} {if $type != 'null'}
<input type="checkbox" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}" <input type="checkbox" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}" {if $item['check_list'][$key_module] == 'checked'}checked="checked"{/if}/>
{if $item['check_list'][$key_module] == 'checked'}checked="checked"{/if}
/>
{else} {else}
-- <input type="hidden" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}"/>--
{/if} {/if}
</td> </td>
{/if} {/if}
@@ -43,7 +43,7 @@
$('document').ready( function() { $('document').ready( function() {
$(".check_product_name") $(".check_product_name")
.autocomplete( .autocomplete(
'{$link->getAdminLink('AdminProducts', true)|escape:'html'}', { '{$link->getAdminLink('AdminProducts', true)|addslashes}', {
minChars: 3, minChars: 3,
max: 10, max: 10,
width: $(".check_product_name").width(), width: $(".check_product_name").width(),
@@ -90,7 +90,7 @@
var table = $('#selectTables select').val(); var table = $('#selectTables select').val();
if (!table) if (!table)
jAlert("{l s='Please choose a table.'}"); jAlert("{l s='Please choose a table.' js='1'}");
else else
AddRequestSql(table); AddRequestSql(table);
}); });
@@ -24,9 +24,9 @@
*} *}
<a href="{$href}" class="delete" <a href="{$href}" class="delete"
{if in_array($id_shop, $shops_having_dependencies)} {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)} {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}"> {/if} title="{$action}">
<img src="../img/admin/delete.gif" alt="{$action}" /> <img src="../img/admin/delete.gif" alt="{$action}" />
</a> </a>
@@ -138,7 +138,7 @@
// check if it's possible to add the product // check if it's possible to add the product
if (product_infos == null || $('#cur_product_name').val() == '') 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; return false;
} }
@@ -69,6 +69,7 @@
var token_admin_customers = '{getAdminToken tab='AdminCustomers' slashes=1}'; var token_admin_customers = '{getAdminToken tab='AdminCustomers' slashes=1}';
var token_admin_customer_threads = '{getAdminToken tab='AdminCustomerThreads' slashes=1}'; var token_admin_customer_threads = '{getAdminToken tab='AdminCustomerThreads' slashes=1}';
var currentIndex = '{$currentIndex}'; var currentIndex = '{$currentIndex}';
var choose_language_translate = "{l s='Choose language' slashes=1 }";
</script> </script>
{/if} {/if}
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); 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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); 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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); 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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); 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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); 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');
+57 -74
View File
@@ -2543,6 +2543,7 @@ class CartCore extends ObjectModel
if (empty($id_carrier) && $this->isCarrierInRange((int)Configuration::get('PS_CARRIER_DEFAULT'), (int)$id_zone)) if (empty($id_carrier) && $this->isCarrierInRange((int)Configuration::get('PS_CARRIER_DEFAULT'), (int)$id_zone))
$id_carrier = (int)Configuration::get('PS_CARRIER_DEFAULT'); $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 (empty($id_carrier))
{ {
if ((int)$this->id_customer) if ((int)$this->id_customer)
@@ -2577,7 +2578,7 @@ class CartCore extends ObjectModel
{ {
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int)$id_zone); $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); $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 // Get only carriers that have a range compatible with cart
@@ -2680,26 +2681,8 @@ class CartCore extends ObjectModel
$id_zone = (int)$default_country->id_zone; $id_zone = (int)$default_country->id_zone;
} }
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int)$carrier->id, $this->getTotalWeight(), (int)$id_zone); 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)
// 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
)) ))
$shipping_cost += 0; $shipping_cost += 0;
else else
@@ -2846,7 +2829,10 @@ class CartCore extends ObjectModel
$formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery); $formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
$formatted_addresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice); $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) if ($total_tax < 0)
$total_tax = 0; $total_tax = 0;
@@ -2944,9 +2930,9 @@ class CartCore extends ObjectModel
'total_shipping_tax_exc' => $total_shipping_tax_exc, 'total_shipping_tax_exc' => $total_shipping_tax_exc,
'total_products_wt' => $total_products_wt, 'total_products_wt' => $total_products_wt,
'total_products' => $total_products, 'total_products' => $total_products,
'total_price' => $this->getOrderTotal(), 'total_price' => $base_total_tax_inc,
'total_tax' => $total_tax, '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), 'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int)Tools::getValue('multi-shipping') == 1),
'free_ship' => $total_shipping ? 0 : 1, 'free_ship' => $total_shipping ? 0 : 1,
'carrier' => new Carrier($this->id_carrier, $id_lang), 'carrier' => new Carrier($this->id_carrier, $id_lang),
@@ -3424,62 +3410,59 @@ class CartCore extends ObjectModel
*/ */
public function setNoMultishipping() public function setNoMultishipping()
{ {
// Upgrading quantities if (Configuration::get('PS_ALLOW_MULTISHIPPING'))
$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` // Upgrading quantities
SET `quantity` = '.$product['quantity'].' $sql = 'SELECT sum(`quantity`) as quantity, id_product, id_product_attribute, count(*) as count
WHERE `id_cart` = '.(int)$this->id.' FROM `'._DB_PREFIX_.'cart_product`
AND `id_shop` = '.(int)$this->id_shop.' WHERE `id_cart` = '.(int)$this->id.'
AND id_product = '.$product['id_product'].' AND `id_shop` = '.(int)$this->id_shop.'
AND id_product_attribute = '.$product['id_product_attribute']; GROUP BY id_product, id_product_attribute
Db::getInstance()->execute($sql); 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 // Update delivery address for each product line
$sql = 'DELETE cp1 Db::getInstance()->execute('
FROM `'._DB_PREFIX_.'cart_product` cp1 UPDATE `'._DB_PREFIX_.'cart_product`
INNER JOIN `'._DB_PREFIX_.'cart_product` cp2 SET `id_address_delivery` = (
ON ( SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart`
(cp1.id_cart = cp2.id_cart) WHERE `id_cart` = '.(int)$this->id.' AND `id_shop` = '.(int)$this->id_shop.'
AND (cp1.id_product = cp2.id_product) )
AND (cp1.id_product_attribute = cp2.id_product_attribute) WHERE `id_cart` = '.(int)$this->id.'
AND (cp1.id_address_delivery <> cp2.id_address_delivery) '.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : ''));
AND (cp1.date_add > cp2.date_add)
)';
Db::getInstance()->execute($sql);
// Upgrading address delivery if (Customization::isFeatureActive())
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product` Db::getInstance()->execute('
SET `id_address_delivery` = UPDATE `'._DB_PREFIX_.'customization`
( SET `id_address_delivery` = (
SELECT `id_address_delivery` SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart`
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`
WHERE `id_cart` = '.(int)$this->id.' WHERE `id_cart` = '.(int)$this->id.'
) )
WHERE `id_cart` = '.(int)$this->id; WHERE `id_cart` = '.(int)$this->id);
Db::getInstance()->execute($sql);
} }
/** /**
+10 -15
View File
@@ -796,7 +796,7 @@ class CategoryCore extends ObjectModel
)).')'; )).')';
$flag = Db::getInstance()->execute(' $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) VALUES '.implode(',', $row)
); );
return $flag; return $flag;
@@ -831,20 +831,15 @@ class CategoryCore extends ObjectModel
if (!Validate::isUnsignedId($id_category) || !Validate::isUnsignedId($id_lang)) if (!Validate::isUnsignedId($id_category) || !Validate::isUnsignedId($id_lang))
return false; return false;
if (isset(self::$_links[$id_category.'-'.$id_lang])) if (!isset(self::$_links[$id_category.'-'.$id_lang]))
return self::$_links[$id_category.'-'.$id_lang]; self::$_links[$id_category.'-'.$id_lang] = Db::getInstance()->getValue('
SELECT cl.`link_rewrite`
$result = Db::getInstance()->getRow(' FROM `'._DB_PREFIX_.'category_lang` cl
SELECT cl.`link_rewrite` WHERE `id_lang` = '.(int)$id_lang.'
FROM `'._DB_PREFIX_.'category_lang` cl '.Shop::addSqlRestrictionOnLang('cl').'
WHERE `id_lang` = '.(int)$id_lang.' AND cl.`id_category` = '.(int)$id_category
'.Shop::addSqlRestrictionOnLang('cl').' );
AND cl.`id_category` = '.(int)$id_category return self::$_links[$id_category.'-'.$id_lang];
);
self::$_links[$id_category.'-'.$id_lang] = $result['link_rewrite'];
return $result['link_rewrite'];
} }
public function getLink(Link $link = null) public function getLink(Link $link = null)
+8 -8
View File
@@ -43,7 +43,7 @@ class CurrencyCore extends ObjectModel
/** @var int bool used for displaying blank between sign and price */ /** @var int bool used for displaying blank between sign and price */
public $blank; public $blank;
/** @var string Conversion rate from euros */ /** @var string exchange rate from euros */
public $conversion_rate; public $conversion_rate;
/** @var boolean True if currency has been deleted (staying in database as deleted) */ /** @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 * Refresh the currency exchange rate
* The XML file define conversion rate for each from a default currency ($isoCodeSource). * 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 $isoCodeSource The default currency used in the XML file
* @param $defaultCurrency The default currency object * @param $defaultCurrency The default currency object
*/ */
public function refreshCurrency($data, $isoCodeSource, $defaultCurrency) public function refreshCurrency($data, $isoCodeSource, $defaultCurrency)
{ {
// fetch the conversion rate of the default currency // fetch the exchange rate of the default currency
$conversion_rate = 1; $exchange_rate = 1;
if ($defaultCurrency->iso_code != $isoCodeSource) if ($defaultCurrency->iso_code != $isoCodeSource)
{ {
foreach ($data->currency as $currency) foreach ($data->currency as $currency)
if ($currency['iso_code'] == $defaultCurrency->iso_code) if ($currency['iso_code'] == $defaultCurrency->iso_code)
{ {
$conversion_rate = round((float)$currency['rate'], 6); $exchange_rate = round((float)$currency['rate'], 6);
break; break;
} }
} }
@@ -364,7 +364,7 @@ class CurrencyCore extends ObjectModel
} }
if (isset($rate)) if (isset($rate))
$this->conversion_rate = round($rate / $conversion_rate, 6); $this->conversion_rate = round($rate / $exchange_rate, 6);
} }
$this->update(); $this->update();
} }
+52 -29
View File
@@ -379,12 +379,12 @@ class DispatcherCore
/** /**
* Load default routes group by languages * Load default routes group by languages
*/ */
protected function loadRoutes() protected function loadRoutes($id_shop = null)
{ {
$context = Context::getContext(); $context = Context::getContext();
// Load custom routes from modules // 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)) if (is_array($modules_routes) && count($modules_routes))
foreach($modules_routes as $module_route) foreach($modules_routes as $module_route)
foreach($module_route as $route => $route_details) foreach($module_route as $route => $route_details)
@@ -405,7 +405,8 @@ class DispatcherCore
$route['controller'], $route['controller'],
$lang['id_lang'], $lang['id_lang'],
$route['keywords'], $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 // Load the custom routes prior the defaults to avoid infinite loops
@@ -420,13 +421,13 @@ class DispatcherCore
// Load routes from meta table // Load routes from meta table
$sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang $sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang
FROM `'._DB_PREFIX_.'meta` m 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'; ORDER BY LENGTH(ml.url_rewrite) DESC';
if ($results = Db::getInstance()->executeS($sql)) if ($results = Db::getInstance()->executeS($sql))
foreach ($results as $row) foreach ($results as $row)
{ {
if ($row['url_rewrite']) 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) // Set default empty route if no empty route (that's weird I know)
@@ -439,7 +440,7 @@ class DispatcherCore
// Load custom routes // Load custom routes
foreach ($this->default_routes as $route_id => $route_data) 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) foreach (Language::getLanguages() as $lang)
$this->addRoute( $this->addRoute(
$route_id, $route_id,
@@ -447,7 +448,8 @@ class DispatcherCore
$route_data['controller'], $route_data['controller'],
$lang['id_lang'], $lang['id_lang'],
$route_data['keywords'], $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 $rule Url rule
* @param string $controller Controller to call if request uri match the rule * @param string $controller Controller to call if request uri match the rule
* @param int $id_lang * @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)) if ($id_lang === null)
$id_lang = Context::getContext()->language->id; $id_lang = (int)Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
$regexp = preg_quote($rule, '#'); $regexp = preg_quote($rule, '#');
if ($keywords) if ($keywords)
@@ -497,10 +503,12 @@ class DispatcherCore
} }
$regexp = '#^/'.$regexp.'(\?.*)?$#u'; $regexp = '#^/'.$regexp.'(\?.*)?$#u';
if (!isset($this->routes[$id_lang])) if (!isset($this->routes[$id_shop]))
$this->routes[$id_lang] = array(); $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, 'rule' => $rule,
'regexp' => $regexp, 'regexp' => $regexp,
'controller' => $controller, 'controller' => $controller,
@@ -514,14 +522,17 @@ class DispatcherCore
* *
* @param string $route_id * @param string $route_id
* @param int $id_lang * @param int $id_lang
* @param int $id_shop
* @return bool * @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)) if ($id_lang === null)
$id_lang = Context::getContext()->language->id; $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 string $route_id
* @param int $id_lang * @param int $id_lang
* @param string $keyword * @param string $keyword
* @param int $id_shop
* @return bool * @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 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 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 * @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) if ($id_lang === null)
$id_lang = Context::getContext()->language->id; $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, '', '&'); $query = http_build_query($params, '', '&');
$index_link = $this->use_routes ? '' : 'index.php'; $index_link = $this->use_routes ? '' : 'index.php';
return ($route_id == 'index') ? $index_link.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '').$anchor; 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 // Check required fields
$query_params = isset($route['params']) ? $route['params'] : array(); $query_params = isset($route['params']) ? $route['params'] : array();
foreach ($route['keywords'] as $key => $data) foreach ($route['keywords'] as $key => $data)
@@ -646,7 +666,7 @@ class DispatcherCore
* *
* @return string * @return string
*/ */
public function getController() public function getController($id_shop = null)
{ {
if (defined('_PS_ADMIN_DIR_')) if (defined('_PS_ADMIN_DIR_'))
$_GET['controllerUri'] = Tools::getvalue('controller'); $_GET['controllerUri'] = Tools::getvalue('controller');
@@ -656,6 +676,9 @@ class DispatcherCore
return $this->controller; return $this->controller;
} }
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
$controller = Tools::getValue('controller'); $controller = Tools::getValue('controller');
if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) 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 // Add empty route as last route to prevent this greedy regexp to match request uri before right time
if ($this->empty_route) 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])) if (isset($this->routes[$id_shop][Context::getContext()->language->id]))
foreach ($this->routes[Context::getContext()->language->id] as $route) foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route)
if (preg_match($route['regexp'], $this->request_uri, $m)) if (preg_match($route['regexp'], $this->request_uri, $m))
{ {
// Route found ! Now fill $_GET with parameters of uri // Route found ! Now fill $_GET with parameters of uri
+16
View File
@@ -128,6 +128,22 @@ class HookCore extends ObjectModel
return Cache::retrieve($cache_id); return Cache::retrieve($cache_id);
} }
/**
* 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);
}
/** /**
* Get list of hook alias * Get list of hook alias
* *
+1 -3
View File
@@ -273,7 +273,7 @@ class LanguageCore extends ObjectModel
'contact.html', 'contact.txt', 'contact.html', 'contact.txt',
'contact_form.html', 'contact_form.txt', 'contact_form.html', 'contact_form.txt',
'credit_slip.html', 'credit_slip.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', 'employee_password.html', 'employee_password.txt',
'forward_msg.html', 'forward_msg.txt', 'forward_msg.html', 'forward_msg.txt',
'guest_to_customer.html', 'guest_to_customer.txt', 'guest_to_customer.html', 'guest_to_customer.txt',
@@ -704,10 +704,8 @@ class LanguageCore extends ObjectModel
$lang->name = $lang_pack->name; $lang->name = $lang_pack->name;
} }
elseif ($params_lang !== null && is_array($params_lang)) elseif ($params_lang !== null && is_array($params_lang))
{
foreach ($params_lang as $key => $value) foreach ($params_lang as $key => $value)
$lang->$key = $value; $lang->$key = $value;
}
else else
return false; return false;
+102 -48
View File
@@ -91,7 +91,7 @@ class LinkCore
if (!$id_lang) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $id_lang = Context::getContext()->language->id;
if (!$id_shop) if ($id_shop === null)
$shop = Context::getContext()->shop; $shop = Context::getContext()->shop;
else else
$shop = new Shop($id_shop); $shop = new Shop($id_shop);
@@ -101,9 +101,9 @@ class LinkCore
if (!is_object($product)) if (!is_object($product))
{ {
if (is_array($product) && isset($product['id_product'])) if (is_array($product) && isset($product['id_product']))
$product = new Product($product['id_product'], false, $id_lang); $product = new Product($product['id_product'], false, $id_lang);
else if (is_numeric($product) || !$product) elseif ((int)$product)
$product = new Product($product, false, $id_lang); $product = new Product((int)$product, false, $id_lang);
else else
throw new PrestaShopException('Invalid product vars'); throw new PrestaShopException('Invalid product vars');
} }
@@ -112,29 +112,30 @@ class LinkCore
$params = array(); $params = array();
$params['id'] = $product->id; $params['id'] = $product->id;
$params['rewrite'] = (!$alias) ? $product->getFieldByLang('link_rewrite') : $alias; $params['rewrite'] = (!$alias) ? $product->getFieldByLang('link_rewrite') : $alias;
$params['ean13'] = (!$ean13) ? $product->ean13 : $ean13; $params['ean13'] = (!$ean13) ? $product->ean13 : $ean13;
$params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords')); $params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords'));
$params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title')); $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)); $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)); $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); $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)); $params['tags'] = Tools::str2url($product->getTags($id_lang));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category')) if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category', $id_shop))
$params['category'] = !is_null($product->category) ? Tools::str2url($product->category) : Tools::str2url($category); $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); $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; $params['category'] = (!$category) ? $product->category : $category;
$cats = array(); $cats = array();
@@ -145,7 +146,7 @@ class LinkCore
} }
$anchor = $ipa ? $product->getAnchor($ipa) : ''; $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 * @param string $selected_filters Url parameter to autocheck filters of the module blocklayered
* @return string * @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) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $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)) if (!is_object($category))
$category = new Category($category, $id_lang); $category = new Category($category, $id_lang);
@@ -184,7 +190,7 @@ class LinkCore
$params['selected_filters'] = $selected_filters; $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 * @param int $id_lang
* @return string * @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) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $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)) $dispatcher = Dispatcher::getInstance();
$category = new CMSCategory($category, $id_lang); 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 // Set available keywords
$params = array(); $params = array();
$params['id'] = $category->id; $params['id'] = $cms_category->id;
$params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; $params['rewrite'] = (!$alias) ? $cms_category->link_rewrite : $alias;
$params['meta_keywords'] = Tools::str2url($category->meta_keywords); $params['meta_keywords'] = Tools::str2url($cms_category->meta_keywords);
$params['meta_title'] = Tools::str2url($category->meta_title); $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 * @param int $id_lang
* @return string * @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) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $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 (!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); $cms = new CMS($cms, $id_lang);
}
// Set available keywords // Set available keywords
$params = array(); $params = array();
$params['id'] = $cms->id; $params['id'] = $cms->id;
$params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias; $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)) 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); $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)) 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); $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 * @param int $id_lang
* @return string * @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) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $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 (!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); $supplier = new Supplier($supplier, $id_lang);
}
// Set available keywords // Set available keywords
$params = array(); $params = array();
@@ -277,7 +311,7 @@ class LinkCore
$params['meta_keywords'] = Tools::str2url($supplier->meta_keywords); $params['meta_keywords'] = Tools::str2url($supplier->meta_keywords);
$params['meta_title'] = Tools::str2url($supplier->meta_title); $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 * @param int $id_lang
* @return string * @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) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $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 (!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); $manufacturer = new Manufacturer($manufacturer, $id_lang);
}
// Set available keywords // Set available keywords
$params = array(); $params = array();
@@ -304,7 +348,7 @@ class LinkCore
$params['meta_keywords'] = Tools::str2url($manufacturer->meta_keywords); $params['meta_keywords'] = Tools::str2url($manufacturer->meta_keywords);
$params['meta_title'] = Tools::str2url($manufacturer->meta_title); $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 * @param int $id_lang
* @return string * @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) if (!$id_lang)
$id_lang = Context::getContext()->language->id; $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 // Set available keywords
$params['module'] = $module; $params['module'] = $module;
$params['controller'] = $controller ? $controller : 'default'; $params['controller'] = $controller ? $controller : 'default';
// If the module has its own route ... just use it ! // 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); return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params);
else 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 * @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); $controller = Tools::strReplaceFirst('.php', '', $controller);
@@ -419,9 +468,14 @@ class LinkCore
parse_str($request, $request); parse_str($request, $request);
} }
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request); if ($id_shop === null)
$url = ($ssl && $this->ssl_enable) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true); $shop = Context::getContext()->shop;
$url .= __PS_BASE_URI__.$this->getLangLink($id_lang).ltrim($uri_path, '/'); 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; return $url;
} }
+12 -1
View File
@@ -44,6 +44,9 @@ class LoggerCore extends ObjectModel
/** @var integer Object ID */ /** @var integer Object ID */
public $object_id; public $object_id;
/** @var integer Object ID */
public $id_employee;
/** @var string Object creation date */ /** @var string Object creation date */
public $date_add; public $date_add;
@@ -61,6 +64,7 @@ class LoggerCore extends ObjectModel
'error_code' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'error_code' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true), 'message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
'object_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), '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'), 'object_type' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => 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) * @param boolean $allow_duplicate if set to true, can log several time the same information (not recommended)
* @return boolean true if succeed * @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 = new Logger();
$log->severity = intval($severity); $log->severity = intval($severity);
@@ -106,6 +110,13 @@ class LoggerCore extends ObjectModel
$log->message = pSQL($message); $log->message = pSQL($message);
$log->date_add = date('Y-m-d H:i:s'); $log->date_add = date('Y-m-d H:i:s');
$log->date_upd = 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)) if (!empty($object_type) && !empty($object_id))
{ {
$log->object_type = pSQL($object_type); $log->object_type = pSQL($object_type);
+3
View File
@@ -249,6 +249,9 @@ class MailCore
if (isset($logo)) if (isset($logo))
$template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($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_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['{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); $template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id);
+8 -5
View File
@@ -546,7 +546,7 @@ abstract class ObjectModelCore
$object_id = Db::getInstance()->Insert_ID(); $object_id = Db::getInstance()->Insert_ID();
if ($definition['multilang']) if (isset($definition['multilang']) && $definition['multilang'])
{ {
$res = Db::getInstance()->executeS(' $res = Db::getInstance()->executeS('
SELECT * SELECT *
@@ -763,6 +763,9 @@ abstract class ObjectModelCore
if (!array_key_exists('active', $this)) if (!array_key_exists('active', $this))
throw new PrestaShopException('property "active" is missing in object '.get_class($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 // Update active status on object
$this->active = !(int)$this->active; $this->active = !(int)$this->active;
@@ -977,11 +980,11 @@ abstract class ObjectModelCore
// Checking for required fields // Checking for required fields
if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0') if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
if (!$this->id || $field != 'passwd') 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 // Checking for maximum fields sizes
if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size']) 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'), Tools::displayError('%1$s is too long. Maximum length: %2$d'),
self::displayFieldName($field, get_class($this), $htmlentities), self::displayFieldName($field, get_class($this), $htmlentities),
$data['size'] $data['size']
@@ -992,7 +995,7 @@ abstract class ObjectModelCore
if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0')) if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0'))
{ {
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required'])) 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 else
{ {
if (isset($data['copy_post']) && !$data['copy_post']) if (isset($data['copy_post']) && !$data['copy_post'])
@@ -1136,7 +1139,7 @@ abstract class ObjectModelCore
$value = Tools::getValue($field); $value = Tools::getValue($field);
if (empty($value)) 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; return $errors;
+5 -1
View File
@@ -208,9 +208,10 @@ class ProductSupplierCore extends ObjectModel
* *
* @param int $id_product * @param int $id_product
* @param int $id_product_attribute Optional * @param int $id_product_attribute Optional
* @param bool $converted_price Optional
* @return Array keys: price_te, id_currency * @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)) if (is_null($id_supplier) || is_null($id_product))
return; return;
@@ -222,6 +223,9 @@ class ProductSupplierCore extends ObjectModel
$query->where('id_supplier = '.(int)$id_supplier); $query->where('id_supplier = '.(int)$id_supplier);
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); $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']; return $row['price_te'];
} }
} }
+1 -3
View File
@@ -37,7 +37,7 @@ class RequestSqlCore extends ObjectModel
'primary' => 'id_request_sql', 'primary' => 'id_request_sql',
'fields' => array( 'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 200), '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)) if ($attribut = $this->cutAttribute(trim($attr), $from))
$tab[] = $attribut; $tab[] = $attribut;
else
return false;
} }
return $tab; return $tab;
} }
+3 -3
View File
@@ -224,7 +224,7 @@ class SearchCore
AND product_shop.`active` = 1 AND product_shop.`active` = 1
AND product_shop.`visibility` IN ("both", "search") AND product_shop.`visibility` IN ("both", "search")
AND product_shop.indexed = 1 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 SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.' WHERE id_customer = '.(int)$id_customer.'
)'); )');
@@ -622,7 +622,7 @@ class SearchCore
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`) LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
WHERE product_shop.`active` = 1 WHERE product_shop.`active` = 1
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.' 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 SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').' WHERE id_customer = '.(int)$id_customer.')').'
AND t.`name` LIKE \'%'.pSQL($tag).'%\''; AND t.`name` LIKE \'%'.pSQL($tag).'%\'';
@@ -656,7 +656,7 @@ class SearchCore
'.Product::sqlStock('p', 0).' '.Product::sqlStock('p', 0).'
WHERE product_shop.`active` = 1 WHERE product_shop.`active` = 1
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.' 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 SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').' WHERE id_customer = '.(int)$id_customer.')').'
AND t.`name` LIKE \'%'.pSQL($tag).'%\' AND t.`name` LIKE \'%'.pSQL($tag).'%\'
+2 -3
View File
@@ -540,9 +540,8 @@ class TabCore extends ObjectModel
$display_type = (string)$value; $display_type = (string)$value;
foreach ($tab->children() as $module) foreach ($tab->children() as $module)
foreach ($module->attributes() as $k => $v) $modules_list[$display_type][(int)$module['position']] = (string)$module['name'];
if ($k == 'name') ksort($modules_list[$display_type]);
$modules_list[$display_type][] = (string)$v;
} }
} }
+77 -53
View File
@@ -338,11 +338,9 @@ class ToolsCore
/* If language does not exist or is disabled, erase it */ /* If language does not exist or is disabled, erase it */
if ($cookie->id_lang) if ($cookie->id_lang)
{ {
//echo $cookie->id_lang;exit;
$lang = new Language((int)$cookie->id_lang); $lang = new Language((int)$cookie->id_lang);
if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop()) if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop())
$cookie->id_lang = null; $cookie->id_lang = null;
} }
/* Automatically detect language if not already defined */ /* Automatically detect language if not already defined */
@@ -399,7 +397,7 @@ class ToolsCore
{ {
$context->cookie->id_lang = $id_lang; $context->cookie->id_lang = $id_lang;
$language = new Language($id_lang); $language = new Language($id_lang);
if (Validate::isLoadedObject($language)) if (Validate::isLoadedObject($language) && $language->active)
$context->language = $language; $context->language = $language;
$params = $_GET; $params = $_GET;
@@ -433,8 +431,11 @@ class ToolsCore
{ {
// get currency from context // get currency from context
$currency = Shop::getEntityIds('currency', Context::getContext()->shop->id); $currency = Shop::getEntityIds('currency', Context::getContext()->shop->id);
$cookie->id_currency = $currency[0]['id_currency']; if (isset($currency[0]) && $currency[0]['id_currency'])
return Currency::getCurrencyInstance((int)$cookie->id_currency); {
$cookie->id_currency = $currency[0]['id_currency'];
return Currency::getCurrencyInstance((int)$cookie->id_currency);
}
} }
} }
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT')); $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
@@ -677,20 +678,24 @@ class ToolsCore
public static function deleteDirectory($dirname, $delete_self = true) public static function deleteDirectory($dirname, $delete_self = true)
{ {
$dirname = rtrim($dirname, '/').'/'; $dirname = rtrim($dirname, '/').'/';
if ($files = scandir($dirname)) if (file_exists($dirname))
{ if ($files = scandir($dirname))
foreach ($files as $file)
if ($file != '.' && $file != '..' && $file != '.svn')
{ {
if (is_dir($dirname.$file)) foreach ($files as $file)
Tools::deleteDirectory($dirname.$file, true); if ($file != '.' && $file != '..' && $file != '.svn')
elseif (file_exists($dirname.$file)) {
unlink($dirname.$file); if (is_dir($dirname.$file))
Tools::deleteDirectory($dirname.$file, true);
elseif (file_exists($dirname.$file))
unlink($dirname.$file);
}
if ($delete_self)
if (!rmdir($dirname))
return false;
return true;
} }
if ($delete_self) return false;
rmdir($dirname); }
}
}
/** /**
* Display an error according to an error code * Display an error according to an error code
@@ -1022,47 +1027,66 @@ class ToolsCore
*/ */
public static function replaceAccentedChars($str) public static function replaceAccentedChars($str)
{ {
/* One source among others:
http://www.tachyonsoft.com/uc0000.htm
http://www.tachyonsoft.com/uc0001.htm
*/
$patterns = array( $patterns = array(
/* Lowercase */ /* Lowercase */
'/[\x{0105}\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}]/u', /* a */ '/[\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}\x{0101}\x{0103}\x{0105}]/u',
'/[\x{00E7}\x{010D}\x{0107}]/u', /* c */ '/[\x{00E7}\x{0107}\x{0109}\x{010D}]/u',
'/[\x{010F}]/u', /* d */ '/[\x{010F}\x{0111}]/u',
'/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{011B}\x{0119}]/u', /* e */ '/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{0113}\x{0115}\x{0117}\x{0119}\x{011B}]/u',
'/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}]/u', /* g */ '/[\x{011F}\x{0121}\x{0123}]/u',
'/[\x{011F}]/u', /* h */ '/[\x{0125}\x{0127}]/u',
'/[\x{0142}\x{013E}\x{013A}]/u', /* i */ '/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}\x{0129}\x{012B}\x{012D}\x{012F}\x{0131}]/u',
'/[\x{00F1}\x{0148}]/u', /* j */ '/[\x{0135}]/u',
'/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}]/u', /* k */ '/[\x{0137}\x{0138}]/u',
'/[\x{0159}\x{0155}]/u', /* l */ '/[\x{013A}\x{013C}\x{013E}\x{0140}\x{0142}]/u',
'/[\x{015B}\x{0161}\x{015F}]/u', /* n */ '/[\x{00F1}\x{0144}\x{0146}\x{0148}\x{0149}\x{014B}]/u',
'/[\x{00DF}]/u', /* o */ '/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}\x{014D}\x{014F}\x{0151}]/u',
'/[\x{0165}]/u', /* r */ '/[\x{0155}\x{0157}\x{0159}]/u',
'/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{016F}]/u', /* s */ '/[\x{015B}\x{015D}\x{015F}\x{0161}]/u',
'/[\x{00FD}\x{00FF}]/u', /* ss*/ '/[\x{00DF}]/u',
'/[\x{017C}\x{017A}\x{017E}]/u', /* t */ '/[\x{0163}\x{0165}\x{0167}]/u',
'/[\x{00E6}]/u', /* u */ '/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{0169}\x{016B}\x{016D}\x{016F}\x{0171}\x{0173}]/u',
'/[\x{0153}]/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 */ /* Uppercase */
'/[\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u', /* A */ '/[\x{0100}\x{0102}\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
'/[\x{00C7}\x{010C}\x{0106}]/u', /* C */ '/[\x{00C7}\x{0106}\x{0108}\x{010A}\x{010C}]/u',
'/[\x{010E}]/u', /* D */ '/[\x{010E}\x{0110}]/u',
'/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{011A}\x{0118}]/u', /* E */ '/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{0112}\x{0114}\x{0116}\x{0118}\x{011A}]/u',
'/[\x{011E}]/u', /* G */ '/[\x{011C}\x{011E}\x{0120}\x{0122}]/u',
'/[\x{0141}\x{013D}\x{0139}]/u', /* H */ '/[\x{0124}\x{0126}]/u',
'/[\x{00D1}\x{0147}]/u', /* I */ '/[\x{0128}\x{012A}\x{012C}\x{012E}\x{0130}]/u',
'/[\x{00D3}]/u', /* J */ '/[\x{0134}]/u',
'/[\x{0158}\x{0154}]/u', /* K */ '/[\x{0136}]/u',
'/[\x{015A}\x{0160}\x{015E}]/u', /* L */ '/[\x{0139}\x{013B}\x{013D}\x{0139}\x{0141}]/u',
'/[\x{0164}]/u', /* N */ '/[\x{00D1}\x{0143}\x{0145}\x{0147}\x{014A}]/u',
'/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{016E}]/u', /* O */ '/[\x{00D3}\x{014C}\x{014E}\x{0150}]/u',
'/[\x{017B}\x{0179}\x{017D}]/u', /* R */ '/[\x{0154}\x{0156}\x{0158}]/u',
'/[\x{00C6}]/u', /* S */ '/[\x{015A}\x{015C}\x{015E}\x{0160}]/u',
'/[\x{0152}]/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( $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', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'w', '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', 'T', 'U', 'Z', 'AE', 'OE'
); );
return preg_replace($patterns, $replacements, $str); return preg_replace($patterns, $replacements, $str);
@@ -1565,7 +1589,7 @@ class ToolsCore
} }
// Write .htaccess data // Write .htaccess data
if (!$write_fd = @fopen($path, 'w')) if (!$write_fd = fopen($path, 'w'))
return false; return false;
fwrite($write_fd, trim($specific_before)."\n\n"); fwrite($write_fd, trim($specific_before)."\n\n");
+1 -1
View File
@@ -144,7 +144,7 @@ abstract class CacheCore
*/ */
public function set($key, $value, $ttl = 0) public function set($key, $value, $ttl = 0)
{ {
if ($this->_set($key, $value)) if ($this->_set($key, $value, $ttl))
{ {
if ($ttl < 0) if ($ttl < 0)
$ttl = 0; $ttl = 0;
+1
View File
@@ -149,6 +149,7 @@ class CacheFsCore extends Cache
*/ */
protected function getFilename($key) protected function getFilename($key)
{ {
$key = md5($key);
$path = _PS_CACHEFS_DIRECTORY_; $path = _PS_CACHEFS_DIRECTORY_;
for ($i = 0; $i < $this->depth; $i++) for ($i = 0; $i < $this->depth; $i++)
$path .= $key[$i].'/'; $path .= $key[$i].'/';
+3 -2
View File
@@ -65,8 +65,9 @@ class CacheMemcacheCore extends Cache
{ {
foreach ($dump as $entries) foreach ($dump as $entries)
{ {
if ($entries) if($entries)
$this->keys = array_merge($this->keys, array_keys($entries)); foreach ($entries as $key => $data)
$this->keys[$key] = $data[1];
} }
} }
} }
+32 -14
View File
@@ -647,12 +647,14 @@ class AdminControllerCore extends Controller
$this->errors[] = Tools::displayError('Unable to delete associated images.'); $this->errors[] = Tools::displayError('Unable to delete associated images.');
$object->deleted = 1; $object->deleted = 1;
if ($object->update()) if ($res = $object->update())
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token; $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->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
$this->errors[] = Tools::displayError('An error occurred during deletion.'); $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 else
@@ -701,6 +703,7 @@ class AdminControllerCore extends Controller
/* voluntary do affectation here */ /* voluntary do affectation here */
elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect) 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); $parent_id = (int)Tools::getValue('id_parent', 1);
$this->afterAdd($this->object); $this->afterAdd($this->object);
$this->updateAssoShop($this->object->id); $this->updateAssoShop($this->object->id);
@@ -735,7 +738,6 @@ class AdminControllerCore extends Controller
{ {
/* Checking fields validity */ /* Checking fields validity */
$this->validateRules(); $this->validateRules();
if (empty($this->errors)) if (empty($this->errors))
{ {
$id = (int)Tools::getValue($this->identifier); $id = (int)Tools::getValue($this->identifier);
@@ -801,6 +803,7 @@ class AdminControllerCore extends Controller
if (empty($this->redirect_after)) if (empty($this->redirect_after))
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=4&token='.$this->token; $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);
} }
else else
$this->errors[] = Tools::displayError('An error occurred while updating an object.'). $this->errors[] = Tools::displayError('An error occurred while updating an object.').
@@ -955,7 +958,8 @@ class AdminControllerCore extends Controller
continue; continue;
// Check if field is required // 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') if (isset($values['type']) && $values['type'] == 'textLang')
{ {
foreach ($languages as $language) foreach ($languages as $language)
@@ -1533,7 +1537,6 @@ class AdminControllerCore extends Controller
public function renderModulesList() public function renderModulesList()
{ {
if ($this->getModulesList($this->filter_modules_list)) if ($this->getModulesList($this->filter_modules_list))
{ {
$helper = new Helper(); $helper = new Helper();
@@ -2232,7 +2235,7 @@ class AdminControllerCore extends Controller
$all_modules = Module::getModulesOnDisk(true); $all_modules = Module::getModulesOnDisk(true);
$this->modules_list = array(); $this->modules_list = array();
foreach($all_modules as $module) foreach ($all_modules as $module)
{ {
$perm = true; $perm = true;
if ($module->id) if ($module->id)
@@ -2248,9 +2251,11 @@ class AdminControllerCore extends Controller
if (in_array($module->name, $filter_modules_list) && $perm) if (in_array($module->name, $filter_modules_list) && $perm)
{ {
$this->fillModuleData($module, 'select'); $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)) if (count($this->modules_list))
return true; return true;
@@ -2709,18 +2714,31 @@ class AdminControllerCore extends Controller
else else
{ {
$result = true; $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; $to_delete->deleted = 1;
$result = $result && $to_delete->update(); if (!$to_delete->update())
{
$result = false;
$delete_ok = false;
}
} }
} else
else if (!$to_delete->delete())
$result = $object->deleteSelection(Tools::getValue($this->table.'Box')); {
$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);
}
if ($result) if ($result)
$this->redirect_after = self::$currentIndex.'&conf=2&token='.$this->token; $this->redirect_after = self::$currentIndex.'&conf=2&token='.$this->token;
$this->errors[] = Tools::displayError('An error occurred while deleting this selection.'); $this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
Regular → Executable
+13 -7
View File
@@ -79,12 +79,7 @@ abstract class DbCore
/** /**
* @var array Object instance for singleton * @var array Object instance for singleton
*/ */
protected static $_servers = array( 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'),
);
/** /**
* Store last executed query * Store last executed query
@@ -170,6 +165,8 @@ abstract class DbCore
/* do not remove, useful for some modules */ /* do not remove, useful for some modules */
abstract public function set_db($db_name); abstract public function set_db($db_name);
abstract public function getBestEngine();
/** /**
* Get Db object instance * Get Db object instance
* *
@@ -180,6 +177,15 @@ abstract class DbCore
{ {
static $id = 0; 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); $total_servers = count(self::$_servers);
if ($master || $total_servers == 1) if ($master || $total_servers == 1)
$id_server = 0; $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)); 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)); return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine));
} }
+43 -12
View File
@@ -53,6 +53,21 @@ class DbMySQLiCore extends Db
return $this->link; 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() * @see DbCore::disconnect()
*/ */
@@ -169,24 +184,40 @@ class DbMySQLiCore extends Db
if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout)) if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout))
return 1; 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; 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(); $link->close();
return 0; 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); $link = @new mysqli($server, $user, $pwd, $db);
if (mysqli_connect_error()) if (mysqli_connect_error())
+39 -26
View File
@@ -46,6 +46,19 @@ class DbPDOCore extends Db
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true)); 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() * @see DbCore::connect()
*/ */
@@ -174,7 +187,7 @@ class DbPDOCore extends Db
return (bool)$result->fetch(); return (bool)$result->fetch();
} }
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine) public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{ {
try { try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5); $link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
@@ -206,35 +219,35 @@ class DbPDOCore extends Db
} catch (PDOException $e) { } catch (PDOException $e) {
return ($e->getCode() == 1049) ? 2 : 1; 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); unset($link);
return 0; 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() * @see Db::checkEncoding()
*/ */
+35 -26
View File
@@ -47,6 +47,15 @@ class MySQLCore extends Db
return $this->link; 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() * @see DbCore::disconnect()
*/ */
@@ -165,36 +174,36 @@ class MySQLCore extends Db
return 1; return 1;
if (!@mysql_select_db($db, $link)) if (!@mysql_select_db($db, $link))
return 2; 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); @mysql_close($link);
return 0; 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 = 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 = null)
{ {
ini_set('mysql.connect_timeout', 5); ini_set('mysql.connect_timeout', 5);
if (!$link = @mysql_connect($server, $user, $pwd, true)) if (!$link = @mysql_connect($server, $user, $pwd, true))
-1
View File
@@ -351,7 +351,6 @@ class HelperCore
public function renderModulesList($modules_list) public function renderModulesList($modules_list)
{ {
$this->tpl_vars = array('modules_list' => $modules_list); $this->tpl_vars = array('modules_list' => $modules_list);
$tpl = $this->createTemplate('helpers/modules_list/list.tpl'); $tpl = $this->createTemplate('helpers/modules_list/list.tpl');
$tpl->assign($this->tpl_vars); $tpl->assign($this->tpl_vars);
+1 -1
View File
@@ -535,7 +535,7 @@ class HelperListCore extends Helper
{ {
if (!isset($params['type'])) if (!isset($params['type']))
$params['type'] = 'text'; $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']) switch ($params['type'])
{ {
case 'bool': case 'bool':
+9
View File
@@ -668,6 +668,7 @@ abstract class ModuleCore
if ($alias = Hook::getRetroHookName($hook_name)) if ($alias = Hook::getRetroHookName($hook_name))
$hook_name = $alias; $hook_name = $alias;
Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
// Get hook id // Get hook id
$id_hook = Hook::getIdByName($hook_name); $id_hook = Hook::getIdByName($hook_name);
@@ -714,6 +715,7 @@ abstract class ModuleCore
)); ));
} }
Hook::exec('actionModuleRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
return $return; return $return;
} }
@@ -729,11 +731,16 @@ abstract class ModuleCore
// Get hook id if a name is given as argument // Get hook id if a name is given as argument
if (!is_numeric($hook_id)) if (!is_numeric($hook_id))
{ {
$hook_name = (int)$hook_id;
// Retrocompatibility // Retrocompatibility
$hook_id = Hook::getIdByName($hook_id); $hook_id = Hook::getIdByName($hook_id);
if (!$hook_id) if (!$hook_id)
return false; 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 // Unregister module on hook by id
$sql = 'DELETE FROM `'._DB_PREFIX_.'hook_module` $sql = 'DELETE FROM `'._DB_PREFIX_.'hook_module`
@@ -744,6 +751,8 @@ abstract class ModuleCore
// Clean modules position // Clean modules position
$this->cleanPositions($hook_id, $shop_list); $this->cleanPositions($hook_id, $shop_list);
Hook::exec('actionModuleUnRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
return $result; return $result;
} }
+29 -7
View File
@@ -63,7 +63,7 @@ class OrderCore extends ObjectModel
/** @var string Payment module */ /** @var string Payment module */
public $module; public $module;
/** @var float Currency conversion rate */ /** @var float Currency exchange rate */
public $conversion_rate; public $conversion_rate;
/** @var boolean Customer is ok for a recyclable package */ /** @var boolean Customer is ok for a recyclable package */
@@ -1146,13 +1146,14 @@ class OrderCore extends ObjectModel
if ($use_existing_payment) if ($use_existing_payment)
{ {
$id_order_payments = Db::getInstance()->executeS(' $id_order_payments = Db::getInstance()->executeS('
SELECT op.id_order_payment SELECT DISTINCT op.id_order_payment
FROM `'._DB_PREFIX_.'order_payment` op FROM `'._DB_PREFIX_.'order_payment` op
INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.reference = op.order_reference) 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) 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)) if (count($id_order_payments))
{
foreach ($id_order_payments as $order_payment) foreach ($id_order_payments as $order_payment)
Db::getInstance()->execute(' Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
@@ -1160,6 +1161,9 @@ class OrderCore extends ObjectModel
`id_order_invoice` = '.(int)$order_invoice->id.', `id_order_invoice` = '.(int)$order_invoice->id.',
`id_order_payment` = '.(int)$order_payment['id_order_payment'].', `id_order_payment` = '.(int)$order_payment['id_order_payment'].',
`id_order` = '.(int)$order_invoice->id_order); `id_order` = '.(int)$order_invoice->id_order);
// Clear cache
Cache::clean('order_invoice_paid_*');
}
} }
// Update order cart rule // Update order cart rule
@@ -1237,12 +1241,11 @@ class OrderCore extends ObjectModel
public function getTotalWeight() public function getTotalWeight()
{ {
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(product_weight * product_quantity) weight SELECT SUM(product_weight * product_quantity)
FROM '._DB_PREFIX_.'order_detail FROM '._DB_PREFIX_.'order_detail
WHERE id_order = '.(int)($this->id)); WHERE id_order = '.(int)($this->id));
return (float)($result);
return (float)($result['weight']);
} }
/** /**
@@ -1466,6 +1469,9 @@ class OrderCore extends ObjectModel
$res = Db::getInstance()->execute(' $res = Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
VALUES('.(int)$order_invoice->id.', '.(int)$order_payment->id.', '.(int)$this->id.')'); VALUES('.(int)$order_invoice->id.', '.(int)$order_payment->id.', '.(int)$this->id.')');
// Clear cache
Cache::clean('order_invoice_paid_*');
} }
return $res; return $res;
@@ -1881,5 +1887,21 @@ class OrderCore extends ObjectModel
$order = new Order($id_order); $order = new Order($id_order);
return $order->getUniqReference(); 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']; $this->purchase_supplier_price = (float)$product['wholesale_price'];
if ($product['id_supplier'] > 0) 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); $this->setSpecificPrice($order, $product);
+6 -4
View File
@@ -522,14 +522,16 @@ class OrderInvoiceCore extends ObjectModel
*/ */
public function getTotalPaid() 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); $payments = OrderPayment::getByInvoiceId($this->id);
foreach ($payments as $payment) 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);
} }
/** /**
+4 -1
View File
@@ -61,12 +61,15 @@ class HTMLTemplateDeliverySlipCore extends HTMLTemplate
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); $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( $this->smarty->assign(array(
'order' => $this->order, 'order' => $this->order,
'order_details' => $this->order_invoice->getProducts(), 'order_details' => $this->order_invoice->getProducts(),
'delivery_address' => $formatted_delivery_address, 'delivery_address' => $formatted_delivery_address,
'invoice_address' => $formatted_invoice_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')); return $this->smarty->fetch($this->getTemplate('delivery-slip'));
+3 -1
View File
@@ -89,6 +89,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$tax_exempt = Configuration::get('VATNUMBER_MANAGEMENT') $tax_exempt = Configuration::get('VATNUMBER_MANAGEMENT')
&& !empty($address->vat_number) && !empty($address->vat_number)
&& $address->id_country != Configuration::get('VATNUMBER_COUNTRY'); && $address->id_country != Configuration::get('VATNUMBER_COUNTRY');
$carrier = new Carrier($this->order->id_carrier);
$this->smarty->assign(array( $this->smarty->assign(array(
'tax_exempt' => $tax_exempt, 'tax_exempt' => $tax_exempt,
@@ -98,7 +99,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
'ecotax_tax_breakdown' => $this->order_invoice->getEcoTaxTaxesBreakdown(), 'ecotax_tax_breakdown' => $this->order_invoice->getEcoTaxTaxesBreakdown(),
'wrapping_tax_breakdown' => $this->order_invoice->getWrappingTaxesBreakdown(), 'wrapping_tax_breakdown' => $this->order_invoice->getWrappingTaxesBreakdown(),
'order' => $this->order, 'order' => $this->order,
'order_invoice' => $this->order_invoice 'order_invoice' => $this->order_invoice,
'carrier' => $carrier
)); ));
return $this->smarty->fetch($this->getTemplate('invoice.tax-tab')); return $this->smarty->fetch($this->getTemplate('invoice.tax-tab'));
+11
View File
@@ -153,4 +153,15 @@ class ShopGroupCore extends ObjectModel
return false; 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 : '')
);
}
} }
+20 -5
View File
@@ -48,6 +48,8 @@ class WebserviceOutputBuilderCore
protected $statusInt; protected $statusInt;
protected $wsParamOverrides; protected $wsParamOverrides;
protected static $_cache_ws_parameters = array();
// Header properties // Header properties
protected $headerParams = array( protected $headerParams = array(
'Access-Time' => 0, 'Access-Time' => 0,
@@ -283,7 +285,7 @@ class WebserviceOutputBuilderCore
if (is_null($this->wsResource)) if (is_null($this->wsResource))
throw new WebserviceException ('You must set web service resource for get the resources list.', array(82, 500)); throw new WebserviceException ('You must set web service resource for get the resources list.', array(82, 500));
$output = ''; $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); $output .= $this->objectRender->renderNodeHeader('api', array(), $more_attr);
foreach ($this->wsResource as $resourceName => $resource) foreach ($this->wsResource as $resourceName => $resource)
{ {
@@ -359,7 +361,11 @@ class WebserviceOutputBuilderCore
$type_of_view = self::VIEW_DETAILS; $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) foreach ($this->wsParamOverrides AS $p)
{ {
$object = $p['object']; $object = $p['object'];
@@ -376,7 +382,7 @@ class WebserviceOutputBuilderCore
{ {
if ($key !== 'empty') if ($key !== 'empty')
{ {
if ($this->fieldsToDisplay === 'minimum') if ($this->fieldsToDisplay === 'minimum')
$output .= $this->renderEntityMinimum($object, $depth); $output .= $this->renderEntityMinimum($object, $depth);
else else
$output .= $this->renderEntity($object, $depth); $output .= $this->renderEntity($object, $depth);
@@ -406,7 +412,11 @@ class WebserviceOutputBuilderCore
*/ */
public function renderEntityMinimum($object, $depth) 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['id'] = $object->id;
$more_attr['xlink_resource'] = $this->wsUrl.$ws_params['objectsNodeName'].'/'.$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); $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) public function renderEntity($object, $depth)
{ {
$output = ''; $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) foreach ($this->wsParamOverrides AS $p)
{ {
$o = $p['object']; $o = $p['object'];
+14 -5
View File
@@ -530,9 +530,10 @@ class WebserviceRequestCore
} }
} }
} }
return $this->returnOutput(); $return = $this->returnOutput();
unset($webservice_call); unset($webservice_call);
unset ($display_errors); unset($display_errors);
return $return;
} }
protected function webserviceChecks() protected function webserviceChecks()
@@ -1158,6 +1159,7 @@ class WebserviceRequestCore
$sorts = array($this->urlFragments['sort']); $sorts = array($this->urlFragments['sort']);
$sql_sort .= ' ORDER BY '; $sql_sort .= ' ORDER BY ';
foreach ($sorts as $sort) foreach ($sorts as $sort)
{ {
$delimiterPosition = strrpos($sort, '_'); $delimiterPosition = strrpos($sort, '_');
@@ -1219,8 +1221,6 @@ class WebserviceRequestCore
return $filters; return $filters;
} }
public function getFilteredObjectList() public function getFilteredObjectList()
{ {
$objects = array(); $objects = array();
@@ -1241,7 +1241,16 @@ class WebserviceRequestCore
if ($sqlObjects) if ($sqlObjects)
{ {
foreach ($sqlObjects as $sqlObject) 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; return $objects;
} }
} }
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); 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');
+1 -1
View File
@@ -36,7 +36,7 @@ function smartyTranslate($params, &$smarty)
{ {
$htmlentities = !isset($params['js']); $htmlentities = !isset($params['js']);
$pdf = isset($params['pdf']); $pdf = isset($params['pdf']);
$addslashes = isset($params['slashes']); $addslashes = (isset($params['slashes']) || isset($params['js']));
$sprintf = isset($params['sprintf']) ? $params['sprintf'] : false; $sprintf = isset($params['sprintf']) ? $params['sprintf'] : false;
if ($pdf) if ($pdf)
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=contact'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); Tools::redirect('index.php?controller=contact'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
@@ -152,18 +152,7 @@ class AdminAddressesControllerCore extends AdminController
$token_customer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id); $token_customer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id);
} }
// @todo in 1.4, this include was done before the class declaration
// We should use a hook now
if (Configuration::get('VATNUMBER_MANAGEMENT') && file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php'))
include_once(_PS_MODULE_DIR_.'vatnumber/vatnumber.php');
if (Configuration::get('VATNUMBER_MANAGEMENT'))
if (file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php') && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT')))
$vat = 'is_applicable';
else
$vat = 'management';
$this->tpl_form_vars = array( $this->tpl_form_vars = array(
'vat' => isset($vat) ? $vat : null,
'customer' => isset($customer) ? $customer : null, 'customer' => isset($customer) ? $customer : null,
'tokenCustomer' => isset ($token_customer) ? $token_customer : null 'tokenCustomer' => isset ($token_customer) ? $token_customer : null
); );
+18 -1
View File
@@ -220,11 +220,28 @@ class AdminCmsControllerCore extends AdminController
$this->displayListFooter($token); $this->displayListFooter($token);
} }
public function postProcess() /**
* Modifying initial getList method to display position feature (drag and drop)
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{ {
if (Tools::isSubmit($this->table.'Orderby') || Tools::isSubmit($this->table.'Orderway')) if (Tools::isSubmit($this->table.'Orderby') || Tools::isSubmit($this->table.'Orderway'))
$this->filter = true; $this->filter = true;
if ($order_by && $this->context->cookie->__get($this->table.'Orderby'))
$order_by = $this->context->cookie->__get($this->table.'Orderby');
else
$order_by = 'position';
if (is_null($order_way))
$order_way = Tools::getValue($this->table.'Orderway', 'ASC');
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
}
public function postProcess()
{
if (Tools::isSubmit('viewcms') && ($id_cms = (int)Tools::getValue('id_cms')) && ($cms = new CMS($id_cms, $this->context->language->id)) && Validate::isLoadedObject($cms)) if (Tools::isSubmit('viewcms') && ($id_cms = (int)Tools::getValue('id_cms')) && ($cms = new CMS($id_cms, $this->context->language->id)) && Validate::isLoadedObject($cms))
{ {
$redir = $this->context->link->getCMSLink($cms); $redir = $this->context->link->getCMSLink($cms);
@@ -38,7 +38,7 @@ class AdminCurrenciesControllerCore extends AdminController
'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 80), '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), '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), 'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false),
'conversion_rate' => array('title' => $this->l('Conversion 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),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
); );
@@ -130,12 +130,12 @@ class AdminCurrenciesControllerCore extends AdminController
), ),
array( array(
'type' => 'text', 'type' => 'text',
'label' => $this->l('Conversion rate:'), 'label' => $this->l('Exchange rate:'),
'name' => 'conversion_rate', 'name' => 'conversion_rate',
'size' => 3, 'size' => 3,
'maxlength' => 11, 'maxlength' => 11,
'required' => true, 'required' => true,
'desc' => $this->l('Conversion rates are calculated from one unit of your shop\'s default currency. For example, if the default currency is euros and your chosen currency is dollars, type "1.20"').' 1&euro; = $1.20', 'desc' => $this->l('Exchange rates are calculated from one unit of your shop\'s default currency. For example, if the default currency is euros and your chosen currency is dollars, type "1.20"').' 1&euro; = $1.20',
), ),
array( array(
'type' => 'select', 'type' => 'select',
@@ -404,7 +404,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$contact = new Contact((int)$ct->id_contact); $contact = new Contact((int)$ct->id_contact);
if (Validate::isLoadedObject($contact)) if (Validate::isLoadedObject($contact))
{ {
$from_name = $contact->name; $from_name = $contact->name[(int)$ct->id_lang];
$from_email = $contact->email; $from_email = $contact->email;
} }
else else
+18 -10
View File
@@ -2710,43 +2710,51 @@ class AdminImportControllerCore extends AdminController
// If i am a superadmin, i can truncate table // If i am a superadmin, i can truncate table
if (((Shop::isFeatureActive() && $this->context->employee->isSuperAdmin()) || !Shop::isFeatureActive()) && Tools::getValue('truncate')) if (((Shop::isFeatureActive() && $this->context->employee->isSuperAdmin()) || !Shop::isFeatureActive()) && Tools::getValue('truncate'))
$this->truncateTables((int)Tools::getValue('entity')); $this->truncateTables((int)Tools::getValue('entity'));
$import_type = false;
switch ((int)Tools::getValue('entity')) switch ((int)Tools::getValue('entity'))
{ {
case $this->entities[$this->l('Categories')]: case $this->entities[$import_type = $this->l('Categories')]:
$this->categoryImport(); $this->categoryImport();
break; break;
case $this->entities[$this->l('Products')]: case $this->entities[$import_type = $this->l('Products')]:
$import_type = $this->l('Categories');
$this->productImport(); $this->productImport();
break; break;
case $this->entities[$this->l('Customers')]: case $this->entities[$import_type = $this->l('Customers')]:
$this->customerImport(); $this->customerImport();
break; break;
case $this->entities[$this->l('Addresses')]: case $this->entities[$import_type = $this->l('Addresses')]:
$this->addressImport(); $this->addressImport();
break; break;
case $this->entities[$this->l('Combinations')]: case $this->entities[$import_type = $this->l('Combinations')]:
$this->attributeImport(); $this->attributeImport();
break; break;
case $this->entities[$this->l('Manufacturers')]: case $this->entities[$import_type = $this->l('Manufacturers')]:
$this->manufacturerImport(); $this->manufacturerImport();
break; break;
case $this->entities[$this->l('Suppliers')]: case $this->entities[$import_type = $this->l('Suppliers')]:
$this->supplierImport(); $this->supplierImport();
break; break;
// @since 1.5.0 // @since 1.5.0
case $this->entities[$this->l('Supply Orders')]: case $this->entities[$import_type = $this->l('Supply Orders')]:
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
$this->supplyOrdersImport(); $this->supplyOrdersImport();
break; break;
// @since 1.5.0 // @since 1.5.0
case $this->entities[$this->l('Supply Order Details')]: case $this->entities[$import_type = $this->l('Supply Order Details')]:
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
$this->supplyOrdersDetailsImport(); $this->supplyOrdersDetailsImport();
break; break;
default: default:
$this->errors[] = $this->l('Please select what you would like to import'); $this->errors[] = $this->l('Please select what you would like to import');
} }
if ($import_type !== false)
{
$log_message = sprintf($this->l('%s import'), $import_type);
if (Tools::getValue('truncate'))
$log_message .= ' '.$this->l('with truncate');
Logger::addLog($log_message, 1, null, $import_type, null, true, (int)$this->context->employee->id);
}
} }
else else
$this->errors[] = $this->l('You must upload a file in order to proceed to the next step'); $this->errors[] = $this->l('You must upload a file in order to proceed to the next step');
@@ -144,7 +144,7 @@ class AdminLanguagesControllerCore extends AdminController
'required' => true, 'required' => true,
'size' => 2, 'size' => 2,
'maxlength' => 5, 'maxlength' => 5,
'desc' => $this->l('Full language code (e.g. EN-US, PT-BR)') 'desc' => $this->l('IETF language tag (e.g. en-US, pt-BR).').' '.sprintf('<a href="http://en.wikipedia.org/wiki/IETF_language_tag" target="_blank">%s <img src="../img/admin/external_link.png" class="icon-top" /></a>', $this->l('IETF on Wikipedia'))
), ),
array( array(
'type' => 'text', 'type' => 'text',
@@ -152,7 +152,7 @@ class AdminLanguagesControllerCore extends AdminController
'name' => 'date_format_lite', 'name' => 'date_format_lite',
'required' => true, 'required' => true,
'size' => 15, 'size' => 15,
'desc' => $this->l('Short date format (e.g. YY-MM-DD)') 'desc' => sprintf($this->l('Short date format (e.g., %s)'), '<a href="http://php.net/date" target="_blank">Y-m-d</a>')
), ),
array( array(
'type' => 'text', 'type' => 'text',
@@ -160,7 +160,7 @@ class AdminLanguagesControllerCore extends AdminController
'name' => 'date_format_full', 'name' => 'date_format_full',
'required' => true, 'required' => true,
'size' => 25, 'size' => 25,
'desc' => $this->l('Full date format (e.g., YYYY-MM-DD)') 'desc' => sprintf($this->l('Full date format (e.g., %s)'), '<a href="http://php.net/date" target="_blank">Y-m-d H:i:s</a>')
), ),
array( array(
'type' => 'file', 'type' => 'file',
@@ -38,6 +38,7 @@ class AdminLogsControllerCore extends AdminController
$this->fields_list = array( $this->fields_list = array(
'id_log' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'id_log' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'employee' => array('title' => $this->l('Employee'), 'align' => 'center', 'width' => 100),
'severity' => array('title' => $this->l('Severity (1-4)'), 'align' => 'center', 'width' => 50), 'severity' => array('title' => $this->l('Severity (1-4)'), 'align' => 'center', 'width' => 50),
'message' => array('title' => $this->l('Message')), 'message' => array('title' => $this->l('Message')),
'object_type' => array('title' => $this->l('Object type'), 'width' => 75), 'object_type' => array('title' => $this->l('Object type'), 'width' => 75),
@@ -62,6 +63,8 @@ class AdminLogsControllerCore extends AdminController
) )
); );
$this->list_no_link = true; $this->list_no_link = true;
$this->_select .= 'CONCAT(LEFT(e.firstname, 1), \'. \', e.lastname) employee';
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'employee e ON (a.id_employee = e.id_employee)';
parent::__construct(); parent::__construct();
} }
@@ -189,7 +189,7 @@ class AdminManufacturersControllerCore extends AdminController
$this->_join .= ' $this->_join .= '
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
ON (a.`id_manufacturer` = m.`id_manufacturer`)'; ON (a.`id_manufacturer` = m.`id_manufacturer`)';
$this->_where = 'AND a.`id_customer` = 0 AND a.`id_supplier` = 0 AND a.`id_warehouse` = 0'; $this->_where = 'AND a.`id_customer` = 0 AND a.`id_supplier` = 0 AND a.`id_warehouse` = 0 AND a.`deleted`=0';
$this->context->smarty->assign('title_list', $this->l('Manufacturers addresses:')); $this->context->smarty->assign('title_list', $this->l('Manufacturers addresses:'));
@@ -406,6 +406,12 @@ class AdminManufacturersControllerCore extends AdminController
'type' => 'hidden', 'type' => 'hidden',
'name' => 'alias', 'name' => 'alias',
); );
$form['input'][] = array(
'type' => 'hidden',
'name' => 'id_address',
);
$form['input'][] = array( $form['input'][] = array(
'type' => 'text', 'type' => 'text',
'label' => $this->l('Last name:'), 'label' => $this->l('Last name:'),
@@ -712,6 +718,9 @@ class AdminManufacturersControllerCore extends AdminController
return $res; return $res;
} }
protected function beforeDelete($object)
{
return true;
}
} }
+1 -1
View File
@@ -650,7 +650,7 @@ class AdminMetaControllerCore extends AdminController
} }
$tab['GB'] = array( $tab['GB'] = array(
'orderby=','orderway=','tag=','id_currency=','search_query=','back=','utm_source=','utm_medium=','utm_campaign=','n=' 'orderby=','orderway=','tag=','id_currency=','search_query=','back=','n='
); );
foreach ($disallow_controllers as $controller) foreach ($disallow_controllers as $controller)
+2 -1
View File
@@ -571,7 +571,8 @@ class AdminModulesControllerCore extends AdminController
else else
{ {
// Uninstall the module before deleting the files, but do not block the process if uninstall returns false // Uninstall the module before deleting the files, but do not block the process if uninstall returns false
$module->uninstall(); if (Module::isInstalled($module->name))
$module->uninstall();
$moduleDir = _PS_MODULE_DIR_.str_replace(array('.', '/', '\\'), array('', '', ''), Tools::getValue('module_name')); $moduleDir = _PS_MODULE_DIR_.str_replace(array('.', '/', '\\'), array('', '', ''), Tools::getValue('module_name'));
$this->recursiveDeleteOnDisk($moduleDir); $this->recursiveDeleteOnDisk($moduleDir);
Tools::redirectAdmin(self::$currentIndex.'&conf=22&token='.$this->token.'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name')); Tools::redirectAdmin(self::$currentIndex.'&conf=22&token='.$this->token.'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name'));
+49 -6
View File
@@ -489,6 +489,14 @@ class AdminOrdersControllerCore extends AdminController
if ($shipping_cost_amount > 0) if ($shipping_cost_amount > 0)
$amount += $shipping_cost_amount; $amount += $shipping_cost_amount;
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
if ($order_carrier->update())
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
if ($amount > 0) if ($amount > 0)
{ {
if (!OrderSlip::createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list)) if (!OrderSlip::createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list))
@@ -656,6 +664,14 @@ class AdminOrdersControllerCore extends AdminController
$order_detail = new OrderDetail((int)$id_order_detail); $order_detail = new OrderDetail((int)$id_order_detail);
if (!$order->deleteProduct($order, $order_detail, $qty_cancel_product)) if (!$order->deleteProduct($order, $order_detail, $qty_cancel_product))
$this->errors[] = Tools::displayError('An error occurred while attempting to delete the product.').' <span class="bold">'.$order_detail->product_name.'</span>'; $this->errors[] = Tools::displayError('An error occurred while attempting to delete the product.').' <span class="bold">'.$order_detail->product_name.'</span>';
// Update weight SUM
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
if ($order_carrier->update())
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
Hook::exec('actionProductCancel', array('order' => $order, 'id_order_detail' => (int)$id_order_detail)); Hook::exec('actionProductCancel', array('order' => $order, 'id_order_detail' => (int)$id_order_detail));
} }
if (!count($this->errors) && $customizationList) if (!count($this->errors) && $customizationList)
@@ -914,13 +930,10 @@ class AdminOrdersControllerCore extends AdminController
$order_detail->updateTaxAmount($order); $order_detail->updateTaxAmount($order);
} }
$id_order_carrier = Db::getInstance()->getValue(' $id_order_carrier = (int)$order->getIdOrderCarrier();
SELECT `id_order_carrier`
FROM `'._DB_PREFIX_.'order_carrier`
WHERE `id_order` = '.(int)$order->id);
if ($id_order_carrier) if ($id_order_carrier)
{ {
$order_carrier = new OrderCarrier($id_order_carrier); $order_carrier = $order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
$order_carrier->shipping_cost_tax_excl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_excl, $old_currency, $currency); $order_carrier->shipping_cost_tax_excl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_excl, $old_currency, $currency);
$order_carrier->shipping_cost_tax_incl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_incl, $old_currency, $currency); $order_carrier->shipping_cost_tax_incl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_incl, $old_currency, $currency);
$order_carrier->update(); $order_carrier->update();
@@ -963,7 +976,7 @@ class AdminOrdersControllerCore extends AdminController
// Update currency in order // Update currency in order
$order->id_currency = $currency->id; $order->id_currency = $currency->id;
// Update conversion rate // Update exchange rate
$order->conversion_rate = (float)$currency->conversion_rate; $order->conversion_rate = (float)$currency->conversion_rate;
$order->update(); $order->update();
} }
@@ -1698,6 +1711,15 @@ class AdminOrdersControllerCore extends AdminController
// Save changes of order // Save changes of order
$order->update(); $order->update();
// Update weight SUM
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
if ($order_carrier->update())
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
// Update Tax lines // Update Tax lines
$order_detail->updateTaxAmount($order); $order_detail->updateTaxAmount($order);
@@ -1904,6 +1926,17 @@ class AdminOrdersControllerCore extends AdminController
// Save order detail // Save order detail
$res &= $order_detail->update(); $res &= $order_detail->update();
// Update weight SUM
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
$res &= $order_carrier->update();
if ($res)
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
// Save order invoice // Save order invoice
if (isset($order_invoice)) if (isset($order_invoice))
$res &= $order_invoice->update(); $res &= $order_invoice->update();
@@ -2003,6 +2036,16 @@ class AdminOrdersControllerCore extends AdminController
// Delete OrderDetail // Delete OrderDetail
$res &= $order_detail->delete(); $res &= $order_detail->delete();
// Update weight SUM
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
$res &= $order_carrier->update();
if ($res)
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
if (!$res) if (!$res)
die(Tools::jsonEncode(array( die(Tools::jsonEncode(array(
'result' => $res, 'result' => $res,
@@ -231,7 +231,7 @@ class AdminPPreferencesControllerCore extends AdminController
// if advanced stock management is disabled, updates concerned tables // if advanced stock management is disabled, updates concerned tables
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 1 && if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 1 &&
(int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0) (int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0 && Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL)
{ {
ObjectModel::updateMultishopTable('Product', array('advanced_stock_management' => 0), 'product_shop.`advanced_stock_management` = 1'); ObjectModel::updateMultishopTable('Product', array('advanced_stock_management' => 0), 'product_shop.`advanced_stock_management` = 1');
+41 -5
View File
@@ -201,7 +201,8 @@ class AdminProductsControllerCore extends AdminController
$this->fields_list['id_product'] = array( $this->fields_list['id_product'] = array(
'title' => $this->l('ID'), 'title' => $this->l('ID'),
'align' => 'center', 'align' => 'center',
'width' => 20 'type' => 'int',
'width' => 40
); );
$this->fields_list['image'] = array( $this->fields_list['image'] = array(
'title' => $this->l('Photo'), 'title' => $this->l('Photo'),
@@ -253,6 +254,7 @@ class AdminProductsControllerCore extends AdminController
$this->fields_list['sav_quantity'] = array( $this->fields_list['sav_quantity'] = array(
'title' => $this->l('Quantity'), 'title' => $this->l('Quantity'),
'width' => 90, 'width' => 90,
'type' => 'int',
'align' => 'right', 'align' => 'right',
'filter_key' => 'sav!quantity', 'filter_key' => 'sav!quantity',
'orderby' => true, 'orderby' => true,
@@ -374,7 +376,14 @@ class AdminProductsControllerCore extends AdminController
$default_product = new Product((int)$this->object->id, false, null, (int)$this->object->id_shop_default); $default_product = new Product((int)$this->object->id, false, null, (int)$this->object->id_shop_default);
$def = ObjectModel::getDefinition($this->object); $def = ObjectModel::getDefinition($this->object);
foreach ($def['fields'] as $field_name => $row) foreach ($def['fields'] as $field_name => $row)
$this->object->$field_name = ObjectModel::formatValue($default_product->$field_name, $def['fields'][$field_name]['type']); {
$fields_array = array();
if(is_array($default_product->$field_name))
foreach ($fields_array as $key => $fields_name)
$this->object->$field_name[$key] = ObjectModel::formatValue($fields_name, $def['fields'][$field_name]['type']);
else
$this->object->$field_name = ObjectModel::formatValue($this->object->$field_name, $def['fields'][$field_name]['type']);
}
} }
$this->object->loadStockData(); $this->object->loadStockData();
} }
@@ -730,7 +739,12 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = sprintf(Tools::displayError('You cannot delete the product #%d because there is physical stock left.'), $product->id); $this->errors[] = sprintf(Tools::displayError('You cannot delete the product #%d because there is physical stock left.'), $product->id);
} }
if (!count($this->errors)) if (!count($this->errors))
$success &= $product->delete(); {
if ($product->delete())
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$product->id, true, (int)$this->context->employee->id);
else
$success = false;
}
else else
$success = 0; $success = 0;
} }
@@ -766,6 +780,26 @@ class AdminProductsControllerCore extends AdminController
if (!Tools::getIsset('attribute_combination_list') || Tools::isEmpty(Tools::getValue('attribute_combination_list'))) if (!Tools::getIsset('attribute_combination_list') || Tools::isEmpty(Tools::getValue('attribute_combination_list')))
$this->errors[] = Tools::displayError('You must add at least one attribute.'); $this->errors[] = Tools::displayError('You must add at least one attribute.');
$array_checks = array(
'reference' => 'isReference',
'supplier_reference' => 'isReference',
'location' => 'isReference',
'ean13' => 'isEan13',
'upc' => 'isUpc',
'wholesale_price' => 'isPrice',
'price' => 'isPrice',
'ecotax' => 'isPrice',
'quantity' => 'isInt',
'weight' => 'isUnsignedFloat',
'unit_price_impact' => 'isPrice',
'default_on' => 'isBool',
'minimal_quantity' => 'isUnsignedInt',
'available_date' => 'isDateFormat'
);
foreach ($array_checks as $property => $check)
if (Tools::getValue('attribute_'.$property) !== false && !call_user_func(array('Validate', $check), Tools::getValue('attribute_'.$property)))
$this->errors[] = sprintf(Tools::displayError('Field %s is not valid'), $property);
if (!count($this->errors)) if (!count($this->errors))
{ {
if (!isset($_POST['attribute_wholesale_price'])) $_POST['attribute_wholesale_price'] = 0; if (!isset($_POST['attribute_wholesale_price'])) $_POST['attribute_wholesale_price'] = 0;
@@ -1687,6 +1721,7 @@ class AdminProductsControllerCore extends AdminController
if ($this->object->add()) if ($this->object->add())
{ {
Logger::addLog(sprintf($this->l('%s addition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
$this->addCarriers(); $this->addCarriers();
$this->updateAccessories($this->object); $this->updateAccessories($this->object);
$this->updatePackItems($this->object); $this->updatePackItems($this->object);
@@ -1828,6 +1863,7 @@ class AdminProductsControllerCore extends AdminController
if ($object->update()) if ($object->update())
{ {
Logger::addLog(sprintf($this->l('%s edition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
if (in_array($this->context->shop->getContext(), array(Shop::CONTEXT_SHOP, Shop::CONTEXT_ALL))) if (in_array($this->context->shop->getContext(), array(Shop::CONTEXT_SHOP, Shop::CONTEXT_ALL)))
{ {
if ($this->isTabSubmitted('Shipping')) if ($this->isTabSubmitted('Shipping'))
@@ -2710,7 +2746,7 @@ class AdminProductsControllerCore extends AdminController
if (!$product_supplier_id) if (!$product_supplier_id)
{ {
$product->addSupplierReference($supplier->id_supplier, (int)$attribute['id_product_attribute'], $reference, (float)Tools::convertPrice($price, $id_currency), (int)$id_currency); $product->addSupplierReference($supplier->id_supplier, (int)$attribute['id_product_attribute'], $reference, (float)$price, (int)$id_currency);
if ($product->id_supplier == $supplier->id_supplier) if ($product->id_supplier == $supplier->id_supplier)
{ {
if ((int)$attribute['id_product_attribute'] > 0) if ((int)$attribute['id_product_attribute'] > 0)
@@ -2736,7 +2772,7 @@ class AdminProductsControllerCore extends AdminController
{ {
$product_supplier = new ProductSupplier($product_supplier_id); $product_supplier = new ProductSupplier($product_supplier_id);
$product_supplier->id_currency = (int)$id_currency; $product_supplier->id_currency = (int)$id_currency;
$product_supplier->product_supplier_price_te = (float)Tools::convertPrice($price, $id_currency); //converted in the default currency $product_supplier->product_supplier_price_te = (float)$price;
$product_supplier->product_supplier_reference = pSQL($reference); $product_supplier->product_supplier_reference = pSQL($reference);
$product_supplier->update(); $product_supplier->update();
+2 -7
View File
@@ -226,13 +226,8 @@ class AdminShopControllerCore extends AdminController
if (Tools::isSubmit('submitAddshopAndStay') || Tools::isSubmit('submitAddshop')) if (Tools::isSubmit('submitAddshopAndStay') || Tools::isSubmit('submitAddshop'))
{ {
$same_name = Db::getInstance()->getValue(' $shop_group = new ShopGroup((int)Tools::getValue('id_shop_group'));
SELECT id_shop if ($shop_group->shopNameExists(Tools::getValue('name'), (int)Tools::getValue('id_shop')))
FROM '._DB_PREFIX_.'shop
WHERE name = "'.pSQL(Tools::getValue('name')).'"
AND id_shop_group = '.(int)Tools::getValue('id_shop_group').'
'.(Tools::getValue('id_shop') ? 'AND id_shop != '.(int)Tools::getValue('id_shop') : ''));
if ($same_name)
$this->errors[] = Tools::displayError('You cannot have two shops with the same name in the same group.'); $this->errors[] = Tools::displayError('You cannot have two shops with the same name in the same group.');
} }
+14 -11
View File
@@ -166,18 +166,21 @@ class AdminTabsControllerCore extends AdminController
) )
); );
if (!Validate::isLoadedObject($this->object) || $this->object->id_parent > 0) $display_parent = true;
if (Validate::isLoadedObject($this->object) && !class_exists($this->object->class_name.'Controller'))
$display_parent = false;
$this->fields_form['input'][] = array( if ($display_parent)
'type' => 'select', $this->fields_form['input'][] = array(
'label' => $this->l('Parent:'), 'type' => 'select',
'name' => 'id_parent', 'label' => $this->l('Parent:'),
'options' => array( 'name' => 'id_parent',
'query' => $tabs, 'options' => array(
'id' => 'id_tab', 'query' => $tabs,
'name' => 'name' 'id' => 'id_tab',
) 'name' => 'name'
); )
);
return parent::renderForm(); return parent::renderForm();
} }
@@ -426,8 +426,8 @@ class AdminTranslationsControllerCore extends AdminController
{ {
$this->exportTabs(); $this->exportTabs();
$items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true)); $items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true));
$gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_.'/export/'.$this->lang_selected->iso_code.'.gzip', true); $file_name = _PS_TRANSLATIONS_DIR_.'/export/'.$this->lang_selected->iso_code.'.gzip';
$file_name = Tools::getCurrentUrlProtocolPrefix().Tools::getShopDomain().__PS_BASE_URI__.'translations/export/'.$this->lang_selected->iso_code.'.gzip'; $gz = new Archive_Tar($file_name, true);
if ($gz->createModify($items, null, _PS_ROOT_DIR_)); if ($gz->createModify($items, null, _PS_ROOT_DIR_));
{ {
ob_start(); ob_start();
@@ -440,7 +440,8 @@ class AdminTranslationsControllerCore extends AdminController
header('Content-Disposition: attachment; filename="'.$this->lang_selected->iso_code.'.gzip'.'"'); header('Content-Disposition: attachment; filename="'.$this->lang_selected->iso_code.'.gzip'.'"');
header('Content-Transfer-Encoding: binary'); header('Content-Transfer-Encoding: binary');
ob_end_flush(); ob_end_flush();
@readfile($file_name); readfile($file_name);
@unlink($file_name);
exit; exit;
} }
$this->errors[] = Tools::displayError('An error occurred while creating archive.'); $this->errors[] = Tools::displayError('An error occurred while creating archive.');
@@ -936,7 +937,6 @@ class AdminTranslationsControllerCore extends AdminController
$this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = html_entity_decode($GLOBALS[$name_var][$default_key], ENT_COMPAT, 'UTF-8'); $this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = html_entity_decode($GLOBALS[$name_var][$default_key], ENT_COMPAT, 'UTF-8');
else else
{ {
//d(array($module_key, $default_key, $key, $GLOBALS[$name_var]));
$this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = ''; $this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = '';
$this->missing_translations++; $this->missing_translations++;
} }
@@ -1470,12 +1470,10 @@ class AdminTranslationsControllerCore extends AdminController
$array_subjects = array(); $array_subjects = array();
if (($subjects = Tools::getValue('subject')) && is_array($subjects)) if (($subjects = Tools::getValue('subject')) && is_array($subjects))
{ {
$array_subjects['core_and_modules'] = array('translations'=>array(), 'path'=>$arr_mail_path['core_mail'].'lang.php'); $array_subjects['core_and_modules'] = array('translations' => array(), 'path' => $arr_mail_path['core_mail'].'lang.php');
foreach ($subjects as $subject_translation) foreach ($subjects as $subject_translation)
$array_subjects['core_and_modules']['translations'] = array_merge($array_subjects['core_and_modules']['translations'], $subject_translation); $array_subjects['core_and_modules']['translations'] = array_merge($array_subjects['core_and_modules']['translations'], $subject_translation);
} }
if (!empty($array_subjects)) if (!empty($array_subjects))
foreach ($array_subjects as $infos) foreach ($array_subjects as $infos)
$this->writeSubjectTranslationFile($infos['translations'], $infos['path']); $this->writeSubjectTranslationFile($infos['translations'], $infos['path']);
@@ -1775,12 +1773,14 @@ class AdminTranslationsControllerCore extends AdminController
if (preg_match('#controllers#', $tmp)) if (preg_match('#controllers#', $tmp))
{ {
$parent_class = explode(DIRECTORY_SEPARATOR, $tmp); $parent_class = explode(DIRECTORY_SEPARATOR, str_replace('/', DIRECTORY_SEPARATOR, $tmp));
$override = array_search('override', $parent_class); $override = array_search('override', $parent_class);
if ($override !== false) if ($override !== false)
$prefix_key = 'Admin'.ucfirst($parent_class[count($parent_class) - 1]); // case override/controllers/admin/templates/controller_name
$prefix_key = 'Admin'.ucfirst($parent_class[$override + 4]);
else else
{ {
// case admin_name/themes/theme_name/template/controllers/controller_name
$key = array_search('controllers', $parent_class); $key = array_search('controllers', $parent_class);
$prefix_key = 'Admin'.ucfirst($parent_class[$key + 1]); $prefix_key = 'Admin'.ucfirst($parent_class[$key + 1]);
} }
@@ -2146,32 +2146,37 @@ class AdminTranslationsControllerCore extends AdminController
<div name="mails_div" id="'.$id_html.'">'; <div name="mails_div" id="'.$id_html.'">';
if (!empty($mails['files'])) if (!empty($mails['files']))
{ {
$topic_already_displayed = array();
foreach ($mails['files'] as $mail_name => $mail_files) foreach ($mails['files'] as $mail_name => $mail_files)
{ {
if (array_key_exists('html', $mail_files) || array_key_exists('txt', $mail_files)) if (array_key_exists('html', $mail_files) || array_key_exists('txt', $mail_files))
{ {
if (array_key_exists($mail_name, $all_subject_mail)) if (array_key_exists($mail_name, $all_subject_mail))
{ {
$subject_mail = $all_subject_mail[$mail_name]; foreach ($all_subject_mail[$mail_name] as $subject_mail)
$value_subject_mail = isset($mails['subject'][$subject_mail]) ? $mails['subject'][$subject_mail] : ''; {
$str_return .= ' $subject_key = 'subject['.Tools::htmlentitiesUTF8($group_name).']['.Tools::htmlentitiesUTF8($subject_mail).']';
<div class="label-subject" style="text-align:center;"> if (in_array($subject_key, $topic_already_displayed))
<label style="text-align:right">'.sprintf($this->l('Subject for %s:'), '<em>'.$mail_name.'</em>').'</label> continue;
<div class="mail-form" style="text-align:left"> $topic_already_displayed[] = $subject_key;
<b>'.$subject_mail.'</b><br />'; $value_subject_mail = isset($mails['subject'][$subject_mail]) ? $mails['subject'][$subject_mail] : '';
if (isset($value_subject_mail['trad']) && $value_subject_mail['trad']) $str_return .= '
$str_return .= '<input type="text" name="subject['.$group_name.']['.$subject_mail.']" value="'.$value_subject_mail['trad'].'" />'; <div class="label-subject" style="text-align:center;">
else <label style="text-align:right">'.sprintf($this->l('Subject for %s:'), '<em>'.$mail_name.'</em>').'</label>
$str_return .= '<input type="text" name="subject['.$group_name.']['.$subject_mail.']" value="" />'; <div class="mail-form" style="text-align:left">
<b>'.$subject_mail.'</b><br />';
if (isset($value_subject_mail['trad']) && $value_subject_mail['trad'])
$str_return .= '<input type="text" name="subject['.Tools::htmlentitiesUTF8($group_name).']['.Tools::htmlentitiesUTF8($subject_mail).']" value="'.$value_subject_mail['trad'].'" />';
else
$str_return .= '<input type="text" name="subject['.Tools::htmlentitiesUTF8($group_name).']['.Tools::htmlentitiesUTF8($subject_mail).']" value="" />';
if (isset($value_subject_mail['use_sprintf']) && $value_subject_mail['use_sprintf']) if (isset($value_subject_mail['use_sprintf']) && $value_subject_mail['use_sprintf'])
{ $str_return .= '<a class="useSpecialSyntax" title="'.$this->l('This expression uses a special syntax:').' '.$value_subject_mail['use_sprintf'].'" style="cursor:pointer">
$str_return .= '<a class="useSpecialSyntax" title="'.$this->l('This expression uses a special syntax:').' '.$value_subject_mail['use_sprintf'].'" style="cursor:pointer"> <img src="'._PS_IMG_.'admin/error.png" alt="'.$value_subject_mail['use_sprintf'].'" />
<img src="'._PS_IMG_.'admin/error.png" alt="'.$value_subject_mail['use_sprintf'].'" /> </a>';
</a>';
}
$str_return .= '</div> $str_return .= '</div>
</div>'; </div>';
}
} }
else else
{ {
@@ -2193,12 +2198,11 @@ class AdminTranslationsControllerCore extends AdminController
} }
} }
else else
{ $str_return .= '<p class="error">
$str_return .= ' '.$this->l('There was a problem getting the mail files.').'<br />
<p class="error">'.$this->l('There was a problem getting the mail files.').'<br />' '.sprintf($this->l('English language files must exist in %s folder'), '<em>'.preg_replace('@/[a-z]{2}(/?)$@', '/en$1', $mails['directory']).'</em>').'
.sprintf($this->l('English language files must exist in %s folder'), '<em>'.$mails['directory'].'en</em>') </p>';
.'</p>';
}
$str_return .= ' $str_return .= '
</div><!-- #'.$id_html.' --> </div><!-- #'.$id_html.' -->
<div class="clear"></div> <div class="clear"></div>
@@ -2409,21 +2413,27 @@ class AdminTranslationsControllerCore extends AdminController
$content = file_get_contents($dir.'/'.$file); $content = file_get_contents($dir.'/'.$file);
$content = str_replace("\n", ' ', $content); $content = str_replace("\n", ' ', $content);
// Subject must match with a template, therefor we first grep the Mail::Send() function then the Mail::l() inside.
if (preg_match_all('/Mail::Send([^;]*);/si', $content, $tab)) if (preg_match_all('/Mail::Send([^;]*);/si', $content, $tab))
for ($i = 0; isset($tab[1][$i]); $i++) for ($i = 0; isset($tab[1][$i]); $i++)
{ {
$tab2 = explode(',', $tab[1][$i]); $tab2 = explode(',', $tab[1][$i]);
if (is_array($tab2)) if (is_array($tab2) && isset($tab2[1]))
if ($tab2 && isset($tab2[1])) {
{ $template = trim(str_replace('\'', '', $tab2[1]));
$tab2[1] = trim(str_replace('\'', '', $tab2[1])); foreach ($tab2 as $tab3)
if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'/s', $tab2[2], $matches)) if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'\)/Us', $tab3.')', $matches))
$subject_mail[$tab2[1]] = $matches[1]; {
} if (!isset($subject_mail[$template]))
$subject_mail[$template] = array();
if (!in_array($matches[1], $subject_mail[$template]))
$subject_mail[$template][] = $matches[1];
}
}
} }
if (!in_array($file, self::$ignore_folder) && is_dir($dir.'/'.$file)) if (!in_array($file, self::$ignore_folder) && is_dir($dir.'/'.$file))
$subject_mail = $this->getSubjectMail($dir, $file, $subject_mail); $subject_mail = $this->getSubjectMail($dir, $file, $subject_mail);
return $subject_mail; return $subject_mail;
} }
+4 -8
View File
@@ -85,11 +85,7 @@ class AuthControllerCore extends FrontController
$this->assignCountries(); $this->assignCountries();
$active_module_newsletter = false; $this->context->smarty->assign('newsletter', 1);
if ($module_newsletter = Module::getInstanceByName('blocknewsletter'))
$active_module_newsletter = $module_newsletter->active;
$this->context->smarty->assign('newsletter', (int)$active_module_newsletter);
$back = Tools::getValue('back'); $back = Tools::getValue('back');
$key = Tools::safeOutput(Tools::getValue('key')); $key = Tools::safeOutput(Tools::getValue('key'));
@@ -403,8 +399,8 @@ class AuthControllerCore extends FrontController
if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')) if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))
$error_phone = true; $error_phone = true;
} }
elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || Configuration::get('PS_ORDER_PROCESS_TYPE')) elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE'))
&& (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create'))) || (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create')))
&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))) && (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
$error_phone = true; $error_phone = true;
elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE') && Tools::getValue('email_create'))) elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE') && Tools::getValue('email_create')))
@@ -418,7 +414,7 @@ class AuthControllerCore extends FrontController
$this->errors = array_unique(array_merge($this->errors, $customer->validateController())); $this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
// Check the requires fields which are settings in the BO // Check the requires fields which are settings in the BO
$this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase()); $this->errors = $this->errors + $customer->validateFieldsRequiredDatabase();
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount'))
{ {
+18 -10
View File
@@ -170,6 +170,7 @@ class ContactControllerCore extends FrontController
'{attached_file}' => '-', '{attached_file}' => '-',
'{message}' => Tools::nl2br(stripslashes($message)), '{message}' => Tools::nl2br(stripslashes($message)),
'{email}' => $from, '{email}' => $from,
'{product_name}' => '',
); );
if (isset($filename)) if (isset($filename))
@@ -177,14 +178,10 @@ class ContactControllerCore extends FrontController
$id_order = (int)Tools::getValue('id_order'); $id_order = (int)Tools::getValue('id_order');
if (isset($ct) && Validate::isLoadedObject($ct)) $id_product = (int)Tools::getValue('id_product');
{
if ($ct->id_order) if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order)
$id_order = $ct->id_order; $id_order = $ct->id_order;
$subject = sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token);
}
else
$subject = Mail::l('Your message has been correctly sent');
if ($id_order) if ($id_order)
{ {
@@ -193,14 +190,25 @@ class ContactControllerCore extends FrontController
$var_list['{id_order}'] = $id_order; $var_list['{id_order}'] = $id_order;
} }
if ($id_product)
{
$product = new Product((int)$id_product);
if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id]))
$var_list['{product_name}'] = $product->name[Context::getContext()->language->id];
}
if (empty($contact->email)) if (empty($contact->email))
Mail::Send($this->context->language->id, 'contact_form', $subject, $var_list, $from, null, null, null, $fileAttachment); 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 else
{ {
if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]', if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]',
$var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''), $var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''),
$fileAttachment) || $fileAttachment) ||
!Mail::Send($this->context->language->id, 'contact_form', $subject, $var_list, $from, null, $contact->email, $contact->name, $fileAttachment)) !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, $contact->email, $contact->name, $fileAttachment))
$this->errors[] = Tools::displayError('An error occurred while sending the message.'); $this->errors[] = Tools::displayError('An error occurred while sending the message.');
} }
} }
+1 -1
View File
@@ -73,7 +73,7 @@ class OrderDetailControllerCore extends FrontController
$ct->id_contact = 0; $ct->id_contact = 0;
$ct->id_customer = (int)$order->id_customer; $ct->id_customer = (int)$order->id_customer;
$ct->id_shop = (int)$this->context->shop->id; $ct->id_shop = (int)$this->context->shop->id;
if ($id_product = (int)Tools::getValue('id_product') && $order->orderContainProduct((int)$id_product)) if (($id_product = (int)Tools::getValue('id_product')) && $order->orderContainProduct((int)$id_product))
$ct->id_product = $id_product; $ct->id_product = $id_product;
$ct->id_order = (int)$order->id; $ct->id_order = (int)$order->id;
$ct->id_lang = (int)$this->context->language->id; $ct->id_lang = (int)$this->context->language->id;
+4 -3
View File
@@ -40,11 +40,12 @@ class OrderFollowControllerCore extends FrontController
if (Tools::isSubmit('submitReturnMerchandise')) if (Tools::isSubmit('submitReturnMerchandise'))
{ {
$customizationQtyInput = Tools::getValue('customization_qty_input'); $customizationQtyInput = Tools::getValue('customization_qty_input');
$order_qte_input = Tools::getValue('order_qte_input');
$customizationIds = Tools::getValue('customization_ids');
if (!$id_order = (int)(Tools::getValue('id_order'))) if (!$id_order = (int)(Tools::getValue('id_order')))
Tools::redirect('index.php?controller=history'); Tools::redirect('index.php?controller=history');
if (!$order_qte_input = Tools::getValue('order_qte_input')) if (!$order_qte_input && !$customizationQtyInput && !$customizationIds)
Tools::redirect('index.php?controller=order-follow&errorDetail1');
if (!$customizationQtyInput && $customizationIds = Tools::getValue('customization_ids'))
Tools::redirect('index.php?controller=order-follow&errorDetail1'); Tools::redirect('index.php?controller=order-follow&errorDetail1');
if (!$customizationIds && !$ids_order_detail = Tools::getValue('ids_order_detail')) if (!$customizationIds && !$ids_order_detail = Tools::getValue('ids_order_detail'))
Tools::redirect('index.php?controller=order-follow&errorDetail2'); Tools::redirect('index.php?controller=order-follow&errorDetail2');
+18 -1
View File
@@ -376,6 +376,9 @@ class OrderOpcControllerCore extends ParentOrderController
$customer = $this->context->customer; $customer = $this->context->customer;
$address_delivery = new Address($this->context->cart->id_address_delivery); $address_delivery = new Address($this->context->cart->id_address_delivery);
$id_address_invoice = $this->context->cart->id_address_invoice != $this->context->cart->id_address_delivery ? (int)$this->context->cart->id_address_invoice : 0;
$address_invoice = new Address($id_address_invoice);
if ($customer->birthday) if ($customer->birthday)
$birthday = explode('-', $customer->birthday); $birthday = explode('-', $customer->birthday);
else else
@@ -404,7 +407,21 @@ class OrderOpcControllerCore extends ParentOrderController
'id_gender' => (int)$customer->id_gender, 'id_gender' => (int)$customer->id_gender,
'sl_year' => $birthday[0], 'sl_year' => $birthday[0],
'sl_month' => $birthday[1], 'sl_month' => $birthday[1],
'sl_day' => $birthday[2] 'sl_day' => $birthday[2],
'id_address_invoice' => $id_address_invoice,
'company_invoice' => Tools::htmlentitiesUTF8($address_invoice->company),
'lastname_invoice' => Tools::htmlentitiesUTF8($address_invoice->lastname),
'firstname_invoice' => Tools::htmlentitiesUTF8($address_invoice->firstname),
'vat_number_invoice' => Tools::htmlentitiesUTF8($address_invoice->vat_number),
'dni_invoice' => Tools::htmlentitiesUTF8($address_invoice->dni),
'address1_invoice' => Tools::htmlentitiesUTF8($address_invoice->address1),
'address2_invoice' => Tools::htmlentitiesUTF8($address_invoice->address2),
'postcode_invoice' => Tools::htmlentitiesUTF8($address_invoice->postcode),
'city_invoice' => Tools::htmlentitiesUTF8($address_invoice->city),
'phone_invoice' => Tools::htmlentitiesUTF8($address_invoice->phone),
'phone_mobile_invoice' => Tools::htmlentitiesUTF8($address_invoice->phone_mobile),
'id_country_invoice' => (int)($address_invoice->id_country),
'id_state_invoice' => (int)($address_invoice->id_state),
); );
} }
+10 -6
View File
@@ -143,7 +143,8 @@ class ProductControllerCore extends FrontController
// Load category // Load category
if (isset($_SERVER['HTTP_REFERER']) if (isset($_SERVER['HTTP_REFERER'])
&& strstr($_SERVER['HTTP_REFERER'], Tools::getHttpHost()) // Assure us the previous page was one of the shop && strstr($_SERVER['HTTP_REFERER'], Tools::getHttpHost()) // Assure us the previous page was one of the shop
&& preg_match('!^(.*)\/([0-9]+)\-(.*[^\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs)) && (stripos($_SERVER['HTTP_REFERER'], '.html') === false)
&& preg_match('~^(.*)\/([0-9]+)\-((?![.]+html).*)|(.*)id_category=([0-9]+)(.*)$~', $_SERVER['HTTP_REFERER'], $regs))
{ {
// If the previous page was a category and is a parent category of the product use this category as parent category // If the previous page was a category and is a parent category of the product use this category as parent category
if (isset($regs[2]) && is_numeric($regs[2])) if (isset($regs[2]) && is_numeric($regs[2]))
@@ -454,7 +455,7 @@ class ProductControllerCore extends FrontController
{ {
if (isset($this->context->smarty->tpl_vars['images']->value)) if (isset($this->context->smarty->tpl_vars['images']->value))
$product_images = $this->context->smarty->tpl_vars['images']->value; $product_images = $this->context->smarty->tpl_vars['images']->value;
if (is_array($product_images) && isset($product_images[$id_image])) if (isset($product_images) && is_array($product_images) && isset($product_images[$id_image]))
{ {
$product_images[$id_image]['cover'] = 1; $product_images[$id_image]['cover'] = 1;
$this->context->smarty->assign('mainImage', $product_images[$id_image]); $this->context->smarty->assign('mainImage', $product_images[$id_image]);
@@ -463,7 +464,7 @@ class ProductControllerCore extends FrontController
} }
if (isset($this->context->smarty->tpl_vars['cover']->value)) if (isset($this->context->smarty->tpl_vars['cover']->value))
$cover = $this->context->smarty->tpl_vars['cover']->value; $cover = $this->context->smarty->tpl_vars['cover']->value;
if (is_array($cover) && is_array($product_images)) if (isset($cover) && is_array($cover) && isset($product_images) && is_array($product_images))
{ {
$product_images[$cover['id_image']]['cover'] = 0; $product_images[$cover['id_image']]['cover'] = 0;
if (isset($product_images[$id_image])) if (isset($product_images[$id_image]))
@@ -510,9 +511,12 @@ class ProductControllerCore extends FrontController
protected function assignAttributesCombinations() protected function assignAttributesCombinations()
{ {
$attributes_combinations = Product::getAttributesInformationsByProduct($this->product->id); $attributes_combinations = Product::getAttributesInformationsByProduct($this->product->id);
foreach ($attributes_combinations as &$ac) if (is_array($attributes_combinations) && count($attributes_combinations))
foreach ($ac as &$val) foreach ($attributes_combinations as &$ac)
$val = str_replace('-', '_', Tools::link_rewrite(str_replace(array(',', '.'), '-', $val))); foreach ($ac as &$val)
$val = str_replace('-', '_', Tools::link_rewrite(str_replace(array(',', '.'), '-', $val)));
else
$attributes_combinations = array();
$this->context->smarty->assign('attributesCombinations', $attributes_combinations); $this->context->smarty->assign('attributesCombinations', $attributes_combinations);
} }
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=discount'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); Tools::redirect('index.php?controller=discount'.((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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=get-file'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); Tools::redirect('index.php?controller=get-file'.((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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=history'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); Tools::redirect('index.php?controller=history'.((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'); require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated(); Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=identity'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently'); Tools::redirect('index.php?controller=identity'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+3 -2
View File
@@ -42,8 +42,9 @@ class InstallSession
public function __construct() public function __construct()
{ {
session_name('install_'.md5(__PS_BASE_URI__)); session_name('install_'.md5($_SERVER['HTTP_HOST']));
if (!($session_started = session_start()) $session_started = session_start();
if (!($session_started)
|| (!isset($_SESSION['session_mode']) && (isset($_POST['submitNext']) || isset($_POST['submitPrevious']) || isset($_POST['language'])))) || (!isset($_SESSION['session_mode']) && (isset($_POST['submitNext']) || isset($_POST['submitPrevious']) || isset($_POST['language']))))
{ {
InstallSession::$_cookie_mode = true; InstallSession::$_cookie_mode = true;
+17 -25
View File
@@ -56,7 +56,6 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$this->session->database_login = trim(Tools::getValue('dbLogin')); $this->session->database_login = trim(Tools::getValue('dbLogin'));
$this->session->database_password = trim(Tools::getValue('dbPassword')); $this->session->database_password = trim(Tools::getValue('dbPassword'));
$this->session->database_prefix = trim(Tools::getValue('db_prefix')); $this->session->database_prefix = trim(Tools::getValue('db_prefix'));
$this->session->database_engine = Tools::getValue('dbEngine');
$this->session->database_clear = Tools::getValue('database_clear'); $this->session->database_clear = Tools::getValue('database_clear');
// Save email config // Save email config
@@ -81,21 +80,23 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$this->session->database_login, $this->session->database_login,
$this->session->database_password, $this->session->database_password,
$this->session->database_prefix, $this->session->database_prefix,
$this->session->database_engine,
// We do not want to validate table prefix if we are already in install process // We do not want to validate table prefix if we are already in install process
($this->session->step == 'process') ? true : $this->session->database_clear ($this->session->step == 'process') ? true : $this->session->database_clear
); );
if (count($this->errors))
return false;
return count($this->errors) ? false : true; if (!isset($this->session->database_engine))
$this->session->database_engine = $this->model_database->getBestEngine($this->session->database_server, $this->session->database_name, $this->session->database_login, $this->session->database_password);
return true;
} }
public function process() public function process()
{ {
if (Tools::getValue('checkDb')) if (Tools::getValue('checkDb'))
$this->processCheckDb(); $this->processCheckDb();
else if (Tools::getValue('sendMail')) elseif (Tools::getValue('createDb'))
$this->processSendMail(); $this->processCreateDb();
} }
/** /**
@@ -108,10 +109,9 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$login = Tools::getValue('dbLogin'); $login = Tools::getValue('dbLogin');
$password = Tools::getValue('dbPassword'); $password = Tools::getValue('dbPassword');
$prefix = Tools::getValue('db_prefix'); $prefix = Tools::getValue('db_prefix');
$engine = Tools::getValue('dbEngine');
$clear = Tools::getValue('clear'); $clear = Tools::getValue('clear');
$errors = $this->model_database->testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear); $errors = $this->model_database->testDatabaseSettings($server, $database, $login, $password, $prefix, $clear);
$this->ajaxJsonAnswer( $this->ajaxJsonAnswer(
(count($errors)) ? false : true, (count($errors)) ? false : true,
@@ -120,28 +120,20 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
} }
/** /**
* Send a test email * Attempt to create the database
*/ */
public function processSendMail() public function processCreateDb()
{ {
$smtp_checked = (Tools::getValue('smtpChecked') == 'true'); $server = Tools::getValue('dbServer');
$server = Tools::getValue('smtpSrv'); $database = Tools::getValue('dbName');
$encryption = Tools::getValue('smtpEnc'); $login = Tools::getValue('dbLogin');
$port = Tools::getValue('smtpPort'); $password = Tools::getValue('dbPassword');
$login = Tools::getValue('smtpLogin');
$password = Tools::getValue('smtpPassword');
$email = Tools::getValue('testEmail');
require_once _PS_INSTALL_MODELS_PATH_.'mail.php'; $success = $this->model_database->createDatabase($server, $database, $login, $password);
$this->model_mail = new InstallModelMail($smtp_checked, $server, $login, $password, $port, $encryption, $email);
$result = $this->model_mail->send(
$this->l('Test message from PrestaShop'),
$this->l('This is a test message, your server is now available to send email')
);
$this->ajaxJsonAnswer( $this->ajaxJsonAnswer(
$result === false, $success,
($result === false) ? $this->l('A test e-mail has been sent to %s', $email) : $this->l('An error occurred while sending email, please verify your parameters') $success ? $this->l('Database is created') : $this->l('Cannot create the database automatically')
); );
} }
+1
View File
@@ -1924,6 +1924,7 @@ CREATE TABLE `PREFIX_log` (
`message` text NOT NULL, `message` text NOT NULL,
`object_type` varchar(32) DEFAULT NULL, `object_type` varchar(32) DEFAULT NULL,
`object_id` int(10) unsigned DEFAULT NULL, `object_id` int(10) unsigned DEFAULT NULL,
`id_employee` int(10) unsigned DEFAULT NULL,
`date_add` datetime NOT NULL, `date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL, `date_upd` datetime NOT NULL,
PRIMARY KEY (`id_log`) PRIMARY KEY (`id_log`)
+1 -1
View File
@@ -96,7 +96,7 @@
<access id="access_2_85" id_profile="Administrator" id_tab="Webservice" view="1" add="1" edit="1" delete="1"/> <access id="access_2_85" id_profile="Administrator" id_tab="Webservice" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_86" id_profile="Administrator" id_tab="Preferences_1" view="1" add="1" edit="1" delete="1"/> <access id="access_2_86" id_profile="Administrator" id_tab="Preferences_1" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_87" id_profile="Administrator" id_tab="Quick_Access" view="1" add="1" edit="1" delete="1"/> <access id="access_2_87" id_profile="Administrator" id_tab="Quick_Access" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_88" id_profile="Administrator" id_tab="Employees" view="1" add="1" edit="1" delete="1"/> <access id="access_2_88" id_profile="Administrator" id_tab="Employees" view="1" add="0" edit="0" delete="0"/>
<access id="access_2_89" id_profile="Administrator" id_tab="Profiles" view="1" add="1" edit="1" delete="1"/> <access id="access_2_89" id_profile="Administrator" id_tab="Profiles" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_90" id_profile="Administrator" id_tab="Permissions" view="1" add="1" edit="1" delete="1"/> <access id="access_2_90" id_profile="Administrator" id_tab="Permissions" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_91" id_profile="Administrator" id_tab="Tabs" view="1" add="1" edit="1" delete="1"/> <access id="access_2_91" id_profile="Administrator" id_tab="Tabs" view="1" add="1" edit="1" delete="1"/>
+1 -1
View File
@@ -41,7 +41,7 @@
<field name="valid"/> <field name="valid"/>
</fields> </fields>
<entities> <entities>
<orders id="orders_1" reference="XKBKNABJK" id_shop_group="1" id_shop="1" id_carrier="My_carrier" id_customer="John" id_cart="cart_1" id_currency="1" id_address_delivery="Mon_adresse" id_address_invoice="Mon_adresse" current_state="1" secure_key="47ce86627c1f3c792a80773c5d2deaf8" conversion_rate="1.000000" recyclable="0" gift="0" shipping_number="" total_discounts="0.00" total_discounts_tax_incl="0.00" total_paid="626.37" total_paid_tax_incl="626.37" total_paid_tax_excl="523.72" total_paid_real="626.37" total_products="516.72" total_products_wt="618.00" total_shipping="7.98" total_shipping_tax_incl="8.37" total_shipping_tax_excl="7.00" carrier_tax_rate="19.600" total_wrapping="0.00" total_wrapping_tax_incl="0.00" total_wrapping_tax_excl="0.00" invoice_number="0" delivery_number="0" invoice_date="0000-00-00 00:00:00" delivery_date="0000-00-00 00:00:00" valid="0"> <orders id="orders_1" reference="XKBKNABJK" id_shop_group="1" id_shop="1" id_carrier="My_carrier" id_customer="John" id_cart="cart_1" id_currency="1" id_address_delivery="Mon_adresse" id_address_invoice="Mon_adresse" current_state="1" secure_key="47ce86627c1f3c792a80773c5d2deaf8" conversion_rate="1.000000" recyclable="0" gift="0" shipping_number="" total_discounts="0.00" total_discounts_tax_incl="0.00" total_paid="626.37" total_paid_tax_incl="626.37" total_paid_tax_excl="523.72" total_paid_real="0" total_products="516.72" total_products_wt="618.00" total_shipping="7.98" total_shipping_tax_incl="8.37" total_shipping_tax_excl="7.00" carrier_tax_rate="19.600" total_wrapping="0.00" total_wrapping_tax_incl="0.00" total_wrapping_tax_excl="0.00" invoice_number="0" delivery_number="0" invoice_date="0000-00-00 00:00:00" delivery_date="0000-00-00 00:00:00" valid="0">
<payment>Chèque</payment> <payment>Chèque</payment>
<module>cheque</module> <module>cheque</module>
<gift_message/> <gift_message/>
+26 -14
View File
@@ -38,7 +38,7 @@ class InstallModelDatabase extends InstallAbstractModel
* @param bool $clear * @param bool $clear
* @return array List of errors * @return array List of errors
*/ */
public function testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear = false) public function testDatabaseSettings($server, $database, $login, $password, $prefix, $clear = false)
{ {
$errors = array(); $errors = array();
@@ -55,14 +55,11 @@ class InstallModelDatabase extends InstallAbstractModel
if ($prefix && !Validate::isTablePrefix($prefix)) if ($prefix && !Validate::isTablePrefix($prefix))
$errors[] = $this->language->l('Tables prefix is invalid'); $errors[] = $this->language->l('Tables prefix is invalid');
if (!Validate::isMySQLEngine($engine))
$errors[] = $this->language->l('Wrong engine chosen for MySQL');
if (!$errors) if (!$errors)
{ {
$dbtype = ' ('.Db::getClass().')'; $dbtype = ' ('.Db::getClass().')';
// Try to connect to database // Try to connect to database
switch (Db::checkConnection($server, $login, $password, $database, true, $engine)) switch (Db::checkConnection($server, $login, $password, $database, true))
{ {
case 0: case 0:
if (!Db::checkEncoding($server, $login, $password)) if (!Db::checkEncoding($server, $login, $password))
@@ -71,28 +68,43 @@ class InstallModelDatabase extends InstallAbstractModel
// Check if a table with same prefix already exists // Check if a table with same prefix already exists
if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix)) if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix))
$errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database'); $errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database');
if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix, $engine)) !== true) if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix)) !== true)
{ {
$errors[] = $this->language->l(sprintf('Your database login don\'t have the privileges to create table on the database "%s". Ask your hosting provider:', $database)); $errors[] = $this->language->l(sprintf('Your database login don\'t have the privileges to create table on the database "%s". Ask your hosting provider:', $database));
if ($create_error != false) if ($create_error != false)
$errors[] = $create_error; $errors[] = $create_error;
} }
break; break;
case 1: case 1:
$errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields').$dbtype; $errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields').$dbtype;
break; break;
case 2: case 2:
$errors[] = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype; $error = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype;
break; if ($this->createDatabase($server, $database, $login, $password, true))
$error .= '<p>'.sprintf('<input type="button" value="%s" class="button" id="btCreateDB">', $this->language->l('Attempt to create the database automatically')).'</p>
case 4: <script type="text/javascript">bindCreateDB();</script>';
$errors[] = $this->language->l('Engine innoDB is not supported by your MySQL server, please use MyISAM').$dbtype; $errors[] = $error;
break; break;
} }
} }
return $errors; return $errors;
} }
public function createDatabase($server, $database, $login, $password, $dropit = false)
{
$class = Db::getClass();
return $class::createDatabase($server, $login, $password, $database, $dropit);
}
public function getBestEngine($server, $database, $login, $password)
{
$class = Db::getClass();
$instance = new $class($server, $login, $password, $database, true);
$engine = $instance->getBestEngine();
unset($instance);
return $engine;
}
} }
+1 -1
View File
@@ -307,7 +307,7 @@ class InstallModelInstall extends InstallAbstractModel
if (!$xml = @simplexml_load_file(_PS_INSTALL_LANGS_PATH_.$iso.'/language.xml')) if (!$xml = @simplexml_load_file(_PS_INSTALL_LANGS_PATH_.$iso.'/language.xml'))
throw new PrestashopInstallerException($this->language->l('File "language.xml" not valid for language iso "%s"', $iso)); throw new PrestashopInstallerException($this->language->l('File "language.xml" not valid for language iso "%s"', $iso));
$params_lang = array('name' => (string)$xml->name, 'iso_code' => (string)$xml->language_code); $params_lang = array('name' => (string)$xml->name, 'iso_code' => substr((string)$xml->language_code, 0, 2));
if (InstallSession::getInstance()->safe_mode) if (InstallSession::getInstance()->safe_mode)
Language::checkAndAddLanguage($iso, false, true, $params_lang); Language::checkAndAddLanguage($iso, false, true, $params_lang);
+38 -1
View File
@@ -31,9 +31,46 @@ $(document).ready(function()
$("#dbResultCheck") $("#dbResultCheck")
.addClass('errorBlock') .addClass('errorBlock')
.removeClass('okBlock') .removeClass('okBlock')
.html('An error occurred:<br /><br />'+xhr.responseText) .html('An error occurred:<br /><br />' + xhr.responseText)
.slideDown('slow'); .slideDown('slow');
} }
}); });
}); });
}); });
function bindCreateDB()
{
// Attempt to create the database
$('#btCreateDB').click(function()
{
$("#dbResultCheck").slideUp('fast');
$.ajax({
url: 'index.php',
data: {
'createDb': 'true',
'dbServer': $('#dbServer').val(),
'dbName': $('#dbName').val(),
'dbLogin': $('#dbLogin').val(),
'dbPassword': $('#dbPassword').val()
},
dataType: 'json',
cache: false,
success: function(json)
{
$("#dbResultCheck")
.addClass((json.success) ? 'okBlock' : 'errorBlock')
.removeClass((json.success) ? 'errorBlock' : 'okBlock')
.html(json.message)
.slideDown('slow');
},
error: function(xhr)
{
$("#dbResultCheck")
.addClass('errorBlock')
.removeClass('okBlock')
.html('An error occurred:<br /><br />' + xhr.responseText)
.slideDown('slow');
}
});
});
}
+2 -1
View File
@@ -27,13 +27,14 @@
<label for="dbPassword"><?php echo $this->l('Database password:') ?> </label> <label for="dbPassword"><?php echo $this->l('Database password:') ?> </label>
<input class="text" size="10" type="password" id="dbPassword" name="dbPassword" value="<?php echo htmlspecialchars($this->database_password) ?>" /> <input class="text" size="10" type="password" id="dbPassword" name="dbPassword" value="<?php echo htmlspecialchars($this->database_password) ?>" />
</p> </p>
<!--
<p> <p>
<label for="dbEngine"><?php echo $this->l('Database Engine:') ?></label> <label for="dbEngine"><?php echo $this->l('Database Engine:') ?></label>
<select id="dbEngine" name="dbEngine"> <select id="dbEngine" name="dbEngine">
<option value="InnoDB" <?php if ($this->database_engine == 'InnoDB'): ?>selected="selected"<?php endif; ?>>InnoDB</option> <option value="InnoDB" <?php if ($this->database_engine == 'InnoDB'): ?>selected="selected"<?php endif; ?>>InnoDB</option>
<option value="MyISAM" <?php if ($this->database_engine == 'MyISAM'): ?>selected="selected"<?php endif; ?>>MyISAM</option> <option value="MyISAM" <?php if ($this->database_engine == 'MyISAM'): ?>selected="selected"<?php endif; ?>>MyISAM</option>
</select> </select>
</p> </p>-->
<p> <p>
<label for="db_prefix"><?php echo $this->l('Tables prefix:')?></label> <label for="db_prefix"><?php echo $this->l('Tables prefix:')?></label>
<input class="text" type="text" id="db_prefix" name="db_prefix" value="<?php echo htmlspecialchars($this->database_prefix) ?>" /> <input class="text" type="text" id="db_prefix" name="db_prefix" value="<?php echo htmlspecialchars($this->database_prefix) ?>" />
@@ -26,6 +26,7 @@
function add_accounting_tab() function add_accounting_tab()
{ {
include_once(_PS_INSTALL_PATH_.'upgrade/php/add_new_tab.php');
$id_parent = add_new_tab( $id_parent = add_new_tab(
'AdminAccounting', 'AdminAccounting',
'en:Accounting|fr:Comptabilité|es:Accounting|de:Accounting|it:Accounting', 'en:Accounting|fr:Comptabilité|es:Accounting|de:Accounting|it:Accounting',
@@ -34,7 +34,7 @@ function add_order_reference_in_order_payment()
ON o.id_order = op.id_order'); ON o.id_order = op.id_order');
if (!is_object($payments)) if (!is_object($payments))
return false; return true;
$errors = array(); $errors = array();
// Populate "order_reference" // Populate "order_reference"
@@ -62,7 +62,7 @@ function add_order_reference_in_order_payment()
HAVING COUNT(*) > 1'); HAVING COUNT(*) > 1');
if (!is_object($duplicate_lines)) if (!is_object($duplicate_lines))
return false; return true;
$order_payments_to_remove = array(); $order_payments_to_remove = array();
while ($order_payments = Db::getInstance()->nextRow($duplicate_lines)) while ($order_payments = Db::getInstance()->nextRow($duplicate_lines))
@@ -61,10 +61,10 @@ function create_multistore()
id_theme = (SELECT id_theme FROM '._DB_PREFIX_.'theme WHERE name="'.Db::getInstance()->escape(_THEME_NAME_).'") id_theme = (SELECT id_theme FROM '._DB_PREFIX_.'theme WHERE name="'.Db::getInstance()->escape(_THEME_NAME_).'")
WHERE id_shop = 1'); WHERE id_shop = 1');
$shop_domain = Db::getInstance()->getValue('SELECT `value` $shop_domain = Db::getInstance()->getValue('SELECT `value`
FROM `'._DB_PREFIX_.'_configuration` FROM `'._DB_PREFIX_.'configuration`
WHERE `name`="PS_SHOP_DOMAIN"'); WHERE `name`="PS_SHOP_DOMAIN"');
$shop_domain_ssl = Db::getInstance()->getValue('SELECT `value` $shop_domain_ssl = Db::getInstance()->getValue('SELECT `value`
FROM `'._DB_PREFIX_.'_configuration` FROM `'._DB_PREFIX_.'configuration`
WHERE `name`="PS_SHOP_DOMAIN_SSL"'); WHERE `name`="PS_SHOP_DOMAIN_SSL"');
if(empty($shop_domain)) if(empty($shop_domain))
{ {
@@ -78,11 +78,11 @@ function create_multistore()
VALUES(1, \''.pSQL($shop_domain).'\', \''.pSQL($shop_domain_ssl).'\', \''.pSQL($_PS_DIRECTORY_).'\', \'\', 1, 1)'); VALUES(1, \''.pSQL($shop_domain).'\', \''.pSQL($shop_domain_ssl).'\', \''.pSQL($_PS_DIRECTORY_).'\', \'\', 1, 1)');
// Stock conversion // Stock conversion
$sql = 'INSERT INTO `'._DB_PREFIX_.'.stock` (`id_product`, `id_product_attribute`, `id_group_shop`, `id_shop`, `quantity`) $sql = 'INSERT INTO `'._DB_PREFIX_.'stock` (`id_product`, `id_product_attribute`, `id_group_shop`, `id_shop`, `quantity`)
VALUES (SELECT p.`id_product`, 0, 1, 1, p.`quantity` FROM `'._DB_PREFIX_.'.product` p);'; VALUES (SELECT p.`id_product`, 0, 1, 1, p.`quantity` FROM `'._DB_PREFIX_.'product` p);';
$res &= Db::getInstance()->execute($sql); $res &= Db::getInstance()->execute($sql);
$sql = 'INSERT INTO `'._DB_PREFIX_.'.stock` (`id_product`, `id_product_attribute`, `id_group_shop`, `id_shop`, `quantity`) $sql = 'INSERT INTO `'._DB_PREFIX_.'stock` (`id_product`, `id_product_attribute`, `id_group_shop`, `id_shop`, `quantity`)
VALUES (SELECT `id_product`, `id_product_attribute`, 1, 1, `quantity` FROM `'._DB_PREFIX_.'product_attribute` p);'; VALUES (SELECT `id_product`, `id_product_attribute`, 1, 1, `quantity` FROM `'._DB_PREFIX_.'product_attribute` p);';
$res &= Db::getInstance()->execute($sql); $res &= Db::getInstance()->execute($sql);
+1 -1
View File
@@ -48,7 +48,7 @@ function p15012_add_missing_columns()
$q_list['cart_product']['id_shop']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product` $q_list['cart_product']['id_shop']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product`
CHANGE `id_shop` `id_shop` int(10) unsigned NOT NULL DEFAULT "1" AFTER `id_address_delivery`'; CHANGE `id_shop` `id_shop` int(10) unsigned NOT NULL DEFAULT "1" AFTER `id_address_delivery`';
$q_list['cart_product']['id_shop']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product` $q_list['cart_product']['id_shop']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product`
ADD `id_shop` `id_shop` int(10) unsigned NOT NULL DEFAULT "1" AFTER `id_address_delivery`'; ADD `id_shop` int(10) unsigned NOT NULL DEFAULT "1" AFTER `id_address_delivery`';
$q_list['cart_product']['id_product_attribute']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product` $q_list['cart_product']['id_product_attribute']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product`
CHANGE `id_product_attribute` `id_product_attribute` int(10) unsigned DEFAULT NULL AFTER `id_shop`'; CHANGE `id_product_attribute` `id_product_attribute` int(10) unsigned DEFAULT NULL AFTER `id_shop`';
$q_list['cart_product']['id_product_attribute']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product` $q_list['cart_product']['id_product_attribute']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product`
Loaded 100 of 444 files, more files were not shown because too many files have changed in this diff. Show more