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

This commit is contained in:
djfm
2013-09-18 16:08:44 +00:00
69 changed files with 578 additions and 2390 deletions
+21 -20
View File
@@ -2,47 +2,48 @@ README
======
![PrestaShop](http://www.prestashop.com/images/banners/general/prestashop_728x90.png "PrestaShop")
PREPARATION
ABOUT
--------
To install PrestaShop, you need a remote web server or on your computer (MAMP), with access to a database like MySQL.
You'll need access to phpMyAdmin to create a database and to indicate the information in the database in the installer.
PrestaShop is a free and open-source e-commerce web application, committed to providing the best shopping cart experience for both merchants and consumers.
SERVER CONFIGURATION
--------
To install PrestaShop, you need a web server running PHP5 and any flavor of MySQL5 (MySQL, MariaDB, Percona Server...).
You will also need a database administration tool, such as phpMyAdmin, in order to create a database for PrestaShop.
We recommend the Apache or Nginx web servers.
If your host does not offer PHP5 by default, here are a few [explanations][2] about PHP5 or the .htaccess file for certain hosting services (1&1, Free, Lycos, OVH, Infomaniak, Amen, GoDaddy, etc).
If you want your online store ready to go, visit [http://www.prestabox.com][1]: it lets you create your online store in less than 10 minutes without any technical knowledge.
If you do not host and unable to create your store, we offer a turnkey store, which lets you create your online store in less than 10 minutes without any technical knowledge.
We invite you to visit: [http://www.prestabox.com][1]
INSTALLATION
--------
Simply go to your PrestaShop web directory and use installer :-)
With your web browser, go to the root of your PrestaShop directory, and the installer will start. Follow the instructions until PrestaShop is installed.
If you have any PHP error, perhaps you don't have PHP5 or you need to activate it on your web host.
Please go to our forum to find pre-installation settings (PHP 5, htaccess) for certain hosting services (1&1, Free, Lycos, OVH, Infomaniak, Amen, GoDaddy, etc).
If you have any PHP error, perhaps you don't have PHP5 or you need to activate it on your web host. See the page linked above.
If you don't find any solution to start the installer, please post on [the PrestaShop forums][3].
English webhost [specifics settings][2]
If you don't find any solution to launch installer, please post on [our forum][3]
There are always solutions for your issues ;-)
DOCUMENTATION
--------
For any extra documentation (how-to), please read our [Online documentation][4]
The official PrestaShop documentation is available online [on its own website][4].
FORUMS
--------
You can also discuss, help and contribute with PrestaShop community on [our forums][5]
You can discuss, help and contribute with PrestaShop community on [the PrestaShop forums][5].
Thanks for downloading and using PrestaShop e-commerce Open-source solution!
Thank you for downloading and using PrestaShop e-commerce Open-source solution!
[1]: http://www.prestabox.com
[2]: http://www.prestashop.com/forums/topic/2946-pre-installation-settings-php-5-htaccess-for-certain-hosting-services/
[3]: http://www.prestashop.com/forums/forum/7-installing-prestashop/
[4]: http://doc.prestashop.com
[5]: http://www.prestashop.com/forums/
[5]: http://www.prestashop.com/forums/
@@ -58,6 +58,7 @@
</ul>
</fieldset>
<h2>{l s='Members of this customer group'}</h2>
<p>{l s='Limited to the 100th first customers.'} {l s='Please use filters to narrow your search.'}</p>
{$customerList}
{/block}
@@ -112,7 +112,6 @@
<fieldset style="float: left; margin: 0pt 20px 0pt 0pt; width: 70%;">
<legend><img src="../img/admin/import.gif" />{l s='Import '}</legend>
<label class="clear">{if count($files_to_import) > 1}{l s='Your CSV file (%d files):' sprintf=count($files_to_import)}{else}{l s='Your CSV file (%d file):' sprintf=count($files_to_import)}{/if}</label>
<div class="margin-form">
{if count($files_to_import)}
@@ -146,7 +145,7 @@
<div class="margin-form">
<select name="entity" id="entity">
{foreach $entities AS $entity => $i}
<option value="{$i}" {if $entity == $i}selected="selected"{/if}>
<option value="{$i}"{if $entity_selected == $i} selected="selected"{/if}>
{$entity}
</option>
{/foreach}
@@ -117,7 +117,7 @@
$('#vouchers_err').hide();
var mytab = new Array();
for (var i = 0; i < data.vouchers.length; i++)
mytab[mytab.length] = { data: data.vouchers[i], value: data.vouchers[i].name+' - '+data.vouchers[i].description };
mytab[mytab.length] = { data: data.vouchers[i], value: data.vouchers[i].name + (data.vouchers[i].code.length > 0 ? ' - ' + data.vouchers[i].code : '')};
return mytab;
},
extraParams: {
@@ -694,17 +694,15 @@
function updateCartVouchers(vouchers)
{
var vouchers_html = '';
if (vouchers.length > 0)
{
$.each(vouchers, function() {
if (typeof(vouchers) == 'object')
$.each(vouchers, function(){
vouchers_html += '<tr><td>'+this.name+'</td><td>'+this.description+'</td><td>'+this.value_real+'</td><td><a href="#" class="delete_discount" rel="'+this.id_discount+'"><img src="../img/admin/delete.gif" /></a></td></tr>';
});
$('#voucher_list').show();
}
else
$('#voucher_list tbody').html($.trim(vouchers_html));
if ($('#voucher_list tbody').html().length == 0)
$('#voucher_list').hide();
$('#voucher_list tbody').html(vouchers_html);
else
$('#voucher_list').show();
}
function updateCartPaymentList(payment_list)
@@ -153,7 +153,7 @@
<br />
<fieldset>
<legend><img src="../img/admin/tab-customers.gif" /> {l s='Customer information'}</legend>
<span style="font-weight: bold; font-size: 14px;"><a href="?tab=AdminCustomers&id_customer={$customer->id}&viewcustomer&token={getAdminToken tab='AdminCustomers'}"> {$customer->firstname} {$customer->lastname}</a></span> ({l s='#'}{$customer->id})<br />
<span style="font-weight: bold; font-size: 14px;"><a href="?tab=AdminCustomers&id_customer={$customer->id}&viewcustomer&token={getAdminToken tab='AdminCustomers'}"> {$gender->name|escape:'htmlall':'UTF-8'} {$customer->firstname} {$customer->lastname}</a></span> ({l s='#'}{$customer->id})<br />
(<a href="mailto:{$customer->email}">{$customer->email}</a>)<br /><br />
{if ($customer->isGuest())}
{l s='This order has been placed by a guest.'}
@@ -41,7 +41,7 @@
{/if}
{$smarty.block.parent}
{if $input.type == 'radio' && $input.name == 'smarty_cache'}
<a href="{$current}&token={$token}&empty_smarty_cache=1" class="clear button" href="">{l s='Clear Smarty cache'}</a>
<a href="{$current}&token={$token}&empty_smarty_cache=1" class="clear button" href="">{l s='Clear Smarty cache & Autoload cache'}</a>
{/if}
{/block}
@@ -33,22 +33,22 @@
{/if}
<form method="post" action="{$currentIndex}&{$identifier}&token={$token}&id_tax_rules_group={$id_tax_rules_group}&updatetax_rules_group#{$table}" class="form">
<input type="hidden" id="submitFilter{$table}" name="submitFilter{$table}" value="0"/>
<input type="hidden" id="submitFilter{$list_id}" name="submitFilter{$list_id}" value="0"/>
<table class="table_grid">
<tr>
<td style="vertical-align: bottom;">
<span style="float: left;">
{if $page > 1}
<input type="image" src="../img/admin/list-prev2.gif" onclick="getE('submitFilter{$table}').value=1"/>&nbsp;
<input type="image" src="../img/admin/list-prev.gif" onclick="getE('submitFilter{$table}').value={$page - 1}"/>
<input type="image" src="../img/admin/list-prev2.gif" onclick="getE('submitFilter{$list_id}').value=1"/>&nbsp;
<input type="image" src="../img/admin/list-prev.gif" onclick="getE('submitFilter{$list_id}').value={$page - 1}"/>
{/if}
{l s='Page'} <b>{$page}</b> / {$total_pages}
{if $page < $total_pages}
<input type="image" src="../img/admin/list-next.gif" onclick="getE('submitFilter{$table}').value={$page + 1};"/>&nbsp;
<input type="image" src="../img/admin/list-next2.gif" onclick="getE('submitFilter{$table}').value={$total_pages}"/>
<input type="image" src="../img/admin/list-next.gif" onclick="getE('submitFilter{$list_id}').value={$page + 1};"/>&nbsp;
<input type="image" src="../img/admin/list-next2.gif" onclick="getE('submitFilter{$list_id}').value={$total_pages}"/>
{/if}
| {l s='Display'}
<select name="pagination" onchange="submit()">
<select name="{$list_id}_pagination" onchange="submit()">
{* Choose number of results per page *}
{foreach $pagination AS $value}
<option value="{$value|intval}"{if $selected_pagination == $value} selected="selected" {elseif $selected_pagination == NULL && $value == $pagination[1]} selected="selected2"{/if}>{$value|intval}</option>
@@ -57,7 +57,7 @@
/ {$list_total} {l s='result(s)'}
</span>
<span style="float: right;">
<input type="submit" name="submitReset{$table}" value="{l s='Reset'}" class="button" />
<input type="submit" name="submitReset{$list_id}" value="{l s='Reset'}" class="button" />
</span>
<span class="clear"></span>
</td>
@@ -66,7 +66,7 @@
<td>
<table
{if $table_id} id={$table_id}{/if}
class="table {if $table_dnd}tableDnD{/if} {$table}"
class="table {if $table_dnd}tableDnD{/if} {$list_id}"
cellpadding="0" cellspacing="0"
style="width: 100%; margin-bottom:10px;"
>
@@ -84,7 +84,7 @@
<tr class="nodrag nodrop">
<th class="center">
{if $has_bulk_actions}
<input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, '{$table}Box[]', this.checked)" />
<input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, '{$list_id}Box[]', this.checked)" />
{/if}
</th>
{foreach $fields_display AS $key => $params}
@@ -30,7 +30,7 @@
{if isset($fields.title)}<h2>{$fields.title}</h2>{/if}
{block name="defaultForm"}
<form id="{if isset($fields.form.form.id_form)}{$fields.form.form.id_form|escape:'htmlall':'UTF-8'}{else}{$table}_form{/if}" class="defaultForm {$name_controller}" action="{$current}&{if !empty($submit_action)}{$submit_action}=1{/if}&token={$token}" method="post" enctype="multipart/form-data" {if isset($style)}style="{$style}"{/if}>
<form id="{if isset($fields.form.form.id_form)}{$fields.form.form.id_form|escape:'htmlall':'UTF-8'}{else}{if $table == null}configuration_form{else}{$table}_form{/if}{/if}" class="defaultForm {$name_controller}" action="{$current}&{if !empty($submit_action)}{$submit_action}=1{/if}&token={$token}" method="post" enctype="multipart/form-data" {if isset($style)}style="{$style}"{/if}>
{if $form_id}
<input type="hidden" name="{$identifier}" id="{$identifier}" value="{$form_id}" />
{/if}
@@ -34,7 +34,7 @@
{block name="defaultOptions"}
<form action="{$current}&token={$token}"
id="{$table}_form"
id="{if $table == null}configuration_form{else}{$table}_form{/if}"
{if isset($categoryData['name'])} name={$categoryData['name']}{/if}
{if isset($categoryData['id'])} id={$categoryData['id']} {/if}
method="post"
@@ -36,7 +36,7 @@
{if $k == 'modules-list'}
<div id="modules_list_container" style="display:none">
<div style="float:right;margin:5px">
<a href="#" onclick="$('#modules_list_container').slideUp();return false;"><img alt="X" src="../img/admin/close.png"></a>
<a href="#" onclick="$('#modules_list_container').slideUp();return false;"><img alt="X" src="../img/admin/close.png" /></a>
</div>
<div id="modules_list_loader"><img src="../img/loader.gif" alt="" border="0" /></div>
<div id="modules_list_container_tab" style="display:none;"></div>
+8 -12
View File
@@ -54,6 +54,8 @@ class Autoload
$this->root_dir = dirname(dirname(__FILE__)).'/';
if (file_exists($this->root_dir.Autoload::INDEX_FILE))
$this->index = include($this->root_dir.Autoload::INDEX_FILE);
else
$this->generateIndex();
}
/**
@@ -80,9 +82,8 @@ class Autoload
if (strpos(strtolower($classname), 'smarty_') === 0)
return;
// regenerate the class index if the requested class is not found in the index or if the requested file doesn't exists
if (!isset($this->index[$classname])
|| ($this->index[$classname] && !is_file($this->root_dir.$this->index[$classname]))
// regenerate the class index if the requested file doesn't exists
if ((isset($this->index[$classname]) && $this->index[$classname] && !is_file($this->root_dir.$this->index[$classname]))
|| (isset($this->index[$classname.'Core']) && $this->index[$classname.'Core'] && !is_file($this->root_dir.$this->index[$classname.'Core'])))
$this->generateIndex();
@@ -138,18 +139,14 @@ class Autoload
{
$filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE)
{
{
@rename($filename_tmp, $filename);
@chmod($filename, 0664);
@chmod($filename, 0666);
}
else
{
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated),
// no need to die.
else
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die.
error_log('Cannot write temporary file '.$filename_tmp);
}
}
$this->index = $classes;
}
@@ -192,4 +189,3 @@ class Autoload
return isset($this->index[$classname]) ? $this->index[$classname] : null;
}
}
+16 -6
View File
@@ -762,10 +762,11 @@ class CartCore extends ObjectModel
{
// You can't add a cart rule that does not exist
$cartRule = new CartRule($id_cart_rule, Context::getContext()->language->id);
if (!Validate::isLoadedObject($cartRule))
return false;
if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$this->id))
if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart_rule = '.(int)$id_cart_rule.' AND id_cart = '.(int)$this->id))
return false;
// Add the cart rule to the cart
@@ -3415,6 +3416,7 @@ class CartCore extends ObjectModel
*/
public function setNoMultishipping()
{
$emptyCache = $result = false;
if (Configuration::get('PS_ALLOW_MULTISHIPPING'))
{
// Upgrading quantities
@@ -3433,7 +3435,9 @@ class CartCore extends ObjectModel
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);
$result = Db::getInstance()->execute($sql);
if ($result)
$emptyCache = true;
}
// Merging multiple lines
@@ -3451,15 +3455,18 @@ class CartCore extends ObjectModel
}
// Update delivery address for each product line
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'cart_product`
$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 : ''));
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '');
$result = Db::getInstance()->execute($sql);
if ($result)
$emptyCache = true;
if (Customization::isFeatureActive())
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'customization`
@@ -3468,6 +3475,9 @@ class CartCore extends ObjectModel
WHERE `id_cart` = '.(int)$this->id.'
)
WHERE `id_cart` = '.(int)$this->id);
if ($emptyCache)
$this->_products = null;
}
/**
+1 -1
View File
@@ -1190,7 +1190,7 @@ class CartRuleCore extends ObjectModel
SELECT cr.*, crl.*
FROM '._DB_PREFIX_.'cart_rule cr
LEFT JOIN '._DB_PREFIX_.'cart_rule_lang crl ON (cr.id_cart_rule = crl.id_cart_rule AND crl.id_lang = '.(int)$id_lang.')
WHERE code LIKE \'%'.pSQL($name).'%\'
WHERE code LIKE \'%'.pSQL($name).'%\' OR name LIKE \'%'.pSQL($name).'%\'
');
}
}
+3 -3
View File
@@ -97,7 +97,7 @@ class ConnectionCore extends ObjectModel
'id_connections' => (int)$cookie->id_connections,
'id_page' => (int)$id_page,
'time_start' => $time_start
));
), false, true, Db::INSERT_IGNORE);
// This array is serialized and used by the ajax request to identify the page
return array(
@@ -114,7 +114,7 @@ class ConnectionCore extends ObjectModel
// This is a bot and we have to retrieve its connection ID
$sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections`
WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).'
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
AND `date_add` > \''.pSQL(date('Y-m-d H:i:00', time() - 1800)).'\'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `date_add` DESC';
if ($id_connections = Db::getInstance()->getValue($sql))
@@ -128,7 +128,7 @@ class ConnectionCore extends ObjectModel
$sql = 'SELECT `id_guest`
FROM `'._DB_PREFIX_.'connections`
WHERE `id_guest` = '.(int)$cookie->id_guest.'
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
AND `date_add` > \''.pSQL(date('Y-m-d H:i:00', time() - 1800)).'\'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `date_add` DESC';
$result = Db::getInstance()->getRow($sql);
+4 -4
View File
@@ -369,7 +369,7 @@ class DispatcherCore
// If there are several languages, get language from uri
if ($this->use_routes && Language::isMultiLanguageActivated())
if (preg_match('#^/([a-z]{2})/#', $this->request_uri, $m))
if (preg_match('#^/([a-z]{2})/?#', $this->request_uri, $m))
{
$_GET['isolang'] = $m[1];
$this->request_uri = substr($this->request_uri, 3);
@@ -549,7 +549,7 @@ class DispatcherCore
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
if ($this->use_routes && !isset($this->routes[$id_shop]))
if (!isset($this->routes[$id_shop]))
$this->loadRoutes($id_shop);
if (!isset($this->routes[$id_shop]) || !isset($this->routes[$id_shop][$id_lang]) || !isset($this->routes[$id_shop][$id_lang][$route_id]))
@@ -594,9 +594,9 @@ class DispatcherCore
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
if ($this->use_routes && !isset($this->routes[$id_shop]))
if (!isset($this->routes[$id_shop]))
$this->loadRoutes($id_shop);
if (!isset($this->routes[$id_shop][$id_lang][$route_id]))
{
$query = http_build_query($params, '', '&');
+34 -53
View File
@@ -91,12 +91,8 @@ class LinkCore
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null)
$shop = new Shop($id_shop);
else
$shop = Context::getContext()->shop;
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
if (!is_object($product))
{
@@ -163,11 +159,7 @@ class LinkCore
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
if (!is_object($category))
$category = new Category($category, $id_lang);
@@ -206,11 +198,7 @@ class LinkCore
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
$dispatcher = Dispatcher::getInstance();
if (!is_object($cms_category))
@@ -239,19 +227,12 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null, $id_shop = null)
public function getCMSLink($cms, $alias = null, $ssl = null, $id_lang = null, $id_shop = null)
{
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://');
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$url = $this->getBaseLink($id_shop, $ssl).$this->getLangLink($id_lang, null, $id_shop);
$dispatcher = Dispatcher::getInstance();
if (!is_object($cms))
@@ -290,11 +271,8 @@ class LinkCore
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
$dispatcher = Dispatcher::getInstance();
if (!is_object($supplier))
@@ -327,11 +305,7 @@ class LinkCore
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$url = $this->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
$dispatcher = Dispatcher::getInstance();
if (!is_object($manufacturer))
@@ -360,18 +334,12 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = false, $id_lang = null, $id_shop = null)
public function getModuleLink($module, $controller = 'default', array $params = array(), $ssl = null, $id_lang = null, $id_shop = null)
{
$base = (($ssl && $this->ssl_enable) ? 'https://' : 'http://');
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
if ($id_shop === null)
$shop = Context::getContext()->shop;
else
$shop = new Shop($id_shop);
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
$url = $this->getBaseLink($id_shop, $ssl).$this->getLangLink($id_lang, null, $id_shop);
// If the module has its own route ... just use it !
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop))
@@ -453,10 +421,9 @@ class LinkCore
*
* @return string Page link
*/
public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
public function getPageLink($controller, $ssl = null, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
{
$controller = Tools::strReplaceFirst('.php', '', $controller);
if (!$id_lang)
$id_lang = (int)Context::getContext()->language->id;
@@ -469,16 +436,9 @@ class LinkCore
parse_str($request, $request);
}
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, null, $id_shop).ltrim($uri_path, '/');
return $url;
return $this->getBaseLink($id_shop, $ssl).$this->getLangLink($id_lang, null, $id_shop).ltrim($uri_path, '/');
}
public function getCatImageLink($name, $id_category, $type = null)
@@ -642,5 +602,26 @@ class LinkCore
return Language::getIsoById($id_lang).'/';
}
protected function getBaseLink($id_shop = null, $ssl = null)
{
static $force_ssl = null;
if ($ssl === null)
{
if ($force_ssl === null)
$force_ssl = (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'));
$ssl = $force_ssl;
}
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null)
$shop = new Shop($id_shop);
else
$shop = Context::getContext()->shop;
$base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain);
return $base.$shop->getBaseURI();
}
}
+10 -6
View File
@@ -50,10 +50,11 @@ class MailCore
* @param bool $modeSMTP
* @param string $template_path
* @param bool $die
* @param string $bcc Bcc recipient
*/
public static function Send($id_lang, $template, $subject, $template_vars, $to,
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null)
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null)
{
$configuration = Configuration::getMultiple(array(
'PS_SHOP_EMAIL',
@@ -127,9 +128,9 @@ class MailCore
}
/* Construct multiple recipients list if needed */
$to_list = new Swift_RecipientList();
if (is_array($to) && isset($to))
{
$to_list = new Swift_RecipientList();
foreach ($to as $key => $addr)
{
$to_name = null;
@@ -153,17 +154,20 @@ class MailCore
$to_list->addTo($addr, self::mimeEncode($to_name));
}
$to_plugin = $to[0];
$to = $to_list;
} else {
/* Simple recipient, one address */
$to_plugin = $to;
if ($to_name == null)
$to_name = $to;
if (function_exists('mb_encode_mimeheader'))
$to = new Swift_Address($to, mb_encode_mimeheader($to_name, 'utf-8'));
$to_list->addTo($to, mb_encode_mimeheader($to_name, 'utf-8'));
else
$to = new Swift_Address($to, self::mimeEncode($to_name));
$to_list->addTo($to, self::mimeEncode($to_name));
}
if(isset($bcc)) {
$to_list->addBcc($bcc);
}
$to = $to_list;
try {
/* Connect with the appropriate configuration */
if ($configuration['PS_MAIL_METHOD'] == 2)
@@ -445,4 +449,4 @@ class MailCore
return $start . $string . $end;
}
}
}
+1 -1
View File
@@ -39,7 +39,7 @@ class MediaCore
'ui.accordion' => array('fileName' => 'jquery.ui.accordion.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.autocomplete' => array('fileName' => 'jquery.ui.autocomplete.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
'ui.button' => array('fileName' => 'jquery.ui.button.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position','ui.button'), 'theme' => true),
'ui.slider' => array('fileName' => 'jquery.ui.slider.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
'ui.tabs' => array('fileName' => 'jquery.ui.tabs.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
'ui.datepicker' => array('fileName' => 'jquery.ui.datepicker.min.js', 'dependencies' => array('ui.core'), 'theme' => true),
+5 -2
View File
@@ -68,8 +68,11 @@ class MetaCore extends ObjectModel
{
if ($file != 'index.php' && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages))
{
$reflection = new ReflectionClass(str_replace('.php', '', $file));
$properties = $reflection->getDefaultProperties();
$class_name = str_replace('.php', '', $file);
if (class_exists($class_name))
$reflection = new ReflectionClass(str_replace('.php', '', $file));
if (isset($reflection) && $reflection)
$properties = $reflection->getDefaultProperties();
if (isset($properties['php_self']))
$selected_pages[$properties['php_self']] = $properties['php_self'];
else if (preg_match('/^[a-z0-9_.-]*\.php$/i', $file))
+8 -8
View File
@@ -3055,18 +3055,18 @@ class ProductCore extends ObjectModel
if (!Combination::isFeatureActive())
return array();
$sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name,
a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, pa.`id_product_attribute`,
IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`price`, product_attribute_shop.`ecotax`, pa.`weight`,
a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, product_attribute_shop.`id_product_attribute`,
IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`price`, product_attribute_shop.`ecotax`, product_attribute_shop.`weight`,
product_attribute_shop.`default_on`, pa.`reference`, product_attribute_shop.`unit_price_impact`,
pa.`minimal_quantity`, pa.`available_date`, ag.`group_type`
product_attribute_shop.`minimal_quantity`, product_attribute_shop.`available_date`, ag.`group_type`
FROM `'._DB_PREFIX_.'product_attribute` pa
'.Shop::addSqlAssociation('product_attribute', 'pa').'
'.Product::sqlStock('pa', 'pa').'
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group`
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group`
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`)
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`)
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute`)
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group`)
'.Shop::addSqlAssociation('attribute', 'a').'
WHERE pa.`id_product` = '.(int)$this->id.'
AND al.`id_lang` = '.(int)$id_lang.'
+12 -21
View File
@@ -1260,6 +1260,13 @@ class ToolsCore
return Tools::strtoupper(Tools::substr($str, 0, 1)).Tools::substr($str, 1);
}
public static function ucwords($str)
{
if (function_exists('mb_convert_case'))
return mb_convert_case($str, MB_CASE_TITLE);
return ucwords(strtolower($str));
}
public static function orderbyPrice(&$array, $order_way)
{
foreach ($array as &$row)
@@ -1401,26 +1408,9 @@ class ToolsCore
public static function copy($source, $destination, $stream_context = null)
{
if ($stream_context == null && preg_match('/^https?:\/\//', $source))
$stream_context = @stream_context_create(array('http' => array('timeout' => 10)));
if (in_array(@ini_get('allow_url_fopen'), array('On', 'on', '1')) || !preg_match('/^https?:\/\//', $source))
return @copy($source, $destination, $stream_context);
elseif (function_exists('curl_init'))
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $source);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$opts = stream_context_get_options($stream_context);
$content = curl_exec($curl);
curl_close($curl);
return file_put_contents($destination, $content);
}
else
return false;
if (is_null($stream_context) && !preg_match('/^https?:\/\//', $source))
return @copy($source, $destination);
return @file_put_contents($destination, Tools::file_get_contents($source, false, $stream_context));
}
/**
@@ -1596,7 +1586,8 @@ class ToolsCore
if (self::$_cache_nb_media_servers && ($id_media_server = (abs(crc32($filename)) % self::$_cache_nb_media_servers + 1)))
return constant('_MEDIA_SERVER_'.$id_media_server.'_');
return Tools::getShopDomain();
return Tools::usingSecureMode() ? Tools::getShopDomainSSL() : Tools::getShopDomain();
}
public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null)
+6 -3
View File
@@ -45,7 +45,7 @@ class AdminControllerCore extends Controller
public $template = 'content.tpl';
/** @var string Associated table name */
public $table;
public $table = 'configuration';
public $list_id;
@@ -2159,8 +2159,11 @@ class AdminControllerCore extends Controller
|| !Validate::isUnsignedId($id_lang))
throw new PrestaShopException('get list params is not valid');
if (isset($this->fields_list[$order_by]) && isset($this->fields_list[$order_by]['filter_key']))
$order_by = $this->fields_list[$order_by]['filter_key'];
if (!isset($this->fields_list[$order_by]['order_key']) && isset($this->fields_list[$order_by]['filter_key']))
$this->fields_list[$order_by]['order_key'] = $this->fields_list[$order_by]['filter_key'];
if (isset($this->fields_list[$order_by]) && isset($this->fields_list[$order_by]['order_key']))
$order_by = $this->fields_list[$order_by]['order_key'];
/* Determine offset from current page */
if ((isset($_POST['submitFilter'.$this->list_id]) ||
+7 -3
View File
@@ -65,6 +65,9 @@ class FrontControllerCore extends Controller
parent::__construct();
if (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'))
$this->ssl = true;
if (isset($useSSL))
$this->ssl = $useSSL;
else
@@ -144,8 +147,6 @@ class FrontControllerCore extends Controller
// Init cookie language
// @TODO This method must be moved into switchLanguage
Tools::setCookieLanguage($this->context->cookie);
$currency = Tools::setCurrency($this->context->cookie);
$protocol_link = (Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode()) ? 'https://' : 'http://';
$useSSL = ((isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED')) || Tools::usingSecureMode()) ? true : false;
@@ -167,6 +168,8 @@ class FrontControllerCore extends Controller
if (($newDefault = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($newDefault))
$this->context->country = $newDefault;
$currency = Tools::setCurrency($this->context->cookie);
if (isset($_GET['logout']) || ($this->context->customer->logged && Customer::isBanned($this->context->customer->id)))
{
$this->context->customer->logout();
@@ -597,7 +600,7 @@ class FrontControllerCore extends Controller
if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET' || Tools::getValue('live_edit'))
return;
$match_url = (($this->ssl && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$match_url = (($this->ssl) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$match_url = rawurldecode($match_url);
if (!preg_match('/^'.Tools::pRegexp(rawurldecode($canonical_url), '/').'([&?].*)?$/', $match_url))
{
@@ -667,6 +670,7 @@ class FrontControllerCore extends Controller
}
}
}
if (isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country))
$this->context->cookie->iso_code_country = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
if (isset($this->context->cookie->iso_code_country) && ($id_country = Country::getByIso(strtoupper($this->context->cookie->iso_code_country))))
+2 -2
View File
@@ -35,10 +35,10 @@ class HelperFormCore extends Helper
/** @var array of forms fields */
protected $fields_form = array();
/** @var array values of form fields */
/** @var array values of form fields */
public $fields_value = array();
public $table;
public $table = 'configuration';
public $name_controller = '';
/** @var string if not null, a title will be added on that list */
+4 -4
View File
@@ -136,6 +136,9 @@ class HelperListCore extends Helper
$this->_list = $list;
$this->fields_list = $fields_display;
$this->orderBy = preg_replace('/^([a-z _]*!)/Ui', '', $this->orderBy);
$this->orderWay = preg_replace('/^([a-z _]*!)/Ui', '', $this->orderWay);
// Display list header (filtering, pagination and column names)
$tpl_vars['header'] = $this->displayListHeader();
@@ -456,7 +459,7 @@ class HelperListCore extends Helper
);
if ($this->specificConfirmDelete !== false)
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : addcslashes(Tools::htmlentitiesDecodeUTF8(self::$cache_lang['DeleteItem'].$name), '\'');
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : Tools::safeOutput(addcslashes(self::$cache_lang['DeleteItem'].$name, '\''));
$tpl->assign(array_merge($this->tpl_delete_link_vars, $data));
@@ -522,9 +525,6 @@ class HelperListCore extends Helper
isset($this->context->cookie->{$this->list_id.'_pagination'}) ? $this->context->cookie->{$this->list_id.'_pagination'} : null
);
// Cleaning links
if (Tools::getValue($this->table.'Orderby') && Tools::getValue($this->table.'Orderway'))
$this->currentIndex = preg_replace('/&'.$this->table.'Orderby=([a-z _]*)&'.$this->table.'Orderway=([a-z]*)/i', '', $this->currentIndex);
if ($this->position_identifier && (int)Tools::getValue($this->position_identifier, 1))
$table_id = substr($this->identifier, 3, strlen($this->identifier));
+26 -10
View File
@@ -118,6 +118,9 @@ abstract class ModuleCore
/** @var Smarty_Data */
protected $smarty;
/** @var currentSmartySubTemplate */
protected $current_subtemplate = null;
const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml';
@@ -1653,20 +1656,35 @@ abstract class ModuleCore
if ($cacheId !== null)
Tools::enableCache();
$smarty_subtemplate = $this->context->smarty->createTemplate(
$this->getTemplatePath($template),
$cacheId,
$compileId,
$this->smarty
);
$result = $smarty_subtemplate->fetch();
$result = $this->getCurrentSubTemplate($template, $cacheId, $compileId)->fetch();
if ($cacheId !== null)
Tools::restoreCacheSettings();
$this->resetCurrentSubTemplate($template, $cacheId, $compileId);
return $result;
}
}
protected function getCurrentSubTemplate($template, $cache_id = null, $compile_id = null)
{
if (!isset($this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id]))
{
$this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id] = $this->context->smarty->createTemplate(
$this->getTemplatePath($template),
$cache_id,
$compile_id,
$this->smarty
);
}
return $this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id];
}
protected function resetCurrentSubTemplate($template, $cache_id, $compile_id)
{
$this->current_subtemplate[$template.'_'.$cache_id.'_'.$compile_id] = null;
}
/**
* Get realpath of a template of current module (check if template is overriden too)
@@ -1696,10 +1714,8 @@ abstract class ModuleCore
public function isCached($template, $cacheId = null, $compileId = null)
{
$context = Context::getContext();
Tools::enableCache();
$is_cached = $context->smarty->isCached($this->getTemplatePath($template), $cacheId, $compileId);
$is_cached = $this->getCurrentSubTemplate($this->getTemplatePath($template), $cacheId, $compileId)->isCached($this->getTemplatePath($template), $cacheId, $compileId);
Tools::restoreCacheSettings();
return $is_cached;
+4 -2
View File
@@ -363,10 +363,12 @@ class ShopCore extends ObjectModel
// Define some $_SERVER variables like HTTP_HOST if PHP is launched with php-cli
if (Tools::isPHPCLI())
{
if(!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
$_SERVER['HTTP_HOST'] = $shop->domain;
if(!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME']))
if (!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME']))
$_SERVER['SERVER_NAME'] = $shop->domain;
if (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR']))
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
}
}
else
-4
View File
@@ -305,11 +305,7 @@ class StockAvailableCore extends ObjectModel
if (!Validate::isUnsignedId($id_product))
return false;
if ($id_shop === null)
$id_shop = Context::getContext()->shop->id;
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, (int)$id_product_attribute, (int)$id_shop);
if ($existing_id > 0)
{
Db::getInstance()->update(
+1 -1
View File
@@ -80,7 +80,7 @@ class TaxRulesTaxManagerCore implements TaxManagerInterface
if (!empty($this->address->postcode))
$postcode = $this->address->postcode;
if (!isset(self::$cache_tax_calculator[$postcode.'-'.$this->type]))
if (!isset(self::$cache_tax_calculator[(int)$this->address->id_country.'-'.$postcode.'-'.$this->type]))
{
$rows = Db::getInstance()->executeS('
SELECT *
+1 -2
View File
@@ -1289,9 +1289,8 @@ class WebserviceRequestCore
$check = ' WHERE ('.implode('OR', $OR).') AND `'.bqSQL($this->resourceConfiguration['fields']['id']['sqlId']).'` = '.(int)$this->urlSegment[1];
if (!Db::getInstance()->getValue($sql.$check))
$this->setError(404, 'This '.$this->resourceConfiguration['retrieveData']['className'].' ('.(int)$this->urlSegment[1].') does not exists on this shop', 131);
else
return $objects;
}
return $objects;
}
if (!count($this->errors))
{
@@ -77,7 +77,7 @@ class AdminAddressesControllerCore extends AdminController
parent::initToolbar();
if (!$this->display)
$this->toolbar_btn['import'] = array(
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type='.$this->table,
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type=addresses',
'desc' => $this->l('Import')
);
}
@@ -246,7 +246,7 @@ class AdminCategoriesControllerCore extends AdminController
'desc' => $this->l('Add New')
);
$this->toolbar_btn['import'] = array(
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type='.$this->table,
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type=categories',
'desc' => $this->l('Import')
);
}
+2 -2
View File
@@ -110,10 +110,10 @@ class AdminCmsControllerCore extends AdminController
'type' => 'text',
'label' => $this->l('Meta title:'),
'name' => 'meta_title',
'id' => 'name', // for copy2friendlyUrl compatibility
'id' => 'name', // for copyMeta2friendlyURL compatibility
'lang' => true,
'required' => true,
'class' => 'copy2friendlyUrl',
'class' => 'copyMeta2friendlyURL',
'hint' => $this->l('Invalid characters:').' <>;=#{}',
'size' => 50
),
@@ -380,7 +380,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$cm->id_employee = (int)$this->context->employee->id;
$cm->id_customer_thread = $ct->id;
$cm->message = Tools::htmlentitiesutf8(Tools::getValue('reply_message'));
$cm->message = Tools::getValue('reply_message');
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
if (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0)
$this->errors[] = Tools::displayError('An error occurred during the file upload process.');
@@ -597,11 +597,12 @@ class AdminCustomerThreadsControllerCore extends AdminController
}
$message['date_add'] = Tools::displayDate($message['date_add'], null, true);
$message['user_agent'] = strip_tags($message['user_agent']);
$message['message'] = preg_replace(
'/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui',
'<a href="\1">\1</a>\2',
html_entity_decode($message['message'],
ENT_NOQUOTES, 'UTF-8')
ENT_QUOTES, 'UTF-8')
);
$tpl->assign(array(
@@ -190,7 +190,7 @@ class AdminCustomersControllerCore extends AdminController
else if (!$this->display) //display import button only on listing
{
$this->toolbar_btn['import'] = array(
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type='.$this->table,
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type=customers',
'desc' => $this->l('Import')
);
}
+1 -1
View File
@@ -193,7 +193,7 @@ class AdminGroupsControllerCore extends AdminController
'active' => array('title' => $this->l('Enabled'),'align' => 'center','width' => 20, 'active' => 'status','type' => 'bool')
));
$customer_list = $group->getCustomers(false, 0, 0, true);
$customer_list = $group->getCustomers(false, 0, 100, true);
$helper = new HelperList();
$helper->currentIndex = Context::getContext()->link->getAdminLink('AdminCustomers', false);
+1 -1
View File
@@ -503,7 +503,7 @@ class AdminHomeControllerCore extends AdminController
// SHOW TIPS OF THE DAY
$content = Tools::file_get_contents($protocol.'api.prestashop.com/partner/tipsoftheday/?iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser), false, $stream_context);
$content = explode('|', utf8_encode($content));
$content = explode('|', $content);
if ($content[0] == 'OK' && Validate::isCleanHtml($content[1]))
$result['discover_prestashop'] .= '<div id="block_partner_tips">'.$content[1].'</div></div>';
+11 -2
View File
@@ -52,8 +52,17 @@ class AdminImagesControllerCore extends AdminController
'stores' => array('title' => $this->l('Stores'), 'width' => 50, 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false)
);
// No need to display the old image system if the install has been made later than 2013-03-26
$this->display_move = (!Configuration::get('PS_LEGACY_IMAGES') && defined('_PS_CREATION_DATE_') && strtotime(_PS_CREATION_DATE_) > strtotime('2013-03-26')) ? false : true;
// No need to display the old image system migration tool except if product images are in _PS_PROD_IMG_DIR_
$this->display_move = false;
$dir = _PS_PROD_IMG_DIR_;
if (is_dir($dir))
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false && $this->display_move == false)
if (!is_dir($dir.DIRECTORY_SEPARATOR.$file) && $file[0] != '.' && is_numeric($file[0]))
$this->display_move = true;
closedir($dh);
}
$this->fields_options = array(
'images' => array(
File diff suppressed because it is too large Load Diff
@@ -140,7 +140,7 @@ class AdminManufacturersControllerCore extends AdminController
'lastname' => array(
'title' => $this->l('Last name'),
'width' => 100,
'filter_key' => 'a!name'
'filter_key' => 'a!lastname'
),
'postcode' => array(
'title' => $this->l('Zip Code/Postal Code'),
@@ -570,7 +570,7 @@ class AdminManufacturersControllerCore extends AdminController
default:
parent::initToolbar();
$this->toolbar_btn['import'] = array(
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type='.$this->table,
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type=manufacturers',
'desc' => $this->l('Import')
);
}
+7 -3
View File
@@ -110,7 +110,8 @@ class AdminOrdersControllerCore extends AdminController
'type' => 'select',
'list' => $statuses_array,
'filter_key' => 'os!id_order_state',
'filter_type' => 'int'
'filter_type' => 'int',
'order_key' => 'osname'
),
'date_add' => array(
'title' => $this->l('Date'),
@@ -506,7 +507,7 @@ class AdminOrdersControllerCore extends AdminController
if (Tools::isSubmit('generateDiscountRefund') && !count($this->errors))
{
$cart_rule = new CartRule();
$cart_rule->description = sprintf($this->l('Credit card slip for order #%d'), $order->id);
$cart_rule->description = sprintf($this->l('Credit slip for order #%d'), $order->id);
$languages = Language::getLanguages(false);
foreach ($languages as $language)
// Define a temporary name
@@ -804,7 +805,7 @@ class AdminOrdersControllerCore extends AdminController
if (!Validate::isLoadedObject($order))
$this->errors[] = Tools::displayError('The order cannot be found');
elseif (!Validate::isNegativePrice($amount))
elseif (!Validate::isNegativePrice($amount) || !(float)$amount)
$this->errors[] = Tools::displayError('The amount is invalid.');
elseif (!Validate::isString(Tools::getValue('payment_method')))
$this->errors[] = Tools::displayError('The selected payment method is invalid.');
@@ -1341,11 +1342,14 @@ class AdminOrdersControllerCore extends AdminController
$product['warehouse_name'] = '--';
}
$gender = new Gender((int)$customer->id_gender, $this->context->language->id);
// Smarty assign
$this->tpl_view_vars = array(
'order' => $order,
'cart' => new Cart($order->id_cart),
'customer' => $customer,
'gender' => $gender,
'customer_addresses' => $customer->getAddresses($this->context->language->id),
'addresses' => array(
'delivery' => $addressDelivery,
@@ -796,6 +796,7 @@ class AdminPerformanceControllerCore extends AdminController
{
$redirectAdmin = true;
Tools::clearSmartyCache();
Autoload::getInstance()->generateIndex();
}
if ($redirectAdmin && (!isset($this->errors) || !count($this->errors)))
@@ -86,6 +86,19 @@ class AdminPreferencesControllerCore extends AdminController
'type' => 'bool',
'default' => '0'
),
);
if (Configuration::get('PS_SSL_ENABLED'))
$fields['PS_SSL_ENABLED_EVERYWHERE'] = array(
'title' => $this->l('Force the SSL on all the pages'),
'desc' => $this->l('Force all your store to use SSL'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'default' => '0'
);
$fields = array_merge($fields, array(
'PS_TOKEN_ENABLE' => array(
'title' => $this->l('Increase Front Office security'),
'desc' => $this->l('Enable or disable token in the Front Office to improve PrestaShop\'s security.'),
@@ -135,7 +148,7 @@ class AdminPreferencesControllerCore extends AdminController
'list' => $activities2,
'identifier' => 'value'
),
);
));
// No HTTPS activation if you haven't already.
if (!Tools::usingSecureMode() && !Configuration::get('PS_SSL_ENABLED'))
+5 -59
View File
@@ -1736,27 +1736,7 @@ class AdminProductsControllerCore extends AdminController
// Save and preview
if (Tools::isSubmit('submitAddProductAndPreview'))
{
$preview_url = $this->context->link->getProductLink(
$this->getFieldValue($this->object, 'id'),
$this->getFieldValue($this->object, 'link_rewrite', $this->context->language->id),
Category::getLinkRewrite($this->getFieldValue($this->object, 'id_category_default'), $this->context->language->id),
null,
null,
Context::getContext()->shop->id,
0,
(bool)Configuration::get('PS_REWRITING_SETTINGS')
);
if (!$this->object->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$preview_url .= '&adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id;
}
$this->redirect_after = $preview_url;
}
$this->redirect_after = $this->getPreviewUrl($this->object);
// Save and stay on same form
if ($this->display == 'edit')
@@ -1901,30 +1881,7 @@ class AdminProductsControllerCore extends AdminController
// Save and preview
if (Tools::isSubmit('submitAddProductAndPreview'))
{
$preview_url = $this->context->link->getProductLink(
$this->getFieldValue($object, 'id'),
$this->getFieldValue($object, 'link_rewrite', $this->context->language->id),
Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), $this->context->language->id),
null,
null,
Context::getContext()->shop->id,
0,
(bool)Configuration::get('PS_REWRITING_SETTINGS')
);
if (!$object->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
if (strpos($preview_url, '?') === false)
$preview_url .= '?';
else
$preview_url .= '&';
$preview_url .= 'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id;
}
$this->redirect_after = $preview_url;
}
$this->redirect_after = $this->getPreviewUrl($object);
else
{
// Save and stay on same form
@@ -2480,7 +2437,7 @@ class AdminProductsControllerCore extends AdminController
}
else
$this->toolbar_btn['import'] = array(
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type='.$this->table,
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type=products',
'desc' => $this->l('Import')
);
@@ -2625,30 +2582,19 @@ class AdminProductsControllerCore extends AdminController
$preview_url = $this->context->link->getProductLink(
$product,
$this->getFieldValue($product, 'link_rewrite', $this->context->language->id),
Category::getLinkRewrite($product->id_category_default, $this->context->language->id),
Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id),
null,
$id_lang,
Context::getContext()->shop->id,
(int)Context::getContext()->shop->id,
0,
$is_rewrite_active
);
if (!$product->active)
{
$preview_url = $this->context->link->getProductLink(
$product,
$this->getFieldValue($product, 'link_rewrite', $this->default_form_language),
Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id),
null,
$id_lang,
Context::getContext()->shop->id,
0,
$is_rewrite_active
);
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$preview_url .= ((strpos($preview_url, '?') === false) ? '?' : '&').'adtoken='.$this->token.'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id;
}
return $preview_url;
@@ -136,6 +136,7 @@ class AdminStatusesControllerCore extends AdminController
{
$this->table = 'order_return_state';
$this->_defaultOrderBy = $this->identifier = 'id_order_return_state';
$this->list_id = 'order_return_state';
$this->deleted = false;
$this->_orderBy = null;
@@ -262,6 +262,24 @@ class AdminSuppliersControllerCore extends AdminController
return parent::renderForm();
}
/**
* AdminController::initToolbar() override
* @see AdminController::initToolbar()
*
*/
public function initToolbar()
{
switch ($this->display)
{
default:
parent::initToolbar();
$this->toolbar_btn['import'] = array(
'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type=suppliers',
'desc' => $this->l('Import')
);
}
}
public function renderView()
{
$products = $this->object->getProductsLite($this->context->language->id);
@@ -78,6 +78,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController
public function initRulesList($id_group)
{
$this->table = 'tax_rule';
$this->list_id = 'tax_rule';
$this->identifier = 'id_tax_rule';
$this->className = 'TaxRule';
$this->lang = false;
+1
View File
@@ -425,6 +425,7 @@ class AuthControllerCore extends FrontController
if (Tools::isSubmit('newsletter'))
$this->processCustomerNewsletter($customer);
$customer->firstname = Tools::ucwords($customer->firstname);
$customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
if (!Validate::isBirthDate($customer->birthday))
$this->errors[] = Tools::displayError('Invalid date of birth.');
+1 -1
View File
@@ -144,7 +144,7 @@ class ContactControllerCore extends FrontController
{
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = Tools::htmlentitiesUTF8($message);
$cm->message = $message;
if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename'])))
$cm->file_name = $fileAttachment['rename'];
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
+1 -1
View File
@@ -79,7 +79,7 @@ class IdentityControllerCore extends FrontController
if (!count($this->errors))
{
$this->customer->id_default_group = (int)$prev_id_default_group;
$this->customer->firstname = Tools::ucfirst(Tools::strtolower($this->customer->firstname));
$this->customer->firstname = Tools::ucwords($this->customer->firstname);
if (!isset($_POST['newsletter']))
$this->customer->newsletter = 0;
@@ -35,9 +35,14 @@ function add_module_to_hook($module_name, $hook_name)
if ((int)$id_module > 0)
{
$id_hook = Db::getInstance()->getValue('
SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = "'.$hook_name.'"
');
$id_hook = Db::getInstance()->getValue('SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = "'.$hook_name.'"');
if(!$id_hook)
{
$res &= Db::getInstance()->execute('
INSERT IGNORE INTO `'._DB_PREFIX_.'hook` (`name`, `title`)
VALUES ("'.pSQL($hook_name).'", "'.pSQL($hook_name).'")');
$id_hook = Db::getInstance()->Insert_ID();
}
if ((int)$id_hook > 0)
{
@@ -51,7 +56,5 @@ function add_module_to_hook($module_name, $hook_name)
)');
}
}
return $res;
}
}
@@ -29,7 +29,8 @@ require_once(_PS_INSTALLER_PHP_UPGRADE_DIR_.'add_new_tab.php');
function create_multistore()
{
$res = true;
if (!defined('_THEME_NAME_'))
define('_THEME_NAME_', 'default');
// @todo : use _PS_ROOT_DIR_
if (defined('__PS_BASE_URI__'))
$INSTALLER__PS_BASE_URI = __PS_BASE_URI__;
+1 -1
View File
@@ -29,6 +29,6 @@ function remove_tab($tabname)
Db::getInstance()->execute('
DELETE t, l
FROM `'._DB_PREFIX_.'tab` t LEFT JOIN `'._DB_PREFIX_.'tab_lang` l ON (t.id_tab = l.id_tab)
WHERE t.`class_name` = '.pSQL($tabname));
WHERE t.`class_name` = "'.pSQL($tabname).'"');
}
+15 -1
View File
@@ -1 +1,15 @@
ALTER TABLE `PREFIX_manufacturer_lang` CHANGE `short_description` `short_description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
ALTER TABLE `PREFIX_manufacturer_lang` CHANGE `short_description` `short_description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
/* PHP:add_module_to_hook(blockcart, actionCartListOverride); */;
/* PHP:add_module_to_hook(blockmanufacturer, actionObjectManufacturerDeleteAfter); */;
/* PHP:add_module_to_hook(blockmanufacturer, actionObjectManufacturerAddAfter); */;
/* PHP:add_module_to_hook(blockmanufacturer, actionObjectManufacturerUpdateAfter); */;
/* PHP:add_module_to_hook(blocksupplier, actionObjectSupplierDeleteAfter); */;
/* PHP:add_module_to_hook(blocksupplier, actionObjectSupplierAddAfter); */;
/* PHP:add_module_to_hook(blocksupplier, actionObjectSupplierUpdateAfter); */;
/* PHP:add_module_to_hook(blockmyaccount, actionModuleRegisterHookAfter); */;
/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleRegisterHookAfter); */;
/* PHP:add_module_to_hook(blockmyaccount, actionModuleUnRegisterHookAfter); */;
/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleUnRegisterHookAfter); */;
/* PHP:remove_tab(AdminRangePrice); */;
/* PHP:remove_tab(AdminRangeWeight); */;
+4 -2
View File
@@ -119,7 +119,8 @@ function copy2friendlyURL()
function copyMeta2friendlyURL()
{
$('#input_link_rewrite_' + id_language).val(str2url($('#name_' + id_language).val().replace(/^[0-9]+\./, ''), 'UTF-8'));
if (!$('input[name="id_cms"]').length)
$('#link_rewrite_' + id_language).val(str2url($('#name_' + id_language).val().replace(/^[0-9]+\./, ''), 'UTF-8'));
}
function updateCurrentText()
@@ -480,7 +481,7 @@ function askFeatureName(selected, selector)
{
var elem;
if (selected.value == 'feature')
if (selected.value == 'features')
{
$('#features_' + selector).show();
$('#feature_name_' + selector).attr('name', selected.name);
@@ -750,6 +751,7 @@ function doAdminAjax(data, success_func, error_func)
{
url : 'index.php',
data : data,
type : 'POST',
success : function(data){
if (success_func)
return success_func(data);
+4 -4
View File
@@ -153,12 +153,13 @@ function displaySummary()
$('tr.range_inf td input').each( function()
{
if (!isNaN(parseFloat($(this).val())) && (range_inf == summary_translation_undefined || range_inf > $(this).val()))
if (!isNaN(parseFloat($(this).val())) && (range_inf == summary_translation_undefined || parseFloat(range_inf) > parseFloat($(this).val())))
range_inf = $(this).val();
});
$('tr.range_sup td input').each( function(){
if (!isNaN(parseFloat($(this).val())) && (range_sup == summary_translation_undefined || range_sup < $(this).val()))
if (!isNaN(parseFloat($(this).val())) && (range_sup == summary_translation_undefined || parseFloat(range_sup) < parseFloat($(this).val())))
range_sup = $(this).val();
});
@@ -272,7 +273,6 @@ function bind_inputs()
});
$('tr.fees td input:checkbox').off('change').on('change', function () {
if($(this).is(':checked'))
{
$(this).closest('tr').children('td').each( function () {
@@ -389,7 +389,7 @@ function hideFees()
function showFees()
{
$('tr.range_inf td, tr.range_sup td, tr.fees_all td, tr.fees td').each( function () {
if ($(this).index() >= 2)
if ($(this).index() > 2)
{
//enable only if zone is active
tr = $(this).parent('tr');
+2 -2
View File
@@ -94,7 +94,7 @@ param_product_url = '';
{if $value.nbr || !$hide_0_values}
<li class="nomargin {if $smarty.foreach.fe.index >= $filter.filter_show_limit}hiddable{/if}">
{if isset($filter.is_color_group) && $filter.is_color_group}
<input class="color-option {if isset($value.checked) && $value.checked}on{/if} {if !$value.nbr}disable{/if}" type="button" name="layered_{$filter.type_lite}_{$id_value}" rel="{$id_value}_{$filter.id_key}" id="layered_id_attribute_group_{$id_value}" {if !$value.nbr}disabled="disabled"{/if} style="background: {if isset($value.color)}{if file_exists($smarty.const._PS_ROOT_DIR_|cat:"/img/co/$id_value.jpg")}url(img/co/{$id_value}.jpg){else}{$value.color}{/if}{else}#CCC{/if};" />
<input class="color-option {if isset($value.checked) && $value.checked}on{/if} {if !$value.nbr}disable{/if}" type="button" name="layered_{$filter.type_lite}_{$id_value}" rel="{$id_value}_{$filter.id_key}" id="layered_id_attribute_group_{$id_value}" {if !$value.nbr}disabled="disabled"{/if} style="background: {if isset($value.color)}{if file_exists($col_img_dir|cat:$id_value|cat:'.jpg')}url({$img_col_dir}{$id_value}.jpg){else}{$value.color}{/if}{else}#CCC{/if};" />
{if isset($value.checked) && $value.checked}<input type="hidden" name="layered_{$filter.type_lite}_{$id_value}" value="{$id_value}" />{/if}
{else}
<input type="checkbox" class="checkbox" name="layered_{$filter.type_lite}_{$id_value}" id="layered_{$filter.type_lite}{if $id_value || $filter.type == 'quantity'}_{$id_value}{/if}" value="{$id_value}{if $filter.id_key}_{$filter.id_key}{/if}"{if isset($value.checked)} checked="checked"{/if}{if !$value.nbr} disabled="disabled"{/if} />
@@ -115,7 +115,7 @@ param_product_url = '';
{if $value.nbr || !$hide_0_values}
<li class="nomargin {if $smarty.foreach.fe.index >= $filter.filter_show_limit}hiddable{/if}">
{if isset($filter.is_color_group) && $filter.is_color_group}
<input class="radio color-option {if isset($value.checked) && $value.checked}on{/if} {if !$value.nbr}disable{/if}" type="button" name="layered_{$filter.type_lite}_{$id_value}" rel="{$id_value}_{$filter.id_key}" id="layered_id_attribute_group_{$id_value}" {if !$value.nbr}disabled="disabled"{/if} style="background: {if isset($value.color)}{if file_exists($smarty.const._PS_ROOT_DIR_|cat:"/img/co/$id_value.jpg")}url(img/co/{$id_value}.jpg){else}{$value.color}{/if}{else}#CCC{/if};"/>
<input class="radio color-option {if isset($value.checked) && $value.checked}on{/if} {if !$value.nbr}disable{/if}" type="button" name="layered_{$filter.type_lite}_{$id_value}" rel="{$id_value}_{$filter.id_key}" id="layered_id_attribute_group_{$id_value}" {if !$value.nbr}disabled="disabled"{/if} style="background: {if isset($value.color)}{if file_exists($col_img_dir|cat:$id_value|cat:'.jpg')}url({$img_col_dir}{$id_value}.jpg){else}{$value.color}{/if}{else}#CCC{/if};"/>
{if isset($value.checked) && $value.checked}<input type="hidden" name="layered_{$filter.type_lite}_{$id_value}" value="{$id_value}" />{/if}
{else}
<input type="radio" class="radio layered_{$filter.type_lite}_{$id_value}" name="layered_{$filter.type_lite}{if $filter.id_key}_{$filter.id_key}{else}_1{/if}" id="layered_{$filter.type_lite}{if $id_value || $filter.type == 'quantity'}_{$id_value}{if $filter.id_key}_{$filter.id_key}{/if}{/if}" value="{$id_value}{if $filter.id_key}_{$filter.id_key}{/if}"{if isset($value.checked)} checked="checked"{/if}{if !$value.nbr} disabled="disabled"{/if} />
@@ -134,6 +134,11 @@ class BlockNewProducts extends Module
{
return $this->hookRightColumn($params);
}
public function hookHome($params)
{
return $this->hookRightColumn($params);
}
public function hookHeader($params)
{
+2 -2
View File
@@ -72,7 +72,7 @@ class CarrierCompare extends Module
$this->postProcess();
$this->smarty->assign('refresh_method', Configuration::get('SE_RERESH_METHOD'));
return $this->smarty->fetch($this->template_directory .'configuration.tpl');
return $this->display(__FILE__, 'template/configuration.tpl');
}
public function postProcess()
@@ -155,7 +155,7 @@ class CarrierCompare extends Module
'refresh_method' => ($refresh_method === false) ? 0 : $refresh_method
));
return $this->smarty->fetch($this->template_directory.'carriercompare.tpl');
return $this->display(__FILE__, 'template/carriercompare.tpl');
}
/*
+3 -3
View File
@@ -218,9 +218,9 @@ class Editorial extends Module
if ($input['name'] != 'body_homepage_logo')
$helper->fields_value[$input['name']] = $editorial->{$input['name']};
$helper->fields_value['image'] = (file_exists(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg') ? '<img src="'.$this->_path.'homepage_logo_'.(int)$id_shop.'.jpg">' : '');
if ($helper->fields_value['image'])
$helper->fields_value['size'] = filesize(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg') / 1000;
$helper->fields_value['body_homepage_logo']['image'] = (file_exists(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg') ? '<img src="'.$this->_path.'homepage_logo_'.(int)$id_shop.'.jpg">' : '');
if ($helper->fields_value['body_homepage_logo'])
$helper->fields_value['body_homepage_logo']['size'] = filesize(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg') / 1000;
$this->_html .= $helper->generateForm($this->fields_form);
return $this->_html;
+46 -17
View File
@@ -36,6 +36,8 @@ class MailAlert extends ObjectModel
public $id_shop;
public $id_lang;
/**
* @see ObjectModel::$definition
*/
@@ -47,15 +49,19 @@ class MailAlert extends ObjectModel
'customer_email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true),
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true)
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true)
),
);
public static function customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop = null)
public static function customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop = null, $id_lang = null)
{
if ($id_shop == null)
$id_shop = Context::getContext()->shop->id;
if ($id_lang == null)
$id_lang = Context::getContext()->language->id;
$customer = new Customer($id_customer);
$customer_email = $customer->email;
@@ -70,14 +76,15 @@ class MailAlert extends ObjectModel
return count(Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql));
}
public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute)
public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute, $id_shop)
{
$sql = '
DELETE FROM `'._DB_PREFIX_.self::$definition['table'].'`
WHERE '.(($id_customer > 0) ? '(`customer_email` = \''.pSQL($customer_email).'\' OR `id_customer` = '.(int)$id_customer.')' :
'`customer_email` = \''.pSQL($customer_email).'\'').
' AND `id_product` = '.(int)$id_product.'
AND `id_product_attribute` = '.(int)$id_product_attribute;
AND `id_product_attribute` = '.(int)$id_product_attribute.'
AND `id_shop` = '.(int)$id_shop;
return Db::getInstance()->execute($sql);
}
@@ -160,17 +167,23 @@ class MailAlert extends ObjectModel
public static function sendCustomerAlert($id_product, $id_product_attribute)
{
$link = new Link();
$id_lang = (int)Context::getContext()->language->id;
$product = new Product((int)$id_product, false, $id_lang);
$templateVars = array(
'{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name),
'{product_link}' => $link->getProductLink($product)
);
$context = Context::getContext()->cloneContext();
$customers = self::getCustomers($id_product, $id_product_attribute);
foreach ($customers as $customer)
{
$id_shop = (int)$customer['id_shop'];
$id_lang = (int)$customer['id_lang'];
$context->shop->id = $id_shop;
$context->language->id = $id_lang;
$product = new Product((int)$id_product, false, $id_lang, $id_shop);
$product_link = $link->getProductLink($product, $product->link_rewrite, null, null, $id_lang, $id_shop);
$templateVars = array(
'{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name),
'{product_link}' => $product_link
);
if ($customer['id_customer'])
{
$customer = new Customer((int)$customer['id_customer']);
@@ -182,14 +195,30 @@ class MailAlert extends ObjectModel
$customer_id = 0;
$customer_email = $customer['customer_email'];
}
$iso = Language::getIsoById($id_lang);
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.html'))
Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'customer_qty', Mail::l('Product available', $id_lang), $templateVars, strval($customer_email), NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
Mail::Send(
$id_lang,
'customer_qty',
Mail::l('Product available', $id_lang),
$templateVars,
strval($customer_email),
NULL,
strval(Configuration::get('PS_SHOP_EMAIL', null, null, $id_shop)),
strval(Configuration::get('PS_SHOP_NAME', null, null, $id_shop)),
NULL,
NULL,
dirname(__FILE__).'/mails/',
false,
$id_shop
);
Hook::exec('actionModuleMailAlertSendCustomer', array('product' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), 'link' => $link->getProductLink($product), 'customer' => $customer, 'product_obj' => $product));
self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute);
Hook::exec('actionModuleMailAlertSendCustomer', array('product' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), 'link' => $product_link, 'customer' => $customer, 'product_obj' => $product));
self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute, $id_shop);
}
}
@@ -244,7 +273,7 @@ class MailAlert extends ObjectModel
public static function getCustomers($id_product, $id_product_attribute)
{
$sql = '
SELECT id_customer, customer_email
SELECT id_customer, customer_email, id_shop, id_lang
FROM `'._DB_PREFIX_.self::$definition['table'].'`
WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute;
@@ -64,8 +64,10 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
if (!Validate::isLoadedObject($product))
die('0');
if (MailAlert::deleteAlert((int)Context::getContext()->customer->id, (int)Context::getContext()->customer->email, (int)$product->id, (int)$this->id_product_attribute))
$context = Context::getContext();
if (MailAlert::deleteAlert((int)$context->customer->id, (int)$context->customer->email, (int)$product->id, (int)$this->id_product_attribute))
die('0');
die(1);
}
@@ -74,29 +76,32 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
*/
public function processAdd()
{
if (Context::getContext()->customer->isLogged())
$context = Context::getContext();
if ($context->customer->isLogged())
{
$id_customer = (int)Context::getContext()->customer->id;
$id_customer = (int)$context->customer->id;
$customer = new Customer($id_customer);
$customer_email = strval($customer->email);
}
else
{
$customer_email = strval(Tools::getValue('customer_email'));
$customer = Context::getContext()->customer->getByEmail($customer_email);
$customer = $context->customer->getByEmail($customer_email);
$id_customer = (isset($customer->id) && ($customer->id != null)) ? (int)$customer->id : null;
}
$id_product = (int)Tools::getValue('id_product');
$id_product_attribute = (int)Tools::getValue('id_product_attribute');
$id_shop = (int)Context::getContext()->shop->id;
$product = new Product($id_product, null, null, $id_shop, Context::getContext());
$id_shop = (int)$context->shop->id;
$id_lang = (int)$context->language->id;
$product = new Product($id_product, false, $id_lang, $id_shop, $context);
$mailAlert = MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop);
if ($mailAlert)
die('2');
else if (!Validate::isLoadedObject($product))
elseif (!Validate::isLoadedObject($product))
die('0');
$mailAlert = new MailAlert();
@@ -106,10 +111,11 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
$mailAlert->id_product = (int)$id_product;
$mailAlert->id_product_attribute = (int)$id_product_attribute;
$mailAlert->id_shop = (int)$id_shop;
$mailAlert->id_lang = (int)$id_lang;
if ($mailAlert->add() !== false)
die('1');
die('0');
}
@@ -122,15 +128,15 @@ class MailalertsActionsModuleFrontController extends ModuleFrontController
die('0');
$id_customer = (int)$this->context->customer->id;
if (!$id_product = (int)(Tools::getValue('id_product')))
die ('0');
$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));
$id_shop = (int)Context::getContext()->shop->id;
if (MailAlert::customerHasNotification((int)$id_customer, (int)$id_product, (int)$id_product_attribute, (int)$id_shop))
die ('1');
if (!$id_product = (int)(Tools::getValue('id_product')))
die('0');
$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));
if (MailAlert::customerHasNotification((int)$id_customer, (int)$id_product, (int)$id_product_attribute, (int)$this->context->shop->id))
die('1');
die('0');
}
}
+115 -80
View File
@@ -40,13 +40,13 @@ class MailAlerts extends Module
private $_merchant_coverage;
private $_product_coverage;
const __MA_MAIL_DELIMITOR__ = ',';
const __MA_MAIL_DELIMITOR__ = "\n";
public function __construct()
{
$this->name = 'mailalerts';
$this->tab = 'administration';
$this->version = '2.4';
$this->version = '2.5';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -100,7 +100,8 @@ class MailAlerts extends Module
`id_product` int(10) unsigned NOT NULL,
`id_product_attribute` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_customer`,`customer_email`,`id_product`,`id_product_attribute`)
`id_lang` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_customer`,`customer_email`,`id_product`,`id_product_attribute`,`id_shop`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
if (!Db::getInstance()->execute($sql))
@@ -161,7 +162,7 @@ class MailAlerts extends Module
$errors[] = $this->l('Invalid e-mail:').' '.Tools::safeOutput($email);
break;
}
else if (!empty($email) && count($email) > 0)
elseif (!empty($email) && count($email) > 0)
$emails[$k] = $email;
else
unset($emails[$k]);
@@ -171,15 +172,15 @@ class MailAlerts extends Module
if (!Configuration::updateValue('MA_MERCHANT_MAILS', strval($emails)))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('mA_merchand_order')))
elseif (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('mA_merchand_order')))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('mA_merchand_oos')))
elseif (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('mA_merchand_oos')))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES')))
elseif (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES')))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('mA_merchant_coverage')))
elseif (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('mA_merchant_coverage')))
$errors[] = $this->l('Cannot update settings');
else if (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE')))
elseif (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE')))
$errors[] = $this->l('Cannot update settings');
}
}
@@ -262,14 +263,16 @@ class MailAlerts extends Module
return;
// Getting differents vars
$id_lang = (int)Context::getContext()->language->id;
$context = Context::getContext();
$id_lang = (int)$context->language->id;
$id_shop = (int)$context->shop->id;
$currency = $params['currency'];
$configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME'));
$order = $params['order'];
$customer = $params['customer'];
$configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME', 'PS_MAIL_COLOR'), $id_lang, null, $id_shop);
$delivery = new Address((int)$order->id_address_delivery);
$invoice = new Address((int)$order->id_address_invoice);
$order_date_text = Tools::displayDate($order->date_add);
$order_date_text = Tools::displayDate($order->date_add, (int)$id_lang);
$carrier = new Carrier((int)$order->id_carrier);
$message = $order->getFirstMessage();
@@ -288,8 +291,7 @@ class MailAlerts extends Module
$customization_text = '';
if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']]))
{
foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']] as $customization)
foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']][$order->id_address_delivery] as $customization)
{
if (isset($customization['datas'][_CUSTOMIZE_TEXTFIELD_]))
foreach ($customization['datas'][_CUSTOMIZE_TEXTFIELD_] as $text)
@@ -339,11 +341,11 @@ class MailAlerts extends Module
'{delivery_block_txt}' => MailAlert::getFormatedAddress($delivery, "\n"),
'{invoice_block_txt}' => MailAlert::getFormatedAddress($invoice, "\n"),
'{delivery_block_html}' => MailAlert::getFormatedAddress($delivery, '<br />', array(
'firstname' => '<span style="color:'.Configuration::get('PS_MAIL_COLOR').'; font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.Configuration::get('PS_MAIL_COLOR').'; font-weight:bold;">%s</span>')),
'firstname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>')),
'{invoice_block_html}' => MailAlert::getFormatedAddress($invoice, '<br />', array(
'firstname' => '<span style="color:'.Configuration::get('PS_MAIL_COLOR').' font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.Configuration::get('PS_MAIL_COLOR').'; font-weight:bold;">%s</span>')),
'firstname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].' font-weight:bold;">%s</span>',
'lastname' => '<span style="color:'.$configuration['PS_MAIL_COLOR'].'; font-weight:bold;">%s</span>')),
'{delivery_company}' => $delivery->company,
'{delivery_firstname}' => $delivery->firstname,
'{delivery_lastname}' => $delivery->lastname,
@@ -353,9 +355,7 @@ class MailAlerts extends Module
'{delivery_postal_code}' => $delivery->postcode,
'{delivery_country}' => $delivery->country,
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
'{delivery_phone}' => $delivery->phone,
'{delivery_phone_mobile}' => $delivery->phone_mobile,
'{delivery_vat_number}' => $delivery->vat_number,
'{delivery_phone}' => $delivery->phone ? $delivery->phone : $delivery->phone_mobile,
'{delivery_other}' => $delivery->other,
'{invoice_company}' => $invoice->company,
'{invoice_firstname}' => $invoice->firstname,
@@ -366,21 +366,18 @@ class MailAlerts extends Module
'{invoice_postal_code}' => $invoice->postcode,
'{invoice_country}' => $invoice->country,
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
'{invoice_phone}' => $invoice->phone,
'{invoice_phone_mobile}' => $invoice->phone_mobile,
'{invoice_vat_number}' => $invoice->vat_number,
'{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile,
'{invoice_other}' => $invoice->other,
'{order_name}' => sprintf('%06d', $order->id),
'{shop_name}' => Configuration::get('PS_SHOP_NAME'),
'{shop_name}' => $configuration['PS_SHOP_NAME'],
'{date}' => $order_date_text,
'{carrier}' => (($carrier->name == '0') ? Configuration::get('PS_SHOP_NAME') : $carrier->name),
'{carrier}' => (($carrier->name == '0') ? $configuration['PS_SHOP_NAME'] : $carrier->name),
'{payment}' => Tools::substr($order->payment, 0, 32),
'{items}' => $items_table,
'{total_paid}' => Tools::displayPrice($order->total_paid, $currency),
'{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency),
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $currency, false),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency),
'{currency}' => $currency->sign,
'{message}' => $message
@@ -390,19 +387,28 @@ class MailAlerts extends Module
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html'))
Mail::Send(
$id_lang,
$template,
sprintf(Mail::l('New order - #%06d', $id_lang), $order->id),
$template_vars,
explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
null,
$configuration['PS_SHOP_EMAIL'],
$configuration['PS_SHOP_NAME'],
null,
null,
dirname(__FILE__).'/mails/'
);
{
// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails);
foreach ($merchant_mails as $merchant_mail)
{
Mail::Send(
$id_lang,
$template,
sprintf(Mail::l('New order - #%06d', $id_lang), $order->id),
$template_vars,
$merchant_mail,
null,
$configuration['PS_SHOP_EMAIL'],
$configuration['PS_SHOP_NAME'],
null,
null,
dirname(__FILE__).'/mails/',
null,
$id_shop
);
}
}
}
public function hookActionProductOutOfStock($params)
@@ -410,18 +416,20 @@ class MailAlerts extends Module
if (!$this->_customer_qty || !Configuration::get('PS_STOCK_MANAGEMENT') || Product::isAvailableWhenOutOfStock($params['product']->out_of_stock))
return;
$context = Context::getContext();
$id_product = (int)$params['product']->id;
$id_product_attribute = 0;
$id_customer = (int)Context::getContext()->customer->id;
$id_customer = (int)$context->customer->id;
if (!(int)Context::getContext()->customer->isLogged())
if ((int)$context->customer->id <= 0)
$this->context->smarty->assign('email', 1);
else if (MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute))
elseif (MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, (int)$context->shop->id))
return;
$this->context->smarty->assign(array(
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute));
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute
));
return $this->display(__FILE__, 'product.tpl');
}
@@ -431,33 +439,47 @@ class MailAlerts extends Module
$id_product = (int)$params['id_product'];
$id_product_attribute = (int)$params['id_product_attribute'];
$quantity = (int)$params['quantity'];
$id_shop = (int)Context::getContext()->shop->id;
$id_lang = (int)Context::getContext()->language->id;
$product = new Product($id_product, true, $id_lang, $id_shop, Context::getContext());
$ma_last_qties = (int)Configuration::get('MA_LAST_QTIES');
$context = Context::getContext();
$id_shop = (int)$context->shop->id;
$id_lang = (int)$context->language->id;
$product = new Product($id_product, true, $id_lang, $id_shop, $context);
$configuration = Configuration::getMultiple(array('MA_LAST_QTIES', 'PS_STOCK_MANAGEMENT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'), $id_lang, null, $id_shop);
$ma_last_qties = (int)$configuration['MA_LAST_QTIES'];
if ($product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && Configuration::get('PS_STOCK_MANAGEMENT'))
if ($product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && $configuration['PS_STOCK_MANAGEMENT'])
{
$iso = Language::getIsoById($id_lang);
$product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang);
$template_vars = array(
'{qty}' => $quantity,
'{last_qty}' => $ma_last_qties,
'{product}' => $product_name);
'{qty}' => $quantity,
'{last_qty}' => $ma_last_qties,
'{product}' => $product_name
);
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.html'))
Mail::Send($id_lang,
'productoutofstock',
Mail::l('Product out of stock', $id_lang),
$template_vars,
explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
null,
strval(Configuration::get('PS_SHOP_EMAIL')),
strval(Configuration::get('PS_SHOP_NAME')),
null,
null,
dirname(__FILE__).'/mails/');
{
// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails);
foreach ($merchant_mails as $merchant_mail)
{
Mail::Send(
$id_lang,
'productoutofstock',
Mail::l('Product out of stock', $id_lang),
$template_vars,
$merchant_mail,
null,
strval($configuration['PS_SHOP_EMAIL']),
strval($configuration['PS_SHOP_NAME']),
null,
null,
dirname(__FILE__).'/mails/',
false,
$id_shop
);
}
}
}
if ($this->_customer_qty && $quantity > 0)
@@ -541,31 +563,44 @@ class MailAlerts extends Module
$coverage = StockManagerFactory::getManager()->getProductCoverage($id_product, $id_product_attribute, $warning_coverage, $id_warehouse);
// if we need to send a notification
if ($product->active == 1 && $coverage !== -1 && ($coverage < $warning_coverage) && !empty($this->_merchant_mails) &&
if ($product->active == 1 &&
($coverage < $warning_coverage) && !empty($this->_merchant_mails) &&
Configuration::getGlobalValue('MA_MERCHANT_COVERAGE'))
{
$id_lang = (int)Context::getContext()->language->id;
$context = Context::getContext();
$id_lang = (int)$context->language->id;
$id_shop = (int)$context->shop->id;
$iso = Language::getIsoById($id_lang);
$product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang);
$template_vars = array(
'{current_coverage}' => $coverage,
'{warning_coverage}' => $warning_coverage,
'{product}' => pSQL($product_name));
'{current_coverage}' => $coverage,
'{warning_coverage}' => $warning_coverage,
'{product}' => pSQL($product_name)
);
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productcoverage.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/productcoverage.html'))
{
Mail::Send($id_lang,
'productcoverage',
Mail::l('Stock coverage', $id_lang),
$template_vars,
explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
null,
strval(Configuration::get('PS_SHOP_EMAIL')),
strval(Configuration::get('PS_SHOP_NAME')),
null,
null,
dirname(__FILE__).'/mails/');
// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails);
foreach ($merchant_mails as $merchant_mail)
{
Mail::Send(
$id_lang,
'productcoverage',
Mail::l('Stock coverage', $id_lang),
$template_vars,
$merchant_mail,
null,
strval(Configuration::get('PS_SHOP_EMAIL')),
strval(Configuration::get('PS_SHOP_NAME')),
null,
null,
dirname(__FILE__).'/mails/',
null,
$id_shop
);
}
}
}
}
@@ -0,0 +1,29 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
function upgrade_module_2_5($object)
{
return Db::getInstance()->execute('
ALTER TABLE '._DB_PREFIX_.'mailalert_customer_oos
ADD '.mailalerts_stripslashes_field('id_lang').' INT( 10 ) UNSIGNED NOT NULL ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (
'.mailalerts_stripslashes_field('id_customer').' ,
'.mailalerts_stripslashes_field('customer_email').' ,
'.mailalerts_stripslashes_field('id_product').' ,
'.mailalerts_stripslashes_field('id_product_attribute').' ,
'.mailalerts_stripslashes_field('id_shop').'
)'
);
}
function mailalerts_stripslashes_field($field)
{
$quotes = array('"\\\'"', '"\'"');
$dquotes = array('\'\\\\"\'', '\'"\'');
$backslashes = array('"\\\\\\\\"', '"\\\\"');
return '`'.bqSQL($field).'` = replace(replace(replace(`'.bqSQL($field).'`, '.$quotes[0].', '.$quotes[1].'), '.$dquotes[0].', '.$dquotes[1].'), '.$backslashes[0].', '.$backslashes[1].')';
}
+22 -13
View File
@@ -844,19 +844,15 @@ class shopimporter extends ImportModule
default:
case 'Product':
$path = _PS_PROD_IMG_DIR_;
$type = 'products';
break;
case 'Category':
$path = _PS_CAT_IMG_DIR_;
$type = 'categories';
break;
case 'Manufacturer':
$path = _PS_MANU_IMG_DIR_;
$type = 'manufacturers';
break;
case 'Supplier':
$path = _PS_SUPP_IMG_DIR_;
$type = 'suppliers';
break;
}
$cover = 1;
@@ -865,11 +861,8 @@ class shopimporter extends ImportModule
foreach($item['images'] as $key => $image)
{
$tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'import');
if (@copy(str_replace(' ', '%20', $image), $tmpfile))
if (@copy(str_replace(' ', '%20', $image), $tmpfile))
{
$imagesTypes = ImageType::getImagesTypes($type);
ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'.jpg');
if ($className == 'Product')
{
$image = new Image();
@@ -884,13 +877,13 @@ class shopimporter extends ImportModule
$legend[Configuration::get('PS_LANG_DEFAULT')] = Tools::link_rewrite($val);
$image->legend = $legend;
$image->add();
ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'-'.(int)$image->id.'.jpg');
foreach ($imagesTypes AS $k => $imageType)
ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'-'.(int)$image->id.'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']);
$path = $image->getPathForCreation();
ImageManager::resize($tmpfile, $path.'.jpg');
}
else
foreach ($imagesTypes as $imageType)
ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']);
{
ImageManager::resize($tmpfile, $path.(int)$matchId[$item[$identifier]].'.jpg');
}
}
else
@unlink($tmpfile);
@@ -1490,9 +1483,11 @@ class shopimporter extends ImportModule
$order->total_products_wt = (float)$item['total_products_wt'];
$order->total_discounts = (float)$item['total_discounts'];
$order->total_shipping = (float)$item['total_shipping'];
$order->total_shipping_tax_incl = (float)$item['total_shipping'];
$order->carrier_tax_rate = (float)$carrier->getTaxesRate(new Address((int)$item[Configuration::get('PS_TAX_ADDRESS_TYPE')]));
$order->total_wrapping = (float)$item['total_wrapping'];
$order->total_paid = (float)$item['total_paid'];
$order->total_paid_tax_incl = (float)$item['total_paid'];
$order->total_paid_real = (float)$item['total_paid_real'];
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
@@ -1505,6 +1500,20 @@ class shopimporter extends ImportModule
$order->valid = 1;
else
$order->valid = 0;
if (array_key_exists('current_state', $item))
$order->current_state = $item['current_state'];
if (array_key_exists('reference', $item))
$order->reference = $item['reference'];
if (array_key_exists('invoice_number', $item))
$order->invoice_number = $item['invoice_number'];
if (array_key_exists('delivery_number', $item))
$order->delivery_number = $item['delivery_number'];
if (array_key_exists('invoice_date', $item))
$order->invoice_date = $item['invoice_date'];
if (array_key_exists('delivery_date', $item))
$order->delivery_date = $item['delivery_date'];
$order->save(false, false);
$this->saveMatchId('order', (int)$order->id, (int)$item['id_cart']);
+7 -7
View File
@@ -36,7 +36,7 @@
var idSelectedCountry = {if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{else}false{/if};
var countries = new Array();
var countriesNeedIDNumber = new Array();
var countriesNeedZipCode = new Array();
var countriesNeedZipCode = new Array();
{if isset($countries)}
{foreach from=$countries item='country'}
{if isset($country.states) && $country.contains_states}
@@ -75,7 +75,7 @@ $(document).ready(function() {
</script>
<h1>{if !isset($email_create)}{l s='Authentication'}{else}{l s='Create an account'}{/if}</h1>
{if !isset($back) || $back != 'my-account'}{assign var='current_step' value='login'}{include file="$tpl_dir./order-steps.tpl"}{/if}
{if !isset($back) || $back != 'my-account'}{assign var='current_step' value='login'}{include file="$tpl_dir./order-steps.tpl"}{/if}
{include file="$tpl_dir./errors.tpl"}
{assign var='stateExist' value=false}
{assign var="postCodeExist" value=false}
@@ -126,7 +126,7 @@ $(document).ready(function() {
$('#center_column').html('<div id="noSlide">'+$('#center_column').html()+'</div>');
$('#noSlide').fadeOut('slow', function(){
$('#noSlide').html(jsonData.page);
// update the state (when this file is called from AJAX you still need to update the state)
// update the state (when this file is called from AJAX you still need to update the state)
bindStateInputAndUpdate();
$(this).fadeIn('slow', function(){
document.location = '#account-creation';
@@ -160,7 +160,7 @@ $(document).ready(function() {
<fieldset>
<h3>{l s='Create an account'}</h3>
<div class="form_content clearfix">
<p class="title_block">{l s='Please enter your email address to create an account.'}.</p>
<p class="title_block">{l s='Please enter your email address to create an account.'}</p>
<div class="error" id="create_account_error" style="display:none"></div>
<p class="text">
<label for="email_create">{l s='Email address'}</label>
@@ -339,7 +339,7 @@ $(document).ready(function() {
<label for="postcode">{l s='Zip / Postal Code'} <sup>*</sup></label>
<input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" onblur="$('#postcode').val($('#postcode').val().toUpperCase());" />
</p>
{/if}
{/if}
<input type="hidden" name="alias" id="alias" value="{l s='My address'}" />
<input type="hidden" name="is_new_customer" id="is_new_customer" value="0" />
<!-- END Account -->
@@ -551,7 +551,7 @@ $(document).ready(function() {
<label for="postcode">{l s='Zip / Postal Code'} <sup>*</sup></label>
<input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" onkeyup="$('#postcode').val($('#postcode').val().toUpperCase());" />
</p>
{/if}
{/if}
{if $stateExist eq false}
<p class="required id_state select hidden">
<label for="id_state">{l s='State'} <sup>*</sup></label>
@@ -598,4 +598,4 @@ $(document).ready(function() {
<span><sup>*</sup>{l s='Required field'}</span>
</p>
</form>
{/if}
{/if}
+1 -1
View File
@@ -34,7 +34,7 @@
</p>
<p>
<h2>{l s='Please provide an explanation for your RMA:'}</h2>
<form method="POST" id="returnOrderMessage"/>
<form method="POST" id="returnOrderMessage">
<p class="textarea">
<textarea name="returnText"></textarea>
</p>
+4 -11
View File
@@ -433,17 +433,10 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
{/if}
{*close if for show price*}
{/if}
{if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE}
<span class="exclusive">
<span></span>
{l s='Add to cart'}
</span>
{else}
<p id="add_to_cart" class="buttons_bottom_block">
<span></span>
<input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" />
</p>
{/if}
<p id="add_to_cart" {if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE}style="display:none"{/if} class="buttons_bottom_block">
<span></span>
<input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" />
</p>
{if isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS}{$HOOK_PRODUCT_ACTIONS}{/if}
<div class="clear"></div>
@@ -278,9 +278,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
//
// render cached template
//
/* PrestaShop related to PSCFV-10040 - http://www.smarty.net/forums/viewtopic.php?p=76467 */
if (isset($_template->properties['unifunc']))
$_template->properties['unifunc']($_template);
$_template->properties['unifunc']($_template);
// any unclosed {capture} tags ?
if (isset($_template->_capture_stack[0][0])) {
$_template->capture_error();