Commit 0fadc7bf authored by Stefano Kowalke's avatar Stefano Kowalke

Merge branch '1.6' of github.com:PrestaShop/PrestaShop into 1.6

# By Gregory Roussac (29) and others
# Via Gregory Roussac (13) and others
* '1.6' of github.com:PrestaShop/PrestaShop: (57 commits)
  // refacto
  [+]BO : Warning added if openssl is not loaded
  [-] TR: Fix bug #PSCSX-4330, could not transalate moudle string with quote
  [-] FO : #PSCSX-4337, move to getProducts
  [*] FO, BO : Removed recall method
  [-] FO : #PSCSX-4337, product total
  [-] FO : Fix bug #PSCSX-4337, bad unit price display and update
  // forgot to commit
  // follow up https://github.com/PrestaShop/PrestaShop/pull/2380
  // norms
  // Submodules updated
  // revert
  Fix small bug
  Fix #PSCSX-4339 - "default" theme name should be customizable
  [-] CORE : Fix bug #PSCSX-4326, bad specific price conversion
  // Norm
  // Escape var for PSCSX-3488
  [-] BO : #PSCSX-3031 - Set KPI for product out of stock
  [*] CORE : Use named constante for GeoLiteCity.dat
  [-]FO : Fix PSCSX-4144 : Logo on invoice can be too big.
  ...
