diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Installation/FormDatabaseSetup.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/Installation/FormDatabaseSetup.php b/plugins/Installation/FormDatabaseSetup.php index 2a54f8722a..bd5e668cf4 100644 --- a/plugins/Installation/FormDatabaseSetup.php +++ b/plugins/Installation/FormDatabaseSetup.php @@ -34,6 +34,7 @@ class FormDatabaseSetup extends QuickForm2 function init() { HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'Piwik\Plugins\Installation\FormDatabaseSetup_Rule_checkValidFilename'); + HTML_QuickForm2_Factory::registerRule('checkValidDbname', 'Piwik\Plugins\Installation\FormDatabaseSetup_Rule_checkValidDbname'); HTML_QuickForm2_Factory::registerRule('checkUserPrivileges', 'Piwik\Plugins\Installation\Rule_checkUserPrivileges'); $availableAdapters = Adapter::getAdapters(); @@ -60,7 +61,7 @@ class FormDatabaseSetup extends QuickForm2 $item = $this->addElement('text', 'dbname') ->setLabel(Piwik::translate('Installation_DatabaseSetupDatabaseName')); $item->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupDatabaseName'))); - $item->addRule('checkValidFilename', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupDatabaseName'))); + $item->addRule('checkValidDbname', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupDatabaseName'))); $this->addElement('text', 'tables_prefix') ->setLabel(Piwik::translate('Installation_DatabaseSetupTablePrefix')) @@ -302,7 +303,7 @@ class Rule_checkUserPrivileges extends HTML_QuickForm2_Rule } /** - * Filename check for prefix/DB name + * Filename check for prefix * */ class FormDatabaseSetup_Rule_checkValidFilename extends HTML_QuickForm2_Rule @@ -315,3 +316,17 @@ class FormDatabaseSetup_Rule_checkValidFilename extends HTML_QuickForm2_Rule } } +/** + * Filename check for DB name + * + */ +class FormDatabaseSetup_Rule_checkValidDbname extends HTML_QuickForm2_Rule +{ + function validateOwner() + { + $prefix = $this->owner->getValue(); + return empty($prefix) + || DbHelper::isValidDbname($prefix); + } +} + |