diff --git a/admin-dev/themes/template/options.tpl b/admin-dev/themes/template/options.tpl
index 2d0f88d7e..1fb5af6b7 100644
--- a/admin-dev/themes/template/options.tpl
+++ b/admin-dev/themes/template/options.tpl
@@ -154,8 +154,8 @@
/>
{/if}
- {if $field['required']}
- * {l s='Required field'}
+ {if $required_fields}
+ * {l s ='Required field'}
{/if}
{if isset($categoryData['bottom'])}{$categoryData['bottom']}{/if}
diff --git a/admin-dev/themes/template/shop_url/form.tpl b/admin-dev/themes/template/shop_url/form.tpl
index bc1bb603b..6089543a8 100644
--- a/admin-dev/themes/template/shop_url/form.tpl
+++ b/admin-dev/themes/template/shop_url/form.tpl
@@ -206,7 +206,7 @@
{/if}
{/foreach}
- {if $requiredFields}
+ {if $required_fields}
* {l s ='Required field'}
{/if}
diff --git a/admin-dev/themes/template/stores/form.tpl b/admin-dev/themes/template/stores/form.tpl
index e2ef4d996..5c487a3ca 100644
--- a/admin-dev/themes/template/stores/form.tpl
+++ b/admin-dev/themes/template/stores/form.tpl
@@ -277,7 +277,7 @@
{/if}
{/foreach}
- {if $requiredFields}
+ {if $required_fields}
* {l s ='Required field'}
{/if}
diff --git a/classes/AdminController.php b/classes/AdminController.php
index c94f3d19e..28d32e620 100644
--- a/classes/AdminController.php
+++ b/classes/AdminController.php
@@ -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')
diff --git a/classes/HelperForm.php b/classes/HelperForm.php
index ee9f4983a..4af40e4a5 100644
--- a/classes/HelperForm.php
+++ b/classes/HelperForm.php
@@ -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,
diff --git a/classes/HelperList.php b/classes/HelperList.php
index f1701ccf2..6eb57a5d5 100644
--- a/classes/HelperList.php
+++ b/classes/HelperList.php
@@ -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,
diff --git a/classes/HelperOptions.php b/classes/HelperOptions.php
index c7bdeca73..98b19316f 100644
--- a/classes/HelperOptions.php
+++ b/classes/HelperOptions.php
@@ -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;
+ }
}
\ No newline at end of file
diff --git a/controllers/admin/AdminBackupController.php b/controllers/admin/AdminBackupController.php
index 02596eae6..bd3c8ff03 100644
--- a/controllers/admin/AdminBackupController.php
+++ b/controllers/admin/AdminBackupController.php
@@ -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').' (ie. "DROP TABLE IF EXISTS")', 'cast' => 'intval', 'type' => 'bool'),
),
+ 'submit' => array()
),
);
$this->identifier = 'filename';
diff --git a/controllers/admin/AdminContactsController.php b/controllers/admin/AdminContactsController.php
index e71133a13..ad471de5a 100644
--- a/controllers/admin/AdminContactsController.php
+++ b/controllers/admin/AdminContactsController.php
@@ -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()
),
);
diff --git a/controllers/admin/AdminCurrenciesController.php b/controllers/admin/AdminCurrenciesController.php
index d646013e7..38112421e 100644
--- a/controllers/admin/AdminCurrenciesController.php
+++ b/controllers/admin/AdminCurrenciesController.php
@@ -63,6 +63,7 @@ class AdminCurrenciesControllerCore extends AdminController
'list' => Currency::getCurrencies()
),
),
+ 'submit' => array()
),
'change' => array(
'title' => $this->l('Currency rates'),
diff --git a/admin-dev/tabs/AdminDb.php b/controllers/admin/AdminDbController.php
similarity index 53%
rename from admin-dev/tabs/AdminDb.php
rename to controllers/admin/AdminDbController.php
index 73d44c0b4..b6b632245 100644
--- a/admin-dev/tabs/AdminDb.php
+++ b/controllers/admin/AdminDbController.php
@@ -1,6 +1,6 @@
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').' '.$values['title'].' '.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').' '.$values['title'].' '.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.')).' ';
- $this->displayOptionsList();
- $engines = $this->_getEngines();
- $irow = 0;
- echo ''.$this->l('MySQL Engine').' ';
- }
-
- 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');
}
diff --git a/controllers/admin/AdminStoresController.php b/controllers/admin/AdminStoresController.php
index 27596cbab..c0113cc27 100644
--- a/controllers/admin/AdminStoresController.php
+++ b/controllers/admin/AdminStoresController.php
@@ -249,7 +249,8 @@ class AdminStoresControllerCore extends AdminController
'type' => 'text',
'size' => '10'
)
- )
+ ),
+ 'submit' => array()
)
);