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

This commit is contained in:
djfm
2013-07-12 09:50:04 +00:00
473 changed files with 12780 additions and 7349 deletions
+70 -1
View File
@@ -7,6 +7,15 @@
.DS_Store
robots.txt
sitemap.xml
cache/cachefs/*
!cache/cachefs/index.php
download/*
!download/index.php
upload/*
!upload/index.php
admin-dev/autoupgrade/*
admin-dev/backups/*
!admin-dev/backups/index.php
cache/smarty/cache/*
!cache/smarty/cache/index.php
cache/smarty/compile/*
@@ -16,6 +25,7 @@ cache/tcpdf/*
!cache/tcpdf/index.php
config/xml/*.xml
config/settings.inc.php
config/settings.old.php
log/*.log
img/*
!img/index.php
@@ -27,6 +37,10 @@ tools/smarty*/compile/*.php
override/classes/*.php
themes/default/cache/*.js
themes/default/cache/*.css
themes/default/modules/*/*.php
!themes/default/modules/*/index.php
themes/default/lang/*.php
!themes/default/lang/index.php
modules/*/translations/*.php
!modules/*/translations/index.php
mails/*
@@ -35,4 +49,59 @@ modules/*/mails/*
!modules/*/mails/en
translations/*
!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');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=address'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=address'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=addresses'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=addresses'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+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 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{
background: #e3e3e3 url('../img/bg-button-degrade.png') repeat-x scroll left top;
@@ -27,13 +27,7 @@
{block name="label"}
{if $input.name == 'vat_number'}
{if $vat == 'is_applicable'}
<div id="vat_area" style="display: visible">
{else if $vat == 'management'}
<div id="vat_area" style="display: hidden">
{else}
<div style="display: none;">
{/if}
<div id="vat_area" style="display: visible">
{/if}
{if $input.type == 'text_customer' && !isset($customer)}
@@ -106,63 +106,61 @@
if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']')
{
exist = true;
jAlert('{l s='This category already exists for this group.'}');
jAlert('{l s='This category already exists for this group.' js='1'}');
return false;
}
});
if (exist)
return;
$.ajax({
type:"POST",
url: "ajax-tab.php",
async: true,
dataType: "json",
data : {
ajax: "1",
token: "{getAdminToken tab='AdminGroups'}",
controller: "AdminGroups",
action: "addCategoryReduction",
category_reduction: $('#category_reduction_fancybox').val() ,
id_category: $('[name="id_category"]:checked').val()
},
success : function(jsonData)
type:"POST",
url: "ajax-tab.php",
async: true,
dataType: "json",
data : {
ajax: "1",
token: "{getAdminToken tab='AdminGroups'}",
controller: "AdminGroups",
action: "addCategoryReduction",
category_reduction: $('#category_reduction_fancybox').val() ,
id_category: $('[name="id_category"]:checked').val()
},
success : function(jsonData) {
if (jsonData.hasError)
{
if (jsonData.hasError)
{
var errors = '';
for(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
jAlert(errors);
}
else
{
$('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}'+jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
var input_hidden = document.createElement("input");
input_hidden.setAttribute('type', 'hidden');
input_hidden.setAttribute('value', jsonData.discount);
input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
input_hidden.setAttribute('class', 'category_reduction');
$('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
$.fancybox.close();
}
var errors = '';
for (error in jsonData.errors)
//IE6 bug fix
if (error != 'indexOf')
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
jAlert(errors);
}
});
else
{
$('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}'+jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
var input_hidden = document.createElement("input");
input_hidden.setAttribute('type', 'hidden');
input_hidden.setAttribute('value', jsonData.discount);
input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
input_hidden.setAttribute('class', 'category_reduction');
$('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
$.fancybox.close();
}
}
});
return false;
}
function initFancyBox()
{
$('[name="id_category"]:checked').removeAttr('checked');
collapseAllCategories();
$('#category_reduction_fancybox').val('0.00');
}
function initFancyBox()
{
$('[name="id_category"]:checked').removeAttr('checked');
collapseAllCategories();
$('#category_reduction_fancybox').val('0.00');
}
</script>
<div class="margin-form">
<a class="button" href="#group_discount_category_fancybox" id="group_discount_category">{l s='Add a category discount'}</a>
@@ -50,14 +50,14 @@
console.log(truncateAuthorized);
if (truncateAuthorized)
{
if (!confirm('{l s='Are you sure that you would like to delete this' js=1}' + ' ' + $.trim($('#entity > option:selected').text().toLowerCase()) + '{l s='?' js=1}'))
if (!confirm('{l s='Are you sure that you would like to delete this' js=1}' + ' ' + $.trim($('#entity > option:selected').text().toLowerCase()) + '?'))
{
e.preventDefault();
}
}
else
{
jAlert('{l s='You do not have permission to delete here. When the multistore is enabled, only a SuperAdmin can delete all items before an import.'}');
jAlert('{l s='You do not have permission to delete here. When the multistore is enabled, only a SuperAdmin can delete all items before an import.' js='1'}');
return false;
}
}
@@ -77,7 +77,7 @@
</dl>
</div>
<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">
{if !isset($module->not_on_disk)}
{$module->optionsHtml}
@@ -58,7 +58,7 @@
</li>
{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">
<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>
</li>
{/foreach}
@@ -110,7 +110,7 @@
{if !isset($document->is_delivery)}
<tr id="invoiceNote{$document->id}" style="display:none" class="current-edit">
<td colspan="5">
<form action="{$current_index}&viewOrder&id_order={$order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}" method="post">
<form action="{$current_index}&viewOrder&id_order={$order->id}{if isset($smarty.get.token)}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}{/if}" method="post">
<p>
<label for="editNote{$document->id}" class="t">{l s='Note'}</label>
<input type="hidden" name="id_order_invoice" value="{$document->id}" />
@@ -130,7 +130,7 @@
<td colspan="5" class="center">
<h3>{l s='No documents are available'}</h3>
{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}
</td>
</tr>
@@ -24,11 +24,11 @@
*}
<table class="table" width="100%" cellspacing="0" cellpadding="0" id="shipping_table">
<colgroup>
<col width="15%">
<col width="15%">
<col width="">
<col width="10%">
<col width="20%">
<col width="15%"/>
<col width="15%"/>
<col width=""/>
<col width="10%"/>
<col width="20%"/>
</colgroup>
<thead>
<tr>
@@ -46,7 +46,7 @@
<td>{dateFormat date=$line.date_add full=true}</td>
<td>{$line.type}</td>
<td>{$line.carrier_name}</td>
<td>{$line.weight|string_format:"%.3f"} {Configuration::get('PS_WEIGHT_UNIT')}</td>
<td class="weight">{$line.weight|string_format:"%.3f"} {Configuration::get('PS_WEIGHT_UNIT')}</td>
<td>
{if $order->getTaxCalculationMethod() == $smarty.const.PS_TAX_INC}
{displayPrice price=$line.shipping_cost_tax_incl currency=$currency->id}
@@ -100,7 +100,7 @@
$('#show_old_carts').click();
$('#payment_module_name').change();
$.ajaxSetup({ type:"post" });
$("#voucher").autocomplete('{$link->getAdminLink('AdminCartRules')|escape:'html'}', {
$("#voucher").autocomplete('{$link->getAdminLink('AdminCartRules')|addslashes}', {
minChars: 3,
max: 15,
width: 250,
@@ -468,7 +468,7 @@
$('#new_address').attr('href', address_link.replace(/id_customer=[0-9]+/, 'id_customer='+id_customer));
$.ajax({
type:"POST",
url : "{$link->getAdminLink('AdminCarts')|escape:'html'}",
url : "{$link->getAdminLink('AdminCarts')|addslashes}",
async: false,
dataType: "json",
data : {
@@ -27,7 +27,7 @@
{block name="override_tpl"}
<script type="text/javascript">
var admin_order_tab_link = "{$link->getAdminLink('AdminOrders')|escape:'html'}";
var admin_order_tab_link = "{$link->getAdminLink('AdminOrders')|addslashes}";
var id_order = {$order->id};
var id_lang = {$current_id_lang};
var id_currency = {$order->id_currency};
@@ -264,8 +264,8 @@
{if (!$order->valid && sizeof($currencies) > 1)}
<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>
<label>{l s='Don\'t forget to update your conversion rate before making this change.'}</label>
<p class="warn">{l s='Do not forget to update your exchange rate before making this change.'}</p>
<label>{l s='Do not forget to update your exchange rate before making this change.'}</label>
<select name="new_currency">
{foreach from=$currencies item=currency_change}
{if $currency_change['id_currency'] != $order->id_currency}
@@ -34,10 +34,10 @@
{if $module->active}
<th>
{if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'}
<input type="hidden" id="checkedBox_{$list['name_id']}_{$module->name}" value="checked">
<input type="hidden" id="checkedBox_{$list['name_id']}_{$module->name}" value="checked"/>
<a href="javascript:checkPaymentBoxes('{$list['name_id']}', '{$module->name}')" style="text-decoration:none;">
{/if}
&nbsp;<img src="{$ps_base_uri}modules/{$module->name}/logo.gif" alt="{$module->name}" title="{$module->displayName}" />
&nbsp;<img src="{$ps_base_uri}modules/{$module->name}/logo.gif" alt="{$module->name}" title="{$module->displayName}"/>
{if $list['name_id'] != 'currency' || $module->currencies_mode == 'checkbox'}
</a>
{/if}
@@ -64,11 +64,9 @@
{$type = 'checkbox'}
{/if}
{if $type != 'null'}
<input type="checkbox" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}"
{if $item['check_list'][$key_module] == 'checked'}checked="checked"{/if}
/>
<input type="checkbox" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}" {if $item['check_list'][$key_module] == 'checked'}checked="checked"{/if}/>
{else}
--
<input type="hidden" name="{$module->name}_{$list['name_id']}[]" value="{$item[$list['identifier']]}"/>--
{/if}
</td>
{/if}
@@ -43,7 +43,7 @@
$('document').ready( function() {
$(".check_product_name")
.autocomplete(
'{$link->getAdminLink('AdminProducts', true)|escape:'html'}', {
'{$link->getAdminLink('AdminProducts', true)|addslashes}', {
minChars: 3,
max: 10,
width: $(".check_product_name").width(),
@@ -90,7 +90,7 @@
var table = $('#selectTables select').val();
if (!table)
jAlert("{l s='Please choose a table.'}");
jAlert("{l s='Please choose a table.' js='1'}");
else
AddRequestSql(table);
});
@@ -24,9 +24,9 @@
*}
<a href="{$href}" class="delete"
{if in_array($id_shop, $shops_having_dependencies)}
onclick="jAlert('{l s='You cannot delete this shop\'s (customer and/or order dependency)'}'); return false;"
onclick="jAlert('{l s='You cannot delete this shop\'s (customer and/or order dependency)' js='1'}'); return false;"
{elseif isset($confirm)}
onclick="if (confirm('{$confirm}')){ return true; }else{ event.stopPropagation(); event.preventDefault();};"
onclick="if (confirm('{$confirm}')){ return true; } else { event.stopPropagation(); event.preventDefault();};"
{/if} title="{$action}">
<img src="../img/admin/delete.gif" alt="{$action}" />
</a>
@@ -138,7 +138,7 @@
// check if it's possible to add the product
if (product_infos == null || $('#cur_product_name').val() == '')
{
jAlert('{l s='Please select at least one product.'}');
jAlert('{l s='Please select at least one product.' js='1'}');
return false;
}
@@ -69,6 +69,7 @@
var token_admin_customers = '{getAdminToken tab='AdminCustomers' slashes=1}';
var token_admin_customer_threads = '{getAdminToken tab='AdminCustomerThreads' slashes=1}';
var currentIndex = '{$currentIndex}';
var choose_language_translate = "{l s='Choose language' slashes=1 }";
</script>
{/if}
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=attachment'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=attachment'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=authentication'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=authentication'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=best-sales'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=best-sales'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=category'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=category'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=change-currency'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=change-currency'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+59 -76
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))
$id_carrier = (int)Configuration::get('PS_CARRIER_DEFAULT');
$total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
if (empty($id_carrier))
{
if ((int)$this->id_customer)
@@ -2577,7 +2578,7 @@ class CartCore extends ObjectModel
{
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int)$id_zone);
$total_order = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
$total_order = $total_package_without_shipping_tax_inc;
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int)$id_zone, (int)$this->id_currency);
// Get only carriers that have a range compatible with cart
@@ -2680,26 +2681,8 @@ class CartCore extends ObjectModel
$id_zone = (int)$default_country->id_zone;
}
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int)$carrier->id, $this->getTotalWeight(), (int)$id_zone);
// Code Review V&V TO FINISH
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice(
$carrier->id,
$this->getOrderTotal(
true,
Cart::BOTH_WITHOUT_SHIPPING,
$product_list
),
$id_zone,
(int)$this->id_currency
);
if ((
$carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT
&& !$check_delivery_price_by_weight
) || (
$carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE
&& !$check_delivery_price_by_price
if (($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int)$id_zone))
|| ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $id_zone, (int)$this->id_currency)
))
$shipping_cost += 0;
else
@@ -2846,7 +2829,10 @@ class CartCore extends ObjectModel
$formatted_addresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
$formatted_addresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice);
$total_tax = $this->getOrderTotal() - $this->getOrderTotal(false);
$base_total_tax_inc = $this->getOrderTotal(true);
$base_total_tax_exc = $this->getOrderTotal(false);
$total_tax = $base_total_tax_inc - $base_total_tax_exc;
if ($total_tax < 0)
$total_tax = 0;
@@ -2944,9 +2930,9 @@ class CartCore extends ObjectModel
'total_shipping_tax_exc' => $total_shipping_tax_exc,
'total_products_wt' => $total_products_wt,
'total_products' => $total_products,
'total_price' => $this->getOrderTotal(),
'total_price' => $base_total_tax_inc,
'total_tax' => $total_tax,
'total_price_without_tax' => $this->getOrderTotal(false),
'total_price_without_tax' => $base_total_tax_exc,
'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int)Tools::getValue('multi-shipping') == 1),
'free_ship' => $total_shipping ? 0 : 1,
'carrier' => new Carrier($this->id_carrier, $id_lang),
@@ -3424,62 +3410,59 @@ class CartCore extends ObjectModel
*/
public function setNoMultishipping()
{
// Upgrading quantities
$sql = 'SELECT sum(`quantity`) as quantity, id_product, id_product_attribute, count(*) as count
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
GROUP BY id_product, id_product_attribute
HAVING count > 1';
foreach (Db::getInstance()->executeS($sql) as $product)
if (Configuration::get('PS_ALLOW_MULTISHIPPING'))
{
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
SET `quantity` = '.$product['quantity'].'
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
AND id_product = '.$product['id_product'].'
AND id_product_attribute = '.$product['id_product_attribute'];
Db::getInstance()->execute($sql);
// Upgrading quantities
$sql = 'SELECT sum(`quantity`) as quantity, id_product, id_product_attribute, count(*) as count
FROM `'._DB_PREFIX_.'cart_product`
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
GROUP BY id_product, id_product_attribute
HAVING count > 1';
foreach (Db::getInstance()->executeS($sql) as $product)
{
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
SET `quantity` = '.$product['quantity'].'
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
AND id_product = '.$product['id_product'].'
AND id_product_attribute = '.$product['id_product_attribute'];
Db::getInstance()->execute($sql);
}
// Merging multiple lines
$sql = 'DELETE cp1
FROM `'._DB_PREFIX_.'cart_product` cp1
INNER JOIN `'._DB_PREFIX_.'cart_product` cp2
ON (
(cp1.id_cart = cp2.id_cart)
AND (cp1.id_product = cp2.id_product)
AND (cp1.id_product_attribute = cp2.id_product_attribute)
AND (cp1.id_address_delivery <> cp2.id_address_delivery)
AND (cp1.date_add > cp2.date_add)
)';
Db::getInstance()->execute($sql);
}
// Merging multiple lines
$sql = 'DELETE cp1
FROM `'._DB_PREFIX_.'cart_product` cp1
INNER JOIN `'._DB_PREFIX_.'cart_product` cp2
ON (
(cp1.id_cart = cp2.id_cart)
AND (cp1.id_product = cp2.id_product)
AND (cp1.id_product_attribute = cp2.id_product_attribute)
AND (cp1.id_address_delivery <> cp2.id_address_delivery)
AND (cp1.date_add > cp2.date_add)
)';
Db::getInstance()->execute($sql);
// Upgrading address delivery
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
SET `id_address_delivery` =
(
SELECT `id_address_delivery`
FROM `'._DB_PREFIX_.'cart`
WHERE `id_cart` = '.(int)$this->id.'
AND `id_shop` = '.(int)$this->id_shop.'
)
WHERE `id_cart` = '.(int)$this->id.'
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '');
Db::getInstance()->execute($sql);
$sql = 'UPDATE `'._DB_PREFIX_.'customization`
SET `id_address_delivery` =
(
SELECT `id_address_delivery`
FROM `'._DB_PREFIX_.'cart`
// Update delivery address for each product line
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'cart_product`
SET `id_address_delivery` = (
SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart`
WHERE `id_cart` = '.(int)$this->id.' AND `id_shop` = '.(int)$this->id_shop.'
)
WHERE `id_cart` = '.(int)$this->id.'
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : ''));
if (Customization::isFeatureActive())
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'customization`
SET `id_address_delivery` = (
SELECT `id_address_delivery` FROM `'._DB_PREFIX_.'cart`
WHERE `id_cart` = '.(int)$this->id.'
)
WHERE `id_cart` = '.(int)$this->id;
Db::getInstance()->execute($sql);
WHERE `id_cart` = '.(int)$this->id);
}
/**
+10 -15
View File
@@ -796,7 +796,7 @@ class CategoryCore extends ObjectModel
)).')';
$flag = Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'category_product` (`id_product`, `id_category`, `position`)
INSERT IGNORE INTO `'._DB_PREFIX_.'category_product` (`id_product`, `id_category`, `position`)
VALUES '.implode(',', $row)
);
return $flag;
@@ -831,20 +831,15 @@ class CategoryCore extends ObjectModel
if (!Validate::isUnsignedId($id_category) || !Validate::isUnsignedId($id_lang))
return false;
if (isset(self::$_links[$id_category.'-'.$id_lang]))
return self::$_links[$id_category.'-'.$id_lang];
$result = Db::getInstance()->getRow('
SELECT cl.`link_rewrite`
FROM `'._DB_PREFIX_.'category_lang` cl
WHERE `id_lang` = '.(int)$id_lang.'
'.Shop::addSqlRestrictionOnLang('cl').'
AND cl.`id_category` = '.(int)$id_category
);
self::$_links[$id_category.'-'.$id_lang] = $result['link_rewrite'];
return $result['link_rewrite'];
if (!isset(self::$_links[$id_category.'-'.$id_lang]))
self::$_links[$id_category.'-'.$id_lang] = Db::getInstance()->getValue('
SELECT cl.`link_rewrite`
FROM `'._DB_PREFIX_.'category_lang` cl
WHERE `id_lang` = '.(int)$id_lang.'
'.Shop::addSqlRestrictionOnLang('cl').'
AND cl.`id_category` = '.(int)$id_category
);
return self::$_links[$id_category.'-'.$id_lang];
}
public function getLink(Link $link = null)
+8 -8
View File
@@ -43,7 +43,7 @@ class CurrencyCore extends ObjectModel
/** @var int bool used for displaying blank between sign and price */
public $blank;
/** @var string Conversion rate from euros */
/** @var string exchange rate from euros */
public $conversion_rate;
/** @var boolean True if currency has been deleted (staying in database as deleted) */
@@ -326,23 +326,23 @@ class CurrencyCore extends ObjectModel
}
/**
* Refresh the currency conversion rate
* The XML file define conversion rate for each from a default currency ($isoCodeSource).
* Refresh the currency exchange rate
* The XML file define exchange rate for each from a default currency ($isoCodeSource).
*
* @param $data XML content which contains all the conversion rates
* @param $data XML content which contains all the exchange rates
* @param $isoCodeSource The default currency used in the XML file
* @param $defaultCurrency The default currency object
*/
public function refreshCurrency($data, $isoCodeSource, $defaultCurrency)
{
// fetch the conversion rate of the default currency
$conversion_rate = 1;
// fetch the exchange rate of the default currency
$exchange_rate = 1;
if ($defaultCurrency->iso_code != $isoCodeSource)
{
foreach ($data->currency as $currency)
if ($currency['iso_code'] == $defaultCurrency->iso_code)
{
$conversion_rate = round((float)$currency['rate'], 6);
$exchange_rate = round((float)$currency['rate'], 6);
break;
}
}
@@ -364,7 +364,7 @@ class CurrencyCore extends ObjectModel
}
if (isset($rate))
$this->conversion_rate = round($rate / $conversion_rate, 6);
$this->conversion_rate = round($rate / $exchange_rate, 6);
}
$this->update();
}
+54 -31
View File
@@ -379,12 +379,12 @@ class DispatcherCore
/**
* Load default routes group by languages
*/
protected function loadRoutes()
protected function loadRoutes($id_shop = null)
{
$context = Context::getContext();
// Load custom routes from modules
$modules_routes = Hook::exec('moduleRoutes', array(), null, true, false);
$modules_routes = Hook::exec('moduleRoutes', array('id_shop' => $id_shop), null, true, false);
if (is_array($modules_routes) && count($modules_routes))
foreach($modules_routes as $module_route)
foreach($module_route as $route => $route_details)
@@ -405,7 +405,8 @@ class DispatcherCore
$route['controller'],
$lang['id_lang'],
$route['keywords'],
isset($route['params']) ? $route['params'] : array()
isset($route['params']) ? $route['params'] : array(),
$id_shop
);
// Load the custom routes prior the defaults to avoid infinite loops
@@ -420,13 +421,13 @@ class DispatcherCore
// Load routes from meta table
$sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang
FROM `'._DB_PREFIX_.'meta` m
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml').')
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml', $id_shop).')
ORDER BY LENGTH(ml.url_rewrite) DESC';
if ($results = Db::getInstance()->executeS($sql))
foreach ($results as $row)
{
if ($row['url_rewrite'])
$this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang']);
$this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang'], array(), array(), $id_shop);
}
// Set default empty route if no empty route (that's weird I know)
@@ -439,7 +440,7 @@ class DispatcherCore
// Load custom routes
foreach ($this->default_routes as $route_id => $route_data)
if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id))
if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id, null, null, $id_shop))
foreach (Language::getLanguages() as $lang)
$this->addRoute(
$route_id,
@@ -447,7 +448,8 @@ class DispatcherCore
$route_data['controller'],
$lang['id_lang'],
$route_data['keywords'],
isset($route_data['params']) ? $route_data['params'] : array()
isset($route_data['params']) ? $route_data['params'] : array(),
$id_shop
);
}
}
@@ -458,11 +460,15 @@ class DispatcherCore
* @param string $rule Url rule
* @param string $controller Controller to call if request uri match the rule
* @param int $id_lang
* @param int $id_shop
*/
public function addRoute($route_id, $rule, $controller, $id_lang = null, array $keywords = array(), array $params = array())
public function addRoute($route_id, $rule, $controller, $id_lang = null, array $keywords = array(), array $params = array(), $id_shop = null)
{
if (is_null($id_lang))
$id_lang = Context::getContext()->language->id;
if ($id_lang === null)
$id_lang = (int)Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
$regexp = preg_quote($rule, '#');
if ($keywords)
@@ -497,10 +503,12 @@ class DispatcherCore
}
$regexp = '#^/'.$regexp.'(\?.*)?$#u';
if (!isset($this->routes[$id_lang]))
$this->routes[$id_lang] = array();
if (!isset($this->routes[$id_shop]))
$this->routes[$id_shop] = array();
if (!isset($this->routes[$id_shop][$id_lang]))
$this->routes[$id_shop][$id_lang] = array();
$this->routes[$id_lang][$route_id] = array(
$this->routes[$id_shop][$id_lang][$route_id] = array(
'rule' => $rule,
'regexp' => $regexp,
'controller' => $controller,
@@ -514,14 +522,17 @@ class DispatcherCore
*
* @param string $route_id
* @param int $id_lang
* @param int $id_shop
* @return bool
*/
public function hasRoute($route_id, $id_lang = null)
public function hasRoute($route_id, $id_lang = null, $id_shop = null)
{
if (is_null($id_lang))
$id_lang = Context::getContext()->language->id;
if ($id_lang === null)
$id_lang = (int)Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
return isset($this->routes[$id_lang]) && isset($this->routes[$id_lang][$route_id]);
return isset($this->routes[$id_shop]) && isset($this->routes[$id_shop][$id_lang]) && isset($this->routes[$id_shop][$id_lang][$route_id]);
}
/**
@@ -530,14 +541,18 @@ class DispatcherCore
* @param string $route_id
* @param int $id_lang
* @param string $keyword
* @param int $id_shop
* @return bool
*/
public function hasKeyword($route_id, $id_lang, $keyword)
public function hasKeyword($route_id, $id_lang, $keyword, $id_shop = null)
{
if (!isset($this->routes[$id_lang]) && !isset($this->routes[$id_lang][$route_id]))
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
if (!isset($this->routes[$id_shop]) || !isset($this->routes[$id_shop][$id_lang]) || !isset($this->routes[$id_shop][$id_lang][$route_id]))
return false;
return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_lang][$route_id]['rule']);
return preg_match('#\{([^{}]*:)?'.preg_quote($keyword, '#').'(:[^{}]*)?\}#', $this->routes[$id_shop][$id_lang][$route_id]['rule']);
}
/**
@@ -569,18 +584,23 @@ class DispatcherCore
* @param bool $use_routes If false, don't use to create this url
* @param string $anchor Optional anchor to add at the end of this url
*/
public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '')
public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '', $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if ($id_lang === null)
$id_lang = (int)Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
if (!isset($this->routes[$id_lang][$route_id]))
if ($this->use_routes && !isset($this->routes[$id_shop]))
$this->loadRoutes($id_shop);
if (!isset($this->routes[$id_shop][$id_lang][$route_id]))
{
$query = http_build_query($params, '', '&');
$index_link = $this->use_routes ? '' : 'index.php';
return ($route_id == 'index') ? $index_link.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '').$anchor;
}
$route = $this->routes[$id_lang][$route_id];
$route = $this->routes[$id_shop][$id_lang][$route_id];
// Check required fields
$query_params = isset($route['params']) ? $route['params'] : array();
foreach ($route['keywords'] as $key => $data)
@@ -646,7 +666,7 @@ class DispatcherCore
*
* @return string
*/
public function getController()
public function getController($id_shop = null)
{
if (defined('_PS_ADMIN_DIR_'))
$_GET['controllerUri'] = Tools::getvalue('controller');
@@ -655,7 +675,10 @@ class DispatcherCore
$_GET['controller'] = $this->controller;
return $this->controller;
}
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
$controller = Tools::getValue('controller');
if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m))
@@ -682,10 +705,10 @@ class DispatcherCore
{
// Add empty route as last route to prevent this greedy regexp to match request uri before right time
if ($this->empty_route)
$this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id);
$this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id, array(), array(), $id_shop);
if (isset($this->routes[Context::getContext()->language->id]))
foreach ($this->routes[Context::getContext()->language->id] as $route)
if (isset($this->routes[$id_shop][Context::getContext()->language->id]))
foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route)
if (preg_match($route['regexp'], $this->request_uri, $m))
{
// Route found ! Now fill $_GET with parameters of uri
@@ -771,4 +794,4 @@ class DispatcherCore
return $controllers;
}
}
}
+16
View File
@@ -128,6 +128,22 @@ class HookCore extends ObjectModel
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
*
+1 -3
View File
@@ -273,7 +273,7 @@ class LanguageCore extends ObjectModel
'contact.html', 'contact.txt',
'contact_form.html', 'contact_form.txt',
'credit_slip.html', 'credit_slip.txt',
'download_product.html', 'download_product.txt', 'download-product.tpl',
'download_product.html', 'download_product.txt',
'employee_password.html', 'employee_password.txt',
'forward_msg.html', 'forward_msg.txt',
'guest_to_customer.html', 'guest_to_customer.txt',
@@ -704,10 +704,8 @@ class LanguageCore extends ObjectModel
$lang->name = $lang_pack->name;
}
elseif ($params_lang !== null && is_array($params_lang))
{
foreach ($params_lang as $key => $value)
$lang->$key = $value;
}
else
return false;
+103 -49
View File
@@ -91,7 +91,7 @@ class LinkCore
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if (!$id_shop)
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
@@ -101,9 +101,9 @@ class LinkCore
if (!is_object($product))
{
if (is_array($product) && isset($product['id_product']))
$product = new Product($product['id_product'], false, $id_lang);
else if (is_numeric($product) || !$product)
$product = new Product($product, false, $id_lang);
$product = new Product($product['id_product'], false, $id_lang);
elseif ((int)$product)
$product = new Product((int)$product, false, $id_lang);
else
throw new PrestaShopException('Invalid product vars');
}
@@ -112,29 +112,30 @@ class LinkCore
$params = array();
$params['id'] = $product->id;
$params['rewrite'] = (!$alias) ? $product->getFieldByLang('link_rewrite') : $alias;
$params['ean13'] = (!$ean13) ? $product->ean13 : $ean13;
$params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords'));
$params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title'));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'manufacturer'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'manufacturer', $id_shop))
$params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'supplier'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'supplier', $id_shop))
$params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'price'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'price', $id_shop))
$params['price'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specificPrice);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'tags'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'tags', $id_shop))
$params['tags'] = Tools::str2url($product->getTags($id_lang));
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category'))
$params['category'] = !is_null($product->category) ? Tools::str2url($product->category) : Tools::str2url($category);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category', $id_shop))
$params['category'] = (!is_null($product->category) && !empty($product->category)) ? Tools::str2url($product->category) : Tools::str2url($category);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'reference'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'reference', $id_shop))
$params['reference'] = Tools::str2url($product->reference);
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories'))
if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories', $id_shop))
{
$params['category'] = (!$category) ? $product->category : $category;
$cats = array();
@@ -145,7 +146,7 @@ class LinkCore
}
$anchor = $ipa ? $product->getAnchor($ipa) : '';
return $url.$dispatcher->createUrl('product_rule', $id_lang, $params, $force_routes, $anchor);
return $url.$dispatcher->createUrl('product_rule', $id_lang, $params, $force_routes, $anchor, $id_shop);
}
/**
@@ -157,11 +158,16 @@ class LinkCore
* @param string $selected_filters Url parameter to autocheck filters of the module blocklayered
* @return string
*/
public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null)
public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
if (!is_object($category))
$category = new Category($category, $id_lang);
@@ -184,7 +190,7 @@ class LinkCore
$params['selected_filters'] = $selected_filters;
}
return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow);
return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -195,24 +201,33 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getCMSCategoryLink($category, $alias = null, $id_lang = null)
public function getCMSCategoryLink($cms_category, $alias = null, $id_lang = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if (!is_object($category))
$category = new CMSCategory($category, $id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
$dispatcher = Dispatcher::getInstance();
if (!is_object($cms_category))
{
if ($alias !== null && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_category_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, array('id' => (int)$cms_category, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$cms_category = new CMSCategory($cms_category, $id_lang);
}
// Set available keywords
$params = array();
$params['id'] = $category->id;
$params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias;
$params['meta_keywords'] = Tools::str2url($category->meta_keywords);
$params['meta_title'] = Tools::str2url($category->meta_title);
$params['id'] = $cms_category->id;
$params['rewrite'] = (!$alias) ? $cms_category->link_rewrite : $alias;
$params['meta_keywords'] = Tools::str2url($cms_category->meta_keywords);
$params['meta_title'] = Tools::str2url($cms_category->meta_title);
return $url.Dispatcher::getInstance()->createUrl('cms_category_rule', $id_lang, $params, $this->allow);
return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -224,33 +239,42 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null, $id_shop = null)
{
$base = (($ssl && $this->ssl_enable) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://');
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
$dispatcher = Dispatcher::getInstance();
if (!is_object($cms))
{
if ($alias !== null && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('cms_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('cms_rule', $id_lang, array('id' => (int)$cms, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$cms = new CMS($cms, $id_lang);
}
// Set available keywords
$params = array();
$params['id'] = $cms->id;
$params['rewrite'] = (!$alias) ? (is_array($cms->link_rewrite) ? $cms->link_rewrite[(int)$id_lang] : $cms->link_rewrite) : $alias;
$params['meta_keywords'] = '';
if (isset($cms->meta_keywords) && !empty($cms->meta_keywords))
$params['meta_keywords'] = is_array($cms->meta_keywords) ? Tools::str2url($cms->meta_keywords[(int)$id_lang]) : Tools::str2url($cms->meta_keywords);
else
$params['meta_keywords'] = '';
$params['meta_title'] = '';
if (isset($cms->meta_title) && !empty($cms->meta_title))
$params['meta_title'] = is_array($cms->meta_title) ? Tools::str2url($cms->meta_title[(int)$id_lang]) : Tools::str2url($cms->meta_title);
else
$params['meta_title'] = '';
return $url.Dispatcher::getInstance()->createUrl('cms_rule', $id_lang, $params, $this->allow);
return $url.$dispatcher->createUrl('cms_rule', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -261,14 +285,24 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getSupplierLink($supplier, $alias = null, $id_lang = null)
public function getSupplierLink($supplier, $alias = null, $id_lang = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
$dispatcher = Dispatcher::getInstance();
if (!is_object($supplier))
{
if ($alias !== null && !$dispatcher->hasKeyword('supplier_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('supplier_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('supplier_rule', $id_lang, array('id' => (int)$supplier, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$supplier = new Supplier($supplier, $id_lang);
}
// Set available keywords
$params = array();
@@ -277,7 +311,7 @@ class LinkCore
$params['meta_keywords'] = Tools::str2url($supplier->meta_keywords);
$params['meta_title'] = Tools::str2url($supplier->meta_title);
return $url.Dispatcher::getInstance()->createUrl('supplier_rule', $id_lang, $params, $this->allow);
return $url.$dispatcher->createUrl('supplier_rule', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -288,14 +322,24 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getManufacturerLink($manufacturer, $alias = null, $id_lang = null)
public function getManufacturerLink($manufacturer, $alias = null, $id_lang = null, $id_shop = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
$dispatcher = Dispatcher::getInstance();
if (!is_object($manufacturer))
{
if ($alias !== null && !$dispatcher->hasKeyword('manufacturer_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('manufacturer_rule', $id_lang, 'meta_title', $id_shop))
return $url.$dispatcher->createUrl('manufacturer_rule', $id_lang, array('id' => (int)$manufacturer, 'rewrite' => (string)$alias), $this->allow, '', $id_shop);
$manufacturer = new Manufacturer($manufacturer, $id_lang);
}
// Set available keywords
$params = array();
@@ -304,7 +348,7 @@ class LinkCore
$params['meta_keywords'] = Tools::str2url($manufacturer->meta_keywords);
$params['meta_title'] = Tools::str2url($manufacturer->meta_title);
return $url.Dispatcher::getInstance()->createUrl('manufacturer_rule', $id_lang, $params, $this->allow);
return $url.$dispatcher->createUrl('manufacturer_rule', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -316,23 +360,28 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null)
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null, $id_shop = null)
{
$base = (($ssl && $this->ssl_enable) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://');
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
// Set available keywords
$params['module'] = $module;
$params['controller'] = $controller ? $controller : 'default';
// If the module has its own route ... just use it !
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang))
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop))
return $this->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params);
else
return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow);
return $url.Dispatcher::getInstance()->createUrl('module', $id_lang, $params, $this->allow, '', $id_shop);
}
/**
@@ -403,7 +452,7 @@ class LinkCore
*
* @return string Page link
*/
public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false)
public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
{
$controller = Tools::strReplaceFirst('.php', '', $controller);
@@ -419,9 +468,14 @@ class LinkCore
parse_str($request, $request);
}
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request);
$url = ($ssl && $this->ssl_enable) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true);
$url .= __PS_BASE_URI__.$this->getLangLink($id_lang).ltrim($uri_path, '/');
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request, false, '', $id_shop);
$url = ($ssl && $this->ssl_enable) ? 'https://' : 'http://';
$url .= $shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang).ltrim($uri_path, '/');
return $url;
}
+12 -1
View File
@@ -43,6 +43,9 @@ class LoggerCore extends ObjectModel
/** @var integer Object ID */
public $object_id;
/** @var integer Object ID */
public $id_employee;
/** @var string Object creation date */
public $date_add;
@@ -61,6 +64,7 @@ class LoggerCore extends ObjectModel
'error_code' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
'object_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'object_type' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
@@ -98,7 +102,7 @@ class LoggerCore extends ObjectModel
* @param boolean $allow_duplicate if set to true, can log several time the same information (not recommended)
* @return boolean true if succeed
*/
public static function addLog($message, $severity = 1, $error_code = null, $object_type = null, $object_id = null, $allow_duplicate = false)
public static function addLog($message, $severity = 1, $error_code = null, $object_type = null, $object_id = null, $allow_duplicate = false, $id_employee = null)
{
$log = new Logger();
$log->severity = intval($severity);
@@ -106,6 +110,13 @@ class LoggerCore extends ObjectModel
$log->message = pSQL($message);
$log->date_add = date('Y-m-d H:i:s');
$log->date_upd = date('Y-m-d H:i:s');
if ($id_employee === null && isset(Context::getContext()->employee) && Validate::isLoadedObject(Context::getContext()->employee))
$id_employee = Context::getContext()->employee->id;
if ($id_employee !== null)
$log->id_employee = (int)$id_employee;
if (!empty($object_type) && !empty($object_id))
{
$log->object_type = pSQL($object_type);
+3
View File
@@ -249,6 +249,9 @@ class MailCore
if (isset($logo))
$template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($logo)));
if ((Context::getContext()->link instanceof Link) === false)
Context::getContext()->link = new Link();
$template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
$template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id);
$template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id);
+9 -6
View File
@@ -546,7 +546,7 @@ abstract class ObjectModelCore
$object_id = Db::getInstance()->Insert_ID();
if ($definition['multilang'])
if (isset($definition['multilang']) && $definition['multilang'])
{
$res = Db::getInstance()->executeS('
SELECT *
@@ -763,6 +763,9 @@ abstract class ObjectModelCore
if (!array_key_exists('active', $this))
throw new PrestaShopException('property "active" is missing in object '.get_class($this));
// Update only active field
$this->setFieldsToUpdate(array('active' => true));
// Update active status on object
$this->active = !(int)$this->active;
@@ -977,11 +980,11 @@ abstract class ObjectModelCore
// Checking for required fields
if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
if (!$this->id || $field != 'passwd')
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
// Checking for maximum fields sizes
if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size'])
$errors[] = sprintf(
$errors[$field] = sprintf(
Tools::displayError('%1$s is too long. Maximum length: %2$d'),
self::displayFieldName($field, get_class($this), $htmlentities),
$data['size']
@@ -992,7 +995,7 @@ abstract class ObjectModelCore
if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0'))
{
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required']))
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
$errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
else
{
if (isset($data['copy_post']) && !$data['copy_post'])
@@ -1136,7 +1139,7 @@ abstract class ObjectModelCore
$value = Tools::getValue($field);
if (empty($value))
$errors[] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities));
$errors[$field] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities));
}
return $errors;
@@ -1608,4 +1611,4 @@ abstract class ObjectModelCore
{
$this->update_fields = $fields;
}
}
}
+6 -2
View File
@@ -208,9 +208,10 @@ class ProductSupplierCore extends ObjectModel
*
* @param int $id_product
* @param int $id_product_attribute Optional
* @param bool $converted_price Optional
* @return Array keys: price_te, id_currency
*/
public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0)
public static function getProductPrice($id_supplier, $id_product, $id_product_attribute = 0, $converted_price = false)
{
if (is_null($id_supplier) || is_null($id_product))
return;
@@ -222,6 +223,9 @@ class ProductSupplierCore extends ObjectModel
$query->where('id_supplier = '.(int)$id_supplier);
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
if ($converted_price)
return Tools::convertPrice($row['price_te'], $row['id_currency']);
return $row['price_te'];
}
}
}
+1 -3
View File
@@ -37,7 +37,7 @@ class RequestSqlCore extends ObjectModel
'primary' => 'id_request_sql',
'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 200),
'sql' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 1000),
'sql' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true),
),
);
@@ -232,8 +232,6 @@ class RequestSqlCore extends ObjectModel
{
if ($attribut = $this->cutAttribute(trim($attr), $from))
$tab[] = $attribut;
else
return false;
}
return $tab;
}
+3 -3
View File
@@ -224,7 +224,7 @@ class SearchCore
AND product_shop.`active` = 1
AND product_shop.`visibility` IN ("both", "search")
AND product_shop.indexed = 1
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
AND cg.`id_group` '.(!$id_customer ? '= '.(int)Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.'
)');
@@ -622,7 +622,7 @@ class SearchCore
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
WHERE product_shop.`active` = 1
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
AND cg.`id_group` '.(!$id_customer ? '= '.(int)Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').'
AND t.`name` LIKE \'%'.pSQL($tag).'%\'';
@@ -656,7 +656,7 @@ class SearchCore
'.Product::sqlStock('p', 0).'
WHERE product_shop.`active` = 1
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
AND cg.`id_group` '.(!$id_customer ? '= '.(int)Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').'
AND t.`name` LIKE \'%'.pSQL($tag).'%\'
+3 -4
View File
@@ -538,11 +538,10 @@ class TabCore extends ObjectModel
foreach($tab->attributes() as $key => $value)
if ($key == 'display_type')
$display_type = (string)$value;
foreach ($tab->children() as $module)
foreach ($module->attributes() as $k => $v)
if ($k == 'name')
$modules_list[$display_type][] = (string)$v;
$modules_list[$display_type][(int)$module['position']] = (string)$module['name'];
ksort($modules_list[$display_type]);
}
}
+77 -53
View File
@@ -338,11 +338,9 @@ class ToolsCore
/* If language does not exist or is disabled, erase it */
if ($cookie->id_lang)
{
//echo $cookie->id_lang;exit;
$lang = new Language((int)$cookie->id_lang);
if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop())
$cookie->id_lang = null;
}
/* Automatically detect language if not already defined */
@@ -399,7 +397,7 @@ class ToolsCore
{
$context->cookie->id_lang = $id_lang;
$language = new Language($id_lang);
if (Validate::isLoadedObject($language))
if (Validate::isLoadedObject($language) && $language->active)
$context->language = $language;
$params = $_GET;
@@ -433,8 +431,11 @@ class ToolsCore
{
// get currency from context
$currency = Shop::getEntityIds('currency', Context::getContext()->shop->id);
$cookie->id_currency = $currency[0]['id_currency'];
return Currency::getCurrencyInstance((int)$cookie->id_currency);
if (isset($currency[0]) && $currency[0]['id_currency'])
{
$cookie->id_currency = $currency[0]['id_currency'];
return Currency::getCurrencyInstance((int)$cookie->id_currency);
}
}
}
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
@@ -677,20 +678,24 @@ class ToolsCore
public static function deleteDirectory($dirname, $delete_self = true)
{
$dirname = rtrim($dirname, '/').'/';
if ($files = scandir($dirname))
{
foreach ($files as $file)
if ($file != '.' && $file != '..' && $file != '.svn')
if (file_exists($dirname))
if ($files = scandir($dirname))
{
if (is_dir($dirname.$file))
Tools::deleteDirectory($dirname.$file, true);
elseif (file_exists($dirname.$file))
unlink($dirname.$file);
foreach ($files as $file)
if ($file != '.' && $file != '..' && $file != '.svn')
{
if (is_dir($dirname.$file))
Tools::deleteDirectory($dirname.$file, true);
elseif (file_exists($dirname.$file))
unlink($dirname.$file);
}
if ($delete_self)
if (!rmdir($dirname))
return false;
return true;
}
if ($delete_self)
rmdir($dirname);
}
}
return false;
}
/**
* Display an error according to an error code
@@ -1022,47 +1027,66 @@ class ToolsCore
*/
public static function replaceAccentedChars($str)
{
/* One source among others:
http://www.tachyonsoft.com/uc0000.htm
http://www.tachyonsoft.com/uc0001.htm
*/
$patterns = array(
/* Lowercase */
'/[\x{0105}\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}]/u',
'/[\x{00E7}\x{010D}\x{0107}]/u',
'/[\x{010F}]/u',
'/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{011B}\x{0119}]/u',
'/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}]/u',
'/[\x{011F}]/u',
'/[\x{0142}\x{013E}\x{013A}]/u',
'/[\x{00F1}\x{0148}]/u',
'/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}]/u',
'/[\x{0159}\x{0155}]/u',
'/[\x{015B}\x{0161}\x{015F}]/u',
'/[\x{00DF}]/u',
'/[\x{0165}]/u',
'/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{016F}]/u',
'/[\x{00FD}\x{00FF}]/u',
'/[\x{017C}\x{017A}\x{017E}]/u',
'/[\x{00E6}]/u',
'/[\x{0153}]/u',
/* a */ '/[\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}\x{0101}\x{0103}\x{0105}]/u',
/* c */ '/[\x{00E7}\x{0107}\x{0109}\x{010D}]/u',
/* d */ '/[\x{010F}\x{0111}]/u',
/* e */ '/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{0113}\x{0115}\x{0117}\x{0119}\x{011B}]/u',
/* g */ '/[\x{011F}\x{0121}\x{0123}]/u',
/* h */ '/[\x{0125}\x{0127}]/u',
/* i */ '/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}\x{0129}\x{012B}\x{012D}\x{012F}\x{0131}]/u',
/* j */ '/[\x{0135}]/u',
/* k */ '/[\x{0137}\x{0138}]/u',
/* l */ '/[\x{013A}\x{013C}\x{013E}\x{0140}\x{0142}]/u',
/* n */ '/[\x{00F1}\x{0144}\x{0146}\x{0148}\x{0149}\x{014B}]/u',
/* o */ '/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}\x{014D}\x{014F}\x{0151}]/u',
/* r */ '/[\x{0155}\x{0157}\x{0159}]/u',
/* s */ '/[\x{015B}\x{015D}\x{015F}\x{0161}]/u',
/* ss*/ '/[\x{00DF}]/u',
/* t */ '/[\x{0163}\x{0165}\x{0167}]/u',
/* u */ '/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{0169}\x{016B}\x{016D}\x{016F}\x{0171}\x{0173}]/u',
/* w */ '/[\x{0175}]/u',
/* y */ '/[\x{00FF}\x{0177}\x{00FD}]/u',
/* z */ '/[\x{017A}\x{017C}\x{017E}]/u',
/* ae*/ '/[\x{00E6}]/u',
/* oe*/ '/[\x{0153}]/u',
/* Uppercase */
'/[\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
'/[\x{00C7}\x{010C}\x{0106}]/u',
'/[\x{010E}]/u',
'/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{011A}\x{0118}]/u',
'/[\x{011E}]/u',
'/[\x{0141}\x{013D}\x{0139}]/u',
'/[\x{00D1}\x{0147}]/u',
'/[\x{00D3}]/u',
'/[\x{0158}\x{0154}]/u',
'/[\x{015A}\x{0160}\x{015E}]/u',
'/[\x{0164}]/u',
'/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{016E}]/u',
'/[\x{017B}\x{0179}\x{017D}]/u',
'/[\x{00C6}]/u',
'/[\x{0152}]/u');
/* A */ '/[\x{0100}\x{0102}\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
/* C */ '/[\x{00C7}\x{0106}\x{0108}\x{010A}\x{010C}]/u',
/* D */ '/[\x{010E}\x{0110}]/u',
/* E */ '/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{0112}\x{0114}\x{0116}\x{0118}\x{011A}]/u',
/* G */ '/[\x{011C}\x{011E}\x{0120}\x{0122}]/u',
/* H */ '/[\x{0124}\x{0126}]/u',
/* I */ '/[\x{0128}\x{012A}\x{012C}\x{012E}\x{0130}]/u',
/* J */ '/[\x{0134}]/u',
/* K */ '/[\x{0136}]/u',
/* L */ '/[\x{0139}\x{013B}\x{013D}\x{0139}\x{0141}]/u',
/* N */ '/[\x{00D1}\x{0143}\x{0145}\x{0147}\x{014A}]/u',
/* O */ '/[\x{00D3}\x{014C}\x{014E}\x{0150}]/u',
/* R */ '/[\x{0154}\x{0156}\x{0158}]/u',
/* S */ '/[\x{015A}\x{015C}\x{015E}\x{0160}]/u',
/* T */ '/[\x{0162}\x{0164}\x{0166}]/u',
/* U */ '/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{0168}\x{016A}\x{016C}\x{016E}\x{0170}\x{0172}]/u',
/* W */ '/[\x{0174}]/u',
/* Y */ '/[\x{0176}]/u',
/* Z */ '/[\x{0179}\x{017B}\x{017D}]/u',
/* AE*/ '/[\x{00C6}]/u',
/* OE*/ '/[\x{0152}]/u');
// ö to oe
// å to aa
// ä to ae
$replacements = array(
'a', 'c', 'd', 'e', 'i', 'g', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'z', 'ae', 'oe',
'A', 'C', 'D', 'E', 'G', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE'
'a', 'c', 'd', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'w', 'z', 'ae', 'oe',
'A', 'C', 'D', 'E', 'G', 'H', 'I', 'J', 'K', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE'
);
return preg_replace($patterns, $replacements, $str);
@@ -1565,7 +1589,7 @@ class ToolsCore
}
// Write .htaccess data
if (!$write_fd = @fopen($path, 'w'))
if (!$write_fd = fopen($path, 'w'))
return false;
fwrite($write_fd, trim($specific_before)."\n\n");
+1 -1
View File
@@ -144,7 +144,7 @@ abstract class CacheCore
*/
public function set($key, $value, $ttl = 0)
{
if ($this->_set($key, $value))
if ($this->_set($key, $value, $ttl))
{
if ($ttl < 0)
$ttl = 0;
+1
View File
@@ -149,6 +149,7 @@ class CacheFsCore extends Cache
*/
protected function getFilename($key)
{
$key = md5($key);
$path = _PS_CACHEFS_DIRECTORY_;
for ($i = 0; $i < $this->depth; $i++)
$path .= $key[$i].'/';
+3 -2
View File
@@ -65,8 +65,9 @@ class CacheMemcacheCore extends Cache
{
foreach ($dump as $entries)
{
if ($entries)
$this->keys = array_merge($this->keys, array_keys($entries));
if($entries)
foreach ($entries as $key => $data)
$this->keys[$key] = $data[1];
}
}
}
+32 -14
View File
@@ -647,12 +647,14 @@ class AdminControllerCore extends Controller
$this->errors[] = Tools::displayError('Unable to delete associated images.');
$object->deleted = 1;
if ($object->update())
if ($res = $object->update())
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
}
elseif ($object->delete())
elseif ($res = $object->delete())
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
$this->errors[] = Tools::displayError('An error occurred during deletion.');
if ($res)
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
}
}
else
@@ -701,6 +703,7 @@ class AdminControllerCore extends Controller
/* voluntary do affectation here */
elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect)
{
Logger::addLog(sprintf($this->l('%s addition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
$parent_id = (int)Tools::getValue('id_parent', 1);
$this->afterAdd($this->object);
$this->updateAssoShop($this->object->id);
@@ -735,7 +738,6 @@ class AdminControllerCore extends Controller
{
/* Checking fields validity */
$this->validateRules();
if (empty($this->errors))
{
$id = (int)Tools::getValue($this->identifier);
@@ -801,6 +803,7 @@ class AdminControllerCore extends Controller
if (empty($this->redirect_after))
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=4&token='.$this->token;
}
Logger::addLog(sprintf($this->l('%s edition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
}
else
$this->errors[] = Tools::displayError('An error occurred while updating an object.').
@@ -955,7 +958,8 @@ class AdminControllerCore extends Controller
continue;
// Check if field is required
if (isset($values['required']) && $values['required'] && !empty($_POST['multishopOverrideOption'][$field]))
if ((!Shop::isFeatureActive() && isset($values['required']) && $values['required'])
|| (Shop::isFeatureActive() && isset($_POST['multishopOverrideOption'][$field]) && isset($values['required']) && $values['required']))
if (isset($values['type']) && $values['type'] == 'textLang')
{
foreach ($languages as $language)
@@ -1533,7 +1537,6 @@ class AdminControllerCore extends Controller
public function renderModulesList()
{
if ($this->getModulesList($this->filter_modules_list))
{
$helper = new Helper();
@@ -2232,7 +2235,7 @@ class AdminControllerCore extends Controller
$all_modules = Module::getModulesOnDisk(true);
$this->modules_list = array();
foreach($all_modules as $module)
foreach ($all_modules as $module)
{
$perm = true;
if ($module->id)
@@ -2248,9 +2251,11 @@ class AdminControllerCore extends Controller
if (in_array($module->name, $filter_modules_list) && $perm)
{
$this->fillModuleData($module, 'select');
$this->modules_list[] = $module;
$this->modules_list[array_search($module->name, $filter_modules_list)] = $module;
}
}
ksort($this->modules_list);
if (count($this->modules_list))
return true;
@@ -2709,18 +2714,31 @@ class AdminControllerCore extends Controller
else
{
$result = true;
if ($this->deleted)
foreach ($this->boxes as $id)
{
foreach ($this->boxes as $id)
$to_delete = new $this->className($id);
$delete_ok = true;
if ($this->deleted)
{
$to_delete = new $this->className($id);
$to_delete->deleted = 1;
$result = $result && $to_delete->update();
if (!$to_delete->update())
{
$result = false;
$delete_ok = false;
}
}
else
if (!$to_delete->delete())
{
$result = false;
$delete_ok = false;
}
if ($delete_ok)
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$to_delete->id, true, (int)$this->context->employee->id);
else
$this->errors[] = sprintf(Tools::displayError('Can\'t delete #%d'), $id);
}
else
$result = $object->deleteSelection(Tools::getValue($this->table.'Box'));
if ($result)
$this->redirect_after = self::$currentIndex.'&conf=2&token='.$this->token;
$this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
Regular → Executable
+13 -7
View File
@@ -79,12 +79,7 @@ abstract class DbCore
/**
* @var array Object instance for singleton
*/
protected static $_servers = array(
array('server' => _DB_SERVER_, 'user' => _DB_USER_, 'password' => _DB_PASSWD_, 'database' => _DB_NAME_), /* MySQL Master server */
// Add here your slave(s) server(s)
// array('server' => '192.168.0.15', 'user' => 'rep', 'password' => '123456', 'database' => 'rep'),
// array('server' => '192.168.0.3', 'user' => 'myuser', 'password' => 'mypassword', 'database' => 'mydatabase'),
);
protected static $_servers = array();
/**
* Store last executed query
@@ -169,6 +164,8 @@ abstract class DbCore
/* do not remove, useful for some modules */
abstract public function set_db($db_name);
abstract public function getBestEngine();
/**
* Get Db object instance
@@ -180,6 +177,15 @@ abstract class DbCore
{
static $id = 0;
// This MUST not be declared with the class members because some defines (like _DB_SERVER_) may not exist yet (the constructor can be called directly with params)
if (!self::$_servers)
self::$_servers = array(
array('server' => _DB_SERVER_, 'user' => _DB_USER_, 'password' => _DB_PASSWD_, 'database' => _DB_NAME_), /* MySQL Master server */
// Add here your slave(s) server(s)
// array('server' => '192.168.0.15', 'user' => 'rep', 'password' => '123456', 'database' => 'rep'),
// array('server' => '192.168.0.3', 'user' => 'myuser', 'password' => 'mypassword', 'database' => 'mydatabase'),
);
$total_servers = count(self::$_servers);
if ($master || $total_servers == 1)
$id_server = 0;
@@ -674,7 +680,7 @@ abstract class DbCore
return call_user_func_array(array(Db::getClass(), 'hasTableWithSamePrefix'), array($server, $user, $pwd, $db, $prefix));
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine));
}
+43 -12
View File
@@ -52,6 +52,21 @@ class DbMySQLiCore extends Db
return $this->link;
}
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
if (strpos($host, ':') !== false)
{
list($host, $port) = explode(':', $host);
$link = @new mysqli($host, $this->user, $this->password, null, $port);
}
else
$link = @new mysqli($host, $user, $password);
$success = $link->query('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`');
if ($dropit && ($link->query('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`') !== false))
return true;
return $success;
}
/**
* @see DbCore::disconnect()
@@ -169,24 +184,40 @@ class DbMySQLiCore extends Db
if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout))
return 1;
if (!$link->real_connect($server, $user, $pwd, $db))
// There is an @ because mysqli throw a warning when the database does not exists
if (!@$link->real_connect($server, $user, $pwd, $db))
return (mysqli_connect_errno() == 1049) ? 2 : 1;
if (strtolower($engine) == 'innodb')
{
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
return 4;
$row = $result->fetch_assoc();
if (!$row || strtolower($row['Value']) != 'yes')
return 4;
}
$link->close();
return 0;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $this->link->query($sql);
if (!$result)
$value = 'MyISAM';
$row = $result->fetch_assoc();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $this->link->query($sql);
while ($row = $result->fetch_assoc())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
$link = @new mysqli($server, $user, $pwd, $db);
if (mysqli_connect_error())
+266 -253
View File
@@ -1,253 +1,266 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* This class is currently only here for tests
*
* @since 1.5.0
*/
class DbPDOCore extends Db
{
protected static function _getPDO($host, $user, $password, $dbname, $timeout = 5)
{
$dsn = 'mysql:';
if ($dbname)
$dsn .= 'dbname='.$dbname.';';
if (preg_match('/^(.*):([0-9]+)$/', $host, $matches))
$dsn .= 'host='.$matches[1].';port='.$matches[2];
elseif (preg_match('#^.*:(/.*)$#', $host, $matches))
$dsn .= 'unix_socket='.$matches[1];
else
$dsn .= 'host='.$host;
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
}
/**
* @see DbCore::connect()
*/
public function connect()
{
try {
$this->link = $this->_getPDO($this->server, $this->user, $this->password, $this->database, 5);
} catch (PDOException $e) {
die(sprintf(Tools::displayError('Link to database cannot be established: %s'), utf8_encode($e->getMessage())));
}
// UTF-8 support
if ($this->link->exec('SET NAMES \'utf8\'') === false)
die(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.'));
return $this->link;
}
/**
* @see DbCore::disconnect()
*/
public function disconnect()
{
unset($this->link);
}
/**
* @see DbCore::_query()
*/
protected function _query($sql)
{
return $this->link->query($sql);
}
/**
* @see DbCore::nextRow()
*/
public function nextRow($result = false)
{
if (!$result)
$result = $this->result;
return $result->fetch(PDO::FETCH_ASSOC);
}
/**
* @see DbCore::_numRows()
*/
protected function _numRows($result)
{
return $result->rowCount();
}
/**
* @see DbCore::Insert_ID()
*/
public function Insert_ID()
{
return $this->link->lastInsertId();
}
/**
* @see DbCore::Affected_Rows()
*/
public function Affected_Rows()
{
return $this->result->rowCount();
}
/**
* @see DbCore::getMsgError()
*/
public function getMsgError($query = false)
{
$error = $this->link->errorInfo();
return ($error[0] == '00000') ? '' : $error[2];
}
/**
* @see DbCore::getNumberError()
*/
public function getNumberError()
{
$error = $this->link->errorInfo();
return isset($error[1]) ? $error[1] : 0;
}
/**
* @see DbCore::getVersion()
*/
public function getVersion()
{
return $this->getValue('SELECT VERSION()');
}
/**
* @see DbCore::_escape()
*/
public function _escape($str)
{
$search = array("\\", "\0", "\n", "\r", "\x1a", "'", '"');
$replace = array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"');
return str_replace($search, $replace, $str);
}
/**
* @see DbCore::set_db()
*/
public function set_db($db_name)
{
return $this->link->exec('USE '.pSQL($db_name));
}
/**
* @see Db::hasTableWithSamePrefix()
*/
public static function hasTableWithSamePrefix($server, $user, $pwd, $db, $prefix)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
} catch (PDOException $e) {
return false;
}
$sql = 'SHOW TABLES LIKE \''.$prefix.'%\'';
$result = $link->query($sql);
return (bool)$result->fetch();
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
} catch (PDOException $e) {
return false;
}
$sql = '
CREATE TABLE `'.$prefix.'test` (
`test` tinyint(1) unsigned NOT NULL
) ENGINE=MyISAM';
$result = $link->query($sql);
if (!$result)
{
$error = $link->errorInfo();
return $error[2];
}
$link->query('DROP TABLE `'.$prefix.'test`');
return true;
}
/**
* @see Db::checkConnection()
*/
public static function tryToConnect($server, $user, $pwd, $db, $newDbLink = true, $engine = null, $timeout = 5)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, $timeout);
} catch (PDOException $e) {
return ($e->getCode() == 1049) ? 2 : 1;
}
if (strtolower($engine) == 'innodb')
{
$value = 0;
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
$value = 4;
$row = $result->fetch();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 4;
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $link->query($sql);
while ($row = $result->fetch())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 0;
break;
}
return $value;
}
unset($link);
return 0;
}
/**
* @see Db::checkEncoding()
*/
public static function tryUTF8($server, $user, $pwd)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, false, 5);
} catch (PDOException $e) {
return false;
}
$result = $link->exec('SET NAMES \'utf8\'');
unset($link);
return ($result === false) ? false : true;
}
}
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* This class is currently only here for tests
*
* @since 1.5.0
*/
class DbPDOCore extends Db
{
protected static function _getPDO($host, $user, $password, $dbname, $timeout = 5)
{
$dsn = 'mysql:';
if ($dbname)
$dsn .= 'dbname='.$dbname.';';
if (preg_match('/^(.*):([0-9]+)$/', $host, $matches))
$dsn .= 'host='.$matches[1].';port='.$matches[2];
elseif (preg_match('#^.*:(/.*)$#', $host, $matches))
$dsn .= 'unix_socket='.$matches[1];
else
$dsn .= 'host='.$host;
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
}
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
try {
$link = DbPDO::_getPDO($host, $user, $password, false);
$success = $link->exec('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`');
if ($dropit && ($link->exec('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`') !== false))
return true;
} catch (PDOException $e) {
return false;
}
return $success;
}
/**
* @see DbCore::connect()
*/
public function connect()
{
try {
$this->link = $this->_getPDO($this->server, $this->user, $this->password, $this->database, 5);
} catch (PDOException $e) {
die(sprintf(Tools::displayError('Link to database cannot be established: %s'), utf8_encode($e->getMessage())));
}
// UTF-8 support
if ($this->link->exec('SET NAMES \'utf8\'') === false)
die(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.'));
return $this->link;
}
/**
* @see DbCore::disconnect()
*/
public function disconnect()
{
unset($this->link);
}
/**
* @see DbCore::_query()
*/
protected function _query($sql)
{
return $this->link->query($sql);
}
/**
* @see DbCore::nextRow()
*/
public function nextRow($result = false)
{
if (!$result)
$result = $this->result;
return $result->fetch(PDO::FETCH_ASSOC);
}
/**
* @see DbCore::_numRows()
*/
protected function _numRows($result)
{
return $result->rowCount();
}
/**
* @see DbCore::Insert_ID()
*/
public function Insert_ID()
{
return $this->link->lastInsertId();
}
/**
* @see DbCore::Affected_Rows()
*/
public function Affected_Rows()
{
return $this->result->rowCount();
}
/**
* @see DbCore::getMsgError()
*/
public function getMsgError($query = false)
{
$error = $this->link->errorInfo();
return ($error[0] == '00000') ? '' : $error[2];
}
/**
* @see DbCore::getNumberError()
*/
public function getNumberError()
{
$error = $this->link->errorInfo();
return isset($error[1]) ? $error[1] : 0;
}
/**
* @see DbCore::getVersion()
*/
public function getVersion()
{
return $this->getValue('SELECT VERSION()');
}
/**
* @see DbCore::_escape()
*/
public function _escape($str)
{
$search = array("\\", "\0", "\n", "\r", "\x1a", "'", '"');
$replace = array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"');
return str_replace($search, $replace, $str);
}
/**
* @see DbCore::set_db()
*/
public function set_db($db_name)
{
return $this->link->exec('USE '.pSQL($db_name));
}
/**
* @see Db::hasTableWithSamePrefix()
*/
public static function hasTableWithSamePrefix($server, $user, $pwd, $db, $prefix)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
} catch (PDOException $e) {
return false;
}
$sql = 'SHOW TABLES LIKE \''.$prefix.'%\'';
$result = $link->query($sql);
return (bool)$result->fetch();
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
} catch (PDOException $e) {
return false;
}
$sql = '
CREATE TABLE `'.$prefix.'test` (
`test` tinyint(1) unsigned NOT NULL
) ENGINE=MyISAM';
$result = $link->query($sql);
if (!$result)
{
$error = $link->errorInfo();
return $error[2];
}
$link->query('DROP TABLE `'.$prefix.'test`');
return true;
}
/**
* @see Db::checkConnection()
*/
public static function tryToConnect($server, $user, $pwd, $db, $newDbLink = true, $engine = null, $timeout = 5)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, $timeout);
} catch (PDOException $e) {
return ($e->getCode() == 1049) ? 2 : 1;
}
unset($link);
return 0;
}
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $this->link->query($sql);
if (!$result)
$value = 'MyISAM';
$row = $result->fetch();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $this->link->query($sql);
while ($row = $result->fetch())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
/**
* @see Db::checkEncoding()
*/
public static function tryUTF8($server, $user, $pwd)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, false, 5);
} catch (PDOException $e) {
return false;
}
$result = $link->exec('SET NAMES \'utf8\'');
unset($link);
return ($result === false) ? false : true;
}
}
+35 -26
View File
@@ -46,6 +46,15 @@ class MySQLCore extends Db
return $this->link;
}
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
$link = mysql_connect($host, $user, $password);
$success = mysql_query('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`', $link);
if ($dropit && (mysql_query('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`', $link) !== false))
return true;
return $success;
}
/**
* @see DbCore::disconnect()
@@ -165,36 +174,36 @@ class MySQLCore extends Db
return 1;
if (!@mysql_select_db($db, $link))
return 2;
if (strtolower($engine) == 'innodb')
{
$value = 0;
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result)
$value = 4;
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes')
$value = 4;
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 0;
break;
}
return $value;
}
@mysql_close($link);
return 0;
}
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result)
$value = 'MyISAM';
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
ini_set('mysql.connect_timeout', 5);
if (!$link = @mysql_connect($server, $user, $pwd, true))
-1
View File
@@ -351,7 +351,6 @@ class HelperCore
public function renderModulesList($modules_list)
{
$this->tpl_vars = array('modules_list' => $modules_list);
$tpl = $this->createTemplate('helpers/modules_list/list.tpl');
$tpl->assign($this->tpl_vars);
+1 -1
View File
@@ -535,7 +535,7 @@ class HelperListCore extends Helper
{
if (!isset($params['type']))
$params['type'] = 'text';
$value = Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.(array_key_exists('filter_key', $params) ? $params['filter_key'] : $key)};
$value = Context::getContext()->cookie->{$prefix.$this->table.'Filter_'.(array_key_exists('filter_key', $params) && $key != 'active' ? $params['filter_key'] : $key)};
switch ($params['type'])
{
case 'bool':
+9
View File
@@ -668,6 +668,7 @@ abstract class ModuleCore
if ($alias = Hook::getRetroHookName($hook_name))
$hook_name = $alias;
Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
// Get hook id
$id_hook = Hook::getIdByName($hook_name);
@@ -714,6 +715,7 @@ abstract class ModuleCore
));
}
Hook::exec('actionModuleRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
return $return;
}
@@ -729,11 +731,16 @@ abstract class ModuleCore
// Get hook id if a name is given as argument
if (!is_numeric($hook_id))
{
$hook_name = (int)$hook_id;
// Retrocompatibility
$hook_id = Hook::getIdByName($hook_id);
if (!$hook_id)
return false;
}
else
$hook_name = Hook::getNameById((int)$hook_id);
Hook::exec('actionModuleUnRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
// Unregister module on hook by id
$sql = 'DELETE FROM `'._DB_PREFIX_.'hook_module`
@@ -744,6 +751,8 @@ abstract class ModuleCore
// Clean modules position
$this->cleanPositions($hook_id, $shop_list);
Hook::exec('actionModuleUnRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
return $result;
}
+30 -8
View File
@@ -63,7 +63,7 @@ class OrderCore extends ObjectModel
/** @var string Payment module */
public $module;
/** @var float Currency conversion rate */
/** @var float Currency exchange rate */
public $conversion_rate;
/** @var boolean Customer is ok for a recyclable package */
@@ -1146,13 +1146,14 @@ class OrderCore extends ObjectModel
if ($use_existing_payment)
{
$id_order_payments = Db::getInstance()->executeS('
SELECT op.id_order_payment
SELECT DISTINCT op.id_order_payment
FROM `'._DB_PREFIX_.'order_payment` op
INNER JOIN `'._DB_PREFIX_.'orders` o ON (o.reference = op.order_reference)
LEFT JOIN `'._DB_PREFIX_.'order_invoice_payment` oip ON (oip.id_order_payment = op.id_order_payment)
WHERE oip.id_order_payment IS NULL AND o.id_order = '.(int)$order_invoice->id_order);
WHERE (oip.id_order != '.(int)$order_invoice->id_order.' OR oip.id_order IS NULL) AND o.id_order = '.(int)$order_invoice->id_order);
if (count($id_order_payments))
{
foreach ($id_order_payments as $order_payment)
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
@@ -1160,6 +1161,9 @@ class OrderCore extends ObjectModel
`id_order_invoice` = '.(int)$order_invoice->id.',
`id_order_payment` = '.(int)$order_payment['id_order_payment'].',
`id_order` = '.(int)$order_invoice->id_order);
// Clear cache
Cache::clean('order_invoice_paid_*');
}
}
// Update order cart rule
@@ -1237,12 +1241,11 @@ class OrderCore extends ObjectModel
public function getTotalWeight()
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT SUM(product_weight * product_quantity) weight
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(product_weight * product_quantity)
FROM '._DB_PREFIX_.'order_detail
WHERE id_order = '.(int)($this->id));
return (float)($result['weight']);
return (float)($result);
}
/**
@@ -1466,6 +1469,9 @@ class OrderCore extends ObjectModel
$res = Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
VALUES('.(int)$order_invoice->id.', '.(int)$order_payment->id.', '.(int)$this->id.')');
// Clear cache
Cache::clean('order_invoice_paid_*');
}
return $res;
@@ -1881,5 +1887,21 @@ class OrderCore extends ObjectModel
$order = new Order($id_order);
return $order->getUniqReference();
}
/**
* Return a unique reference like : GWJTHMZUN#2
*
* With multishipping, order reference are the same for all orders made with the same cart
* in this case this method suffix the order reference by a # and the order number
*
* @since 1.5.5.0
*/
public function getIdOrderCarrier()
{
return (int)Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `'._DB_PREFIX_.'order_carrier`
WHERE `id_order` = '.(int)$this->id);
}
}
+1 -1
View File
@@ -508,7 +508,7 @@ class OrderDetailCore extends ObjectModel
$this->purchase_supplier_price = (float)$product['wholesale_price'];
if ($product['id_supplier'] > 0)
$this->purchase_supplier_price = (float)ProductSupplier::getProductPrice((int)$product['id_supplier'], $product['id_product'], $product['id_product_attribute']);
$this->purchase_supplier_price = (float)ProductSupplier::getProductPrice((int)$product['id_supplier'], $product['id_product'], $product['id_product_attribute'], true);
$this->setSpecificPrice($order, $product);
+6 -4
View File
@@ -522,14 +522,16 @@ class OrderInvoiceCore extends ObjectModel
*/
public function getTotalPaid()
{
if (!array_key_exists($this->id, self::$_total_paid_cache))
$cache_id = 'order_invoice_paid_'.(int)$this->id;
if (!Cache::isStored($cache_id))
{
self::$_total_paid_cache[$this->id] = 0;
$amount = 0;
$payments = OrderPayment::getByInvoiceId($this->id);
foreach ($payments as $payment)
self::$_total_paid_cache[$this->id] += $payment->amount;
$amount += $payment->amount;
Cache::store($cache_id, $amount);
}
return self::$_total_paid_cache[$this->id];
return Cache::retrieve($cache_id);
}
/**
+5 -2
View File
@@ -60,13 +60,16 @@ class HTMLTemplateDeliverySlipCore extends HTMLTemplate
$invoice_address = new Address((int)$this->order->id_address_invoice);
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
}
$carrier = new Carrier($this->order->id_carrier);
$carrier->name = ($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name);
$this->smarty->assign(array(
'order' => $this->order,
'order_details' => $this->order_invoice->getProducts(),
'delivery_address' => $formatted_delivery_address,
'invoice_address' => $formatted_invoice_address,
'order_invoice' => $this->order_invoice
'order_invoice' => $this->order_invoice,
'carrier' => $carrier
));
return $this->smarty->fetch($this->getTemplate('delivery-slip'));
+4 -2
View File
@@ -89,7 +89,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$tax_exempt = Configuration::get('VATNUMBER_MANAGEMENT')
&& !empty($address->vat_number)
&& $address->id_country != Configuration::get('VATNUMBER_COUNTRY');
$carrier = new Carrier($this->order->id_carrier);
$this->smarty->assign(array(
'tax_exempt' => $tax_exempt,
'use_one_after_another_method' => $this->order_invoice->useOneAfterAnotherTaxComputationMethod(),
@@ -98,7 +99,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
'ecotax_tax_breakdown' => $this->order_invoice->getEcoTaxTaxesBreakdown(),
'wrapping_tax_breakdown' => $this->order_invoice->getWrappingTaxesBreakdown(),
'order' => $this->order,
'order_invoice' => $this->order_invoice
'order_invoice' => $this->order_invoice,
'carrier' => $carrier
));
return $this->smarty->fetch($this->getTemplate('invoice.tax-tab'));
+12 -1
View File
@@ -153,4 +153,15 @@ class ShopGroupCore extends ObjectModel
return false;
}
}
public function shopNameExists($name, $id_shop = false)
{
return Db::getInstance()->getValue('
SELECT id_shop
FROM '._DB_PREFIX_.'shop
WHERE name = "'.pSQL($name).'"
AND id_shop_group = '.(int)$this->id.'
'.($id_shop ? 'AND id_shop != '.(int)$id_shop : '')
);
}
}
+21 -6
View File
@@ -47,6 +47,8 @@ class WebserviceOutputBuilderCore
protected $virtualFields = array();
protected $statusInt;
protected $wsParamOverrides;
protected static $_cache_ws_parameters = array();
// Header properties
protected $headerParams = array(
@@ -283,7 +285,7 @@ class WebserviceOutputBuilderCore
if (is_null($this->wsResource))
throw new WebserviceException ('You must set web service resource for get the resources list.', array(82, 500));
$output = '';
$more_attr = array('shop_name' => htmlentities(Configuration::get('PS_SHOP_NAME')));
$more_attr = array('shop_name' => htmlspecialchars(Configuration::get('PS_SHOP_NAME')));
$output .= $this->objectRender->renderNodeHeader('api', array(), $more_attr);
foreach ($this->wsResource as $resourceName => $resource)
{
@@ -359,7 +361,11 @@ class WebserviceOutputBuilderCore
$type_of_view = self::VIEW_DETAILS;
}
$ws_params = $objects['empty']->getWebserviceParameters();
$class = get_class($objects['empty']);
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $objects['empty']->getWebserviceParameters();
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
foreach ($this->wsParamOverrides AS $p)
{
$object = $p['object'];
@@ -376,7 +382,7 @@ class WebserviceOutputBuilderCore
{
if ($key !== 'empty')
{
if ($this->fieldsToDisplay === 'minimum')
if ($this->fieldsToDisplay === 'minimum')
$output .= $this->renderEntityMinimum($object, $depth);
else
$output .= $this->renderEntity($object, $depth);
@@ -406,7 +412,11 @@ class WebserviceOutputBuilderCore
*/
public function renderEntityMinimum($object, $depth)
{
$ws_params = $object->getWebserviceParameters();
$class = get_class($object);
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $object->getWebserviceParameters();
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
$more_attr['id'] = $object->id;
$more_attr['xlink_resource'] = $this->wsUrl.$ws_params['objectsNodeName'].'/'.$object->id;
$output = $this->setIndent($depth).$this->objectRender->renderNodeHeader($ws_params['objectNodeName'], $ws_params, $more_attr, false);
@@ -446,7 +456,12 @@ class WebserviceOutputBuilderCore
public function renderEntity($object, $depth)
{
$output = '';
$ws_params = $object->getWebserviceParameters();
$class = get_class($object);
if (!isset(WebserviceOutputBuilder::$_cache_ws_parameters[$class]))
WebserviceOutputBuilder::$_cache_ws_parameters[$class] = $object->getWebserviceParameters();
$ws_params = WebserviceOutputBuilder::$_cache_ws_parameters[$class];
foreach ($this->wsParamOverrides AS $p)
{
$o = $p['object'];
@@ -792,4 +807,4 @@ class WebserviceOutputBuilderCore
{
$this->fieldsToDisplay = $fields;
}
}
}
+14 -5
View File
@@ -530,9 +530,10 @@ class WebserviceRequestCore
}
}
}
return $this->returnOutput();
$return = $this->returnOutput();
unset($webservice_call);
unset ($display_errors);
unset($display_errors);
return $return;
}
protected function webserviceChecks()
@@ -1158,6 +1159,7 @@ class WebserviceRequestCore
$sorts = array($this->urlFragments['sort']);
$sql_sort .= ' ORDER BY ';
foreach ($sorts as $sort)
{
$delimiterPosition = strrpos($sort, '_');
@@ -1219,8 +1221,6 @@ class WebserviceRequestCore
return $filters;
}
public function getFilteredObjectList()
{
$objects = array();
@@ -1241,7 +1241,16 @@ class WebserviceRequestCore
if ($sqlObjects)
{
foreach ($sqlObjects as $sqlObject)
$objects[] = new $this->resourceConfiguration['retrieveData']['className']((int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']]);
{
if ($this->fieldsToDisplay == 'minimum')
{
$obj = new $this->resourceConfiguration['retrieveData']['className']();
$obj->id = (int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']];
$objects[] = $obj;
}
else
$objects[] = new $this->resourceConfiguration['retrieveData']['className']((int)$sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']]);
}
return $objects;
}
}
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=cms'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
Tools::redirect('index.php?controller=cms'.((count($_GET) || count($_POST)) ? '&'.http_build_query(array_merge($_GET, $_POST), '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');
+1 -1
View File
@@ -36,7 +36,7 @@ function smartyTranslate($params, &$smarty)
{
$htmlentities = !isset($params['js']);
$pdf = isset($params['pdf']);
$addslashes = isset($params['slashes']);
$addslashes = (isset($params['slashes']) || isset($params['js']));
$sprintf = isset($params['sprintf']) ? $params['sprintf'] : false;
if ($pdf)
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
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);
}
// @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(
'vat' => isset($vat) ? $vat : null,
'customer' => isset($customer) ? $customer : null,
'tokenCustomer' => isset ($token_customer) ? $token_customer : null
);
+18 -1
View File
@@ -220,11 +220,28 @@ class AdminCmsControllerCore extends AdminController
$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'))
$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))
{
$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_num' => array('title' => $this->l('ISO code number'), 'align' => 'center', 'width' => 120),
'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false),
'conversion_rate' => array('title' => $this->l('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),
);
@@ -130,12 +130,12 @@ class AdminCurrenciesControllerCore extends AdminController
),
array(
'type' => 'text',
'label' => $this->l('Conversion rate:'),
'label' => $this->l('Exchange rate:'),
'name' => 'conversion_rate',
'size' => 3,
'maxlength' => 11,
'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(
'type' => 'select',
@@ -404,7 +404,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$contact = new Contact((int)$ct->id_contact);
if (Validate::isLoadedObject($contact))
{
$from_name = $contact->name;
$from_name = $contact->name[(int)$ct->id_lang];
$from_email = $contact->email;
}
else
@@ -805,4 +805,4 @@ class AdminCustomerThreadsControllerCore extends AdminController
die('{"hasError" : false, "errors" : ["'.$str_errors.$str_error_delete.'"]}');
}
}
}
}
+19 -11
View File
@@ -2710,43 +2710,51 @@ class AdminImportControllerCore extends AdminController
// If i am a superadmin, i can truncate table
if (((Shop::isFeatureActive() && $this->context->employee->isSuperAdmin()) || !Shop::isFeatureActive()) && Tools::getValue('truncate'))
$this->truncateTables((int)Tools::getValue('entity'));
$import_type = false;
switch ((int)Tools::getValue('entity'))
{
case $this->entities[$this->l('Categories')]:
case $this->entities[$import_type = $this->l('Categories')]:
$this->categoryImport();
break;
case $this->entities[$this->l('Products')]:
case $this->entities[$import_type = $this->l('Products')]:
$import_type = $this->l('Categories');
$this->productImport();
break;
case $this->entities[$this->l('Customers')]:
case $this->entities[$import_type = $this->l('Customers')]:
$this->customerImport();
break;
case $this->entities[$this->l('Addresses')]:
case $this->entities[$import_type = $this->l('Addresses')]:
$this->addressImport();
break;
case $this->entities[$this->l('Combinations')]:
case $this->entities[$import_type = $this->l('Combinations')]:
$this->attributeImport();
break;
case $this->entities[$this->l('Manufacturers')]:
case $this->entities[$import_type = $this->l('Manufacturers')]:
$this->manufacturerImport();
break;
case $this->entities[$this->l('Suppliers')]:
case $this->entities[$import_type = $this->l('Suppliers')]:
$this->supplierImport();
break;
// @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'))
$this->supplyOrdersImport();
break;
// @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'))
$this->supplyOrdersDetailsImport();
break;
default:
$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
$this->errors[] = $this->l('You must upload a file in order to proceed to the next step');
@@ -2806,4 +2814,4 @@ class AdminImportControllerCore extends AdminController
die;
}
}
}
}
@@ -144,7 +144,7 @@ class AdminLanguagesControllerCore extends AdminController
'required' => true,
'size' => 2,
'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(
'type' => 'text',
@@ -152,7 +152,7 @@ class AdminLanguagesControllerCore extends AdminController
'name' => 'date_format_lite',
'required' => true,
'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(
'type' => 'text',
@@ -160,7 +160,7 @@ class AdminLanguagesControllerCore extends AdminController
'name' => 'date_format_full',
'required' => true,
'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(
'type' => 'file',
@@ -38,6 +38,7 @@ class AdminLogsControllerCore extends AdminController
$this->fields_list = array(
'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),
'message' => array('title' => $this->l('Message')),
'object_type' => array('title' => $this->l('Object type'), 'width' => 75),
@@ -62,6 +63,8 @@ class AdminLogsControllerCore extends AdminController
)
);
$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();
}
@@ -189,7 +189,7 @@ class AdminManufacturersControllerCore extends AdminController
$this->_join .= '
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
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:'));
@@ -406,6 +406,12 @@ class AdminManufacturersControllerCore extends AdminController
'type' => 'hidden',
'name' => 'alias',
);
$form['input'][] = array(
'type' => 'hidden',
'name' => 'id_address',
);
$form['input'][] = array(
'type' => 'text',
'label' => $this->l('Last name:'),
@@ -712,6 +718,9 @@ class AdminManufacturersControllerCore extends AdminController
return $res;
}
}
protected function beforeDelete($object)
{
return true;
}
}
+1 -1
View File
@@ -650,7 +650,7 @@ class AdminMetaControllerCore extends AdminController
}
$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)
+2 -1
View File
@@ -571,7 +571,8 @@ class AdminModulesControllerCore extends AdminController
else
{
// 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'));
$this->recursiveDeleteOnDisk($moduleDir);
Tools::redirectAdmin(self::$currentIndex.'&conf=22&token='.$this->token.'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name'));
+50 -7
View File
@@ -489,6 +489,14 @@ class AdminOrdersControllerCore extends AdminController
if ($shipping_cost_amount > 0)
$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 (!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);
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>';
// 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));
}
if (!count($this->errors) && $customizationList)
@@ -914,13 +930,10 @@ class AdminOrdersControllerCore extends AdminController
$order_detail->updateTaxAmount($order);
}
$id_order_carrier = Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `'._DB_PREFIX_.'order_carrier`
WHERE `id_order` = '.(int)$order->id);
$id_order_carrier = (int)$order->getIdOrderCarrier();
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_incl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_incl, $old_currency, $currency);
$order_carrier->update();
@@ -963,7 +976,7 @@ class AdminOrdersControllerCore extends AdminController
// Update currency in order
$order->id_currency = $currency->id;
// Update conversion rate
// Update exchange rate
$order->conversion_rate = (float)$currency->conversion_rate;
$order->update();
}
@@ -1697,6 +1710,15 @@ class AdminOrdersControllerCore extends AdminController
// Save changes of order
$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
$order_detail->updateTaxAmount($order);
@@ -1904,6 +1926,17 @@ class AdminOrdersControllerCore extends AdminController
// Save order detail
$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
if (isset($order_invoice))
$res &= $order_invoice->update();
@@ -1996,12 +2029,22 @@ class AdminOrdersControllerCore extends AdminController
$order->total_products_wt -= $order_detail->total_price_tax_incl;
$res &= $order->update();
// Reinject quantity in stock
$this->reinjectQuantity($order_detail, $order_detail->product_quantity);
// Delete OrderDetail
$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)
die(Tools::jsonEncode(array(
@@ -231,7 +231,7 @@ class AdminPPreferencesControllerCore extends AdminController
// if advanced stock management is disabled, updates concerned tables
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');
+41 -5
View File
@@ -201,7 +201,8 @@ class AdminProductsControllerCore extends AdminController
$this->fields_list['id_product'] = array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 20
'type' => 'int',
'width' => 40
);
$this->fields_list['image'] = array(
'title' => $this->l('Photo'),
@@ -253,6 +254,7 @@ class AdminProductsControllerCore extends AdminController
$this->fields_list['sav_quantity'] = array(
'title' => $this->l('Quantity'),
'width' => 90,
'type' => 'int',
'align' => 'right',
'filter_key' => 'sav!quantity',
'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);
$def = ObjectModel::getDefinition($this->object);
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();
}
@@ -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);
}
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
$success = 0;
}
@@ -765,6 +779,26 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = Tools::displayError('The price attribute is required.');
if (!Tools::getIsset('attribute_combination_list') || Tools::isEmpty(Tools::getValue('attribute_combination_list')))
$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))
{
@@ -1687,6 +1721,7 @@ class AdminProductsControllerCore extends AdminController
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->updateAccessories($this->object);
$this->updatePackItems($this->object);
@@ -1828,6 +1863,7 @@ class AdminProductsControllerCore extends AdminController
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 ($this->isTabSubmitted('Shipping'))
@@ -2710,7 +2746,7 @@ class AdminProductsControllerCore extends AdminController
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 ((int)$attribute['id_product_attribute'] > 0)
@@ -2736,7 +2772,7 @@ class AdminProductsControllerCore extends AdminController
{
$product_supplier = new ProductSupplier($product_supplier_id);
$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->update();
+2 -7
View File
@@ -226,13 +226,8 @@ class AdminShopControllerCore extends AdminController
if (Tools::isSubmit('submitAddshopAndStay') || Tools::isSubmit('submitAddshop'))
{
$same_name = Db::getInstance()->getValue('
SELECT 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)
$shop_group = new ShopGroup((int)Tools::getValue('id_shop_group'));
if ($shop_group->shopNameExists(Tools::getValue('name'), (int)Tools::getValue('id_shop')))
$this->errors[] = Tools::displayError('You cannot have two shops with the same name in the same group.');
}
+16 -13
View File
@@ -165,19 +165,22 @@ class AdminTabsControllerCore extends AdminController
'class' => 'button'
)
);
if (!Validate::isLoadedObject($this->object) || $this->object->id_parent > 0)
$this->fields_form['input'][] = array(
'type' => 'select',
'label' => $this->l('Parent:'),
'name' => 'id_parent',
'options' => array(
'query' => $tabs,
'id' => 'id_tab',
'name' => 'name'
)
);
$display_parent = true;
if (Validate::isLoadedObject($this->object) && !class_exists($this->object->class_name.'Controller'))
$display_parent = false;
if ($display_parent)
$this->fields_form['input'][] = array(
'type' => 'select',
'label' => $this->l('Parent:'),
'name' => 'id_parent',
'options' => array(
'query' => $tabs,
'id' => 'id_tab',
'name' => 'name'
)
);
return parent::renderForm();
}
@@ -426,8 +426,8 @@ class AdminTranslationsControllerCore extends AdminController
{
$this->exportTabs();
$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 = Tools::getCurrentUrlProtocolPrefix().Tools::getShopDomain().__PS_BASE_URI__.'translations/export/'.$this->lang_selected->iso_code.'.gzip';
$file_name = _PS_TRANSLATIONS_DIR_.'/export/'.$this->lang_selected->iso_code.'.gzip';
$gz = new Archive_Tar($file_name, true);
if ($gz->createModify($items, null, _PS_ROOT_DIR_));
{
ob_start();
@@ -440,7 +440,8 @@ class AdminTranslationsControllerCore extends AdminController
header('Content-Disposition: attachment; filename="'.$this->lang_selected->iso_code.'.gzip'.'"');
header('Content-Transfer-Encoding: binary');
ob_end_flush();
@readfile($file_name);
readfile($file_name);
@unlink($file_name);
exit;
}
$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');
else
{
//d(array($module_key, $default_key, $key, $GLOBALS[$name_var]));
$this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = '';
$this->missing_translations++;
}
@@ -1470,12 +1470,10 @@ class AdminTranslationsControllerCore extends AdminController
$array_subjects = array();
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)
$array_subjects['core_and_modules']['translations'] = array_merge($array_subjects['core_and_modules']['translations'], $subject_translation);
}
if (!empty($array_subjects))
foreach ($array_subjects as $infos)
$this->writeSubjectTranslationFile($infos['translations'], $infos['path']);
@@ -1775,12 +1773,14 @@ class AdminTranslationsControllerCore extends AdminController
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);
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
{
// case admin_name/themes/theme_name/template/controllers/controller_name
$key = array_search('controllers', $parent_class);
$prefix_key = 'Admin'.ucfirst($parent_class[$key + 1]);
}
@@ -2146,32 +2146,37 @@ class AdminTranslationsControllerCore extends AdminController
<div name="mails_div" id="'.$id_html.'">';
if (!empty($mails['files']))
{
$topic_already_displayed = array();
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($mail_name, $all_subject_mail))
{
$subject_mail = $all_subject_mail[$mail_name];
$value_subject_mail = isset($mails['subject'][$subject_mail]) ? $mails['subject'][$subject_mail] : '';
$str_return .= '
<div class="label-subject" style="text-align:center;">
<label style="text-align:right">'.sprintf($this->l('Subject for %s:'), '<em>'.$mail_name.'</em>').'</label>
<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['.$group_name.']['.$subject_mail.']" value="'.$value_subject_mail['trad'].'" />';
else
$str_return .= '<input type="text" name="subject['.$group_name.']['.$subject_mail.']" value="" />';
foreach ($all_subject_mail[$mail_name] as $subject_mail)
{
$subject_key = 'subject['.Tools::htmlentitiesUTF8($group_name).']['.Tools::htmlentitiesUTF8($subject_mail).']';
if (in_array($subject_key, $topic_already_displayed))
continue;
$topic_already_displayed[] = $subject_key;
$value_subject_mail = isset($mails['subject'][$subject_mail]) ? $mails['subject'][$subject_mail] : '';
$str_return .= '
<div class="label-subject" style="text-align:center;">
<label style="text-align:right">'.sprintf($this->l('Subject for %s:'), '<em>'.$mail_name.'</em>').'</label>
<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'])
{
$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'].'" />
</a>';
}
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">
<img src="'._PS_IMG_.'admin/error.png" alt="'.$value_subject_mail['use_sprintf'].'" />
</a>';
$str_return .= '</div>
</div>';
</div>';
}
}
else
{
@@ -2193,12 +2198,11 @@ class AdminTranslationsControllerCore extends AdminController
}
}
else
{
$str_return .= '
<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>'.$mails['directory'].'en</em>')
.'</p>';
}
$str_return .= '<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>').'
</p>';
$str_return .= '
</div><!-- #'.$id_html.' -->
<div class="clear"></div>
@@ -2409,21 +2413,27 @@ class AdminTranslationsControllerCore extends AdminController
$content = file_get_contents($dir.'/'.$file);
$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))
for ($i = 0; isset($tab[1][$i]); $i++)
{
$tab2 = explode(',', $tab[1][$i]);
if (is_array($tab2))
if ($tab2 && isset($tab2[1]))
{
$tab2[1] = trim(str_replace('\'', '', $tab2[1]));
if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'/s', $tab2[2], $matches))
$subject_mail[$tab2[1]] = $matches[1];
}
if (is_array($tab2) && isset($tab2[1]))
{
$template = trim(str_replace('\'', '', $tab2[1]));
foreach ($tab2 as $tab3)
if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'\)/Us', $tab3.')', $matches))
{
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))
$subject_mail = $this->getSubjectMail($dir, $file, $subject_mail);
$subject_mail = $this->getSubjectMail($dir, $file, $subject_mail);
return $subject_mail;
}
@@ -2755,4 +2765,4 @@ class AdminTranslationsControllerCore extends AdminController
return true;
return false;
}
}
}
+5 -9
View File
@@ -85,11 +85,7 @@ class AuthControllerCore extends FrontController
$this->assignCountries();
$active_module_newsletter = false;
if ($module_newsletter = Module::getInstanceByName('blocknewsletter'))
$active_module_newsletter = $module_newsletter->active;
$this->context->smarty->assign('newsletter', (int)$active_module_newsletter);
$this->context->smarty->assign('newsletter', 1);
$back = Tools::getValue('back');
$key = Tools::safeOutput(Tools::getValue('key'));
@@ -403,8 +399,8 @@ class AuthControllerCore extends FrontController
if (!Tools::getValue('phone') && !Tools::getValue('phone_mobile'))
$error_phone = true;
}
elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || Configuration::get('PS_ORDER_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'))
|| (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create')))
&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
$error_phone = true;
elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE') && Tools::getValue('email_create')))
@@ -414,11 +410,11 @@ class AuthControllerCore extends FrontController
if ($error_phone)
$this->errors[] = Tools::displayError('You must register at least one phone number.');
$this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
// 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'))
{
+18 -10
View File
@@ -170,6 +170,7 @@ class ContactControllerCore extends FrontController
'{attached_file}' => '-',
'{message}' => Tools::nl2br(stripslashes($message)),
'{email}' => $from,
'{product_name}' => '',
);
if (isset($filename))
@@ -177,14 +178,10 @@ class ContactControllerCore extends FrontController
$id_order = (int)Tools::getValue('id_order');
if (isset($ct) && Validate::isLoadedObject($ct))
{
if ($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');
$id_product = (int)Tools::getValue('id_product');
if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order)
$id_order = $ct->id_order;
if ($id_order)
{
@@ -193,14 +190,25 @@ class ContactControllerCore extends FrontController
$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))
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
{
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 : ''),
$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.');
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ class OrderDetailControllerCore extends FrontController
$ct->id_contact = 0;
$ct->id_customer = (int)$order->id_customer;
$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_order = (int)$order->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'))
{
$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')))
Tools::redirect('index.php?controller=history');
if (!$order_qte_input = Tools::getValue('order_qte_input'))
Tools::redirect('index.php?controller=order-follow&errorDetail1');
if (!$customizationQtyInput && $customizationIds = Tools::getValue('customization_ids'))
if (!$order_qte_input && !$customizationQtyInput && !$customizationIds)
Tools::redirect('index.php?controller=order-follow&errorDetail1');
if (!$customizationIds && !$ids_order_detail = Tools::getValue('ids_order_detail'))
Tools::redirect('index.php?controller=order-follow&errorDetail2');
+18 -1
View File
@@ -376,6 +376,9 @@ class OrderOpcControllerCore extends ParentOrderController
$customer = $this->context->customer;
$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)
$birthday = explode('-', $customer->birthday);
else
@@ -404,7 +407,21 @@ class OrderOpcControllerCore extends ParentOrderController
'id_gender' => (int)$customer->id_gender,
'sl_year' => $birthday[0],
'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
if (isset($_SERVER['HTTP_REFERER'])
&& 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 (isset($regs[2]) && is_numeric($regs[2]))
@@ -454,7 +455,7 @@ class ProductControllerCore extends FrontController
{
if (isset($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;
$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))
$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;
if (isset($product_images[$id_image]))
@@ -510,9 +511,12 @@ class ProductControllerCore extends FrontController
protected function assignAttributesCombinations()
{
$attributes_combinations = Product::getAttributesInformationsByProduct($this->product->id);
foreach ($attributes_combinations as &$ac)
foreach ($ac as &$val)
$val = str_replace('-', '_', Tools::link_rewrite(str_replace(array(',', '.'), '-', $val)));
if (is_array($attributes_combinations) && count($attributes_combinations))
foreach ($attributes_combinations as &$ac)
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);
}
+1 -1
View File
@@ -34,4 +34,4 @@
require(dirname(__FILE__).'/config/config.inc.php');
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');
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');
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');
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()
{
session_name('install_'.md5(__PS_BASE_URI__));
if (!($session_started = session_start())
session_name('install_'.md5($_SERVER['HTTP_HOST']));
$session_started = session_start();
if (!($session_started)
|| (!isset($_SESSION['session_mode']) && (isset($_POST['submitNext']) || isset($_POST['submitPrevious']) || isset($_POST['language']))))
{
InstallSession::$_cookie_mode = true;
+18 -26
View File
@@ -56,7 +56,6 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$this->session->database_login = trim(Tools::getValue('dbLogin'));
$this->session->database_password = trim(Tools::getValue('dbPassword'));
$this->session->database_prefix = trim(Tools::getValue('db_prefix'));
$this->session->database_engine = Tools::getValue('dbEngine');
$this->session->database_clear = Tools::getValue('database_clear');
// Save email config
@@ -81,21 +80,23 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$this->session->database_login,
$this->session->database_password,
$this->session->database_prefix,
$this->session->database_engine,
// We do not want to validate table prefix if we are already in install process
($this->session->step == 'process') ? true : $this->session->database_clear
);
return count($this->errors) ? false : true;
if (count($this->errors))
return false;
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()
{
if (Tools::getValue('checkDb'))
$this->processCheckDb();
else if (Tools::getValue('sendMail'))
$this->processSendMail();
elseif (Tools::getValue('createDb'))
$this->processCreateDb();
}
/**
@@ -108,10 +109,9 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$login = Tools::getValue('dbLogin');
$password = Tools::getValue('dbPassword');
$prefix = Tools::getValue('db_prefix');
$engine = Tools::getValue('dbEngine');
$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(
(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('smtpSrv');
$encryption = Tools::getValue('smtpEnc');
$port = Tools::getValue('smtpPort');
$login = Tools::getValue('smtpLogin');
$password = Tools::getValue('smtpPassword');
$email = Tools::getValue('testEmail');
$server = Tools::getValue('dbServer');
$database = Tools::getValue('dbName');
$login = Tools::getValue('dbLogin');
$password = Tools::getValue('dbPassword');
require_once _PS_INSTALL_MODELS_PATH_.'mail.php';
$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')
);
$success = $this->model_database->createDatabase($server, $database, $login, $password);
$this->ajaxJsonAnswer(
$result === false,
($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,
$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,
`object_type` varchar(32) DEFAULT NULL,
`object_id` int(10) unsigned DEFAULT NULL,
`id_employee` int(10) unsigned DEFAULT NULL,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
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_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_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_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"/>
+1 -1
View File
@@ -41,7 +41,7 @@
<field name="valid"/>
</fields>
<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>
<module>cheque</module>
<gift_message/>
+26 -14
View File
@@ -38,7 +38,7 @@ class InstallModelDatabase extends InstallAbstractModel
* @param bool $clear
* @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();
@@ -55,14 +55,11 @@ class InstallModelDatabase extends InstallAbstractModel
if ($prefix && !Validate::isTablePrefix($prefix))
$errors[] = $this->language->l('Tables prefix is invalid');
if (!Validate::isMySQLEngine($engine))
$errors[] = $this->language->l('Wrong engine chosen for MySQL');
if (!$errors)
{
$dbtype = ' ('.Db::getClass().')';
// Try to connect to database
switch (Db::checkConnection($server, $login, $password, $database, true, $engine))
switch (Db::checkConnection($server, $login, $password, $database, true))
{
case 0:
if (!Db::checkEncoding($server, $login, $password))
@@ -71,28 +68,43 @@ class InstallModelDatabase extends InstallAbstractModel
// Check if a table with same prefix already exists
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');
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));
if ($create_error != false)
$errors[] = $create_error;
}
break;
break;
case 1:
$errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields').$dbtype;
break;
break;
case 2:
$errors[] = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype;
break;
case 4:
$errors[] = $this->language->l('Engine innoDB is not supported by your MySQL server, please use MyISAM').$dbtype;
break;
$error = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype;
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>
<script type="text/javascript">bindCreateDB();</script>';
$errors[] = $error;
break;
}
}
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;
}
}
+2 -2
View File
@@ -307,8 +307,8 @@ class InstallModelInstall extends InstallAbstractModel
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));
$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)
Language::checkAndAddLanguage($iso, false, true, $params_lang);
else
+76 -39
View File
@@ -1,39 +1,76 @@
$(document).ready(function()
{
// Check database configuration
$('#btTestDB').click(function()
{
$("#dbResultCheck").slideUp('slow');
$.ajax({
url: 'index.php',
data: {
'checkDb': 'true',
'dbServer': $('#dbServer').val(),
'dbName': $('#dbName').val(),
'dbLogin': $('#dbLogin').val(),
'dbPassword': $('#dbPassword').val(),
'dbEngine': $('#dbEngine').val(),
'db_prefix': $('#db_prefix').val(),
'clear': $('#db_clear').prop('checked') ? '1' : '0'
},
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');
}
});
});
});
$(document).ready(function()
{
// Check database configuration
$('#btTestDB').click(function()
{
$("#dbResultCheck").slideUp('slow');
$.ajax({
url: 'index.php',
data: {
'checkDb': 'true',
'dbServer': $('#dbServer').val(),
'dbName': $('#dbName').val(),
'dbLogin': $('#dbLogin').val(),
'dbPassword': $('#dbPassword').val(),
'dbEngine': $('#dbEngine').val(),
'db_prefix': $('#db_prefix').val(),
'clear': $('#db_clear').prop('checked') ? '1' : '0'
},
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');
}
});
});
});
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>
<input class="text" size="10" type="password" id="dbPassword" name="dbPassword" value="<?php echo htmlspecialchars($this->database_password) ?>" />
</p>
<!--
<p>
<label for="dbEngine"><?php echo $this->l('Database Engine:') ?></label>
<select id="dbEngine" name="dbEngine">
<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>
</select>
</p>
</p>-->
<p>
<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) ?>" />
@@ -26,6 +26,7 @@
function add_accounting_tab()
{
include_once(_PS_INSTALL_PATH_.'upgrade/php/add_new_tab.php');
$id_parent = add_new_tab(
'AdminAccounting',
'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');
if (!is_object($payments))
return false;
return true;
$errors = array();
// Populate "order_reference"
@@ -62,7 +62,7 @@ function add_order_reference_in_order_payment()
HAVING COUNT(*) > 1');
if (!is_object($duplicate_lines))
return false;
return true;
$order_payments_to_remove = array();
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_).'")
WHERE id_shop = 1');
$shop_domain = Db::getInstance()->getValue('SELECT `value`
FROM `'._DB_PREFIX_.'_configuration`
FROM `'._DB_PREFIX_.'configuration`
WHERE `name`="PS_SHOP_DOMAIN"');
$shop_domain_ssl = Db::getInstance()->getValue('SELECT `value`
FROM `'._DB_PREFIX_.'_configuration`
FROM `'._DB_PREFIX_.'configuration`
WHERE `name`="PS_SHOP_DOMAIN_SSL"');
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)');
// Stock conversion
$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);';
$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);';
$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);';
$res &= Db::getInstance()->execute($sql);
+2 -2
View File
@@ -48,7 +48,7 @@ function p15012_add_missing_columns()
$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`';
$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`
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`
@@ -187,4 +187,4 @@ function p15012_add_missing_columns()
}
else
return true;
}
}

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