// 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
+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);