diff --git a/modules/authorizeaim/authorizeaim.php b/modules/authorizeaim/authorizeaim.php index 832978e0b..abc43ae39 100755 --- a/modules/authorizeaim/authorizeaim.php +++ b/modules/authorizeaim/authorizeaim.php @@ -136,7 +136,6 @@ class authorizeAIM extends PaymentModule if (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off' AND Configuration::get('PS_SSL_ENABLED')) { $invoiceAddress = new Address((int)$params['cart']->id_address_invoice); - $customer = new Customer((int)$cookie->id_customer); $authorizeAIMParams = array(); $authorizeAIMParams['x_login'] = Configuration::get('AUTHORIZE_AIM_LOGIN_ID'); diff --git a/modules/bankwire/validation.php b/modules/bankwire/validation.php index cd85497ec..059971456 100644 --- a/modules/bankwire/validation.php +++ b/modules/bankwire/validation.php @@ -48,9 +48,9 @@ if (!$authorized) $customer = new Customer((int)$cart->id_customer); if (!Validate::isLoadedObject($customer)) - Tools::redirect('index.php?controller=order&step=1'); + Tools::redirec('index.php?controller=order&step=1'); -$currency = new Currency(Tools::getValue('currency_payement', false) ? Tools::getValue('currency_payement') : $cookie->id_currency); +$currency = Tools::getValue('currency_payement', false) ? new Currency(Tools::getValue('currency_payement')) : Context::getContext()->currency; $total = (float)($cart->getOrderTotal(true, Cart::BOTH)); $mailVars = array( '{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'), diff --git a/modules/blockcart/blockcart-set-collapse.php b/modules/blockcart/blockcart-set-collapse.php index fd60ae96e..d1c284d40 100644 --- a/modules/blockcart/blockcart-set-collapse.php +++ b/modules/blockcart/blockcart-set-collapse.php @@ -30,12 +30,12 @@ if ( isset($_POST['ajax_blockcart_display']) || isset($_GET['ajax_blockcart_disp { if (Tools::getValue('ajax_blockcart_display') == 'collapse') { - $cookie->ajax_blockcart_display = 'collapsed'; + Context::getContext()->cookie->ajax_blockcart_display = 'collapsed'; die ('collapse status of the blockcart module updated in the cookie'); } if (Tools::getValue('ajax_blockcart_display') == 'expand') { - $cookie->ajax_blockcart_display = 'expanded'; + Context::getContext()->cookie->ajax_blockcart_display = 'expanded'; die ('expand status of the blockcart module updated in the cookie'); } die ('ERROR : bad status setted. Only collapse or expand status of the blockcart module are available.'); diff --git a/modules/blockcms/ajax_blockcms.php b/modules/blockcms/ajax_blockcms.php index fca22c15a..53089bed9 100755 --- a/modules/blockcms/ajax_blockcms.php +++ b/modules/blockcms/ajax_blockcms.php @@ -29,6 +29,7 @@ include_once('../../config/config.inc.php'); include_once('../../init.php'); include_once('blockcms.php'); +$context = Context::getContext(); $blockcms = new BlockCms(); if (!Tools::isSubmit('secure_key') OR Tools::getValue('secure_key') != $blockcms->secure_key OR !Tools::isSubmit('action')) die(1); @@ -42,7 +43,7 @@ if (Tools::getValue('action') == 'getCms') SELECT * FROM `'._DB_PREFIX_.'cms_category` c JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (c.`id_cms_category` = cl.`id_cms_category`) WHERE c.`id_parent` = '.(int)Tools::getValue('id_cms_category').' - AND cl.`id_lang` = '.(int)$cookie->id_lang.' + AND cl.`id_lang` = '.(int)$context->language->id.' ORDER BY c.`id_cms_category`'); $cms_pages = Db::getInstance()->ExecuteS(' @@ -50,7 +51,7 @@ if (Tools::getValue('action') == 'getCms') JOIN `'._DB_PREFIX_.'cms_lang` cl ON (c.`id_cms` = cl.`id_cms`) WHERE c.`id_cms_category` = '.(int)Tools::getValue('id_cms_category').' AND c.`active` = 1 - AND cl.`id_lang` = '.(int)$cookie->id_lang.' + AND cl.`id_lang` = '.(int)$context->language->id.' ORDER BY c.`id_cms`'); if (Tools::getValue('id_cms_block')) diff --git a/modules/blockcustomerprivacy/blockcustomerprivacy.php b/modules/blockcustomerprivacy/blockcustomerprivacy.php index a97ae6ec2..ebd84e553 100644 --- a/modules/blockcustomerprivacy/blockcustomerprivacy.php +++ b/modules/blockcustomerprivacy/blockcustomerprivacy.php @@ -54,11 +54,10 @@ class blockcustomerprivacy extends Module public function getContent() { - global $cookie; - + $context = Context::getContext(); $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); - $iso = Language::getIsoById((int)$cookie->id_lang); + $iso = $context->language->iso_code; if (Tools::isSubmit('submitCustPrivMess')) { @@ -152,16 +151,10 @@ class blockcustomerprivacy extends Module { if (!$this->active) return ; - - global $smarty, $cookie; + $context = Context::getContext(); - /* Languages preliminaries */ - $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); - $languages = Language::getLanguages(false); - $iso = Language::getIsoById((int)($cookie->id_lang)); - - $smarty->assign(array( - 'privacy_message' => Configuration::get('CUSTPRIV_MESSAGE', (int)($cookie->id_lang)), + $context->smarty->assign(array( + 'privacy_message' => Configuration::get('CUSTPRIV_MESSAGE', $context->language->id), 'error_message' => $this->l('Please agree with the customer data privacy by ticking the checkbox below.') )); return $this->display(__FILE__, 'blockcustomerprivacy.tpl'); diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 443f11c85..092aa0e5f 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -134,8 +134,8 @@ class BlockLayered extends Module public function getContent() { - global $cookie; - + $context = Context::getContext(); + $errors = array(); $html = ''; @@ -313,7 +313,7 @@ class BlockLayered extends Module '.(int)$filtersTemplate['id_layered_filter'].' '.$filtersTemplate['name'].' '.(int)$filtersTemplate['n_categories'].' - '.Tools::displayDate($filtersTemplate['date_add'], (int)$cookie->id_lang, true).' + '.Tools::displayDate($filtersTemplate['date_add'], (int)$context->language->id, true).' @@ -772,7 +772,6 @@ class BlockLayered extends Module LEFT JOIN '._DB_PREFIX_.'category_group cg ON (cg.id_category = c.id_category) LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category) WHERE c.nleft > '.(int)$category->nleft.' and c.nright <= '.(int)$category->nright.' AND c.active = 1 AND c.id_parent = '.(int)$category->id.' AND cl.id_lang = '.(int)$context->language->id.' - WHERE c.nleft > '.(int)$category->nleft.' and c.nright <= '.(int)$category->nright.' AND c.active = 1 AND c.id_parent = '.(int)$category->id.' AND cl.id_lang = '.(int)$cookie->id_lang.' AND cg.id_group '.pSQL(sizeof($groups) ? 'IN ('.implode(',', $groups).')' : '= 1').' GROUP BY c.id_category ORDER BY c.position ASC'); @@ -1103,8 +1102,8 @@ class BlockLayered extends Module public function ajaxCallBackOffice($categoryBox = array(), $id_layered_filter = NULL) { - global $cookie; - + $context = Context::getContext(); + if (!empty($id_layered_filter)) { $layeredFilter = Db::getInstance()->getRow('SELECT * FROM '._DB_PREFIX_.'layered_filter WHERE id_layered_filter = '.(int)$id_layered_filter); @@ -1124,7 +1123,7 @@ class BlockLayered extends Module LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute) LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON (pa.id_product_attribute = pac.id_product_attribute) LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = pa.id_product)' : '').' - WHERE agl.id_lang = '.(int)$cookie->id_lang. + WHERE agl.id_lang = '.(int)$context->language->id. (sizeof($categoryBox) ? ' AND cp.id_category IN ('.implode(',', $categoryBox).')' : '').' GROUP BY ag.id_attribute_group'); @@ -1135,7 +1134,7 @@ class BlockLayered extends Module '.(sizeof($categoryBox) ? ' LEFT JOIN '._DB_PREFIX_.'feature_product fp ON (fp.id_feature = fv.id_feature) LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = fp.id_product)' : '').' - WHERE (fv.custom IS NULL OR fv.custom = 0) AND fl.id_lang = '.(int)$cookie->id_lang. + WHERE (fv.custom IS NULL OR fv.custom = 0) AND fl.id_lang = '.(int)$context->language->id. (sizeof($categoryBox) ? ' AND cp.id_category IN ('.implode(',', $categoryBox).')' : '').' GROUP BY fl.id_feature'); diff --git a/modules/blockwishlist/WishList.php b/modules/blockwishlist/WishList.php index dad62e0a7..393391ca7 100644 --- a/modules/blockwishlist/WishList.php +++ b/modules/blockwishlist/WishList.php @@ -68,12 +68,12 @@ class WishList extends ObjectModel public function delete() { - global $cookie; + $context = Context::getContext(); Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'wishlist_email` WHERE `id_wishlist` = '.(int)($this->id)); Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'wishlist_product` WHERE `id_wishlist` = '.(int)($this->id)); - if (isset($cookie->id_wishlist)) - unset($cookie->id_wishlist); + if (isset($context->cookie->id_wishlist)) + unset($context->cookie->id_wishlist); return (parent::delete()); } @@ -102,13 +102,13 @@ class WishList extends ObjectModel public static function isExistsByNameForUser($name) { - global $cookie; - + $context = Context::getContext(); + return Db::getInstance()->getValue(' SELECT COUNT(*) AS total FROM `'._DB_PREFIX_.'wishlist` WHERE `name` = \''.pSQL($name).'\' - AND `id_customer` = '.(int)($cookie->id_customer) + AND `id_customer` = '.(int)$context->customer->id ); } diff --git a/modules/blockwishlist/cart.php b/modules/blockwishlist/cart.php index 1658b683c..1ea34b0b2 100644 --- a/modules/blockwishlist/cart.php +++ b/modules/blockwishlist/cart.php @@ -30,6 +30,7 @@ require_once(dirname(__FILE__).'/../../init.php'); require_once(dirname(__FILE__).'/WishList.php'); require_once(dirname(__FILE__).'/blockwishlist.php'); +$context = Context::getContext(); $action = Tools::getValue('action'); $add = (!strcmp($action, 'add') ? 1 : 0); $delete = (!strcmp($action, 'delete') ? 1 : 0); @@ -39,39 +40,39 @@ $quantity = (int)(Tools::getValue('quantity')); $id_product_attribute = (int)(Tools::getValue('id_product_attribute')); if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND strcmp(Tools::getToken(false), Tools::getValue('token')) AND - $cookie->isLogged() === true) + $context->cookie->isLogged() === true) echo Tools::displayError('Invalid token'); -if ($cookie->isLogged()) +if ($context->cookie->isLogged()) { - if ($id_wishlist AND WishList::exists($id_wishlist, $cookie->id_customer) === true) - $cookie->id_wishlist = (int)($id_wishlist); - if (empty($cookie->id_wishlist) === true OR $cookie->id_wishlist == false) - $smarty->assign('error', true); + if ($id_wishlist AND WishList::exists($id_wishlist, $context->customer->id) === true) + $context->cookie->id_wishlist = (int)($id_wishlist); + if (empty($context->cookie->id_wishlist) === true OR $context->cookie->id_wishlist == false) + $context->smarty->assign('error', true); if (($add OR $delete) AND empty($id_product) === false) { - if(!isset($cookie->id_wishlist) OR $cookie->id_wishlist == '') + if(!isset($context->cookie->id_wishlist) OR $context->cookie->id_wishlist == '') { $wishlist = new WishList(); $modWishlist = new BlockWishList(); $wishlist->name = $modWishlist->default_wishlist_name; - $wishlist->id_customer = (int)($cookie->id_customer); + $wishlist->id_customer = (int)($context->customer->id); list($us, $s) = explode(' ', microtime()); srand($s * $us); - $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$cookie->id_customer), 0, 16)); + $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$context->customer->id), 0, 16)); $wishlist->add(); - $cookie->id_wishlist = (int)($wishlist->id); + $context->cookie->id_wishlist = (int)($wishlist->id); } if ($add AND $quantity) - WishList::addProduct($cookie->id_wishlist, $cookie->id_customer, $id_product, $id_product_attribute, $quantity); + WishList::addProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute, $quantity); else if ($delete) - WishList::removeProduct($cookie->id_wishlist, $cookie->id_customer, $id_product, $id_product_attribute); + WishList::removeProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute); } - $smarty->assign('products', WishList::getProductByIdCustomer($cookie->id_wishlist, $cookie->id_customer, $cookie->id_lang, null, true)); + $context->smarty->assign('products', WishList::getProductByIdCustomer($context->cookie->id_wishlist, $context->customer->id, $context->language->id, null, true)); if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl')) - $smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl'); + $context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl'); elseif (Tools::file_exists_cache(dirname(__FILE__).'/blockwishlist-ajax.tpl')) - $smarty->display(dirname(__FILE__).'/blockwishlist-ajax.tpl'); + $context->smarty->display(dirname(__FILE__).'/blockwishlist-ajax.tpl'); else echo Tools::displayError('No template found'); } diff --git a/modules/blockwishlist/managewishlist.php b/modules/blockwishlist/managewishlist.php index 17683f511..7c4bbb55a 100644 --- a/modules/blockwishlist/managewishlist.php +++ b/modules/blockwishlist/managewishlist.php @@ -31,8 +31,8 @@ $useSSL = true; require_once(dirname(__FILE__).'/../../config/config.inc.php'); require_once(dirname(__FILE__).'/../../init.php'); require_once(dirname(__FILE__).'/WishList.php'); - -if ($cookie->isLogged()) +$context = Context::getContext(); +if ($context->cookie->isLogged()) { $action = Tools::getValue('action'); $id_wishlist = (int)Tools::getValue('id_wishlist'); @@ -51,26 +51,26 @@ if ($cookie->isLogged()) else { if (!strcmp($action, 'delete')) - WishList::removeProduct($id_wishlist, (int)($cookie->id_customer), $id_product, $id_product_attribute); + WishList::removeProduct($id_wishlist, (int)$context->customer->id, $id_product, $id_product_attribute); - $products = WishList::getProductByIdCustomer($id_wishlist, $cookie->id_customer, $cookie->id_lang); + $products = WishList::getProductByIdCustomer($id_wishlist, $context->customer->id, $context->language->id); $bought = WishList::getBoughtProduct($id_wishlist); for ($i = 0; $i < sizeof($products); ++$i) { - $obj = new Product((int)($products[$i]['id_product']), false, (int)($cookie->id_lang)); + $obj = new Product((int)($products[$i]['id_product']), false, $context->language->id); if (!Validate::isLoadedObject($obj)) continue; else { if ($products[$i]['id_product_attribute'] != 0) { - $combination_imgs = $obj->getCombinationImages((int)($cookie->id_lang)); + $combination_imgs = $obj->getCombinationImages($context->language->id); $products[$i]['cover'] = $obj->id.'-'.$combination_imgs[$products[$i]['id_product_attribute']][0]['id_image']; } else { - $images = $obj->getImages((int)($cookie->id_lang)); + $images = $obj->getImages($context->language->id); foreach ($images AS $k => $image) if ($image['cover']) { @@ -79,7 +79,7 @@ if ($cookie->isLogged()) } } if (!isset($products[$i]['cover'])) - $products[$i]['cover'] = Language::getIsoById($cookie->id_lang).'-default'; + $products[$i]['cover'] = $context->language->iso_code.'-default'; } $products[$i]['bought'] = false; for ($j = 0, $k = 0; $j < sizeof($bought); ++$j) @@ -95,7 +95,7 @@ if ($cookie->isLogged()) foreach ($products as $product) if (sizeof($product['bought'])) $productBoughts[] = $product; - $smarty->assign(array( + $context->smarty->assign(array( 'products' => $products, 'productsBoughts' => $productBoughts, 'id_wishlist' => $id_wishlist, @@ -104,9 +104,9 @@ if ($cookie->isLogged()) )); if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/managewishlist.tpl')) - $smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/managewishlist.tpl'); + $context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/managewishlist.tpl'); elseif (Tools::file_exists_cache(dirname(__FILE__).'/managewishlist.tpl')) - $smarty->display(dirname(__FILE__).'/managewishlist.tpl'); + $context->smarty->display(dirname(__FILE__).'/managewishlist.tpl'); else echo Tools::displayError('No template found'); } diff --git a/modules/blockwishlist/mywishlist.php b/modules/blockwishlist/mywishlist.php index 24c98f497..636551f4e 100644 --- a/modules/blockwishlist/mywishlist.php +++ b/modules/blockwishlist/mywishlist.php @@ -32,6 +32,7 @@ include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../header.php'); include_once(dirname(__FILE__).'/WishList.php'); +$context = Context::getContext(); $errors = array(); if ($cookie->isLogged()) @@ -58,21 +59,21 @@ if ($cookie->isLogged()) { $wishlist = new WishList(); $wishlist->name = $name; - $wishlist->id_customer = (int)$cookie->id_customer; + $wishlist->id_customer = (int)$context->customer->id; list($us, $s) = explode(' ', microtime()); srand($s * $us); - $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$cookie->id_customer), 0, 16)); + $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$context->customer->id), 0, 16)); $wishlist->add(); - Mail::Send((int)($cookie->id_lang), 'wishlink', Mail::l('Your wishlist\'s link'), + Mail::Send($context->language->id, 'wishlink', Mail::l('Your wishlist\'s link'), array( '{wishlist}' => $wishlist->name, '{message}' => Tools::getProtocol().htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/blockwishlist/view.php?token='.$wishlist->token), - $cookie->email, $cookie->firstname.' '.$cookie->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/'); + $context->customer->email, $context->customer->firstname.' '.$context->customer->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/'); } } } else if ($add) - WishList::addCardToWishlist((int)($cookie->id_customer), (int)(Tools::getValue('id_wishlist')), (int)($cookie->id_lang)); + WishList::addCardToWishlist($context->customer->id, Tools::getValue('id_wishlist'), $context->language->id); else if ($delete AND empty($id_wishlist) === false) { $wishlist = new WishList((int)($id_wishlist)); @@ -81,23 +82,23 @@ if ($cookie->isLogged()) else $errors[] = Tools::displayError('Cannot delete this wishlist'); } - $smarty->assign('wishlists', WishList::getByIdCustomer((int)($cookie->id_customer))); - $smarty->assign('nbProducts', WishList::getInfosByIdCustomer((int)($cookie->id_customer))); + $context->smarty->assign('wishlists', WishList::getByIdCustomer($context->customer->id)); + $context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($context->customer->id)); } else { Tools::redirect('index.php?controller=authentication&back=modules/blockwishlist/mywishlist.php'); } -$smarty->assign(array( - 'id_customer' => (int)($cookie->id_customer), +$context->smarty->assign(array( + 'id_customer' => (int)$context->customer->id, 'errors' => $errors )); if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/mywishlist.tpl')) - $smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/mywishlist.tpl'); + $context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/mywishlist.tpl'); elseif (Tools::file_exists_cache(dirname(__FILE__).'/mywishlist.tpl')) - $smarty->display(dirname(__FILE__).'/mywishlist.tpl'); + $context->smarty->display(dirname(__FILE__).'/mywishlist.tpl'); else echo Tools::displayError('No template found'); diff --git a/modules/blockwishlist/sendwishlist.php b/modules/blockwishlist/sendwishlist.php index c1f4d320f..189c7ab83 100644 --- a/modules/blockwishlist/sendwishlist.php +++ b/modules/blockwishlist/sendwishlist.php @@ -31,10 +31,10 @@ require_once(dirname(__FILE__).'/WishList.php'); if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND strcmp(Tools::getToken(false), Tools::getValue('token')) AND - $cookie->isLogged() === true) + $context->cookie->isLogged() === true) exit(Tools::displayError('invalid token',false)); -if ($cookie->isLogged()) +if ($context->cookie->isLogged()) { $id_wishlist = (int)(Tools::getValue('id_wishlist')); if (empty($id_wishlist) === true) @@ -42,15 +42,15 @@ if ($cookie->isLogged()) for ($i = 1; empty($_POST['email'.strval($i)]) === false; ++$i) { $to = Tools::getValue('email'.$i); - $wishlist = WishList::exists($id_wishlist, $cookie->id_customer, true); + $wishlist = WishList::exists($id_wishlist, $context->customer->id, true); if ($wishlist === false) exit(Tools::displayError('Invalid wishlist',false)); if (WishList::addEmail($id_wishlist, $to) === false) exit(Tools::displayError('Wishlist send error',false)); $toName = strval(Configuration::get('PS_SHOP_NAME')); - $customer = new Customer((int)($cookie->id_customer)); + $customer = $context->customer; if (Validate::isLoadedObject($customer)) - Mail::Send((int)($cookie->id_lang), 'wishlist', Mail::l('Message from ').$customer->lastname.' '.$customer->firstname, + Mail::Send($context->language->id, 'wishlist', Mail::l('Message from ').$customer->lastname.' '.$customer->firstname, array( '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, diff --git a/modules/blockwishlist/view.php b/modules/blockwishlist/view.php index 7b1d9ed93..6f1e437c0 100644 --- a/modules/blockwishlist/view.php +++ b/modules/blockwishlist/view.php @@ -32,6 +32,7 @@ require_once(dirname(__FILE__).'/../../config/config.inc.php'); require_once(dirname(__FILE__).'/../../header.php'); require_once(dirname(__FILE__).'/WishList.php'); +$context = Context::getContext(); $token = Tools::getValue('token'); if (empty($token) === false) { @@ -39,22 +40,22 @@ if (empty($token) === false) if (empty($result) === true || $result === false) $errors[] = Tools::displayError('Invalid wishlist token'); WishList::refreshWishList($wishlist['id_wishlist']); - $products = WishList::getProductByIdCustomer((int)($wishlist['id_wishlist']), (int)($wishlist['id_customer']), (int)($cookie->id_lang), null, true); + $products = WishList::getProductByIdCustomer((int)($wishlist['id_wishlist']), (int)($wishlist['id_customer']), $context->language->id, null, true); for ($i = 0; $i < sizeof($products); ++$i) { - $obj = new Product((int)($products[$i]['id_product']), false, (int)($cookie->id_lang)); + $obj = new Product($products[$i]['id_product'], false, $context->language->id); if (!Validate::isLoadedObject($obj)) continue; else { if ($products[$i]['id_product_attribute'] != 0) { - $combination_imgs = $obj->getCombinationImages((int)($cookie->id_lang)); + $combination_imgs = $obj->getCombinationImages($context->language->id); $products[$i]['cover'] = $obj->id.'-'.$combination_imgs[$products[$i]['id_product_attribute']][0]['id_image']; } else { - $images = $obj->getImages((int)($cookie->id_lang)); + $images = $obj->getImages($context->language->id); foreach ($images AS $k => $image) { if ($image['cover']) @@ -64,13 +65,13 @@ if (empty($token) === false) } } if (!isset($products[$i]['cover'])) - $products[$i]['cover'] = Language::getIsoById((int)($cookie->id_lang)).'-default'; + $products[$i]['cover'] = $context->language->iso_code.'-default'; } } } WishList::incCounter((int)($wishlist['id_wishlist'])); $ajax = Configuration::get('PS_BLOCK_CART_AJAX'); - $smarty->assign(array ( + $context->context->smarty->assign(array ( 'current_wishlist' => $wishlist, 'token' => $token, 'ajax' => ((isset($ajax) AND (int)($ajax) == 1) ? '1' : '0'), @@ -79,9 +80,9 @@ if (empty($token) === false) } if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/view.tpl')) - $smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/view.tpl'); + $context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/view.tpl'); elseif (Tools::file_exists_cache(dirname(__FILE__).'/view.tpl')) - $smarty->display(dirname(__FILE__).'/view.tpl'); + $context->smarty->display(dirname(__FILE__).'/view.tpl'); else echo Tools::displayError('No template found'); diff --git a/modules/carriercompare/carriercompare.php b/modules/carriercompare/carriercompare.php index a311cb611..26112ac44 100755 --- a/modules/carriercompare/carriercompare.php +++ b/modules/carriercompare/carriercompare.php @@ -178,8 +178,6 @@ class CarrierCompare extends Module */ private function isModuleAvailable() { - global $cookie; - $fileName = basename($_SERVER['SCRIPT_FILENAME']); /** * This module is only available on standard order process because @@ -191,7 +189,7 @@ class CarrierCompare extends Module * If visitor is logged, the module isn't available on Front office, * we use the account informations for carrier selection and taxes. */ - if ($cookie->id_customer) + if (Context::getContext()->customer->id) return false; return true; } diff --git a/modules/cheque/payment.php b/modules/cheque/payment.php index 260cb1766..3f402c48e 100644 --- a/modules/cheque/payment.php +++ b/modules/cheque/payment.php @@ -32,7 +32,7 @@ include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../header.php'); include(dirname(__FILE__).'/cheque.php'); -if (!$cookie->isLogged(true)) +if (!Context::getContext()->cookie->isLogged(true)) Tools::redirect('index.php?controller=authentication&back=order.php'); $cheque = new Cheque(); diff --git a/modules/cheque/validation.php b/modules/cheque/validation.php index 596c42f3f..13eecb44e 100644 --- a/modules/cheque/validation.php +++ b/modules/cheque/validation.php @@ -29,6 +29,8 @@ include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../header.php'); include(dirname(__FILE__).'/cheque.php'); +$context = Context::getContext(); +$cart = $context->cart; $cheque = new Cheque(); if ($cart->id_customer == 0 OR $cart->id_address_delivery == 0 OR $cart->id_address_invoice == 0 OR !$cheque->active) @@ -45,12 +47,12 @@ foreach (Module::getPaymentModules() as $module) if (!$authorized) die(Tools::displayError('This payment method is not available.')); -$customer = new Customer((int)$cart->id_customer); +$customer = new Customer($cart->id_customer); if (!Validate::isLoadedObject($customer)) Tools::redirect('index.php?controller=order&step=1'); -$currency = new Currency((int)(Tools::isSubmit('currency_payement') ? Tools::getValue('currency_payement') : $cookie->id_currency)); +$currency = Tools::isSubmit('currency_payement') ? new Currency(Tools::getValue('currency_payement')) : $context->currency; $total = (float)$cart->getOrderTotal(true, Cart::BOTH); $mailVars = array( diff --git a/modules/dejala/dejalacarrierutils.php b/modules/dejala/dejalacarrierutils.php index 18c5d8437..ecbd49b86 100644 --- a/modules/dejala/dejalacarrierutils.php +++ b/modules/dejala/dejalacarrierutils.php @@ -87,9 +87,7 @@ class DejalaCarrierUtils } public static function getCarrierByName($name) { - global $cookie ; - - $carriers = Carrier::getCarriers((int)$cookie->id_lang, true, false, false, NULL, ALL_CARRIERS); + $carriers = Carrier::getCarriers(Context::getContext()->language->id, true, false, false, NULL, ALL_CARRIERS); foreach($carriers as $carrier) if (!$carrier['deleted'] AND $carrier['external_module_name'] == $name) return new Carrier((int)$carrier['id_carrier']) ; diff --git a/modules/editorial/editorial.php b/modules/editorial/editorial.php index 4c1bdc787..be29cf78e 100644 --- a/modules/editorial/editorial.php +++ b/modules/editorial/editorial.php @@ -117,7 +117,7 @@ class Editorial extends Module public function getContent() { - global $cookie; + $context = Context::getContext(); /* display the module name */ $this->_html = '

'.$this->displayName.'

'; @@ -132,7 +132,7 @@ class Editorial extends Module { unlink(dirname(__FILE__).'/homepage_logo.jpg'); Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 1); - Tools::redirectAdmin('index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminToken('AdminModules'.(int)(Tab::getIdFromClassName('AdminModules')).(int)($cookie->id_employee))); + Tools::redirectAdmin('index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminToken('AdminModules'.(int)(Tab::getIdFromClassName('AdminModules')).(int)$context->employee->id)); } $this->_html .= $errors; } @@ -180,17 +180,15 @@ class Editorial extends Module private function _displayForm() { - global $cookie; + $context = Context::getContext(); /* Languages preliminaries */ $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); - $iso = Language::getIsoById((int)($cookie->id_lang)); + $iso = $context->language->iso_code; $divLangName = 'title¤subheading¤cpara¤logo_subheading'; $editorial = new EditorialClass(1); // TinyMCE - global $cookie; - $iso = Language::getIsoById((int)($cookie->id_lang)); $isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en'); $ad = dirname($_SERVER["PHP_SELF"]); $this->_html .= ' @@ -296,15 +294,15 @@ class Editorial extends Module public function hookHome($params) { - global $cookie, $smarty; - - $editorial = new EditorialClass(1, (int)$cookie->id_lang); - $smarty->assign(array( + $context = Context::getContext(); + + $editorial = new EditorialClass(1, $context->language->id); + $context->smarty->assign(array( 'editorial' => $editorial, - 'default_lang' => (int)$cookie->id_lang, + 'default_lang' => (int)$context->language->id, 'image_width' => Configuration::get('EDITORIAL_IMAGE_WIDTH'), 'image_height' => Configuration::get('EDITORIAL_IMAGE_HEIGHT'), - 'id_lang' => $cookie->id_lang, + 'id_lang' => $context->language->id, 'homepage_logo' => !Configuration::get('EDITORIAL_IMAGE_DISABLE') && file_exists('modules/editorial/homepage_logo.jpg'), 'image_path' => $this->_path.'homepage_logo.jpg' )); diff --git a/modules/envoimoinscher/AdminEnvoiMoinsCher.php b/modules/envoimoinscher/AdminEnvoiMoinsCher.php index bf2599268..f3fc6ce0c 100755 --- a/modules/envoimoinscher/AdminEnvoiMoinsCher.php +++ b/modules/envoimoinscher/AdminEnvoiMoinsCher.php @@ -37,7 +37,6 @@ class AdminEnvoiMoinsCher extends AdminTab public function display() { - global $cookie; $emc = new Envoimoinscher(); echo '

'.$emc->lang('List of orders to export').'

'; if (Tools::isSubmit('submitExport')) @@ -83,7 +82,7 @@ class AdminEnvoiMoinsCher extends AdminTab else echo '

'.$emc->lang('Please configure this module in order').'

'; } - echo '

+ echo '

' . $emc->lang('Change configuration') . '

'; } @@ -113,7 +112,6 @@ class AdminEnvoiMoinsCher extends AdminTab private function displayOrders($orders) { - global $cookie; echo ' @@ -148,7 +146,7 @@ class AdminEnvoiMoinsCher extends AdminTab echo ' - '; } @@ -161,7 +159,6 @@ class AdminEnvoiMoinsCher extends AdminTab private function getOrderDetails($id_order) { - global $cookie; $confs = Configuration::getMultiple(array('EMC_LOGIN', 'PS_SHOP_NAME', 'EMC_GENDER', 'EMC_FIRST_NAME', 'EMC_LAST_NAME', 'EMC_ADDRESS', 'EMC_ZIP_CODE', 'EMC_CITY', 'EMC_COUNTRY', 'EMC_PHONE', 'EMC_EMAIL', 'EMC_EMAILS')); $orderDetails = array(); @@ -218,7 +215,7 @@ class AdminEnvoiMoinsCher extends AdminTab $orderDelivery['adresse'] = htmlspecialchars($adresseDelivery->address1, ENT_COMPAT, 'UTF-8'); $orderDelivery['codepostal'] = htmlspecialchars($adresseDelivery->postcode, ENT_COMPAT, 'UTF-8'); $orderDelivery['ville'] = htmlspecialchars($adresseDelivery->city, ENT_COMPAT, 'UTF-8'); - $orderDelivery['pz_id'] = Country::getIsoById(Country::getIdByName((int)($cookie->id_lang),$adresseDelivery->country)); + $orderDelivery['pz_id'] = Country::getIsoById(Country::getIdByName($this->context->language->id, $adresseDelivery->country)); if (isset($adresseDelivery->phone)) $orderDelivery['tel'] = htmlspecialchars($adresseDelivery->phone, ENT_COMPAT, 'UTF-8'); else @@ -226,13 +223,11 @@ class AdminEnvoiMoinsCher extends AdminTab $orderDelivery['email'] = htmlspecialchars($customer->email, ENT_COMPAT, 'UTF-8'); $orderDetails['destinataire'] = $orderDelivery; - //d($orderDetails); return $orderDetails; } private function getFeatures($id) { - global $cookie; $featuresTab = array(); $confs = Configuration::getMultiple(array('EMC_WIDTH', 'EMC_HEIGHT', 'EMC_DEPTH')); $features = Product::getFeaturesStatic((int)$id); @@ -242,15 +237,15 @@ class AdminEnvoiMoinsCher extends AdminTab { case $confs['EMC_WIDTH'] : $featureValue = new FeatureValue((int)($feature['id_feature_value'])); - $featuresTab['largeur'] = $featureValue->value[(int)($cookie->id_lang)]; + $featuresTab['largeur'] = $featureValue->value[(int)$this->context->language->id]; break; case $confs['EMC_HEIGHT'] : $featureValue = new FeatureValue((int)($feature['id_feature_value'])); - $featuresTab['hauteur'] = $featureValue->value[(int)($cookie->id_lang)]; + $featuresTab['hauteur'] = $featureValue->value[(int)$this->context->language->id]; break; case $confs['EMC_DEPTH'] : $featureValue = new FeatureValue((int)($feature['id_feature_value'])); - $featuresTab['longueur'] = $featureValue->value[(int)($cookie->id_lang)]; + $featuresTab['longueur'] = $featureValue->value[(int)$this->context->language->id]; break; } }
'.envoimoinscher::selectNature(Configuration::get('EMC_CONTENT'),(int)($order['id_order'])).' + '.$emc->lang('View').'