[*] BO #PSFV-94 : Added AdminPreferencesController

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9719 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vChabot
2011-10-28 14:08:07 +00:00
parent 6b32d53742
commit 9a616a7f3f
3 changed files with 69 additions and 44 deletions
@@ -0,0 +1,53 @@
{*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 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/afl-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: 9540 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file="../options.tpl"}
{block name="start_field_block"}
{if $field['type'] == 'price'}
<div class="margin-form">
{$field['currency_left']}
<input type="text"{if isset($field['id']) } id="{$field['id']}"{/if} size="{if isset($field['size'])}{$field['size']|intval}{else} 5{/if}" name="{$key}" value="{$field['value']|escape:'htmlall':'UTF-8'}" />
{if isset($field['next'])} &nbsp; {$field['next']|strval}{/if}
{$field['currency_right']}
{elseif $field['type'] == 'disabled'}
<div class="margin-form">
{$field['disabled']}
{elseif $field['type'] == 'maintenance_ip'}
<div class="margin-form">
{$field['script_ip']}
<input type="text"{if isset($field['id']) } id="{$field['id']}"{/if} size="{if isset($field['size'])}{$field['size']|intval}{else} 5{/if}" name="{$key}" value="{$field['value']|escape:'htmlall':'UTF-8'}" />
{$field['link_remove_ip']}
{else}
<div class="margin-form">
{/if}
{/block}
{block name="end_field_block"}
{if $field['type'] == 'checkbox_table'}
<div class="clear"></div>
<br />
{/if}
{/block}
+2
View File
@@ -122,6 +122,8 @@ class HelperOptionsCore extends Helper
}
</script>';
$field['link_remove_ip'] = ' &nbsp<a href="#" class="button" onclick="addRemoteAddr(); return false;">'.$this->l('Add my IP').'</a>';
if (!isset($category_data['bottom']))
$category_data['bottom'] = '<script type="text/javascript">changeCMSActivationAuthorization();</script>';
} else if ($field['type'] == 'price')
{
$field['currency_left'] = $this->context->currency->getSign('left');
@@ -25,8 +25,9 @@
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminPreferences extends AdminTab
class AdminPreferencesControllerCore extends AdminController
{
public function __construct()
{
$this->context = Context::getContext();
@@ -34,7 +35,7 @@ class AdminPreferences extends AdminTab
$this->table = 'configuration';
// Prevent classes which extend AdminPreferences to load useless data
if (get_class($this) == 'AdminPreferences')
if (get_class($this) == 'AdminPreferencesController')
{
$timezones = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT name FROM '._DB_PREFIX_.'timezone');
$taxes[] = array('id' => 0, 'name' => $this->l('None'));
@@ -97,6 +98,7 @@ class AdminPreferences extends AdminTab
'PS_COOKIE_LIFETIME_FO' => array('title' => $this->l('Lifetime of the Front Office cookie'), 'desc' => $this->l('Indicate the number of hours'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text', 'default' => '480', 'visibility' => Shop::CONTEXT_ALL),
'PS_COOKIE_LIFETIME_BO' => array('title' => $this->l('Lifetime of the Back Office cookie'), 'desc' => $this->l('Indicate the number of hours'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text', 'default' => '480', 'visibility' => Shop::CONTEXT_ALL),
'PS_ORDER_PROCESS_TYPE' => array('title' => $this->l('Order process type'), 'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $order_process_type, 'identifier' => 'value'),
'PS_REGISTRATION_PROCESS_TYPE' => array('title' => $this->l('Registration process type'), 'desc' => $this->l('The 2 steps register process allows the customer to register faster, and create his address later.'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $registration_process_type, 'identifier' => 'value'),
'PS_GUEST_CHECKOUT_ENABLED' => array('title' => $this->l('Enable guest checkout'), 'desc' => $this->l('Your guest can make an order without registering'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_CONDITIONS' => array('title' => $this->l('Terms of service'), 'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'js' => array('on' => 'onchange="changeCMSActivationAuthorization()"', 'off' => 'onchange="changeCMSActivationAuthorization()"')),
'PS_CONDITIONS_CMS_ID' => array('title' => $this->l('Conditions of use CMS page'), 'desc' => $this->l('Choose the Conditions of use CMS page'), 'validation' => 'isInt', 'type' => 'select', 'list' => $cms_tab, 'identifier' => 'id', 'cast' => 'intval'),
@@ -113,7 +115,6 @@ class AdminPreferences extends AdminTab
'PS_SHOW_NEW_ORDERS' => array('title' => $this->l('Show notifications for new orders'), 'desc' => $this->l('This will display notifications when new orders will be made on your shop'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_SHOW_NEW_CUSTOMERS' => array('title' => $this->l('Show notifications for new customers'), 'desc' => $this->l('This will display notifications when new customers will register on your shop'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_SHOW_NEW_MESSAGES' => array('title' => $this->l('Show notifications for new messages'), 'desc' => $this->l('This will display notifications when new messages will be posted on your shop'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_REGISTRATION_PROCESS_TYPE' => array('title' => $this->l('Registration process type'), 'desc' => $this->l('The 2 steps register process allows the customer to register faster, and create his address later.'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $registration_process_type, 'identifier' => 'value'),
);
if (function_exists('date_default_timezone_set'))
@@ -126,11 +127,12 @@ class AdminPreferences extends AdminTab
$fields['PS_SSL_ENABLED']['disabled'] = '<a href="https://'.Tools::getShopDomainSsl().Tools::safeOutput($_SERVER['REQUEST_URI']).'">'.$this->l('Please click here to use HTTPS protocol before enabling SSL.').'</a>';
}
$this->optionsList = array(
$this->options = array(
'general' => array(
'title' => $this->l('General'),
'icon' => 'tab-preferences',
'fields' => $fields,
'submit' => array('title' => $this->l(' Save '), 'class' => 'button')
),
);
}
@@ -138,11 +140,6 @@ class AdminPreferences extends AdminTab
parent::__construct();
}
public function display()
{
$this->displayOptionsList();
}
public function postProcess()
{
Tools::clearCache($this->context->smarty);
@@ -164,11 +161,11 @@ class AdminPreferences extends AdminTab
public function beforeUpdateOptions()
{
if (get_class($this) != 'AdminPreferences')
return ;
return;
$sql = 'SELECT `id_cms` FROM `'._DB_PREFIX_.'cms`
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
if (Tools::getValue('PS_CONDITIONS') && (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 OR !Db::getInstance()->getValue($sql)))
if (Tools::getValue('PS_CONDITIONS') && (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 || !Db::getInstance()->getValue($sql)))
$this->_errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.');
}
@@ -178,39 +175,12 @@ class AdminPreferences extends AdminTab
public function updateOptionPsAttachementMaximumSize($value)
{
if (!$value)
return ;
return;
$uploadMaxSize = (int)str_replace('M', '',ini_get('upload_max_filesize'));
$postMaxSize = (int)str_replace('M', '', ini_get('post_max_size'));
$maxSize = $uploadMaxSize < $postMaxSize ? $uploadMaxSize : $postMaxSize;
Configuration::update('PS_ATTACHMENT_MAXIMUM_SIZE', ($maxSize < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE')) ? $maxSize : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE'));
}
/**
* Display option IP maintenance
*/
public function displayOptionTypeMaintenanceIp($key, $field, $value)
{
echo '<script type="text/javascript">
function addRemoteAddr()
{
var length = $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\').length;
if (length > 0)
$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\') +\','.Tools::getRemoteAddr().'\');
else
$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',\''.Tools::getRemoteAddr().'\');
}
</script>';
$this->displayOptionTypeText($key, $field, $value);
echo (isset($field['next']) ? '&nbsp;'.strval($field['next']) : '');
echo ' &nbsp<a href="#" class="button" onclick="addRemoteAddr(); return false;">'.$this->l('Add my IP').'</a>';
}
public function displayBottomOptionCategory($category, $categoryData)
{
if (get_class($this) == 'AdminPreferences')
echo '<script type="text/javascript">changeCMSActivationAuthorization();</script>';
$upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize'));
$post_max_size = (int)str_replace('M', '', ini_get('post_max_size'));
$max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size;
$value = ($max_size < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE')) ? $max_size : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE');
Configuration::update('PS_ATTACHMENT_MAXIMUM_SIZE', $value);
}
}