diff --git a/admin-dev/ajax-tab.php b/admin-dev/ajax-tab.php index a6a4ddd07..faf9d8df4 100755 --- a/admin-dev/ajax-tab.php +++ b/admin-dev/ajax-tab.php @@ -42,7 +42,7 @@ if (empty($tab) and !sizeof($_POST)) } if ($adminObj = checkingTab($tab)) { - $isoUser = Language::getIsoById(intval($cookie->id_lang)); + $isoUser = Context::getContext()->language->iso_code; if (Validate::isLoadedObject($adminObj)) { diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php index e21159235..72639aacc 100644 --- a/admin-dev/ajax.php +++ b/admin-dev/ajax.php @@ -626,8 +626,8 @@ if (Tools::isSubmit('getAdminHomeElement')) $result = array(); $protocol = (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'; - $isoUser = Language::getIsoById(intval($cookie->id_lang)); - $isoCountry = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')); + $isoUser = Context::getContext()->language->iso_code; + $isoCountry = Context::getContext()->country->iso_code; $stream_context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5))); // SCREENCAST @@ -637,7 +637,7 @@ if (Tools::isSubmit('getAdminHomeElement')) $result['screencast'] = 'NOK'; // PREACTIVATION - $content = @file_get_contents($protocol.'://www.prestashop.com/partner/preactivation/preactivation-block.php?version=1.0&shop='.urlencode(Configuration::get('PS_SHOP_NAME')).'&protocol='.$protocol.'&url='.urlencode($_SERVER['HTTP_HOST']).'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)$cookie->id_lang.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&date_creation='._PS_CREATION_DATE_.'&v='._PS_VERSION_.'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context); + $content = @file_get_contents($protocol.'://www.prestashop.com/partner/preactivation/preactivation-block.php?version=1.0&shop='.urlencode(Configuration::get('PS_SHOP_NAME')).'&protocol='.$protocol.'&url='.urlencode($_SERVER['HTTP_HOST']).'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)Context::getContext()->language->id.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&date_creation='._PS_CREATION_DATE_.'&v='._PS_VERSION_.'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context); if (!$content) $result['partner_preactivation'] = 'NOK'; else @@ -663,7 +663,7 @@ if (Tools::isSubmit('getAdminHomeElement')) } // PREACTIVATION PAYPAL WARNING - $content = @file_get_contents('https://www.prestashop.com/partner/preactivation/preactivation-warnings.php?version=1.0&partner=paypal&iso_country='.Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))).'&iso_lang='.Tools::strtolower(Language::getIsoById(intval($cookie->id_lang))).'&id_lang='.(int)$cookie->id_lang.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context); + $content = @file_get_contents('https://www.prestashop.com/partner/preactivation/preactivation-warnings.php?version=1.0&partner=paypal&iso_country='.Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))).'&iso_lang='.Tools::strtolower(Context::getContext()->language->iso_code).'&id_lang='.(int)Context::getContext().'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context); $content = explode('|', $content); if ($content[0] == 'OK') Configuration::updateValue('PS_PREACTIVATION_PAYPAL_WARNING', $content[1]); @@ -671,7 +671,7 @@ if (Tools::isSubmit('getAdminHomeElement')) Configuration::updateValue('PS_PREACTIVATION_PAYPAL_WARNING', ''); // DISCOVER PRESTASHOP - $content = @file_get_contents($protocol.'://www.prestashop.com/partner/prestashop/prestashop-link.php?iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)$cookie->id_lang, false, $stream_context); + $content = @file_get_contents($protocol.'://www.prestashop.com/partner/prestashop/prestashop-link.php?iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)Context::getContext()->language->id, false, $stream_context); if (!$content) $result['discover_prestashop'] = 'NOK'; else @@ -685,7 +685,7 @@ if (Tools::isSubmit('getAdminHomeElement')) if (@fsockopen('www.prestashop.com', 80, $errno, $errst, 3)) $result['discover_prestashop'] .= ''; - $content = @file_get_contents($protocol.'://www.prestashop.com/partner/paypal/paypal-tips.php?protocol='.$protocol.'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)$cookie->id_lang, false, $stream_context); + $content = @file_get_contents($protocol.'://www.prestashop.com/partner/paypal/paypal-tips.php?protocol='.$protocol.'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)Context::getContext()->language->id, false, $stream_context); $content = explode('|', $content); if ($content[0] == 'OK') $result['discover_prestashop'] .= $content[1]; @@ -696,7 +696,7 @@ if (Tools::isSubmit('getAdminHomeElement')) if (Tools::isSubmit('getChildrenCategories') && Tools::getValue('id_category_parent')) { - $children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat', array()), $cookie->id_lang); + $children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat', array()), Context::getContext()->language->id); die(Tools::jsonEncode($children_categories)); } diff --git a/admin-dev/ajax_products_list.php b/admin-dev/ajax_products_list.php index ed1e7d758..20d43734a 100644 --- a/admin-dev/ajax_products_list.php +++ b/admin-dev/ajax_products_list.php @@ -57,7 +57,7 @@ $items = Db::getInstance()->ExecuteS(' SELECT p.`id_product`, `reference`, pl.name FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product) -WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query).'%\') AND pl.id_lang = '.(int)($cookie->id_lang). +WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query).'%\') AND pl.id_lang = '.(int)Context::getContext()->language->id. (!empty($excludeIds) ? ' AND p.id_product NOT IN ('.$excludeIds.') ' : ' '). ($excludeVirtuals ? 'AND p.id_product NOT IN (SELECT pd.id_product FROM `'._DB_PREFIX_.'product_download` pd WHERE (pd.id_product = p.id_product))' : '')); diff --git a/admin-dev/backup.php b/admin-dev/backup.php index e23a63d30..c772df331 100644 --- a/admin-dev/backup.php +++ b/admin-dev/backup.php @@ -29,12 +29,10 @@ define('PS_ADMIN_DIR', getcwd()); include(PS_ADMIN_DIR.'/../config/config.inc.php'); -/* Header can't be included, so cookie must be created here */ -$cookie = new Cookie('psAdmin'); -if (!$cookie->id_employee) +if (!Context::getContext()->employee->isLoggedBack()) Tools::redirectAdmin('login.php'); -$tabAccess = Profile::getProfileAccess($cookie->profile, Tab::getIdFromClassName('AdminBackup')); +$tabAccess = Profile::getProfileAccess(Context::getContext()->employee->id_profile, Tab::getIdFromClassName('AdminBackup')); if ($tabAccess['view'] !== '1') die (Tools::displayError('You do not have permission to view here')); diff --git a/admin-dev/drawer.php b/admin-dev/drawer.php index af602d49f..38ca6ffae 100644 --- a/admin-dev/drawer.php +++ b/admin-dev/drawer.php @@ -27,7 +27,6 @@ define('PS_ADMIN_DIR', getcwd()); include_once(dirname(__FILE__).'/../config/config.inc.php'); -$cookie = new Cookie('psAdmin'); $module = Tools::getValue('module'); $render = Tools::getValue('render'); @@ -39,7 +38,7 @@ $height = Tools::getValue('height'); $id_employee = Tools::getValue('id_employee'); $id_lang = Tools::getValue('id_lang'); -if ($cookie->id_employee != $id_employee) +if (Context::getContext()->employee->id != $id_employee) die; if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php')) diff --git a/admin-dev/footer.inc.php b/admin-dev/footer.inc.php index 4342a81b0..0686d3734 100644 --- a/admin-dev/footer.inc.php +++ b/admin-dev/footer.inc.php @@ -34,7 +34,7 @@ echo ' '.translate('Load time:').' '.number_format(microtime(true) - $timerStart, 3, '.', '').'s
'; -if (strtoupper(Language::getIsoById($cookie->id_lang)) == 'FR') echo 'Questions / Renseignements / Formations : +33 (0)1.40.18.30.04 de 09h à 18h '; +if (strtoupper(Context::getContext()->language->iso_code) == 'FR') echo 'Questions / Renseignements / Formations : +33 (0)1.40.18.30.04 de 09h à 18h '; echo ' | '.translate('Contact').' | '.translate('Bug Tracker').' diff --git a/admin-dev/grider.php b/admin-dev/grider.php index 7d30d69b7..b0b384bb4 100644 --- a/admin-dev/grider.php +++ b/admin-dev/grider.php @@ -25,8 +25,8 @@ * International Registered Trademark & Property of PrestaShop SA */ +define('PS_ADMIN_DIR', getcwd()); include_once(dirname(__FILE__).'/../config/config.inc.php'); -$cookie = new Cookie('psAdmin'); $module = Tools::getValue('module'); $render = Tools::getValue('render'); @@ -41,7 +41,7 @@ $dir = Tools::getValue('dir', 0); // Should be a String : Either ASC or DESC $id_employee = (int)(Tools::getValue('id_employee')); $id_lang = (int)(Tools::getValue('id_lang')); -if ($cookie->id_employee != $id_employee) +if (Context::getContext()->employee->id != $id_employee) die; if (!Validate::isModuleName($module)) diff --git a/admin-dev/header.inc.php b/admin-dev/header.inc.php index 4ff47d2b6..07c867aaf 100644 --- a/admin-dev/header.inc.php +++ b/admin-dev/header.inc.php @@ -41,7 +41,7 @@ echo ' - + PrestaShop™ - '.translate('Administration panel').'