[+] BO : Added customer language on the customer page
This commit is contained in:
+30
-21
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user