// Context part 7

This commit is contained in:
tDidierjean
2011-07-15 13:59:26 +00:00
parent c8acd7a824
commit 6e93cc2848
24 changed files with 101 additions and 163 deletions
+12 -16
View File
@@ -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 '<script type="text/javascript">parent.parent.document.location.href = "'.addslashes(urldecode(Tools::getValue('changeParentUrl'))).'";</script>';
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'))
+1 -3
View File
@@ -37,13 +37,11 @@
$catalog = new AdminCatalog();
$adminProducts = new AdminProducts();
global $cookie;
echo ' <tr>
<td class="col-left"><label for="id_category_default" class="t">'.$adminProducts->getL('Default category:').'</label></td>
<td>
<select id="id_category_default" name="id_category_default" onchange="checkDefaultCategory(this.value);">';
$categories = Category::getCategories((int)($cookie->id_lang), false);
$categories = Category::getCategories(Context::getContext()->language->id, false);
Category::recurseCategory($categories, $categories[0][1], 1, (int)(Tools::getValue('id_category_default')));
echo ' </select>
</td>
+15 -21
View File
@@ -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 '<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/jquery-ui-1.8.10.custom.min.js"></script>';
$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 '<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/datepicker/ui/i18n/ui.datepicker-'.$iso.'.js"></script>';
echo '<script type="text/javascript">';
@@ -132,8 +131,7 @@ function displayDate($sqlDate, $withTime = false)
*/
function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryType = 'catalog', $home = false)
{
global $cookie;
$context = Context::getContext();
if ($categoryType == 'catalog')
{
$category = Db::getInstance()->getRow('
@@ -146,7 +144,7 @@ function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryT
SELECT c.id_category, cl.name, cl.link_rewrite
FROM '._DB_PREFIX_.'category c
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 cl.id_lang = '.(int)$cookie->id_lang.($home ? ' AND c.id_category='.$id_category : '').'
WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)$context->language->id.($home ? ' AND c.id_category='.$id_category : '').'
GROUP BY c.id_category
ORDER BY c.level_depth ASC
LIMIT '.(!$home ? (int)($category['level_depth'] + 1) : 1));
@@ -155,9 +153,9 @@ function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryT
$nCategories = (int)sizeof($categories);
foreach ($categories AS $category)
{
$edit = '<a href="'.$urlBase.'&id_category='.(int)$category['id_category'].'&'.(($category['id_category'] == 1 || $home) ? 'viewcategory' : 'addcategory').'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.($category['id_category'] == 1 ? 'Home' : 'Modify').'"><img src="../img/admin/'.(($category['id_category'] == 1 || $home) ? 'home' : 'edit').'.gif" alt="" /></a> ';
$edit = '<a href="'.$urlBase.'&id_category='.(int)$category['id_category'].'&'.(($category['id_category'] == 1 || $home) ? 'viewcategory' : 'addcategory').'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id).'" title="'.($category['id_category'] == 1 ? 'Home' : 'Modify').'"><img src="../img/admin/'.(($category['id_category'] == 1 || $home) ? 'home' : 'edit').'.gif" alt="" /></a> ';
$fullPath .= $edit.
($n < $nCategories ? '<a href="'.$urlBase.'&id_category='.(int)$category['id_category'].'&viewcategory&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'">' : '').
($n < $nCategories ? '<a href="'.$urlBase.'&id_category='.(int)$category['id_category'].'&viewcategory&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id).'" title="'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'">' : '').
(!empty($highlight) ? str_ireplace($highlight, '<span class="highlight">'.htmlentities($highlight, ENT_NOQUOTES, 'UTF-8').'</span>', $category['name']) : $category['name']).
($n < $nCategories ? '</a>' : '').
(($n++ != $nCategories OR !empty($path)) ? ' > ' : '');
@@ -168,17 +166,17 @@ function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryT
}
elseif ($categoryType == 'cms')
{
$category = new CMSCategory($id_category, (int)($cookie->id_lang));
$category = new CMSCategory($id_category, $context->language->id);
if (!$category->id)
return $path;
$name = ($highlight != NULL) ? str_ireplace($highlight, '<span class="highlight">'.$highlight.'</span>', CMSCategory::hideCMSCategoryPosition($category->name)) : CMSCategory::hideCMSCategoryPosition($category->name);
$edit = '<a href="'.$urlBase.'&id_cms_category='.$category->id.'&addcategory&token=' . Tools::getAdminToken('AdminCMSContent'.(int)(Tab::getIdFromClassName('AdminCMSContent')).(int)($cookie->id_employee)).'">
$edit = '<a href="'.$urlBase.'&id_cms_category='.$category->id.'&addcategory&token=' . Tools::getAdminToken('AdminCMSContent'.(int)(Tab::getIdFromClassName('AdminCMSContent')).(int)$context->employee->id).'">
<img src="../img/admin/edit.gif" alt="Modify" /></a> ';
if ($category->id == 1)
$edit = '<a href="'.$urlBase.'&id_cms_category='.$category->id.'&viewcategory&token=' . Tools::getAdminToken('AdminCMSContent'.(int)(Tab::getIdFromClassName('AdminCMSContent')).(int)($cookie->id_employee)).'">
$edit = '<a href="'.$urlBase.'&id_cms_category='.$category->id.'&viewcategory&token=' . Tools::getAdminToken('AdminCMSContent'.(int)(Tab::getIdFromClassName('AdminCMSContent')).(int)$context->employee->id).'">
<img src="../img/admin/home.gif" alt="Home" /></a> ';
$path = $edit.'<a href="'.$urlBase.'&id_cms_category='.$category->id.'&viewcategory&token=' . Tools::getAdminToken('AdminCMSContent'.(int)(Tab::getIdFromClassName('AdminCMSContent')).(int)($cookie->id_employee)).'">
$path = $edit.'<a href="'.$urlBase.'&id_cms_category='.$category->id.'&viewcategory&token=' . Tools::getAdminToken('AdminCMSContent'.(int)(Tab::getIdFromClassName('AdminCMSContent')).(int)$context->employee->id).'">
'.$name.'</a> > '.$path;
if ($category->id == 1)
return substr($path, 0, strlen($path) - 3);
@@ -225,14 +223,13 @@ function translate($string)
return str_replace('"', '&quot;', stripslashes($str));
}
function recursiveTab($id_tab)
function recursiveTab($id_tab, $tabs)
{
global $cookie, $tabs;
$adminTab = Tab::getTab((int)$cookie->id_lang, $id_tab);
$adminTab = Tab::getTab((int)Context::getContext()->language->id, $id_tab);
$tabs[]= $adminTab;
if ($adminTab['id_parent'] > 0)
recursiveTab($adminTab['id_parent']);
$tabs = recursiveTab($adminTab['id_parent'], $tabs);
return $tabs;
}
/**
@@ -243,8 +240,6 @@ function recursiveTab($id_tab)
*/
function checkingTab($tab)
{
global $cookie;
$tab = trim($tab);
if (!Validate::isTabName($tab))
return false;
@@ -268,7 +263,7 @@ function checkingTab($tab)
return false;
}
$adminObj = new $tab;
if (!$adminObj->viewAccess() AND ($adminObj->table != 'employee' OR $cookie->id_employee != Tools::getValue('id_employee') OR !Tools::isSubmit('updateemployee')))
if (!$adminObj->viewAccess() AND ($adminObj->table != 'employee' OR Context::getContext()->employee->id != Tools::getValue('id_employee') OR !Tools::isSubmit('updateemployee')))
{
$adminObj->_errors = array(Tools::displayError('Access denied'));
echo $adminObj->displayErrors();
@@ -279,11 +274,10 @@ function checkingTab($tab)
function checkTabRights($id_tab)
{
global $cookie;
static $tabAccesses = NULL;
if ($tabAccesses === NULL)
$tabAccesses = Profile::getProfileAccesses($cookie->profile);
$tabAccesses = Profile::getProfileAccesses(Context::getContext()->employee->id_profile);
if (isset($tabAccesses[(int)($id_tab)]['view']))
return ($tabAccesses[(int)($id_tab)]['view'] === '1');
+2 -2
View File
@@ -42,7 +42,7 @@ if (empty($tab) and !sizeof($_POST))
{
$isoUser = Language::getIsoById(intval($cookie->id_lang));
$tabs = array();
recursiveTab($adminObj->id);
$tabs = recursiveTab($adminObj->id, $tabs);
$tabs = array_reverse($tabs);
$bread = '';
@@ -116,7 +116,7 @@ if (empty($tab) and !sizeof($_POST))
}
elseif (strncmp($key, $adminObj->table.'OrderBy', 7) === 0 OR strncmp($key, $adminObj->table.'Orderway', 12) === 0)
$cookie->$key = $value;
$adminObj->smarty = $smarty;
$adminObj->displayConf();
$adminObj->postProcess();
$adminObj->displayErrors();
+1 -1
View File
@@ -94,5 +94,5 @@ $context->cookie = $cookie;
$context->link = $link;
$context->language = $language;
$context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$context->country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'));
$context->country = $defaultCountry;
$context->shop = new Shop(Shop::getContext('shop', true));
-6
View File
@@ -43,12 +43,9 @@ class AdminAttributes extends AdminTab
/**
* Display form
*
* @global string $currentIndex Current URL in order to keep current Tab
*/
public function displayForm($token = NULL)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
@@ -127,12 +124,9 @@ class AdminAttributes extends AdminTab
/**
* Manage page processing
*
* @global string $currentIndex Current URL in order to keep current Tab
*/
public function postProcess($token = NULL)
{
global $currentIndex;
if (Tools::getValue('submitDel'.$this->table))
{
if ($this->tabAccess['delete'] === '1')
+3 -10
View File
@@ -50,8 +50,6 @@ class AdminAttributesGroups extends AdminTab
public function display()
{
global $currentIndex;
if ((isset($_POST['submitAddattribute']) AND sizeof($this->adminAttributes->_errors))
OR isset($_GET['updateattribute']) OR isset($_GET['addattribute']))
{
@@ -66,10 +64,8 @@ class AdminAttributesGroups extends AdminTab
}
public function postProcess()
{
global $cookie, $currentIndex;
$this->adminAttributes->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
{
$this->adminAttributes->tabAccess = Profile::getProfileAccess(Context::getContext()->employee->id_profile, $this->id);
$this->adminAttributes->postProcess($this->token);
if(Tools::getValue('submitDel'.$this->table))
@@ -102,8 +98,6 @@ class AdminAttributesGroups extends AdminTab
/* Report to AdminTab::displayList() for more details */
public function displayList()
{
global $currentIndex, $cookie;
echo '<br /><a href="'.self::$currentIndex.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> <b>'.$this->l('Add attributes group').'</b></a><br />
<a href="'.self::$currentIndex.'&addattribute&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add attribute').'</a><br /><br />
'.$this->l('Click on the group name to view its attributes. Click again to hide them.').'<br /><br />';
@@ -132,7 +126,7 @@ class AdminAttributesGroups extends AdminTab
<th width="100%">'.$this->l('Attribute').'</th>
<th>'.$this->l('Actions').'</th>
</tr>';
$attributes = AttributeGroup::getAttributes((int)($cookie->id_lang), $id);
$attributes = AttributeGroup::getAttributes(Context::getContext()->language->id, $id);
foreach ($attributes AS $attribute)
{
echo '
@@ -173,7 +167,6 @@ class AdminAttributesGroups extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
+3 -9
View File
@@ -111,8 +111,6 @@ class AdminBackup extends AdminTab
*/
public function viewbackup()
{
global $currentIndex;
if (!($object = $this->loadObject()))
return;
if ($object->id)
@@ -131,8 +129,6 @@ class AdminBackup extends AdminTab
public function displayHowTo($showForm = true)
{
global $currentIndex;
echo '
<div class="error width1" style="float: left; margin-right: 10px;">
<p>'.$this->l('Disclaimer before creating a new Backup').'</p>
@@ -176,8 +172,6 @@ class AdminBackup extends AdminTab
public function displayList()
{
global $currentIndex;
// Test if the backup dir is writable
if(!is_writable(PS_ADMIN_DIR.'/backups/'))
$this->displayWarning($this->l('"Backups" Directory in admin directory must be writeable (CHMOD 755 / 777)'));
@@ -190,7 +184,7 @@ class AdminBackup extends AdminTab
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = NULL)
{
global $cookie;
$context = Context::getContext();
if (!Validate::isTableOrIdentifier($this->table))
die('filter is corrupted');
@@ -223,9 +217,9 @@ class AdminBackup extends AdminTab
$orderWay = 'desc';
}
if (empty($limit))
$limit = ((!isset($cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $cookie->{$this->table.'_pagination'});
$limit = ((!isset($context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $context->cookie->{$this->table.'_pagination'});
$limit = (int)(Tools::getValue('pagination', $limit));
$cookie->{$this->table.'_pagination'} = $limit;
$context->cookie->{$this->table.'_pagination'} = $limit;
/* Determine offset from current page */
if (!empty($_POST['submitFilter'.$this->table]) AND is_numeric($_POST['submitFilter'.$this->table]))
+12 -18
View File
@@ -75,11 +75,10 @@ class AdminCMS extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
$context = Context::getContext();
parent::displayForm();
$obj = $this->loadObject(true);
$iso = Language::getIsoById((int)($cookie->id_lang));
$divLangName = 'meta_title¤meta_description¤meta_keywords¤ccontent¤link_rewrite';
echo '
@@ -92,7 +91,7 @@ class AdminCMS extends AdminTab
echo '<label>'.$this->l('CMS Category:').' </label>
<div class="margin-form">
<select name="id_cms_category">';
$categories = CMSCategory::getCategories((int)($cookie->id_lang), false);
$categories = CMSCategory::getCategories($context->language->id, false);
CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_cms_category'));
echo '
</select>
@@ -168,9 +167,7 @@ class AdminCMS extends AdminTab
'.$this->_displayDraftWarning($obj->active).'
</form>';
// TinyMCE
global $cookie;
$iso = Language::getIsoById((int)($cookie->id_lang));
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en');
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$context->language->iso_code.'.js') ? $context->language->iso_code : 'en');
$ad = dirname($_SERVER["PHP_SELF"]);
echo '
<script type="text/javascript">
@@ -184,12 +181,12 @@ class AdminCMS extends AdminTab
public function display($token = NULL)
{
global $currentIndex, $cookie;
$context = Context::getContext();
if (($id_cms_category = (int)Tools::getValue('id_cms_category')))
$currentIndex .= '&id_cms_category='.$id_cms_category;
$this->getList((int)($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$cookie->__get($this->table.'Orderway') ? 'ASC' : NULL);
//$this->getList((int)($cookie->id_lang));
$this->getList($context->language->id, !$context->cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$context->cookie->__get($this->table.'Orderway') ? 'ASC' : NULL);
if (!$id_cms_category)
$id_cms_category = 1;
echo '<h3>'.(!$this->_listTotal ? ($this->l('No pages found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('pages') : $this->l('page')))).' '.
@@ -201,9 +198,7 @@ class AdminCMS extends AdminTab
}
public function displayList($token = NULL)
{
global $currentIndex;
{
/* Display list header (filtering, pagination and column names) */
$this->displayListHeader($token);
if (!sizeof($this->_list))
@@ -218,11 +213,10 @@ class AdminCMS extends AdminTab
function postProcess()
{
global $cookie, $link, $currentIndex;
if (Tools::isSubmit('viewcms') AND ($id_cms = (int)(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, (int)($cookie->id_lang)) AND Validate::isLoadedObject($cms))
$context = Context::getContext();
if (Tools::isSubmit('viewcms') AND ($id_cms = (int)(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, $context->language->id) AND Validate::isLoadedObject($cms))
{
$redir = $link->getCMSLink($cms);
$redir = $context->link->getCMSLink($cms);
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
@@ -282,7 +276,7 @@ class AdminCMS extends AdminTab
$this->_errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.' ('.mysql_error().')</b>';
elseif (Tools::isSubmit('submitAddcmsAndPreview'))
{
$preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int)($cookie->id_lang));
$preview_url = $context->link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), $context->language->id);
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
@@ -304,7 +298,7 @@ class AdminCMS extends AdminTab
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.' ('.mysql_error().')</b>';
elseif (Tools::isSubmit('submitAddcmsAndPreview'))
{
$preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int)($cookie->id_lang));
$preview_url = $context->link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), $context->language->id);
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
+1 -7
View File
@@ -33,8 +33,6 @@ class AdminCarriers extends AdminTab
public function __construct()
{
global $cookie;
$this->table = 'carrier';
$this->className = 'Carrier';
$this->lang = true;
@@ -82,12 +80,10 @@ class AdminCarriers extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$currentLanguage = (int)($cookie->id_lang);
echo '<script type="text/javascript">
$(document).ready(function(){
@@ -139,7 +135,7 @@ class AdminCarriers extends AdminTab
</div>
<label>'.$this->l('Group access').'</label>
<div class="margin-form">';
$groups = Group::getGroups((int)($cookie->id_lang));
$groups = Group::getGroups(Context::getContext()->language->id));
if (sizeof($groups))
{
echo '
@@ -274,8 +270,6 @@ class AdminCarriers extends AdminTab
public function postProcess()
{
global $currentIndex;
if (Tools::getValue('submitAdd'.$this->table))
{
/* Checking fields validity */
+9 -16
View File
@@ -58,10 +58,9 @@ class AdminCarts extends AdminTab
public function viewDetails()
{
global $currentIndex, $cookie;
if (!($cart = $this->loadObject(true)))
return;
$context = Context::getContext();
$customer = new Customer($cart->id_customer);
$customerStats = $customer->getStats();
$products = $cart->getProducts();
@@ -69,9 +68,7 @@ class AdminCarts extends AdminTab
Product::addCustomizationPrice($products, $customizedDatas);
$summary = $cart->getSummaryDetails();
$discounts = $cart->getDiscounts();
$currency = new Currency($cart->id_currency);
$currentLanguage = new Language((int)($cookie->id_lang));
// display cart header
echo '<h2>'.(($customer->id) ? $customer->firstname.' '.$customer->lastname : $this->l('Guest')).' - '.$this->l('Cart #').sprintf('%06d', $cart->id).' '.$this->l('from').' '.$cart->date_upd.'</h2>';
@@ -85,9 +82,9 @@ class AdminCarts extends AdminTab
<span style="font-weight: bold; font-size: 14px;">';
if ($customer->id)
echo '
<a href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee)).'"> '.$customer->firstname.' '.$customer->lastname.'</a></span> ('.$this->l('#').$customer->id.')<br />
<a href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$context->employee->id).'"> '.$customer->firstname.' '.$customer->lastname.'</a></span> ('.$this->l('#').$customer->id.')<br />
(<a href="mailto:'.$customer->email.'">'.$customer->email.'</a>)<br /><br />
'.$this->l('Account registered:').' '.Tools::displayDate($customer->date_add, (int)($cookie->id_lang), true).'<br />
'.$this->l('Account registered:').' '.Tools::displayDate($customer->date_add, $context->language->id, true).'<br />
'.$this->l('Valid orders placed:').' <b>'.$customerStats['nb_orders'].'</b><br />
'.$this->l('Total paid since registration:').' <b>'.Tools::displayPrice($customerStats['total_orders'], $currency, false).'</b><br />';
else
@@ -122,9 +119,9 @@ class AdminCarts extends AdminTab
<span style="font-weight: bold; font-size: 14px;">';
if ($order->id)
echo '
<a href="?tab=AdminOrders&id_order='.(int)($order->id).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)).'"> '.$this->l('Order #').sprintf('%06d', $order->id).'</a></span>
<a href="?tab=AdminOrders&id_order='.(int)($order->id).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$context->employee->id).'"> '.$this->l('Order #').sprintf('%06d', $order->id).'</a></span>
<br /><br />
'.$this->l('Made on:').' '.Tools::displayDate($order->date_add, (int)$cookie->id_lang, true).'<br /><br /><br /><br />';
'.$this->l('Made on:').' '.Tools::displayDate($order->date_add, $context->language->id, true).'<br /><br /><br /><br />';
else
echo $this->l('No order created from this cart').'</span>';
echo '</fieldset>';
@@ -147,7 +144,7 @@ class AdminCarts extends AdminTab
<th style="width: 30px; text-align: center">'.$this->l('Stock').'</th>
<th style="width: 90px; text-align: right; font-weight:bold;">'.$this->l('Total').'</th>
</tr>';
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee));
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id);
foreach ($products as $k => $product)
{
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
@@ -238,7 +235,7 @@ class AdminCarts extends AdminTab
foreach ($discounts as $discount)
echo '
<tr>
<td><a href="?tab=AdminDiscounts&id_discount='.$discount['id_discount'].'&updatediscount&token='.Tools::getAdminToken('AdminDiscounts'.(int)(Tab::getIdFromClassName('AdminDiscounts')).(int)($cookie->id_employee)).'">'.$discount['name'].'</a></td>
<td><a href="?tab=AdminDiscounts&id_discount='.$discount['id_discount'].'&updatediscount&token='.Tools::getAdminToken('AdminDiscounts'.(int)(Tab::getIdFromClassName('AdminDiscounts')).(int)$context->employee->id).'">'.$discount['name'].'</a></td>
<td align="center">- '.Tools::displayPrice($discount['value_real'], $currency, false).'</td>
</tr>';
echo '
@@ -312,21 +309,17 @@ class AdminCarts extends AdminTab
public function display()
{
global $cookie;
if (isset($_GET['view'.$this->table]))
$this->viewDetails();
else
{
$this->getList((int)($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
$this->getList(Context::getContext()->language->id, !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
$this->displayList();
}
}
protected function _displayDeleteLink($token = NULL, $id)
{
global $currentIndex;
{
foreach ($this->_list as $cart)
if ($id == $cart['id_cart'])
if ($cart['id_order'])
+2 -4
View File
@@ -136,8 +136,6 @@ class AdminCatalog extends AdminTab
public function display()
{
global $currentIndex;
if (((Tools::isSubmit('submitAddcategory') OR Tools::isSubmit('submitAddcategoryAndStay')) AND sizeof($this->adminCategories->_errors)) OR isset($_GET['updatecategory']) OR isset($_GET['addcategory']))
{
$this->adminCategories->displayForm($this->token);
@@ -180,10 +178,10 @@ class AdminCatalog extends AdminTab
}
$catalog_tabs = array('category', 'product');
// Cleaning links
$catBarIndex = $currentIndex;
$catBarIndex = self::$currentIndex;
foreach ($catalog_tabs AS $tab)
if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway'))
$catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', $currentIndex);
$catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex);
echo '<div class="cat_bar"><span style="color: #3C8534;">'.$this->l('Current category').' :</span>&nbsp;&nbsp;&nbsp;'.getPath($catBarIndex, $id_category, '', '', 'catalog', $home).'</div>';
echo '<h2>'.$this->l('Categories').'</h2>';
-1
View File
@@ -58,7 +58,6 @@ class AdminContacts extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
+1 -4
View File
@@ -31,8 +31,6 @@ class AdminCountries extends AdminTab
{
public function __construct()
{
global $cookie;
$this->table = 'country';
$this->className = 'Country';
$this->lang = true;
@@ -50,7 +48,7 @@ class AdminCountries extends AdminTab
'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'));
$this->optionTitle = $this->l('Countries options');
$this->_fieldsOptions = array('PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries((int)($cookie->id_lang))));
$this->_fieldsOptions = array('PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries(Context::getContext()->language->id)));
parent::__construct();
}
@@ -126,7 +124,6 @@ class AdminCountries extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
$defaultLayout = '';
-5
View File
@@ -65,8 +65,6 @@ class AdminCurrencies extends AdminTab
public function postProcess()
{
global $currentIndex;
if (isset($_GET['delete'.$this->table]))
{
if ($this->tabAccess['delete'] === '1')
@@ -126,8 +124,6 @@ class AdminCurrencies extends AdminTab
public function displayOptionsList()
{
global $currentIndex;
parent::displayOptionsList();
echo '<br /><br />
<form action="'.self::$currentIndex.'&token='.$this->token.'" method="post">
@@ -146,7 +142,6 @@ class AdminCurrencies extends AdminTab
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
-3
View File
@@ -45,8 +45,6 @@ class AdminDb extends AdminPreferences
public function postProcess()
{
global $currentIndex;
if (isset($_POST['submitDatabase'.$this->table]))
{
if ($this->tabAccess['edit'] === '1')
@@ -101,7 +99,6 @@ class AdminDb extends AdminPreferences
public function display()
{
global $currentIndex;
echo $this->displayWarning($this->l('Be VERY CAREFUL with these settings, as changes may cause your PrestaShop online store to malfunction. For all issues, check the config/settings.inc.php file.')).'<br />';
$this->_displayForm('database', $this->_fieldsDatabase, $this->l('Database'), 'width2', 'database_gear');
$engines = $this->_getEngines();
+4 -8
View File
@@ -148,15 +148,13 @@ class AdminHome extends AdminTab
}
public function display()
{
global $cookie;
$context = Context::getContext();
$this->warnDomainName();
$tab = get_class();
$protocol = (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')?'https':'http';
$isoDefault = Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT')));
$isoUser = Language::getIsoById(intval($cookie->id_lang));
$isoCountry = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
$isoUser = $context->language->iso_code;
$currency = $context->currency;
echo '<div>
<h1>'.$this->l('Dashboard').'</h1>
<hr style="background-color: #812143;color: #812143;" />
@@ -172,9 +170,7 @@ class AdminHome extends AdminTab
}
echo '</div>';
if (!isset($cookie->show_screencast))
$cookie->show_screencast = true;
if ($cookie->show_screencast)
if ($context->employee->show_screencast)
echo'
<div id="adminpresentation">
<iframe src="'.$protocol.'://screencasts.prestashop.com/screencast.php?iso_lang='.Tools::strtolower($isoUser).'" style="border:none;width:100%;height:420px;" scrolling="no"></iframe>
+2 -4
View File
@@ -169,18 +169,16 @@ class AdminPreferences extends AdminTab
*/
protected function _postConfig($fields)
{
global $smarty;
$languages = Language::getLanguages(false);
if (!Configuration::get('PS_FORCE_SMARTY_2'))
{
$files = scandir(_PS_THEME_DIR_);
foreach ($files AS $file)
if (!preg_match('/^\..*/', $file))
$smarty->clearCache($file);
$this->smarty->clearCache($file);
}
else
$smarty->clear_all_cache();
$this->smarty->clear_all_cache();
/* Check required fields */
foreach ($fields AS $field => $values)
+5 -6
View File
@@ -142,6 +142,8 @@ abstract class AdminTabCore
public $specificConfirmDelete = NULL;
public static $currentIndex;
public $smarty;
protected $identifiersDnd = array('id_product' => 'id_product', 'id_category' => 'id_category_to_move','id_cms_category' => 'id_cms_category_to_move', 'id_cms' => 'id_cms');
@@ -1591,7 +1593,6 @@ abstract class AdminTabCore
}
}
protected function _displayEnableLink($token, $id, $value, $active, $id_category = NULL, $id_product = NULL)
{
echo '<a href="'.self::$currentIndex.'&'.$this->identifier.'='.$id.'&'.$active.$this->table.
@@ -1600,7 +1601,7 @@ abstract class AdminTabCore
alt="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" title="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" /></a>';
}
protected function _displayDuplicate($token = NULL, $id)
protected function _displayDuplicate($token = NULL, $id)
{
$_cacheLang['Duplicate'] = $this->l('Duplicate');
$_cacheLang['Copy images too?'] = $this->l('Copy images too?', __CLASS__, TRUE, FALSE);
@@ -1664,15 +1665,13 @@ abstract class AdminTabCore
*/
public function displayOptionsList()
{
global $tab;
$context = Context::getContext();
if (!isset($this->_fieldsOptions) OR !sizeof($this->_fieldsOptions))
return false;
$defaultLanguage = (int)Configuration::get('PS_LANG_DEFAULT');
$defaultLanguage = (int)$context->language->id;
$this->_languages = Language::getLanguages(false);
$tab = Tab::getTab($context->language->id, Tab::getIdFromClassName($tab));
$tab = Tab::getTab($defaultLanguage, $this->id);
echo '<br /><br />';
echo (isset($this->optionTitle) ? '<h2>'.$this->optionTitle.'</h2>' : '');
echo '
+6 -1
View File
@@ -65,10 +65,14 @@ class EmployeeCore extends ObjectModel
/** @var boolean Status */
public $active = 1;
/** @var boolean show screencast */
public $show_screencast = 1;
protected $fieldsRequired = array('lastname', 'firstname', 'email', 'passwd', 'id_profile', 'id_lang');
protected $fieldsSize = array('lastname' => 32, 'firstname' => 32, 'email' => 128, 'passwd' => 32, 'bo_color' => 32, 'bo_theme' => 32);
protected $fieldsValidate = array('lastname' => 'isName', 'firstname' => 'isName', 'email' => 'isEmail', 'id_lang' => 'isUnsignedInt',
'passwd' => 'isPasswdAdmin', 'active' => 'isBool', 'id_profile' => 'isInt', 'bo_color' => 'isColor', 'bo_theme' => 'isGenericName', 'bo_uimode' => 'isGenericName');
'passwd' => 'isPasswdAdmin', 'active' => 'isBool', 'id_profile' => 'isInt', 'bo_color' => 'isColor', 'bo_theme' => 'isGenericName',
'bo_uimode' => 'isGenericName', 'show_screencast' => 'isBool');
protected $table = 'employee';
protected $identifier = 'id_employee';
@@ -108,6 +112,7 @@ class EmployeeCore extends ObjectModel
$fields['bo_theme'] = pSQL($this->bo_theme);
$fields['bo_uimode'] = pSQL($this->bo_uimode);
$fields['active'] = (int)$this->active;
$fields['show_screencast'] = (int)$this->show_screencast;
return $fields;
}
+19 -17
View File
@@ -104,8 +104,6 @@ class FrontControllerCore
if ($this->auth AND !$cookie->isLogged($this->guestAllowed))
Tools::redirect('index.php?controller=authentication'.($this->authRedirection ? '&back='.$this->authRedirection : ''));
/* Loading default country */
$defaultCountry = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
/* Theme is missing or maintenance */
if (!is_dir(_PS_THEME_DIR_))
die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
@@ -399,7 +397,7 @@ class FrontControllerCore
/* Check if Maxmind Database exists */
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
{
if (!isset($context->country->iso_code) OR (isset($context->country->iso_code) AND !in_array(strtoupper($context->country->iso_code), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))))
if (!isset($context->cookie->iso_code_country) OR (isset($context->cookie->iso_code_country) AND !in_array(strtoupper($context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))))
{
include_once(_PS_GEOIP_DIR_.'geoipcity.inc');
include_once(_PS_GEOIP_DIR_.'geoipregionvars.php');
@@ -407,24 +405,28 @@ class FrontControllerCore
$gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, Tools::getRemoteAddr());
if (is_object($record) AND !in_array(strtoupper($record->country_code), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) AND !self::isInWhitelistForGeolocation())
if (is_object($record))
{
if (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_)
$this->restrictedCountry = true;
elseif (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_)
$this->smarty->assign(array(
'restricted_country_mode' => true,
'geolocation_country' => $record->country_name
));
}
elseif (is_object($record))
{
$context->country->iso_code = strtoupper($record->country_code);
$hasBeenSet = true;
if (!in_array(strtoupper($record->country_code), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) AND !self::isInWhitelistForGeolocation())
{
if (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_)
$this->restrictedCountry = true;
elseif (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_)
$this->smarty->assign(array(
'restricted_country_mode' => true,
'geolocation_country' => $record->country_name
));
}
else
{
$context->cookie->iso_code_country = strtoupper($record->country_code);
$hasBeenSet = true;
}
}
}
if (isset($context->country->iso_code) AND (int)($id_country = Country::getByIso(strtoupper($context->cookie->iso_code_country))))
if (isset($context->cookie->iso_code_country)
&& (int)($id_country = Country::getByIso(strtoupper($context->cookie->iso_code_country))))
{
/* Update defaultCountry */
$defaultCountry = new Country($id_country);
-1
View File
@@ -114,7 +114,6 @@ Configuration::loadConfiguration();
Language::loadLanguages();
/* Loading default country */
global $defaultCountry;
$defaultCountry = new Country((int)(Configuration::get('PS_COUNTRY_DEFAULT')), Configuration::get('PS_LANG_DEFAULT'));
/* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
+1
View File
@@ -608,6 +608,7 @@ CREATE TABLE `PREFIX_employee` (
`bo_theme` varchar(32) default NULL,
`bo_uimode` ENUM('hover','click') default 'click',
`active` tinyint(1) unsigned NOT NULL default '0',
`show_screencast` tinyint(1) unsigned NOT NULL default '1',
PRIMARY KEY (`id_employee`),
KEY `employee_login` (`email`,`passwd`),
KEY `id_employee_passwd` (`id_employee`,`passwd`),
+2
View File
@@ -300,4 +300,6 @@ CREATE TABLE `PREFIX_referrer_shop` (
INSERT INTO `PREFIX_referrer_shop` (`id_referrer`, `id_shop`) SELECT `id_referrer`, 1 FROM `PREFIX_referrer`;
ALTER TABLE `PREFIX_referrer` DROP `cache_visitors`, DROP `cache_visits`, DROP `cache_pages`, DROP `cache_registrations`, DROP `cache_orders`, DROP `cache_sales`, DROP `cache_reg_rate`, DROP `cache_order_rate`;
ALTER TABLE PREFIX_employee ADD `show_screencast` tinyint(1) unsigned NOT NULL default '1';
/* PHP:create_multistore(); */