// Fix error with AdminGeolocation trying to process serialized countries

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13966 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean committed 2012-03-08 13:33:16 +00:00
1 parent 60a6855ec8
commit edc36a2294
1 file changed
+14 -17
@@ -65,13 +65,6 @@ class AdminGeolocationControllerCore extends AdminController
array('key' => _PS_GEOLOCATION_NO_CATALOG_, 'name' => $this->l('Visitors can\'t see your catalog')), array('key' => _PS_GEOLOCATION_NO_CATALOG_, 'name' => $this->l('Visitors can\'t see your catalog')),
array('key' => _PS_GEOLOCATION_NO_ORDER_, 'name' => $this->l('Visitors can see your catalog but can\'t make an order'))) array('key' => _PS_GEOLOCATION_NO_ORDER_, 'name' => $this->l('Visitors can see your catalog but can\'t make an order')))
), ),
'countries' => array(
'title' => $this->l('Select countries that can access your store:'),
'type' => 'checkbox_table',
'identifier' => 'iso_code',
'list' => Country::getCountries($this->context->language->id),
'auto_value' => false
),
), ),
), ),
'geolocationWhitelist' => array( 'geolocationWhitelist' => array(
@@ -91,15 +84,14 @@ class AdminGeolocationControllerCore extends AdminController
*/ */
public function processUpdateOptions($token) public function processUpdateOptions($token)
{ {
$redirectAdmin = false;
if ($this->isGeoLiteCityAvailable()) if ($this->isGeoLiteCityAvailable())
{
Configuration::updateValue('PS_GEOLOCATION_ENABLED', intval(Tools::getValue('PS_GEOLOCATION_ENABLED'))); Configuration::updateValue('PS_GEOLOCATION_ENABLED', intval(Tools::getValue('PS_GEOLOCATION_ENABLED')));
$redirectAdmin = true; // stop processing if geolocation is set to yes but geolite pack is not available
} elseif (Tools::getValue('PS_GEOLOCATION_ENABLED'))
else
$this->errors[] = Tools::displayError('Geolocation database is unavailable.'); $this->errors[] = Tools::displayError('Geolocation database is unavailable.');
if (empty($this->errors))
{
if (!is_array(Tools::getValue('countries')) || !count(Tools::getValue('countries'))) if (!is_array(Tools::getValue('countries')) || !count(Tools::getValue('countries')))
$this->errors[] = Tools::displayError('Country selection is invalid'); $this->errors[] = Tools::displayError('Country selection is invalid');
else else
@@ -110,7 +102,6 @@ class AdminGeolocationControllerCore extends AdminController
); );
Configuration::updateValue('PS_GEOLOCATION_NA_BEHAVIOR', (int)Tools::getValue('PS_GEOLOCATION_NA_BEHAVIOR')); Configuration::updateValue('PS_GEOLOCATION_NA_BEHAVIOR', (int)Tools::getValue('PS_GEOLOCATION_NA_BEHAVIOR'));
Configuration::updateValue('PS_ALLOWED_COUNTRIES', implode(';', Tools::getValue('countries'))); Configuration::updateValue('PS_ALLOWED_COUNTRIES', implode(';', Tools::getValue('countries')));
$redirectAdmin = true;
} }
if (!Validate::isCleanHtml(Tools::getValue('PS_GEOLOCATION_WHITELIST'))) if (!Validate::isCleanHtml(Tools::getValue('PS_GEOLOCATION_WHITELIST')))
@@ -121,17 +112,23 @@ class AdminGeolocationControllerCore extends AdminController
'PS_GEOLOCATION_WHITELIST', 'PS_GEOLOCATION_WHITELIST',
str_replace("\n", ';', str_replace("\r", '', Tools::getValue('PS_GEOLOCATION_WHITELIST'))) str_replace("\n", ';', str_replace("\r", '', Tools::getValue('PS_GEOLOCATION_WHITELIST')))
); );
$redirectAdmin = true;
} }
}
if ($redirectAdmin)
$this->redirect_after = self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4';
return parent::processUpdateOptions($token); return parent::processUpdateOptions($token);
} }
public function renderOptions() public function renderOptions()
{ {
// This field is not declared in class constructor because we want it to be manually post processed
$this->options['geolocationCountries']['fields']['countries'] = array(
'title' => $this->l('Select countries that can access your store:'),
'type' => 'checkbox_table',
'identifier' => 'iso_code',
'list' => Country::getCountries($this->context->language->id),
'auto_value' => false
);
$this->tpl_option_vars = array('allowed_countries' => explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))); $this->tpl_option_vars = array('allowed_countries' => explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')));
return parent::renderOptions(); return parent::renderOptions();