diff --git a/admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl
index 91f90749a..68b709244 100644
--- a/admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl
+++ b/admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl
@@ -81,6 +81,7 @@
+ {l s='Language:'} {if isset($customerLanguage)}{$customerLanguage->name}{else}{l s='undefined'}{/if}
{l s='Newsletter:'} {if $customer->newsletter}
{else}
{/if}
{l s='Opt in:'} {if $customer->optin}
{else}
{/if}
{l s='Age:'} {$customer_stats['age']} {if isset($customer->birthday['age'])}({$customer_birthday}){else}{l s='unknown'}{/if}
diff --git a/classes/Customer.php b/classes/Customer.php
index e0f38488e..b05a0e042 100644
--- a/classes/Customer.php
+++ b/classes/Customer.php
@@ -44,6 +44,9 @@ class CustomerCore extends ObjectModel
/** @var integer Default group ID */
public $id_default_group;
+ /** @var integer Current language used by the customer */
+ public $id_lang;
+
/** @var string Lastname */
public $lastname;
@@ -135,6 +138,7 @@ class CustomerCore extends ObjectModel
protected $webserviceParameters = array(
'fields' => array(
'id_default_group' => array('xlink_resource' => 'groups'),
+ 'id_lang' => array('xlink_resource' => 'languages'),
'newsletter_date_add' => array(),
'ip_registration_newsletter' => array(),
'last_passwd_gen' => array('setter' => null),
@@ -181,6 +185,7 @@ class CustomerCore extends ObjectModel
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'id_default_group' => array('type' => self::TYPE_INT, 'copy_post' => false),
+ 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
),
@@ -200,6 +205,7 @@ class CustomerCore extends ObjectModel
{
$this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->id;
$this->id_shop_group = ($this->id_shop_group) ? $this->id_shop_group : Context::getContext()->shop->id_shop_group;
+ $this->id_lang = ($this->id_lang) ? $this->id_lang : Context::getContext()->language->id;
$this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days);
$this->secure_key = md5(uniqid(rand(), true));
$this->last_passwd_gen = date('Y-m-d H:i:s', strtotime('-'.Configuration::get('PS_PASSWD_TIME_FRONT').'minutes'));
diff --git a/config/config.inc.php b/config/config.inc.php
index 52cac6ac1..612fd961b 100644
--- a/config/config.inc.php
+++ b/config/config.inc.php
@@ -82,11 +82,13 @@ if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI']))
/* Trying to redefine HTTP_HOST if empty (on some webservers...) */
if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
$_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
+
+$context = Context::getContext();
/* Initialize the current Shop */
-Context::getContext()->shop = Shop::initialize();
-define('_THEME_NAME_', Context::getContext()->shop->getTheme());
-define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
+$context->shop = Shop::initialize();
+define('_THEME_NAME_', $context->shop->getTheme());
+define('__PS_BASE_URI__', $context->shop->getBaseURI());
/* Include all defines related to base uri and theme name */
require_once(dirname(__FILE__).'/defines_uri.inc.php');
@@ -102,7 +104,7 @@ Language::loadLanguages();
/* Loading default country */
$defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
-Context::getContext()->country = $defaultCountry;
+$context->country = $defaultCountry;
/* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
@date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
@@ -124,24 +126,32 @@ if (defined('_PS_ADMIN_DIR_'))
$cookie = new Cookie('psAdmin', '', $cookie_lifetime);
else
{
- if (Context::getContext()->shop->getGroup()->share_order)
- $cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookie_lifetime, Context::getContext()->shop->getUrlsSharedCart());
+ if ($context->shop->getGroup()->share_order)
+ $cookie = new Cookie('ps-sg'.$context->shop->getGroup()->id, '', $cookie_lifetime, $context->shop->getUrlsSharedCart());
else
{
$domains = null;
- if (Context::getContext()->shop->domain != Context::getContext()->shop->domain_ssl)
- $domains = array(Context::getContext()->shop->domain_ssl, Context::getContext()->shop->domain);
+ if ($context->shop->domain != $context->shop->domain_ssl)
+ $domains = array($context->shop->domain_ssl, $context->shop->domain);
- $cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookie_lifetime, $domains);
+ $cookie = new Cookie('ps-s'.$context->shop->id, '', $cookie_lifetime, $domains);
}
}
-Context::getContext()->cookie = $cookie;
+$context->cookie = $cookie;
+
+/* if the language stored in the cookie is not available language, use default language */
+if (isset($cookie->id_lang) && $cookie->id_lang)
+ $language = new Language($cookie->id_lang);
+if (!isset($language) || !Validate::isLoadedObject($language))
+ $language = new Language(Configuration::get('PS_LANG_DEFAULT'));
+$context->language = $language;
+
/* Create employee if in BO, customer else */
if (defined('_PS_ADMIN_DIR_'))
{
$employee = new Employee($cookie->id_employee);
- Context::getContext()->employee = $employee;
+ $context->employee = $employee;
/* Auth on shops are recached after employee assignation */
if ($employee->id_profile != _PS_ADMIN_PROFILE_)
@@ -155,6 +165,12 @@ else
{
$customer = new Customer($cookie->id_customer);
$customer->logged = $cookie->logged;
+
+ if ($customer->id_lang != $context->language->id)
+ {
+ $customer->id_lang = $context->language->id;
+ $customer->update();
+ }
}
else
{
@@ -165,19 +181,12 @@ else
$customer->id_default_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
}
$customer->id_guest = $cookie->id_guest;
- Context::getContext()->customer = $customer;
+ $context->customer = $customer;
}
-/* if the language stored in the cookie is not available language, use default language */
-if (isset($cookie->id_lang) && $cookie->id_lang)
- $language = new Language($cookie->id_lang);
-if (!isset($language) || !Validate::isLoadedObject($language))
- $language = new Language(Configuration::get('PS_LANG_DEFAULT'));
-Context::getContext()->language = $language;
-
/* Link should also be initialized in the context here for retrocompatibility */
$https_link = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
-Context::getContext()->link = new Link($https_link, $https_link);
+$context->link = new Link($https_link, $https_link);
/**
* @deprecated : these defines are going to be deleted on 1.6 version of Prestashop
@@ -198,4 +207,4 @@ define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
/* Get smarty */
require_once(dirname(__FILE__).'/smarty.config.inc.php');
-Context::getContext()->smarty = $smarty;
+$context->smarty = $smarty;
diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php
index 7b47f8882..727df43ec 100644
--- a/controllers/admin/AdminCustomersController.php
+++ b/controllers/admin/AdminCustomersController.php
@@ -666,7 +666,8 @@ class AdminCustomersControllerCore extends AdminController
'customer_birthday' => Tools::displayDate($customer->birthday, $this->default_form_language),
'last_update' => Tools::displayDate($customer->date_upd, $this->default_form_language, true),
'customer_exists' => Customer::customerExists($customer->email),
- 'id_lang' => (int)(count($orders) ? $orders[0]['id_lang'] : Configuration::get('PS_LANG_DEFAULT')),
+ 'id_lang' => $customer->id_lang,
+ 'customerLanguage' => (new Language($customer->id_lang)),
// Add a Private note
'customer_note' => Tools::htmlentitiesUTF8($customer->note),
diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql
index d324afdbf..572de3a2c 100644
--- a/install-dev/data/db_structure.sql
+++ b/install-dev/data/db_structure.sql
@@ -537,6 +537,7 @@ CREATE TABLE `PREFIX_customer` (
`id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1',
`id_gender` int(10) unsigned NOT NULL,
`id_default_group` int(10) unsigned NOT NULL DEFAULT '1',
+ `id_lang` int(10) unsigned NULL,
`id_risk` int(10) unsigned NOT NULL DEFAULT '1',
`company` varchar(64),
`siret` varchar(14),
diff --git a/install-dev/upgrade/sql/1.5.4.0.sql b/install-dev/upgrade/sql/1.5.4.0.sql
index 03e7f3a60..7cafe8b67 100644
--- a/install-dev/upgrade/sql/1.5.4.0.sql
+++ b/install-dev/upgrade/sql/1.5.4.0.sql
@@ -3,3 +3,12 @@ SET NAMES 'utf8';
UPDATE `PREFIX_meta` SET `page` = 'supplier' WHERE `page` = 'supply';
ALTER TABLE `PREFIX_image_type` CHANGE `name` `name` VARCHAR( 64 ) NOT NULL;
+
+ALTER TABLE `PREFIX_customer` ADD `id_lang` INT UNSIGNED NULL AFTER `id_default_group`;
+UPDATE `PREFIX_customer` SET id_lang = (SELECT `value` FROM `PREFIX_configuration` WHERE name = 'PS_LANG_DEFAULT' LIMIT 1);
+UPDATE `PREFIX_customer` c, `PREFIX_orders` o SET c.id_lang = o.id_lang WHERE c.id_customer = o.id_customer;
+
+
+
+
+