From 6e93cc284896ca969f8a48308d6e7ddad83e9c92 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Fri, 15 Jul 2011 13:59:26 +0000 Subject: [PATCH] // Context part 7 --- admin-dev/ajax.php | 28 ++++++++---------- admin-dev/ajax_category_list.php | 4 +-- admin-dev/functions.php | 36 ++++++++++-------------- admin-dev/index.php | 4 +-- admin-dev/init.php | 2 +- admin-dev/tabs/AdminAttributes.php | 6 ---- admin-dev/tabs/AdminAttributesGroups.php | 13 ++------- admin-dev/tabs/AdminBackup.php | 12 ++------ admin-dev/tabs/AdminCMS.php | 30 ++++++++------------ admin-dev/tabs/AdminCarriers.php | 8 +----- admin-dev/tabs/AdminCarts.php | 25 ++++++---------- admin-dev/tabs/AdminCatalog.php | 6 ++-- admin-dev/tabs/AdminContacts.php | 1 - admin-dev/tabs/AdminCountries.php | 5 +--- admin-dev/tabs/AdminCurrencies.php | 5 ---- admin-dev/tabs/AdminDb.php | 3 -- admin-dev/tabs/AdminHome.php | 12 +++----- admin-dev/tabs/AdminPreferences.php | 6 ++-- classes/AdminTab.php | 11 ++++---- classes/Employee.php | 7 ++++- classes/FrontController.php | 36 +++++++++++++----------- config/config.inc.php | 1 - install-dev/sql/db.sql | 1 + install-dev/sql/upgrade/1.5.0.0.sql | 2 ++ 24 files changed, 101 insertions(+), 163 deletions(-) diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php index 1c5feae27..4e9b5abd6 100644 --- a/admin-dev/ajax.php +++ b/admin-dev/ajax.php @@ -32,6 +32,8 @@ require_once(dirname(__FILE__).'/init.php'); require_once(PS_ADMIN_DIR.'/tabs/AdminCounty.php'); +$context = Context::getContext(); + if (isset($_GET['changeParentUrl'])) echo ''; if (isset($_GET['installBoughtModule'])) @@ -122,8 +124,6 @@ if (isset($_GET['ajaxProductAccessories'])) if (isset($_GET['ajaxDiscountCustomers'])) { - global $cookie; - $currentIndex = 'index.php?tab=AdminDiscounts'; $jsonArray = array(); $filter = Tools::getValue('filter'); @@ -146,7 +146,7 @@ if (isset($_GET['ajaxDiscountCustomers'])) $groups = Db::getInstance()->ExecuteS(' SELECT g.`id_group`, gl.`name` FROM `'._DB_PREFIX_.'group` g - LEFT JOIN `'._DB_PREFIX_.'group_lang` AS gl ON (g.`id_group` = gl.`id_group` AND gl.`id_lang` = '.(int)($cookie->id_lang).') + LEFT JOIN `'._DB_PREFIX_.'group_lang` AS gl ON (g.`id_group` = gl.`id_group` AND gl.`id_lang` = '.(int)($context->language->id).') WHERE '.(Validate::isUnsignedInt($filter) ? 'g.`id_group` = '.(int)($filter) : 'gl.`name` LIKE "%'.pSQL($filter).'%" '.((Validate::isBool_Id($filter) AND $filterArray[0] == 1) ? 'OR g.`id_group` = '.(int)($filterArray[1]) : '')).' ORDER BY gl.`name` ASC @@ -165,9 +165,9 @@ if (isset($_GET['ajaxDiscountCustomers'])) } if (Tools::getValue('page') == 'prestastore' AND @fsockopen('addons.prestashop.com', 80, $errno, $errst, 3)) - readfile('http://addons.prestashop.com/adminmodules.php?lang='.Language::getIsoById($cookie->id_lang)); + readfile('http://addons.prestashop.com/adminmodules.php?lang='.$context->language->iso_code); if (Tools::getValue('page') == 'themes' AND @fsockopen('addons.prestashop.com', 80, $errno, $errst, 3)) - readfile('http://addons.prestashop.com/adminthemes.php?lang='.Language::getIsoById($cookie->id_lang)); + readfile('http://addons.prestashop.com/adminthemes.php?lang='.$context->language->iso_code); if ($step = (int)(Tools::getValue('ajaxProductTab'))) { @@ -388,26 +388,24 @@ if (Tools::isSubmit('submitCustomerNote') AND $id_customer = (int)Tools::getValu if (Tools::getValue('form_language_id')) { - if (!($cookie->employee_form_lang = (int)(Tools::getValue('form_language_id')))) + if (!($context->cookie->employee_form_lang = (int)(Tools::getValue('form_language_id')))) die ('Error while updating cookie.'); die ('Form language updated.'); } if (Tools::getValue('submitPublishProduct')) { - global $cookie; - if (Tools::getIsset('id_product')) { $id_product = (int)(Tools::getValue('id_product')); $id_tab_catalog = (int)(Tab::getIdFromClassName('AdminCatalog')); - $token = Tools::getAdminToken('AdminCatalog'.(int)($id_tab_catalog).(int)($cookie->id_employee)); + $token = Tools::getAdminToken('AdminCatalog'.(int)($id_tab_catalog).(int)$context->employee->id); $bo_product_url = dirname($_SERVER['PHP_SELF']).'/index.php?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.$token; if (Tools::getValue('redirect')) die($bo_product_url); - $profileAccess = Profile::getProfileAccess((int)$cookie->profile, $id_tab_catalog); + $profileAccess = Profile::getProfileAccess($context->employee->id_profile, $id_tab_catalog); if($profileAccess['edit']) { $product = new Product((int)(Tools::getValue('id_product'))); @@ -431,19 +429,17 @@ if (Tools::getValue('submitPublishProduct')) if (Tools::getValue('submitPublishCMS')) { - global $cookie; - if (Tools::getIsset('id_cms')) { $id_cms = (int)(Tools::getValue('id_cms')); $id_tab_cms = (int)(Tab::getIdFromClassName('AdminCMSContent')); - $token = Tools::getAdminToken('AdminCMSContent'.(int)($id_tab_cms).(int)($cookie->id_employee)); + $token = Tools::getAdminToken('AdminCMSContent'.(int)($id_tab_cms).(int)$context->employee->id); $bo_cms_url = dirname($_SERVER['PHP_SELF']).'/index.php?tab=AdminCMSContent&id_cms='.(int)$id_cms.'&updatecms&token='.$token; if (Tools::getValue('redirect')) die($bo_cms_url); - $profileAccess = Profile::getProfileAccess((int)$cookie->profile, $id_tab_cms); + $profileAccess = Profile::getProfileAccess($context->employee->id_profile, $id_tab_cms); if($profileAccess['edit']) { $cms = new CMS((int)(Tools::getValue('id_cms'))); @@ -506,8 +502,8 @@ if (Tools::isSubmit('loadImportMatchs')) if (Tools::isSubmit('toggleScreencast')) { - global $cookie; - $cookie->show_screencast = (int)(!(bool)$cookie->show_screencast); + $context->employee->show_screencast = (int)(!(bool)$context->employee->show_screencast); + $context->employee->save(); } if (Tools::isSubmit('ajaxAddZipCode') OR Tools::isSubmit('ajaxRemoveZipCode')) diff --git a/admin-dev/ajax_category_list.php b/admin-dev/ajax_category_list.php index a29196651..7e35f8328 100755 --- a/admin-dev/ajax_category_list.php +++ b/admin-dev/ajax_category_list.php @@ -37,13 +37,11 @@ $catalog = new AdminCatalog(); $adminProducts = new AdminProducts(); - global $cookie; - echo ' diff --git a/admin-dev/functions.php b/admin-dev/functions.php index 6375a438e..b045e5c28 100644 --- a/admin-dev/functions.php +++ b/admin-dev/functions.php @@ -52,9 +52,8 @@ function bindDatepicker($id, $time) // id can be a identifier or an array of identifiers function includeDatepicker($id, $time = false) { - global $cookie; echo ''; - $iso = Db::getInstance()->getValue('SELECT iso_code FROM '._DB_PREFIX_.'lang WHERE `id_lang` = '.(int)($cookie->id_lang)); + $iso = Db::getInstance()->getValue('SELECT iso_code FROM '._DB_PREFIX_.'lang WHERE `id_lang` = '.(int)Context::getContext()->language->id); if ($iso != 'en') echo ''; echo '