parents 3f055935 558a0ef3
......@@ -137,6 +137,13 @@
i
font-size: 1.3em
color: $brand-primary
.version
color: darken(white,40%)
text-align: center
font-size: 0.9em
padding: 0 0 3px 0
sup
font-size: 0.7em
#header_quick
@extend .nav
......
......@@ -35,7 +35,7 @@
</h3>
<p>
<a class="btn btn-default" href="{$backup_url}">
<i class="icon-download"></i>
<i class="icon-download"></i>
{l s='Download the backup file (%s MB)' sprintf=$backup_weight}
</a>
</p>
......@@ -59,12 +59,23 @@
</ol>
<form action="{$currentIndex|escape:'html':'UTF-8'}&amp;add{$table}&amp;token={$token|escape:'html':'UTF-8'}" method="post" class="form-horizontal">
<button type="submit" class="btn btn-default">
<i class="icon-save"></i>
<i class="icon-save"></i>
{l s='I have read the disclaimer. Please create a new backup.'}
</button>
</form>
</div>
{if $host_mode}
<div class="alert alert-info">
<h4>{l s='How to restore a database backup'}</h4>
<ol>
<li>{l s='If you wish to restore a database backup, we invite you to open a support ticket on your [1]PrestaShop.com account[/1].' tags=['<a href="https://www.prestashop.com/cloud/support?init=ask">']}</li>
<li>{l s='Our team will take care of restoring your database safely.'}</li>
<li>{l s='Why can\'t I restore it by myself?'}</li>
<li>{l s='Your shop is hosted by PrestaShop. Although you can create backup files here below, there are core settings you cannot access for security reasons, like the database management. Thus, only our team can proceed to a restoration.'}</li>
</ol>
</div>
{else}
<div class="alert alert-info">
<h4>{l s='How to restore a database backup in 10 easy steps'}</h4>
<ol>
......@@ -80,5 +91,6 @@
<li>{l s='Click on the "Go" button and please wait patiently for the import process to conclude. This may take several minutes.'}</li>
</ol>
</div>
{/if}
{/block}
......@@ -44,7 +44,7 @@
<tbody>
{foreach from=$available_features item=available_feature}
<tr>
<td>{$available_feature.name}</td>
<td>
......@@ -60,19 +60,19 @@
</select>
{else}
<input type="hidden" name="feature_{$available_feature.id_feature}_value" value="0" />
<span>{l s='N/A'} -
<span>{l s='N/A'} -
<a href="{$link->getAdminLink('AdminFeatures')|escape:'html':'UTF-8'}&amp;addfeature_value&amp;id_feature={$available_feature.id_feature}"
class="confirm_leave btn btn-link"><i class="icon-plus-sign"></i> {l s='Add pre-defined values first'} <i class="icon-external-link-sign"></i></a>
</span>
{/if}
</td>
<td>
<div class="row lang-0" style='display: none;'>
<div class="col-lg-9">
<textarea class="custom_{$available_feature.id_feature}_ALL textarea-autosize" name="custom_{$available_feature.id_feature}_ALL"
cols="40" style='background-color:#CCF' rows="1" onkeyup="{foreach from=$languages key=k item=language}$('.custom_{$available_feature.id_feature}_{$language.id_lang}').val($(this).val());{/foreach}" >{$available_feature.val[1].value|escape:'html':'UTF-8'|default:""}</textarea>
</div>
{if $languages|count > 1}
<div class="col-lg-3">
......@@ -90,7 +90,7 @@
</div>
{/if}
</div>
{foreach from=$languages key=k item=language}
{if $languages|count > 1}
<div class="row translatable-field lang-{$language.id_lang}">
......@@ -102,7 +102,7 @@
cols="40"
rows="1"
onkeyup="if (isArrowKey(event)) return ;$('#feature_{$available_feature.id_feature}_value').val(0);" >{$available_feature.val[$k].value|escape:'html':'UTF-8'|default:""}</textarea>
{if $languages|count > 1}
</div>
<div class="col-lg-3">
......@@ -111,7 +111,7 @@
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="javascript:void(0);" onclick="all_languages($(this));">{l s='ALL'}</a></li>
<li><a href="javascript:void(0);" onclick="all_languages($(this));">{l s='ALL'}</a></li>
{foreach from=$languages item=language}
<li>
<a href="javascript:hideOtherLanguage({$language.id_lang});">{$language.iso_code}</a>
......@@ -152,9 +152,11 @@
function all_languages(pos)
{
{/literal}
{foreach from=$languages key=k item=language}
pos.parents('td').find('.lang-{$language.id_lang}').addClass('nolang-{$language.id_lang}').removeClass('lang-{$language.id_lang}');
{/foreach}
{if isset($languages) && is_array($languages)}
{foreach from=$languages key=k item=language}
pos.parents('td').find('.lang-{$language.id_lang}').addClass('nolang-{$language.id_lang}').removeClass('lang-{$language.id_lang}');
{/foreach}
{/if}
pos.parents('td').find('.translatable-field').hide();
pos.parents('td').find('.lang-0').show();
{literal}
......@@ -163,12 +165,14 @@
function restore_lng(pos,i)
{
{/literal}
{foreach from=$languages key=k item=language}
pos.parents('td').find('.nolang-{$language.id_lang}').addClass('lang-{$language.id_lang}').removeClass('nolang-{$language.id_lang}');
{/foreach}
{if isset($languages) && is_array($languages)}
{foreach from=$languages key=k item=language}
pos.parents('td').find('.nolang-{$language.id_lang}').addClass('lang-{$language.id_lang}').removeClass('nolang-{$language.id_lang}');
{/foreach}
{/if}
{literal}
pos.parents('td').find('.lang-0').hide();
hideOtherLanguage(i);
}
</script>
{/literal}
\ No newline at end of file
{/literal}
......@@ -99,7 +99,7 @@
{foreach from=$languages item=language}
<div class="alert alert-warning translatable-field lang-{$language.id_lang}">
<i class="icon-link"></i> {l s='The product link will look like this:'}<br/>
<strong>{$curent_shop_url|escape:'html':'UTF-8'}lang/{if isset($product->id)}{$product->id}{else}id_product{/if}-<span id="friendly-url_{$language.id_lang}">{$product->link_rewrite[$default_language]|escape:'html':'UTF-8'}</span>.html</strong>
<strong>{if isset($rewritten_links[$language.id_lang][0])}{$rewritten_links[$language.id_lang][0]|escape:'html':'UTF-8'}{/if}<span id="friendly-url_{$language.id_lang}">{$product->link_rewrite[$language.id_lang]|escape:'html':'UTF-8'}</span>{if isset($rewritten_links[$language.id_lang][1])}{$rewritten_links[$language.id_lang][1]|escape:'html':'UTF-8'}{/if}</strong>
</div>
{/foreach}
</div>
......
......@@ -76,7 +76,7 @@
<i class="icon-book"></i>
{l s='Training'}
</a>
{if $iso_is_fr && host_mode == 0}
{if $iso_is_fr && !host_mode}
<p>Questions • Renseignements • Formations :
<strong>+33 (0)1.40.18.30.04</strong>
</p>
......
......@@ -303,6 +303,8 @@
{/if}
<li class="divider"></li>
<li><a id="header_logout" href="{$default_tab_link|escape:'html':'UTF-8'}&amp;logout"><i class="icon-signout"></i> {l s='Sign out'}</a></li>
<li class="divider"></li>
<li class="version"><span>Prestashop<sup>TM</sup> {$current_version|escape:'html':'UTF-8'}</span></li>
</ul>
</li>
</ul>
......
......@@ -534,7 +534,10 @@ class CartCore extends ObjectModel
if (empty($result))
return array();
$ecotax_rate = (float)Tax::getProductEcotaxRate($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$apply_eco_tax = Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX');
$cart_shop_context = Context::getContext()->cloneContext();
foreach ($result as &$row)
{
if (isset($row['ecotax_attr']) && $row['ecotax_attr'] > 0)
......@@ -595,6 +598,14 @@ class CartCore extends ObjectModel
break;
}
$row['price_wt'] = $tax_calculator->addTaxes($row['price']);
$ecotax_tax_amount = Tools::ps_round($row['ecotax'], 2);
if ($apply_eco_tax)
$ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
$row['price'] += $ecotax_tax_amount;
$row['price_wt'] += $ecotax_tax_amount;
$row['total'] += $ecotax_tax_amount * $row['cart_quantity'];
$row['total_wt'] += $ecotax_tax_amount * $row['cart_quantity'];
$row['description_short'] = Tools::nl2br($row['description_short']);
if (!isset($row['pai_id_image']) || $row['pai_id_image'] == 0)
......@@ -2935,6 +2946,26 @@ class CartCore extends ObjectModel
$currency = new Currency($this->id_currency);
$products = $this->getProducts($refresh);
foreach ($products as $key => &$product)
{
$product['price_without_quantity_discount'] = Product::getPriceStatic(
$product['id_product'],
!Product::getTaxCalculationMethod(),
$product['id_product_attribute'],
6,
null,
false,
false
);
if ($product['reduction_type'] == 'amount')
{
$reduction = (float)$product['price_wt'] - (float)$product['price_without_quantity_discount'];
$product['reduction_formatted'] = Tools::displayPrice($reduction);
}
}
$gift_products = array();
$cart_rules = $this->getCartRules();
$total_shipping = $this->getTotalShippingCost();
......@@ -2947,7 +2978,6 @@ class CartCore extends ObjectModel
// The cart content is altered for display
foreach ($cart_rules as &$cart_rule)
{
// If the cart rule is automatic (wihtout any code) and include free shipping, it should not be displayed as a cart rule but only set the shipping cost to 0
if ($cart_rule['free_shipping'] && (empty($cart_rule['code']) || preg_match('/^'.CartRule::BO_ORDER_CODE_PREFIX.'[0-9]+/', $cart_rule['code'])))
{
......
......@@ -1260,6 +1260,7 @@ class ProductCore extends ObjectModel
$obj->default_on = $default_on;
$default_on = 0;
$this->setAvailableDate();
$obj->save();
......@@ -1557,8 +1558,13 @@ class ProductCore extends ObjectModel
Db::getInstance()->update('stock_available', array('quantity' => 0), '`id_product` = '.$this->id);
$id_default_attribute = Product::updateDefaultAttribute($this->id);
if ($id_default_attribute)
{
$this->cache_default_attribute = $id_default_attribute;
if (!$combination->available_date)
$this->setAvailableDate();
}
if (!empty($id_images))
$combination->setImages($id_images);
......@@ -2758,19 +2764,21 @@ class ProductCore extends ObjectModel
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($res as $row)
{
$array_tmp = array(
'price' => $row['price'],
'ecotax' => $row['ecotax'],
'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null)
);
self::$_pricesLevel2[$cache_id_2][(int)$row['id_product_attribute']] = $array_tmp;
if (is_array($res) && count($res))
foreach ($res as $row)
{
$array_tmp = array(
'price' => $row['price'],
'ecotax' => $row['ecotax'],
'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null)
);
self::$_pricesLevel2[$cache_id_2][(int)$row['id_product_attribute']] = $array_tmp;
if (isset($row['default_on']) && $row['default_on'] == 1)
self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
}
if (isset($row['default_on']) && $row['default_on'] == 1)
self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
}
}
if (!isset(self::$_pricesLevel2[$cache_id_2][(int)$id_product_attribute]))
return;
......@@ -3180,7 +3188,7 @@ class ProductCore extends ObjectModel
JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.')
JOIN `'._DB_PREFIX_.'attribute_group` ag ON (a.id_attribute_group = ag.`id_attribute_group`)
WHERE pa.`id_product` IN ('.implode(array_map('intval', $products), ',').') AND ag.`is_color_group` = 1
GROUP BY pa.`id_product`, `group_by`
GROUP BY pa.`id_product`, a.`id_attribute`, `group_by`
'.($check_stock ? 'HAVING qty > 0' : '').'
ORDER BY a.`position` ASC;'
)
......
......@@ -198,6 +198,7 @@ class SearchCore
$word = str_replace('%', '\\%', $word);
$word = str_replace('_', '\\_', $word);
$start_search = Configuration::get('PS_SEARCH_START') ? '%': '';
$end_search = Configuration::get('PS_SEARCH_END') ? '': '%';
$intersect_array[] = 'SELECT si.id_product
FROM '._DB_PREFIX_.'search_word sw
......@@ -206,12 +207,12 @@ class SearchCore
AND sw.id_shop = '.$context->shop->id.'
AND sw.word LIKE
'.($word[0] == '-'
? ' \''.$start_search.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
: ' \''.$start_search.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
? ' \''.$start_search.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).$end_search.'\''
: ' \''.$start_search.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).$end_search.'\''
);
if ($word[0] != '-')
$score_array[] = 'sw.word LIKE \''.$start_search.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'';
$score_array[] = 'sw.word LIKE \''.$start_search.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).$end_search.'\'';
}
else
unset($words[$key]);
......
......@@ -1927,12 +1927,14 @@ class ToolsCore
{
global $current_css_file;
$protocol_link = Tools::getCurrentUrlProtocolPrefix();
if (array_key_exists(1, $matches) && array_key_exists(2, $matches))
{
if (!preg_match('/^(?:https?:)?\/\//iUs', $matches[2]))
{
$tmp = dirname($current_css_file).'/'.$matches[2];
return $matches[1].$protocol_link.Tools::getMediaServer($tmp).$tmp;
$server = Tools::getMediaServer($tmp);
return $matches[1].$protocol_link.$server.$tmp;
}
else
return $matches[0];
......@@ -1999,7 +2001,7 @@ class ToolsCore
self::$_cache_nb_media_servers = 3;
}
if (self::$_cache_nb_media_servers && ($id_media_server = (abs(crc32($filename)) % self::$_cache_nb_media_servers + 1)))
if ($filename && 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::usingSecureMode() ? Tools::getShopDomainSSL() : Tools::getShopDomain();
......@@ -2216,7 +2218,12 @@ class ToolsCore
fwrite($write_fd, "AddType application/vnd.ms-fontobject .eot\n");
fwrite($write_fd, "AddType font/ttf .ttf\n");
fwrite($write_fd, "AddType font/otf .otf\n");
fwrite($write_fd, "AddType application/x-font-woff .woff\n\n");
fwrite($write_fd, "AddType application/x-font-woff .woff\n");
fwrite($write_fd, "<IfModule mod_headers.c>
<FilesMatch \"\.(ttf|ttc|otf|eot|woff|svg)$\">
Header add Access-Control-Allow-Origin \"*\"
</FilesMatch>
</IfModule>\n\n");
// Cache control
if ($cache_control)
......@@ -2593,7 +2600,7 @@ exit;
switch ($type)
{
case 'by' :
$list = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity');
$list = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity', 7 => 'reference');
$value = (is_null($value) || $value === false || $value === '') ? (int)Configuration::get('PS_PRODUCTS_ORDER_BY') : $value;
$value = (isset($list[$value])) ? $list[$value] : ((in_array($value, $list)) ? $value : 'position');
$order_by_prefix = '';
......
......@@ -65,7 +65,7 @@ class TranslateCore
return Translate::getModuleTranslation(Module::$classInModule[$class_name_controller], $string, $class_name_controller, $sprintf, $addslashes);
}
$string = preg_replace("/\\*'/", "\'", $string);
$string = preg_replace("/\\\*'/", "\'", $string);
$key = md5($string);
if (isset($_LANGADM[$class.$key]))
$str = $_LANGADM[$class.$key];
......@@ -93,7 +93,7 @@ class TranslateCore
*/
public static function getGenericAdminTranslation($string, $key = null, &$lang_array)
{
$string = preg_replace("/\\*'/", "\'", $string);
$string = preg_replace("/\\\*'/", "\'", $string);
if (is_null($key))
$key = md5($string);
......@@ -149,7 +149,7 @@ class TranslateCore
$translations_merged[$name] = true;
}
}
$string = preg_replace("/\\*'/", "\'", $string);
$string = preg_replace("/\\\*'/", "\'", $string);
$key = md5($string);
$cache_key = $name.'|'.$string.'|'.$source.'|'.(int)$js;
......@@ -172,13 +172,13 @@ class TranslateCore
$default_key_file = strtolower('<{'.$name.'}prestashop>'.$file).'_'.$key;
}
if (isset($current_key_file) && isset($_MODULES[$current_key_file]))
if (isset($current_key_file) && !empty($_MODULES[$current_key_file]))
$ret = stripslashes($_MODULES[$current_key_file]);
elseif (isset($default_key_file) && isset($_MODULES[$default_key_file]))
elseif (isset($default_key_file) && !empty($_MODULES[$default_key_file]))
$ret = stripslashes($_MODULES[$default_key_file]);
elseif (isset($_MODULES[$current_key]))
elseif (!empty($_MODULES[$current_key]))
$ret = stripslashes($_MODULES[$current_key]);
elseif (isset($_MODULES[$default_key]))
elseif (!empty($_MODULES[$default_key]))
$ret = stripslashes($_MODULES[$default_key]);
// if translation was not found in module, look for it in AdminController or Helpers
elseif (!empty($_LANGADM))
......@@ -229,7 +229,7 @@ class TranslateCore
if (!isset($_LANGPDF) || !is_array($_LANGPDF))
return str_replace('"', '&quot;', $string);
$string = preg_replace("/\\*'/", "\'", $string);
$string = preg_replace("/\\\*'/", "\'", $string);
$key = md5($string);
$str = (array_key_exists('PDF'.$key, $_LANGPDF) ? $_LANGPDF['PDF'.$key] : $string);
......
......@@ -313,11 +313,22 @@ class AdminControllerCore extends Controller
if ($this->multishop_context == -1)
$this->multishop_context = Shop::CONTEXT_ALL | Shop::CONTEXT_GROUP | Shop::CONTEXT_SHOP;
$this->bo_theme = ((Validate::isLoadedObject($this->context->employee) && $this->context->employee->bo_theme) ? $this->context->employee->bo_theme : 'default');
if (!file_exists(_PS_BO_ALL_THEMES_DIR_.$this->bo_theme.DIRECTORY_SEPARATOR.'template'))
$this->bo_theme = 'default';
$this->bo_css = ((Validate::isLoadedObject($this->context->employee) && $this->context->employee->bo_css) ? $this->context->employee->bo_css : 'admin-theme.css');
if (!file_exists(_PS_BO_ALL_THEMES_DIR_.$this->bo_theme.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.$this->bo_css))
$default_theme_name = 'default';
if (defined('_PS_BO_DEFAULT_THEME_') && _PS_BO_DEFAULT_THEME_
&& @filemtime(_PS_BO_ALL_THEMES_DIR_._PS_BO_DEFAULT_THEME_.DIRECTORY_SEPARATOR.'template'))
$default_theme_name = _PS_BO_DEFAULT_THEME_;
$this->bo_theme = ((Validate::isLoadedObject($this->context->employee)
&& $this->context->employee->bo_theme) ? $this->context->employee->bo_theme : $default_theme_name);
if (!@filemtime(_PS_BO_ALL_THEMES_DIR_.$this->bo_theme.DIRECTORY_SEPARATOR.'template'))
$this->bo_theme = $default_theme_name;
$this->bo_css = ((Validate::isLoadedObject($this->context->employee)
&& $this->context->employee->bo_css) ? $this->context->employee->bo_css : 'admin-theme.css');
if (!@filemtime(_PS_BO_ALL_THEMES_DIR_.$this->bo_theme.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.$this->bo_css))
$this->bo_css = 'admin-theme.css';
$this->context->smarty->setTemplateDir(array(
......@@ -1723,6 +1734,7 @@ class AdminControllerCore extends Controller
'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && isset($accesses['AdminCustomers']) && $accesses['AdminCustomers']['view'],
'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && isset($accesses['AdminCustomerThreads']) && $accesses['AdminCustomerThreads']['view'],
'employee' => $this->context->employee,
'current_version' => (string)Configuration::get('PS_INSTALL_VERSION'),
'search_type' => Tools::getValue('bo_search_type'),
'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))),
'quick_access' => $quick_access,
......@@ -2327,9 +2339,8 @@ class AdminControllerCore extends Controller
public function setMedia()
{
//Bootstrap + Specific Admin Theme
//Bootstrap
$this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/css/'.$this->bo_css, 'all', 0);
$this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/css/overrides.css', 'all', 99);
$this->addJquery();
$this->addjQueryPlugin(array('scrollTo', 'alerts', 'chosen', 'autosize', 'fancybox' ));
......@@ -2356,6 +2367,9 @@ class AdminControllerCore extends Controller
// Execute Hook AdminController SetMedia
Hook::exec('actionAdminControllerSetMedia');
// Specific Admin Theme
$this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/css/overrides.css', 'all', PHP_INT_MAX);
}
/**
......
<?php
/*
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
......@@ -687,13 +687,13 @@ class FrontControllerCore extends Controller
if (!in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1')))
{
/* Check if Maxmind Database exists */
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
if (@filemtime(_PS_GEOIP_DIR_._PS_GEOIP_CITY_FILE_))
{
if (!isset($this->context->cookie->iso_code_country) || (isset($this->context->cookie->iso_code_country) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))))
{
include_once(_PS_GEOIP_DIR_.'geoipcity.inc');
$gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD);
$gi = geoip_open(realpath(_PS_GEOIP_DIR_._PS_GEOIP_CITY_FILE_), GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, Tools::getRemoteAddr());
if (is_object($record))
......
......@@ -55,6 +55,18 @@ abstract class HTMLTemplateCore
if (!empty($path_logo))
list($width, $height) = getimagesize($path_logo);
// Limit the height of the logo for the PDF render
if (Context::getContext()->controller->controller_name == 'AdminPdf')
{
$maximum_height = 100;
if ($height > $maximum_height)
{
$ratio = $maximum_height / $height;
$height *= $ratio;
$width *= $ratio;
}
}
$this->smarty->assign(array(
'logo_path' => $path_logo,
'img_ps_dir' => 'http://'.Tools::getMediaServer(_PS_IMG_)._PS_IMG_,
......
<?php
/*
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
......@@ -91,6 +91,7 @@ define('_PS_FRONT_CONTROLLER_DIR_', _PS_CORE_DIR_.'/controllers/front/');
define('_PS_TOOL_DIR_', _PS_CORE_DIR_.'/tools/');
define('_PS_GEOIP_DIR_', _PS_TOOL_DIR_.'geoip/');
define('_PS_GEOIP_CITY_FILE_', 'GeoLiteCity.dat');
define('_PS_PEAR_XML_PARSER_PATH_', _PS_TOOL_DIR_.'pear_xml_parser/');
define('_PS_SWIFT_DIR_', _PS_TOOL_DIR_.'swift/');
define('_PS_TAASC_PATH_', _PS_TOOL_DIR_.'taasc/');
......@@ -195,4 +196,3 @@ define('_PS_SMARTY_CONSOLE_OPEN_BY_URL_', 1);
define('_PS_SMARTY_CONSOLE_OPEN_', 2);
define('_PS_JQUERY_VERSION_', '1.11.0');
......@@ -138,7 +138,7 @@ class AdminAttributeGeneratorControllerCore extends AdminController
SpecificPriceRule::enableAnyApplication();
SpecificPriceRule::applyAllRules(array((int)$this->product->id));
Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)Tools::getValue('id_product').'&addproduct&key_tab=Combinations&conf=4');
Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)Tools::getValue('id_product').'&updateproduct&key_tab=Combinations&conf=4');
}
else
$this->errors[] = Tools::displayError('Unable to initialize these parameters. A combination is missing or an object cannot be loaded.');
......@@ -220,7 +220,7 @@ class AdminAttributeGeneratorControllerCore extends AdminController
foreach ($attributes as $k => $attribute)
$attribute_js[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name'];
$attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
$this->product = new Product((int)Tools::getValue('id_product'));
......
<?php
/*
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
......@@ -140,7 +140,7 @@ class AdminGeolocationControllerCore extends AdminController
{
$this->display = 'options';
if (!$this->isGeoLiteCityAvailable())
$this->displayWarning($this->l('In order to use Geolocation, please download').'
$this->displayWarning($this->l('In order to use Geolocation, please download').'
<a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz">'.$this->l('this file').'</a> '.
$this->l('and extract it (using Winrar or Gzip) into the /tools/geoip/ directory.'));
......@@ -149,9 +149,9 @@ class AdminGeolocationControllerCore extends AdminController
protected function isGeoLiteCityAvailable()
{
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
if (@filemtime(_PS_GEOIP_DIR_._PS_GEOIP_CITY_FILE_))
return true;
return false;
}
}
......@@ -291,7 +291,7 @@ class AdminImportControllerCore extends AdminController
self::$default_values = array(
'id_category' => array((int)Configuration::get('PS_HOME_CATEGORY')),
'id_category_default' => (int)Configuration::get('PS_HOME_CATEGORY'),
'id_category_default' => null,
'active' => '1',
'width' => 0.000000,
'height' => 0.000000,
......
......@@ -165,6 +165,9 @@ class AdminLocalizationControllerCore extends AdminController
return;
}
if (!extension_loaded('openssl'))
$this->displayWarning($this->l('Importing a new language may fail without the OpenSSL module. Please enable "openssl.so" on your server configuration.'));
if (Tools::isSubmit('submitLocalizationPack'))
{
$version = str_replace('.', '', _PS_VERSION_);
......
......@@ -36,8 +36,8 @@ class AdminLogsControllerCore extends AdminController
$this->fields_list = array(
'id_log' => array(
'title' => $this->l('ID'),
'align' => 'text-center',
'title' => $this->l('ID'),
'align' => 'text-center',
'class' => 'fixed-width-xs'
),
'employee' => array(
......@@ -47,31 +47,31 @@ class AdminLogsControllerCore extends AdminController
'callback_object' => $this
),
'severity' => array(
'title' => $this->l('Severity (1-4)'),
'align' => 'text-center',
'title' => $this->l('Severity (1-4)'),
'align' => 'text-center',
'class' => 'fixed-width-xs'
),
'message' => array(
'title' => $this->l('Message')
),
'object_type' => array(
'title' => $this->l('Object type'),
'title' => $this->l('Object type'),
'class' => 'fixed-width-sm'
),
'object_id' => array(
'title' => $this->l('Object ID'),
'align' => 'center',
'title' => $this->l('Object ID'),