[*] BO : #PSFV-94 - added AdminDbController
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9452 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -163,7 +163,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $requiredFields}
|
||||
{if $required_fields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
{*
|
||||
* 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$
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
<br />
|
||||
{$content}
|
||||
<br />
|
||||
<fieldset class="width2">
|
||||
<legend>{l s='MySQL Engine'}</legend>
|
||||
<form name="updateEngine" action="{$update_url}" method="post">
|
||||
<table cellspacing="0" cellpadding="0" class="table width2 clear">
|
||||
<tr>
|
||||
<th><input type="checkbox" onclick="checkDelBoxes(this.form, 'tablesBox[]', this.checked)" class="noborder" name="checkme"></th>
|
||||
<th>{l s='Table'}</th><th>{l s='Table Engine'}</th>
|
||||
</tr>
|
||||
{foreach $table_status AS $table}
|
||||
<tr class="{if $table@iteration is even}alt_row{/if}">
|
||||
<td class="noborder"><input type="checkbox" name="tablesBox[]" value="{$table['Name']}"/></td><td>{$table['Name']}</td><td>{$table['Engine']}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
<br />
|
||||
<label for="dbEngine">{l s='Change Engine to'}</label>
|
||||
<div class="margin-form">
|
||||
<select name="engineType">
|
||||
{foreach $engines AS $engine}
|
||||
<option value="{$engine}">{$engine}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<input style="margin-left:15px;" class="button" type="submit" value="Submit" name="submitEngine" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
@@ -248,7 +248,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $requiredFields}
|
||||
{if $required_fields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $requiredFields}
|
||||
{if $required_fields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $requiredFields}
|
||||
{if $required_fields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
@@ -25,75 +25,74 @@
|
||||
*}
|
||||
|
||||
{if !$simple_header}
|
||||
|
||||
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('.filter').keypress(function(event){
|
||||
formSubmit(event, 'submitFilterButton{$table}')
|
||||
})
|
||||
});
|
||||
</script>
|
||||
{* Display column names and arrows for ordering (ASC, DESC) *}
|
||||
{if $is_order_position}
|
||||
<script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script>
|
||||
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
var token = '{$token}';
|
||||
var come_from = '{$table}';
|
||||
var alternate = {if $order_way == 'DESC'}'1'{else}'0'{/if};
|
||||
$(document).ready(function() {
|
||||
$('.filter').keypress(function(event){
|
||||
formSubmit(event, 'submitFilterButton{$table}')
|
||||
})
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="../js/admin-dnd.js"></script>
|
||||
{/if}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
if ($(".datepicker").length > 0)
|
||||
$(".datepicker").datepicker({
|
||||
prevText: '',
|
||||
nextText: ''
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{if $add_button}
|
||||
<br /><a href="{$currentIndex}&add{$table}&token={$token}"><img src="../img/admin/add.gif" border="0" /> {l s='Add new'}</a><br /><br />
|
||||
{/if}
|
||||
<a name="{$table}"> </a>
|
||||
|
||||
<form method="post" action="{$action}" class="form">
|
||||
{* Display column names and arrows for ordering (ASC, DESC) *}
|
||||
{if $is_order_position}
|
||||
<script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script>
|
||||
<script type="text/javascript">
|
||||
var token = '{$token}';
|
||||
var come_from = '{$table}';
|
||||
var alternate = {if $order_way == 'DESC'}'1'{else}'0'{/if};
|
||||
</script>
|
||||
<script type="text/javascript" src="../js/admin-dnd.js"></script>
|
||||
{/if}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
if ($(".datepicker").length > 0)
|
||||
$(".datepicker").datepicker({
|
||||
prevText: '',
|
||||
nextText: ''
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{if $add_button}
|
||||
<br /><a href="{$currentIndex}&add{$table}&token={$token}"><img src="../img/admin/add.gif" border="0" /> {l s='Add new'}</a><br /><br />
|
||||
{/if}
|
||||
<a name="{$table}"> </a>
|
||||
|
||||
<form method="post" action="{$action}" class="form">
|
||||
{/if}{* End if simple_header *}
|
||||
<input type="hidden" id="submitFilter{$table}" name="submitFilter{$table}" value="0"/>
|
||||
<table style="table-layout: fixed; width: 100%;">
|
||||
{if !$simple_header}
|
||||
<tr>
|
||||
<td style="vertical-align: bottom;">
|
||||
<span style="float: left;">
|
||||
{if $page > 1}
|
||||
<input type="image" src="../img/admin/list-prev2.gif" onclick="getE(\'submitFilter{$table}\').value=1"/>
|
||||
<input type="image" src="../img/admin/list-prev.gif" onclick="getE(\'submitFilter{$table}\').value={$page - 1}"/>
|
||||
{/if}
|
||||
{l s='Page '}<b>{$page}</b> / {$total_pages}
|
||||
{if $page < $total_pages}
|
||||
<input type="image" src="../img/admin/list-next.gif" onclick="getE(\'submitFilter{$table}\').value={$page + 1}"/>
|
||||
<input type="image" src="../img/admin/list-next2.gif" onclick="getE(\'submitFilter{$table}'\').value={$total_pages}"/>
|
||||
{/if}
|
||||
| {l s='Display'}
|
||||
<select name="pagination">
|
||||
{* Choose number of results per page *}
|
||||
{foreach $pagination AS $value}
|
||||
<option value="{$value|intval}"{if $selected_pagination == $value} selected="selected" {elseif $selected_pagination == NULL && $value == $pagination[1]} selected="selected2"{/if}>{$value|intval}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
/ {$list_total} {l s='result(s)'}
|
||||
</span>
|
||||
<span style="float: right;">
|
||||
<input type="submit" name="submitReset{$table}" value="{l s='Reset'}" class="button" />
|
||||
<input type="submit" id="submitFilterButton{$table}" name="submitFilter" value="{l s='Filter'}" class="button" />
|
||||
</span>
|
||||
<span class="clear"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: bottom;">
|
||||
<span style="float: left;">
|
||||
{if $page > 1}
|
||||
<input type="image" src="../img/admin/list-prev2.gif" onclick="getE(\'submitFilter{$table}\').value=1"/>
|
||||
<input type="image" src="../img/admin/list-prev.gif" onclick="getE(\'submitFilter{$table}\').value={$page - 1}"/>
|
||||
{/if}
|
||||
{l s='Page '}<b>{$page}</b> / {$total_pages}
|
||||
{if $page < $total_pages}
|
||||
<input type="image" src="../img/admin/list-next.gif" onclick="getE(\'submitFilter{$table}\').value={$page + 1}"/>
|
||||
<input type="image" src="../img/admin/list-next2.gif" onclick="getE(\'submitFilter{$table}'\').value={$total_pages}"/>
|
||||
{/if}
|
||||
| {l s='Display'}
|
||||
<select name="pagination">
|
||||
{* Choose number of results per page *}
|
||||
{foreach $pagination AS $value}
|
||||
<option value="{$value|intval}"{if $selected_pagination == $value} selected="selected" {elseif $selected_pagination == NULL && $value == $pagination[1]} selected="selected2"{/if}>{$value|intval}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
/ {$list_total} {l s='result(s)'}
|
||||
</span>
|
||||
<span style="float: right;">
|
||||
<input type="submit" name="submitReset{$table}" value="{l s='Reset'}" class="button" />
|
||||
<input type="submit" id="submitFilterButton{$table}" name="submitFilter" value="{l s='Filter'}" class="button" />
|
||||
</span>
|
||||
<span class="clear"></span>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td{if $simple_header} style="border:none;"{/if}>
|
||||
|
||||
@@ -154,8 +154,8 @@
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{if $field['required']}
|
||||
<div class="small"><sup>*</sup> {l s='Required field'}</div>
|
||||
{if $required_fields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset><br />
|
||||
{if isset($categoryData['bottom'])}{$categoryData['bottom']}{/if}
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $requiredFields}
|
||||
{if $required_fields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $requiredFields}
|
||||
{if $required_fields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
@@ -1006,7 +1006,8 @@ class AdminControllerCore extends Controller
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'current' => self::$currentIndex,
|
||||
'token' => $this->token
|
||||
'token' => $this->token,
|
||||
'table' => $this->table
|
||||
));
|
||||
|
||||
if ($this->display == 'edit' || $this->display == 'add')
|
||||
|
||||
@@ -72,7 +72,7 @@ class HelperFormCore extends Helper
|
||||
'back' => Tools::getValue('back'),
|
||||
'fields' => $this->fields_form,
|
||||
'fields_value' => $this->fields_value,
|
||||
'requiredFields' => $this->getFieldsRequired(),
|
||||
'required_fields' => $this->getFieldsRequired(),
|
||||
'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'),
|
||||
'module_dir' => _MODULE_DIR_,
|
||||
'contains_states' => (isset($this->fields_value['id_country']) && isset($this->fields_value['id_state'])) ? Country::containsStates($this->fields_value['id_country']) : null,
|
||||
|
||||
@@ -46,7 +46,7 @@ class HelperListCore extends Helper
|
||||
public $_orderBy;
|
||||
|
||||
/** @var string Default ORDER BY clause when $_orderBy is not defined */
|
||||
protected $_defaultOrderBy = false;
|
||||
public $_defaultOrderBy = false;
|
||||
|
||||
/** @var string Order way (ASC, DESC) determined by arrows in list header */
|
||||
public $_orderWay;
|
||||
@@ -95,8 +95,7 @@ class HelperListCore extends Helper
|
||||
'id_category' => 'id_category_to_move',
|
||||
'id_cms_category' => 'id_cms_category_to_move',
|
||||
'id_cms' => 'id_cms',
|
||||
'id_attribute' => 'id_attribute',
|
||||
'id_carrier' => 'id_carrier'
|
||||
'id_attribute' => 'id_attribute'
|
||||
);
|
||||
|
||||
// @var boolean ask for simple header : no filters, no paginations and no sorting
|
||||
@@ -218,7 +217,7 @@ class HelperListCore extends Helper
|
||||
else if (isset($params['position']))
|
||||
{
|
||||
$this->_list[$index][$key] = array(
|
||||
'position' => (int)$tr[$key],
|
||||
'position' => $tr[$key],
|
||||
'position_url_down' => $this->currentIndex.
|
||||
'&'.$key_to_get.'='.(int)$id_category.'&'.$this->identifiersDnd[$this->identifier].'='.$id.
|
||||
'&way=1&position='.((int)$tr['position'] + 1).'&token='.$this->token,
|
||||
@@ -282,7 +281,6 @@ class HelperListCore extends Helper
|
||||
'id_category' => $id_category,
|
||||
'bulk_actions' => $this->bulk_actions,
|
||||
'key_to_get' => $key_to_get,
|
||||
'order_by' => $this->_orderBy,
|
||||
'positions' => isset($positions) ? $positions : null,
|
||||
'is_cms' => $this->is_cms,
|
||||
'fields_display' => $this->fieldsDisplay,
|
||||
|
||||
@@ -109,6 +109,10 @@ class HelperOptionsCore extends Helper
|
||||
|
||||
// Assign the modifications back to parent array
|
||||
$category_data['fields'][$key] = $field;
|
||||
|
||||
// Is at least one required field present?
|
||||
if (isset($field['required']) && $field['required'])
|
||||
$required_fields = true;
|
||||
}
|
||||
// Assign the modifications back to parent array
|
||||
$option_list[$category] = $category_data;
|
||||
@@ -118,6 +122,7 @@ class HelperOptionsCore extends Helper
|
||||
'current' => $this->currentIndex,
|
||||
'option_list' => $option_list,
|
||||
'current_id_lang' => $this->context->language->id,
|
||||
'required_fields' => $required_fields,
|
||||
));
|
||||
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl);
|
||||
}
|
||||
@@ -202,4 +207,13 @@ class HelperOptionsCore extends Helper
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getFieldsRequired()
|
||||
{
|
||||
if (isset($this->fields_form['input']))
|
||||
foreach ($this->fields_form['input'] as $input)
|
||||
if (array_key_exists('required', $input) && $input['required'])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ class AdminBackupControllerCore extends AdminController
|
||||
'PS_BACKUP_DROP_TABLE' => array('title' => $this->l('Drop existing tables during import:'),
|
||||
'desc' => $this->l('Select this option to instruct the backup file to drop your tables prior to restoring the backed up data').'<br />(ie. "DROP TABLE IF EXISTS")', 'cast' => 'intval', 'type' => 'bool'),
|
||||
),
|
||||
'submit' => array()
|
||||
),
|
||||
);
|
||||
$this->identifier = 'filename';
|
||||
|
||||
@@ -53,6 +53,7 @@ class AdminContactsControllerCore extends AdminController
|
||||
)),
|
||||
'PS_CUSTOMER_SERVICE_SIGNATURE' => array('title' => $this->l('Pre-defined message'), 'desc' => $this->l('Please fill the message that appears by default when you answer a thread on the customer service page'), 'cast' => 'pSQL', 'type' => 'textareaLang', 'identifier' => 'value', 'cols' => 40, 'rows' => 8),
|
||||
),
|
||||
'submit' => array()
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ class AdminCurrenciesControllerCore extends AdminController
|
||||
'list' => Currency::getCurrencies()
|
||||
),
|
||||
),
|
||||
'submit' => array()
|
||||
),
|
||||
'change' => array(
|
||||
'title' => $this->l('Currency rates'),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -25,18 +25,16 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
include_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminDb extends AdminPreferences
|
||||
class AdminDbControllerCore extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->optionsList = array(
|
||||
$this->options = array(
|
||||
'database' => array(
|
||||
'title' => $this->l('Database'),
|
||||
'icon' => 'database_gear',
|
||||
@@ -48,75 +46,100 @@ class AdminDb extends AdminPreferences
|
||||
'db_user' => array('title' => $this->l('User:'), 'size' => 30, 'type' => 'text', 'required' => true, 'defaultValue' => _DB_USER_, 'visibility' => Shop::CONTEXT_ALL),
|
||||
'db_passwd' => array('title' => $this->l('Password:'), 'size' => 30, 'type' => 'password', 'desc' => $this->l('Leave blank if no change'), 'defaultValue' => _DB_PASSWD_, 'visibility' => Shop::CONTEXT_ALL),
|
||||
),
|
||||
'submit' => array()
|
||||
),
|
||||
);
|
||||
|
||||
$this->fieldsDisplay = array (
|
||||
'table' => array('title' => $this->l('Table'), 'type' => 'string', 'width' => 120),
|
||||
'table_engine' => array('title' => $this->l('Table Engine'), 'type' => 'string', 'width' => 120),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
|
||||
$this->warnings[] = $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.');
|
||||
|
||||
$helper = new HelperOptions();
|
||||
$helper->id = $this->id;
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$this->content .= $helper->generateOptions($this->options);
|
||||
|
||||
$table_status = $this->getTablesStatus();
|
||||
foreach ($table_status as $key => $table)
|
||||
if (!preg_match('#^'._DB_PREFIX_.'.*#Ui', $table['Name']))
|
||||
unset($table_status[$key]);
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'update_url' => self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token,
|
||||
'table_status' => $table_status,
|
||||
'engines' => $this->getEngines(),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
// PrestaShop demo mode
|
||||
if (_PS_MODE_DEMO_)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('This functionnality has been disabled.');
|
||||
return;
|
||||
}
|
||||
/* PrestaShop demo mode*/
|
||||
|
||||
if (isset($_POST['submitDatabase'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
foreach ($this->optionsList['database']['fields'] AS $field => $values)
|
||||
if (isset($values['required']) AND $values['required'])
|
||||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required.');
|
||||
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
/* Datas are not saved in database but in config/settings.inc.php */
|
||||
$settings = array();
|
||||
foreach ($this->optionsList['database']['fields'] as $k => $data)
|
||||
if ($value = Tools::getValue($k))
|
||||
$settings['_'.Tools::strtoupper($k).'_'] = $value;
|
||||
|
||||
if (Db::checkConnection(
|
||||
isset($settings['_DB_SERVER_']) ? $settings['_DB_SERVER_'] : _DB_SERVER_,
|
||||
isset($settings['_DB_USER_']) ? $settings['_DB_USER_'] : _DB_USER_,
|
||||
isset($settings['_DB_PASSWD_']) ? $settings['_DB_PASSWD_'] : _DB_PASSWD_,
|
||||
isset($settings['_DB_NAME_']) ? $settings['_DB_NAME_'] : _DB_NAME_,
|
||||
true
|
||||
) == 0)
|
||||
{
|
||||
rewriteSettingsFile(NULL, NULL, $settings);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Unable to connect to a database with these identifiers.');
|
||||
if ($this->action == 'update_options')
|
||||
{
|
||||
foreach ($this->optionsList['database']['fields'] AS $field => $values)
|
||||
if (isset($values['required']) AND $values['required'])
|
||||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required.');
|
||||
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
/* Datas are not saved in database but in config/settings.inc.php */
|
||||
$settings = array();
|
||||
foreach ($this->optionsList['database']['fields'] as $k => $data)
|
||||
if ($value = Tools::getValue($k))
|
||||
$settings['_'.Tools::strtoupper($k).'_'] = $value;
|
||||
|
||||
if (Db::checkConnection(
|
||||
isset($settings['_DB_SERVER_']) ? $settings['_DB_SERVER_'] : _DB_SERVER_,
|
||||
isset($settings['_DB_USER_']) ? $settings['_DB_USER_'] : _DB_USER_,
|
||||
isset($settings['_DB_PASSWD_']) ? $settings['_DB_PASSWD_'] : _DB_PASSWD_,
|
||||
isset($settings['_DB_NAME_']) ? $settings['_DB_NAME_'] : _DB_NAME_,
|
||||
true
|
||||
) == 0)
|
||||
{
|
||||
rewriteSettingsFile(NULL, NULL, $settings);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Unable to connect to a database with these identifiers.');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitEngine'))
|
||||
// Change engine
|
||||
if ($this->action == 'save')
|
||||
{
|
||||
if (!isset($_POST['tablesBox']) OR !sizeof($_POST['tablesBox']))
|
||||
$this->_errors[] = Tools::displayError('You did not select any tables');
|
||||
else
|
||||
{
|
||||
$available_engines = $this->_getEngines();
|
||||
$tables_status = $this->_getTablesStatus();
|
||||
$available_engines = $this->getEngines();
|
||||
$tables_status = $this->getTablesStatus();
|
||||
$tables_engine = array();
|
||||
|
||||
foreach ($tables_status AS $table)
|
||||
$tables_engine[$table['Name']] = $table['Engine'];
|
||||
|
||||
|
||||
$engineType = pSQL(Tools::getValue('engineType'));
|
||||
|
||||
|
||||
/* Datas are not saved in database but in config/settings.inc.php */
|
||||
$settings = array('_MYSQL_ENGINE_' => $engineType);
|
||||
rewriteSettingsFile(NULL, NULL, $settings);
|
||||
|
||||
|
||||
foreach ($_POST['tablesBox'] AS $table)
|
||||
{
|
||||
if ($engineType == $tables_engine[$table])
|
||||
@@ -132,36 +155,7 @@ class AdminDb extends AdminPreferences
|
||||
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
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->displayOptionsList();
|
||||
$engines = $this->_getEngines();
|
||||
$irow = 0;
|
||||
echo '<br /><fieldset class="width2"><legend>'.$this->l('MySQL Engine').'</legend><form name="updateEngine" action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post"><table cellspacing="0" cellpadding="0" class="table width2 clear">
|
||||
<tr><th><input type="checkbox" onclick="checkDelBoxes(this.form, \'tablesBox[]\', this.checked)" class="noborder" name="checkme"></th><th>'.$this->l('Table').'</th><th>'.$this->l('Table Engine').'</th></tr>';
|
||||
$tables_status = $this->_getTablesStatus();
|
||||
foreach ($tables_status AS $table)
|
||||
{
|
||||
if (!preg_match('/^'._DB_PREFIX_.'.*/Ui', $table['Name']))
|
||||
continue;
|
||||
echo '<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td class="noborder"><input type="checkbox" name="tablesBox[]" value="'.$table['Name'].'"/></td><td>'.$table['Name'].'</td><td>'.$table['Engine'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table><br />
|
||||
<label for="dbEngine">'.$this->l('Change Engine to').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="engineType">';
|
||||
foreach ($engines AS $engine)
|
||||
echo '<option value="'.$engine.'">'.$engine.'</option>';
|
||||
echo '</select>
|
||||
<input style="margin-left:15px;" class="button" type="submit" value="Submit" name="submitEngine" />
|
||||
</div>
|
||||
</fieldset>';
|
||||
}
|
||||
|
||||
private function _getEngines()
|
||||
public function getEngines()
|
||||
{
|
||||
$engines = Db::getInstance()->executeS('SHOW ENGINES');
|
||||
$allowed_engines = array();
|
||||
@@ -172,8 +166,8 @@ class AdminDb extends AdminPreferences
|
||||
}
|
||||
return $allowed_engines;
|
||||
}
|
||||
|
||||
private function _getTablesStatus()
|
||||
|
||||
public function getTablesStatus()
|
||||
{
|
||||
return Db::getInstance()->executeS('SHOW TABLE STATUS');
|
||||
}
|
||||
@@ -249,7 +249,8 @@ class AdminStoresControllerCore extends AdminController
|
||||
'type' => 'text',
|
||||
'size' => '10'
|
||||
)
|
||||
)
|
||||
),
|
||||
'submit' => array()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user