[*] 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:
tDidierjean committed 2011-10-19 13:18:51 +00:00
1 parent 4c2e1ca2c8
commit 6303b68d51
18 files changed
+127 -62

No files matched your search

+1 -1
View File
@@ -163,7 +163,7 @@
</div> </div>
{/if} {/if}
{/foreach} {/foreach}
{if $requiredFields} {if $required_fields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div> <div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if} {/if}
</fieldset> </fieldset>
+55
View File
@@ -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>
+1 -1
View File
@@ -248,7 +248,7 @@
</div> </div>
{/if} {/if}
{/foreach} {/foreach}
{if $requiredFields} {if $required_fields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div> <div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if} {/if}
</fieldset> </fieldset>
@@ -145,7 +145,7 @@
</div> </div>
{/if} {/if}
{/foreach} {/foreach}
{if $requiredFields} {if $required_fields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div> <div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if} {/if}
</fieldset> </fieldset>
@@ -63,7 +63,7 @@
</div> </div>
{/if} {/if}
{/foreach} {/foreach}
{if $requiredFields} {if $required_fields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div> <div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if} {/if}
</fieldset> </fieldset>
@@ -25,7 +25,6 @@
*} *}
{if !$simple_header} {if !$simple_header}
<link href="../css/admin.css" rel="stylesheet" type="text/css" /> <link href="../css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"> <script type="text/javascript">
+1 -1
View File
@@ -154,7 +154,7 @@
/> />
</div> </div>
{/if} {/if}
{if $field['required']} {if $required_fields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div> <div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if} {/if}
</fieldset><br /> </fieldset><br />
+1 -1
View File
@@ -206,7 +206,7 @@
</div> </div>
{/if} {/if}
{/foreach} {/foreach}
{if $requiredFields} {if $required_fields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div> <div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if} {/if}
</fieldset> </fieldset>
+1 -1
View File
@@ -277,7 +277,7 @@
</div> </div>
{/if} {/if}
{/foreach} {/foreach}
{if $requiredFields} {if $required_fields}
<div class="small"><sup>*</sup> {l s ='Required field'}</div> <div class="small"><sup>*</sup> {l s ='Required field'}</div>
{/if} {/if}
</fieldset> </fieldset>
+2 -1
View File
@@ -1006,7 +1006,8 @@ class AdminControllerCore extends Controller
{ {
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'current' => self::$currentIndex, 'current' => self::$currentIndex,
'token' => $this->token 'token' => $this->token,
'table' => $this->table
)); ));
if ($this->display == 'edit' || $this->display == 'add') if ($this->display == 'edit' || $this->display == 'add')
+1 -1
View File
@@ -72,7 +72,7 @@ class HelperFormCore extends Helper
'back' => Tools::getValue('back'), 'back' => Tools::getValue('back'),
'fields' => $this->fields_form, 'fields' => $this->fields_form,
'fields_value' => $this->fields_value, 'fields_value' => $this->fields_value,
'requiredFields' => $this->getFieldsRequired(), 'required_fields' => $this->getFieldsRequired(),
'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'), 'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'),
'module_dir' => _MODULE_DIR_, '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, 'contains_states' => (isset($this->fields_value['id_country']) && isset($this->fields_value['id_state'])) ? Country::containsStates($this->fields_value['id_country']) : null,
+3 -5
View File
@@ -46,7 +46,7 @@ class HelperListCore extends Helper
public $_orderBy; public $_orderBy;
/** @var string Default ORDER BY clause when $_orderBy is not defined */ /** @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 */ /** @var string Order way (ASC, DESC) determined by arrows in list header */
public $_orderWay; public $_orderWay;
@@ -95,8 +95,7 @@ class HelperListCore extends Helper
'id_category' => 'id_category_to_move', 'id_category' => 'id_category_to_move',
'id_cms_category' => 'id_cms_category_to_move', 'id_cms_category' => 'id_cms_category_to_move',
'id_cms' => 'id_cms', 'id_cms' => 'id_cms',
'id_attribute' => 'id_attribute', 'id_attribute' => 'id_attribute'
'id_carrier' => 'id_carrier'
); );
// @var boolean ask for simple header : no filters, no paginations and no sorting // @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'])) else if (isset($params['position']))
{ {
$this->_list[$index][$key] = array( $this->_list[$index][$key] = array(
'position' => (int)$tr[$key], 'position' => $tr[$key],
'position_url_down' => $this->currentIndex. 'position_url_down' => $this->currentIndex.
'&'.$key_to_get.'='.(int)$id_category.'&'.$this->identifiersDnd[$this->identifier].'='.$id. '&'.$key_to_get.'='.(int)$id_category.'&'.$this->identifiersDnd[$this->identifier].'='.$id.
'&way=1&position='.((int)$tr['position'] + 1).'&token='.$this->token, '&way=1&position='.((int)$tr['position'] + 1).'&token='.$this->token,
@@ -282,7 +281,6 @@ class HelperListCore extends Helper
'id_category' => $id_category, 'id_category' => $id_category,
'bulk_actions' => $this->bulk_actions, 'bulk_actions' => $this->bulk_actions,
'key_to_get' => $key_to_get, 'key_to_get' => $key_to_get,
'order_by' => $this->_orderBy,
'positions' => isset($positions) ? $positions : null, 'positions' => isset($positions) ? $positions : null,
'is_cms' => $this->is_cms, 'is_cms' => $this->is_cms,
'fields_display' => $this->fieldsDisplay, 'fields_display' => $this->fieldsDisplay,
+14
View File
@@ -109,6 +109,10 @@ class HelperOptionsCore extends Helper
// Assign the modifications back to parent array // Assign the modifications back to parent array
$category_data['fields'][$key] = $field; $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 // Assign the modifications back to parent array
$option_list[$category] = $category_data; $option_list[$category] = $category_data;
@@ -118,6 +122,7 @@ class HelperOptionsCore extends Helper
'current' => $this->currentIndex, 'current' => $this->currentIndex,
'option_list' => $option_list, 'option_list' => $option_list,
'current_id_lang' => $this->context->language->id, 'current_id_lang' => $this->context->language->id,
'required_fields' => $required_fields,
)); ));
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl); return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl);
} }
@@ -202,4 +207,13 @@ class HelperOptionsCore extends Helper
return $value; 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:'), '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'), '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'; $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), '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() 'list' => Currency::getCurrencies()
), ),
), ),
'submit' => array()
), ),
'change' => array( 'change' => array(
'title' => $this->l('Currency rates'), 'title' => $this->l('Currency rates'),
@@ -25,9 +25,7 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
include_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php'); class AdminDbControllerCore extends AdminController
class AdminDb extends AdminPreferences
{ {
public function __construct() public function __construct()
{ {
@@ -36,7 +34,7 @@ class AdminDb extends AdminPreferences
parent::__construct(); parent::__construct();
$this->optionsList = array( $this->options = array(
'database' => array( 'database' => array(
'title' => $this->l('Database'), 'title' => $this->l('Database'),
'icon' => 'database_gear', 'icon' => 'database_gear',
@@ -48,23 +46,50 @@ 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_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), '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() public function postProcess()
{ {
/* PrestaShop demo mode */ // PrestaShop demo mode
if (_PS_MODE_DEMO_) if (_PS_MODE_DEMO_)
{ {
$this->_errors[] = Tools::displayError('This functionnality has been disabled.'); $this->_errors[] = Tools::displayError('This functionnality has been disabled.');
return; return;
} }
/* PrestaShop demo mode*/
if (isset($_POST['submitDatabase'.$this->table])) if ($this->action == 'update_options')
{
if ($this->tabAccess['edit'] === '1')
{ {
foreach ($this->optionsList['database']['fields'] AS $field => $values) foreach ($this->optionsList['database']['fields'] AS $field => $values)
if (isset($values['required']) AND $values['required']) if (isset($values['required']) AND $values['required'])
@@ -94,18 +119,16 @@ class AdminDb extends AdminPreferences
$this->_errors[] = Tools::displayError('Unable to connect to a database with these identifiers.'); $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'])) if (!isset($_POST['tablesBox']) OR !sizeof($_POST['tablesBox']))
$this->_errors[] = Tools::displayError('You did not select any tables'); $this->_errors[] = Tools::displayError('You did not select any tables');
else else
{ {
$available_engines = $this->_getEngines(); $available_engines = $this->getEngines();
$tables_status = $this->_getTablesStatus(); $tables_status = $this->getTablesStatus();
$tables_engine = array(); $tables_engine = array();
foreach ($tables_status AS $table) foreach ($tables_status AS $table)
@@ -132,36 +155,7 @@ class AdminDb extends AdminPreferences
} }
public function display() public function getEngines()
{
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()
{ {
$engines = Db::getInstance()->executeS('SHOW ENGINES'); $engines = Db::getInstance()->executeS('SHOW ENGINES');
$allowed_engines = array(); $allowed_engines = array();
@@ -173,7 +167,7 @@ class AdminDb extends AdminPreferences
return $allowed_engines; return $allowed_engines;
} }
private function _getTablesStatus() public function getTablesStatus()
{ {
return Db::getInstance()->executeS('SHOW TABLE STATUS'); return Db::getInstance()->executeS('SHOW TABLE STATUS');
} }
+2 -1
View File
@@ -249,7 +249,8 @@ class AdminStoresControllerCore extends AdminController
'type' => 'text', 'type' => 'text',
'size' => '10' 'size' => '10'
) )
) ),
'submit' => array()
) )
); );