[*] BO : #PSFV-94 - added AdminGeolocationController, added options.tpl override
This commit is contained in:
@@ -1,187 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Open Software License (OSL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/osl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 6844 $
|
|
||||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*/
|
|
||||||
|
|
||||||
class AdminGeolocation extends AdminTab
|
|
||||||
{
|
|
||||||
public function display()
|
|
||||||
{
|
|
||||||
$this->context = Context::getContext();
|
|
||||||
echo '
|
|
||||||
<h2>'.$this->l('Geolocation').'</h2>
|
|
||||||
';
|
|
||||||
|
|
||||||
if (!$this->_isGeoLiteCityAvailable())
|
|
||||||
$this->displayWarning($this->l('In order to use Geolocation, please download').' <a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz">'.$this->l('this file').'</a> '.$this->l('and decompress it into tools/geoip/ directory'));
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<form method="POST" action="'.self::$currentIndex.'&token='.Tools::getValue('token').'">
|
|
||||||
<fieldset class="width3">
|
|
||||||
<legend><img src="../img/admin/world.gif" alt="" /> '.$this->l('Geolocation by IP').'</legend>
|
|
||||||
|
|
||||||
<label>'.$this->l('Geolocation by IP:').'</label>
|
|
||||||
<div class="margin-form">
|
|
||||||
<input type="radio" name="PS_GEOLOCATION_ENABLED" id="PS_GEOLOCATION_ENABLED_1" value="1" '.(Configuration::get('PS_GEOLOCATION_ENABLED') ? 'checked="checked"' : '').' /> <label class="t" for="PS_GEOLOCATION_ENABLED_1"><img src="../img/admin/enabled.gif" alt="" /> '.$this->l('Enabled').'</label>
|
|
||||||
<input type="radio" name="PS_GEOLOCATION_ENABLED" id="PS_GEOLOCATION_ENABLED_0" value="0" '.(!Configuration::get('PS_GEOLOCATION_ENABLED') ? 'checked="checked"' : '').' /> <label class="t" for="PS_GEOLOCATION_ENABLED_0"><img src="../img/admin/disabled.gif" alt="" /> '.$this->l('Disabled').'</label>
|
|
||||||
<p>'.$this->l('This option allows you, among other things, to restrict access to your shop for many countries. See below.').'</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="margin-form">
|
|
||||||
<input type="submit" class="button" name="submitGeolocationConfiguration" value="'.$this->l('Save').'" />
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
';
|
|
||||||
$allowedCountries = explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'));
|
|
||||||
echo '
|
|
||||||
<form method="POST" action="'.self::$currentIndex.'&token='.Tools::getValue('token').'">
|
|
||||||
<fieldset style="margin-top: 10px;" class="width3">
|
|
||||||
<legend><img src="../img/admin/world.gif" alt="" /> '.$this->l('Options').'</legend>
|
|
||||||
|
|
||||||
<div class="hint" style="display:block;margin-bottom:20px;">
|
|
||||||
'.$this->l('The following features are only available if you enable the Geolocation by IP feature.').'
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label>'.$this->l('Geolocation behavior for restricted countries:').'</label>
|
|
||||||
<div class="margin-form">
|
|
||||||
<select name="PS_GEOLOCATION_BEHAVIOR">
|
|
||||||
<option value="'._PS_GEOLOCATION_NO_CATALOG_.'" '.(Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ ? 'selected' : '').'>'.$this->l('Visitors can\'t see your catalog').'</option>
|
|
||||||
<option value="'._PS_GEOLOCATION_NO_ORDER_.'" '.(Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ ? 'selected' : '').'>'.$this->l('Visitors can see your catalog but can\'t make an order').'</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="clear" style="margin-top:10px;"></div>
|
|
||||||
|
|
||||||
<label>'.$this->l('Geolocation behavior for undefined countries:').'</label>
|
|
||||||
<div class="margin-form">
|
|
||||||
<select name="PS_GEOLOCATION_NA_BEHAVIOR">
|
|
||||||
<option value="-1" '.(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == -1 ? 'selected' : '').'>'.$this->l('All features are available').'</option>
|
|
||||||
<option value="'._PS_GEOLOCATION_NO_CATALOG_.'" '.(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ ? 'selected' : '').'>'.$this->l('Visitors can\'t see your catalog').'</option>
|
|
||||||
<option value="'._PS_GEOLOCATION_NO_ORDER_.'" '.(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ ? 'selected' : '').'>'.$this->l('Visitors can see your catalog but can\'t make an order').'</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="clear" style="margin-top:10px;"></div>
|
|
||||||
|
|
||||||
<label>'.$this->l('Select countries that can access your store:').'</label>
|
|
||||||
<div class="margin-form" style="float: left; padding-left: 0; width: 317px; margin-top: 6px; height: 300px; overflow-y: auto;">
|
|
||||||
<table class="table" cellspacing="0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th><input type="checkbox" name="checkAll" onclick="checkDelBoxes(this.form, \'countries[]\', this.checked)" /></th>
|
|
||||||
<th>'.$this->l('Name').'</th>
|
|
||||||
<tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
';
|
|
||||||
foreach (Country::getCountries($this->context->language->id) AS $country)
|
|
||||||
echo '
|
|
||||||
<tr>
|
|
||||||
<td><input type="checkbox" name="countries[]" value="'.strtoupper(Tools::htmlentitiesUTF8($country['iso_code'])).'" '.(in_array(strtoupper($country['iso_code']), $allowedCountries) ? 'checked="checked"' : '').' /></td>
|
|
||||||
<td>'.Tools::htmlentitiesUTF8($country['name']).'</td>
|
|
||||||
</tr>
|
|
||||||
';
|
|
||||||
echo '
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="clear"></div>
|
|
||||||
<br />
|
|
||||||
<div class="margin-form">
|
|
||||||
<input type="submit" class="button" name="submitGeolocationCountries" value="'.$this->l('Save').'" />
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form method="POST" action="'.self::$currentIndex.'&token='.Tools::getValue('token').'">
|
|
||||||
<fieldset style="margin-top: 10px;" class="width3">
|
|
||||||
<legend><img src="../img/admin/world.gif" alt="" /> '.$this->l('Whitelist of IP addresses').'</legend>
|
|
||||||
|
|
||||||
<div class="hint" style="display:block;margin-bottom:20px;">
|
|
||||||
'.$this->l('You can add many IP addresses, these addresses will always be allowed to access your shop (e.g. Google bots IP).').'
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label for="PS_GEOLOCATION_WHITELIST">'.$this->l('Allowed IP addresses:').'</label>
|
|
||||||
<div class="margin-form">
|
|
||||||
<textarea name="PS_GEOLOCATION_WHITELIST" id="PS_GEOLOCATION_WHITELIST" cols="80" rows="30">'.Tools::htmlentitiesUTF8(str_replace(';', "\n", Configuration::get('PS_GEOLOCATION_WHITELIST'))).'</textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="margin-form">
|
|
||||||
<input type="submit" class="button" name="submitGeolocationWhitelist" value="'.$this->l('Save').'" />
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postProcess()
|
|
||||||
{
|
|
||||||
if (Tools::isSubmit('submitGeolocationConfiguration'))
|
|
||||||
{
|
|
||||||
if ($this->_isGeoLiteCityAvailable())
|
|
||||||
{
|
|
||||||
Configuration::updateValue('PS_GEOLOCATION_ENABLED', intval(Tools::getValue('PS_GEOLOCATION_ENABLED')));
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('Geolocation database is unavailable.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tools::isSubmit('submitGeolocationCountries'))
|
|
||||||
{
|
|
||||||
if (!is_array(Tools::getValue('countries')) OR !sizeof(Tools::getValue('countries')))
|
|
||||||
$this->_errors[] = Tools::displayError('Country selection is invalid');
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Configuration::updateValue('PS_GEOLOCATION_BEHAVIOR', (!(int)(Tools::getValue('PS_GEOLOCATION_BEHAVIOR')) ? _PS_GEOLOCATION_NO_CATALOG_ : _PS_GEOLOCATION_NO_ORDER_));
|
|
||||||
Configuration::updateValue('PS_GEOLOCATION_NA_BEHAVIOR', (int)Tools::getValue('PS_GEOLOCATION_NA_BEHAVIOR'));
|
|
||||||
Configuration::updateValue('PS_ALLOWED_COUNTRIES', implode(';', Tools::getValue('countries')));
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tools::isSubmit('submitGeolocationWhitelist'))
|
|
||||||
{
|
|
||||||
if (!Validate::isCleanHtml(Tools::getValue('PS_GEOLOCATION_WHITELIST')))
|
|
||||||
$this->_errors[] = Tools::displayError('Invalid whitelist');
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Configuration::updateValue('PS_GEOLOCATION_WHITELIST', str_replace("\n", ';', str_replace("\r", '', Tools::getValue('PS_GEOLOCATION_WHITELIST'))));
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::postProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function _isGeoLiteCityAvailable()
|
|
||||||
{
|
|
||||||
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{foreach $categoryData['fields'] AS $key => $field}
|
{foreach $categoryData['fields'] AS $key => $field}
|
||||||
|
|
||||||
{if $field['type'] == 'hidden'}
|
{if $field['type'] == 'hidden'}
|
||||||
<input type="hidden" name="{$key}" value="{$field['value']}" />
|
<input type="hidden" name="{$key}" value="{$field['value']}" />
|
||||||
{else}
|
{else}
|
||||||
@@ -57,8 +58,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{$field['title']}</label>
|
{$field['title']}</label>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="margin-form">
|
{block name="start_field_block"}
|
||||||
|
<div class="margin-form">
|
||||||
|
{/block}
|
||||||
{if $field['type'] == 'select'}
|
{if $field['type'] == 'select'}
|
||||||
<select name="{$key}"{if isset($field['js'])} onchange="{$field['js']}"{/if} id="{$key}">
|
<select name="{$key}"{if isset($field['js'])} onchange="{$field['js']}"{/if} id="{$key}">
|
||||||
{foreach $field['list'] AS $k => $option}
|
{foreach $field['list'] AS $k => $option}
|
||||||
@@ -165,6 +167,7 @@
|
|||||||
{if isset($field['desc'])}<p class="preference_description">{$field['desc']}</p>{/if}
|
{if isset($field['desc'])}<p class="preference_description">{$field['desc']}</p>{/if}
|
||||||
{if $field['is_invisible']}<p class="multishop_warning">{l s='You can\'t change the value of this configuration field in this shop context'}</p>{/if}
|
{if $field['is_invisible']}<p class="multishop_warning">{l s='You can\'t change the value of this configuration field in this shop context'}</p>{/if}
|
||||||
</div></div>
|
</div></div>
|
||||||
|
{block name="end_field_block"}{/block}
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{if isset($categoryData['submit'])}
|
{if isset($categoryData['submit'])}
|
||||||
|
|||||||
@@ -1157,6 +1157,9 @@ class AdminControllerCore extends Controller
|
|||||||
if ($this->options && is_array($this->options))
|
if ($this->options && is_array($this->options))
|
||||||
{
|
{
|
||||||
$helper = new HelperOptions();
|
$helper = new HelperOptions();
|
||||||
|
// Check if form template has been overriden
|
||||||
|
if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'options.tpl'))
|
||||||
|
$helper->tpl = $this->tpl_folder.'options.tpl';
|
||||||
$helper->id = $this->id;
|
$helper->id = $this->id;
|
||||||
$helper->token = $this->token;
|
$helper->token = $this->token;
|
||||||
$helper->table = $this->table;
|
$helper->table = $this->table;
|
||||||
|
|||||||
@@ -48,6 +48,29 @@ class AdminCountriesControllerCore extends AdminController
|
|||||||
'dir' => 'st'
|
'dir' => 'st'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->options = array(
|
||||||
|
'general' => array(
|
||||||
|
'title' => $this->l('Countries options'),
|
||||||
|
'fields' => 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)
|
||||||
|
),
|
||||||
|
'PS_RESTRICT_DELIVERED_COUNTRIES' => array(
|
||||||
|
'title' => $this->l('Restrict countries in FO by those delivered by active carriers'),
|
||||||
|
'cast' => 'intval',
|
||||||
|
'type' => 'bool',
|
||||||
|
'default' => '0'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'submit' => array()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$this->fieldsDisplay = array(
|
$this->fieldsDisplay = array(
|
||||||
'id_country' => array(
|
'id_country' => array(
|
||||||
'title' => $this->l('ID'),
|
'title' => $this->l('ID'),
|
||||||
@@ -85,29 +108,6 @@ class AdminCountriesControllerCore extends AdminController
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->options = array(
|
|
||||||
'general' => array(
|
|
||||||
'title' => $this->l('Countries options'),
|
|
||||||
'fields' => 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)
|
|
||||||
),
|
|
||||||
'PS_RESTRICT_DELIVERED_COUNTRIES' => array(
|
|
||||||
'title' => $this->l('Restrict countries in FO by those delivered by active carriers'),
|
|
||||||
'cast' => 'intval',
|
|
||||||
'type' => 'bool',
|
|
||||||
'default' => '0'
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'submit' => array()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+146
@@ -0,0 +1,146 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Open Software License (OSL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/osl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision: 6844 $
|
||||||
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AdminGeolocationControllerCore extends AdminController
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->options = array(
|
||||||
|
'geolocationConfiguration' => array(
|
||||||
|
'title' => $this->l('Geolocation by IP:'),
|
||||||
|
'icon' => 'world',
|
||||||
|
'class' => 'width3',
|
||||||
|
'fields' => array(
|
||||||
|
'PS_GEOLOCATION_ENABLED' => array('title' => $this->l('Geolocation by IP:'), 'desc' => $this->l('This option allows you, among other things, to restrict access to your shop for many countries. See below.'), 'validation' => 'isUnsignedId', 'cast' => 'intval', 'type' => 'bool'),
|
||||||
|
),
|
||||||
|
'submit' => array(),
|
||||||
|
),
|
||||||
|
'geolocationCountries' => array(
|
||||||
|
'title' => $this->l('Options'),
|
||||||
|
'icon' => 'world',
|
||||||
|
'class' => 'width4',
|
||||||
|
'description' => $this->l('The following features are only available if you enable the Geolocation by IP feature.'),
|
||||||
|
'fields' => array(
|
||||||
|
'PS_GEOLOCATION_BEHAVIOR' => array(
|
||||||
|
'title' => $this->l('Geolocation behavior for restricted countries:'),
|
||||||
|
'type' => 'select',
|
||||||
|
'identifier' => 'key',
|
||||||
|
'list' => array(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'))),
|
||||||
|
),
|
||||||
|
'PS_GEOLOCATION_NA_BEHAVIOR' => array(
|
||||||
|
'title' => $this->l('Geolocation behavior for undefined countries:'),
|
||||||
|
'type' => 'select',
|
||||||
|
'identifier' => 'key',
|
||||||
|
'list' => array(array('key' => '-1', 'name' => $this->l('All features are available')),
|
||||||
|
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')))
|
||||||
|
),
|
||||||
|
'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)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'submit' => array(),
|
||||||
|
),
|
||||||
|
'geolocationWhitelist' => array(
|
||||||
|
'title' => $this->l('Whitelist of IP addresses'),
|
||||||
|
'icon' => 'world',
|
||||||
|
'class' => 'width3',
|
||||||
|
'description' => $this->l('You can add many IP addresses, these addresses will always be allowed to access your shop (e.g. Google bots IP).'),
|
||||||
|
'fields' => array(
|
||||||
|
'PS_GEOLOCATION_WHITELIST' => array('title' => $this->l('Allowed IP addresses:'), 'type' => 'textarea_newlines', 'cols' => 80, 'rows' => 30),
|
||||||
|
),
|
||||||
|
'submit' => array(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postProcess()
|
||||||
|
{
|
||||||
|
if (Tools::isSubmit('submitGeolocationConfiguration'))
|
||||||
|
{
|
||||||
|
if ($this->_isGeoLiteCityAvailable())
|
||||||
|
{
|
||||||
|
Configuration::updateValue('PS_GEOLOCATION_ENABLED', intval(Tools::getValue('PS_GEOLOCATION_ENABLED')));
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('Geolocation database is unavailable.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tools::isSubmit('submitGeolocationCountries'))
|
||||||
|
{
|
||||||
|
if (!is_array(Tools::getValue('countries')) OR !sizeof(Tools::getValue('countries')))
|
||||||
|
$this->_errors[] = Tools::displayError('Country selection is invalid');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Configuration::updateValue('PS_GEOLOCATION_BEHAVIOR', (!(int)(Tools::getValue('PS_GEOLOCATION_BEHAVIOR')) ? _PS_GEOLOCATION_NO_CATALOG_ : _PS_GEOLOCATION_NO_ORDER_));
|
||||||
|
Configuration::updateValue('PS_GEOLOCATION_NA_BEHAVIOR', (int)Tools::getValue('PS_GEOLOCATION_NA_BEHAVIOR'));
|
||||||
|
Configuration::updateValue('PS_ALLOWED_COUNTRIES', implode(';', Tools::getValue('countries')));
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tools::isSubmit('submitGeolocationWhitelist'))
|
||||||
|
{
|
||||||
|
if (!Validate::isCleanHtml(Tools::getValue('PS_GEOLOCATION_WHITELIST')))
|
||||||
|
$this->_errors[] = Tools::displayError('Invalid whitelist');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Configuration::updateValue('PS_GEOLOCATION_WHITELIST', str_replace("\n", ';', str_replace("\r", '', Tools::getValue('PS_GEOLOCATION_WHITELIST'))));
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::postProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initContent()
|
||||||
|
{
|
||||||
|
if (!$this->_isGeoLiteCityAvailable())
|
||||||
|
$this->displayWarning($this->l('In order to use Geolocation, please download').' <a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz">'.$this->l('this file').'</a> '.$this->l('and decompress it into tools/geoip/ directory'));
|
||||||
|
|
||||||
|
$this->context->smarty->assign(array(
|
||||||
|
'allowed_countries' => explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')),
|
||||||
|
'url_countries' => self::$currentIndex.'&token='.Tools::getValue('token'),
|
||||||
|
));
|
||||||
|
parent::initContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _isGeoLiteCityAvailable()
|
||||||
|
{
|
||||||
|
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user