Skip to content
Snippets Groups Projects
Commit ce82d462 authored by Demian Katz's avatar Demian Katz
Browse files

Don't skip form validation just because we are skipping SQL execution; style...

Don't skip form validation just because we are skipping SQL execution; style fixes; XHTML compliance fixes.
parent 45b79957
No related merge requests found
...@@ -298,22 +298,22 @@ class InstallController extends AbstractBase ...@@ -298,22 +298,22 @@ class InstallController extends AbstractBase
$view->dbuser = $this->params()->fromPost('dbuser', 'vufind'); $view->dbuser = $this->params()->fromPost('dbuser', 'vufind');
$view->dbhost = $this->params()->fromPost('dbhost', 'localhost'); $view->dbhost = $this->params()->fromPost('dbhost', 'localhost');
$view->dbrootuser = $this->params()->fromPost('dbrootuser', 'root'); $view->dbrootuser = $this->params()->fromPost('dbrootuser', 'root');
$skip = $this->params()->fromPost('printsql', 'nope') == 'Skip'; $skip = $this->params()->fromPost('printsql', 'nope') == 'Skip';
if (!$skip && !preg_match('/^\w*$/', $view->dbname)) { if (!preg_match('/^\w*$/', $view->dbname)) {
$this->flashMessenger()->setNamespace('error') $this->flashMessenger()->setNamespace('error')
->addMessage('Database name must be alphanumeric.'); ->addMessage('Database name must be alphanumeric.');
} else if (!$skip && !preg_match('/^\w*$/', $view->dbuser)) { } else if (!preg_match('/^\w*$/', $view->dbuser)) {
$this->flashMessenger()->setNamespace('error') $this->flashMessenger()->setNamespace('error')
->addMessage('Database user must be alphanumeric.'); ->addMessage('Database user must be alphanumeric.');
} else if ($skip || strlen($this->params()->fromPost('submit', '')) > 0) { } else if ($skip || strlen($this->params()->fromPost('submit', '')) > 0) {
$newpass = $this->params()->fromPost('dbpass'); $newpass = $this->params()->fromPost('dbpass');
$newpassConf = $this->params()->fromPost('dbpassconfirm'); $newpassConf = $this->params()->fromPost('dbpassconfirm');
if (!$skip && (empty($newpass) || empty($newpassConf))) { if ((empty($newpass) || empty($newpassConf))) {
$this->flashMessenger()->setNamespace('error') $this->flashMessenger()->setNamespace('error')
->addMessage('Password fields must not be blank.'); ->addMessage('Password fields must not be blank.');
} else if (!$skip && $newpass != $newpassConf) { } else if ($newpass != $newpassConf) {
$this->flashMessenger()->setNamespace('error') $this->flashMessenger()->setNamespace('error')
->addMessage('Password fields must match.'); ->addMessage('Password fields must match.');
} else { } else {
...@@ -335,8 +335,9 @@ class InstallController extends AbstractBase ...@@ -335,8 +335,9 @@ class InstallController extends AbstractBase
$sql = file_get_contents( $sql = file_get_contents(
APPLICATION_PATH . '/module/VuFind/sql/mysql.sql' APPLICATION_PATH . '/module/VuFind/sql/mysql.sql'
); );
if($skip == 'Skip') { if ($skip == 'Skip') {
$omnisql = $query .";\n". $grant .";\nFLUSH PRIVILEGES;\n\n". $sql; $omnisql = $query . ";\n". $grant
. ";\nFLUSH PRIVILEGES;\n\n" . $sql;
$this->getRequest()->getQuery()->set('sql', $omnisql); $this->getRequest()->getQuery()->set('sql', $omnisql);
return $this->forwardTo('Install', 'showsql'); return $this->forwardTo('Install', 'showsql');
} else { } else {
...@@ -358,8 +359,9 @@ class InstallController extends AbstractBase ...@@ -358,8 +359,9 @@ class InstallController extends AbstractBase
// forward back to the home action! // forward back to the home action!
$string = "mysql://{$view->dbuser}:{$newpass}@" $string = "mysql://{$view->dbuser}:{$newpass}@"
. $view->dbhost . '/' . $view->dbname; . $view->dbhost . '/' . $view->dbname;
$config $config = ConfigReader::getLocalConfigPath(
= ConfigReader::getLocalConfigPath('config.ini', null, true); 'config.ini', null, true
);
$writer = new ConfigWriter($config); $writer = new ConfigWriter($config);
$writer->set('Database', 'database', $string); $writer->set('Database', 'database', $string);
if (!$writer->save()) { if (!$writer->save()) {
...@@ -375,15 +377,22 @@ class InstallController extends AbstractBase ...@@ -375,15 +377,22 @@ class InstallController extends AbstractBase
} }
return $view; return $view;
} }
protected function showsqlAction() { /**
* Display captured SQL commands for database action.
*
* @return mixed
*/
protected function showsqlAction()
{
$continue = $this->params()->fromPost('continue', 'nope'); $continue = $this->params()->fromPost('continue', 'nope');
if ($continue == 'Next') { if ($continue == 'Next') {
return $this->redirect()->toRoute('install-home'); return $this->redirect()->toRoute('install-home');
} }
return $this->createViewModel(array('sql' => $this->params()->fromQuery('sql'))); return $this->createViewModel(
return $view; array('sql' => $this->params()->fromQuery('sql'))
);
} }
/** /**
......
...@@ -4,24 +4,20 @@ ...@@ -4,24 +4,20 @@
// Set up breadcrumbs: // Set up breadcrumbs:
$this->layout()->breadcrumbs = '<em>' . $this->transEsc('Install VuFind') . '</em>'; $this->layout()->breadcrumbs = '<em>' . $this->transEsc('Install VuFind') . '</em>';
// Set up styles:
$this->headstyle()->appendStyle(
".pre {\n"
. " white-space:pre-wrap; width:90%; overflow-y:visible; padding:8px; margin:1em 2em; background:#EEE; border:1px dashed #CCC;\n"
. "}\n"
);
?> ?>
<style>
.pre {
width:90%;
overflow-y:visible;
padding:8px;
margin:1em 2em;
background:#EEE;
border:1px dashed #CCC;
white-space:pre-wrap;
}
</style>
<h1><?=$this->transEsc('Install VuFind')?></h1> <h1><?=$this->transEsc('Install VuFind')?></h1>
<?=$this->flashmessages()?> <?=$this->flashmessages()?>
<p>Save this SQL somewhere safe:</p> <p>Save this SQL somewhere safe:</p>
<textarea class="pre" rows="20" readonly onClick="this.select()"><?=trim($this->sql) ?></textarea> <textarea class="pre" rows="20" readonly onClick="this.select()"><?=trim($this->sql) ?></textarea>
<form method="POST" action="<?=$this->url('install-showsql')?>"> <form method="post" action="<?=$this->url('install-showsql')?>">
<input type="submit" name="continue" value="Next"> <input type="submit" name="continue" value="Next" />
</form> </form>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment