Improve behaviour when multiple databases are disabled
This commit is contained in:
parent
56c03c16b0
commit
04d0e76d8a
@ -11,6 +11,7 @@ use PicoDb\Database;
|
||||
Router\get_action('new-db', function() {
|
||||
|
||||
if (ENABLE_MULTIPLE_DB) {
|
||||
|
||||
Response\html(Template\layout('new_db', array(
|
||||
'errors' => array(),
|
||||
'values' => array(),
|
||||
@ -25,6 +26,8 @@ Router\get_action('new-db', function() {
|
||||
// Create a new database
|
||||
Router\post_action('new-db', function() {
|
||||
|
||||
if (ENABLE_MULTIPLE_DB) {
|
||||
|
||||
$values = Request\values();
|
||||
list($valid, $errors) = Model\Database\validate($values);
|
||||
|
||||
@ -46,6 +49,9 @@ Router\post_action('new-db', function() {
|
||||
'menu' => 'config',
|
||||
'title' => t('New database')
|
||||
)));
|
||||
}
|
||||
|
||||
Response\redirect('?action=config');
|
||||
});
|
||||
|
||||
// Auto-update
|
||||
|
@ -18,7 +18,7 @@ function create($filename, $username, $password)
|
||||
{
|
||||
$filename = DATA_DIRECTORY.DIRECTORY_SEPARATOR.$filename;
|
||||
|
||||
if (! file_exists($filename)) {
|
||||
if (ENABLE_MULTIPLE_DB && ! file_exists($filename)) {
|
||||
|
||||
$db = new \PicoDb\Database(array(
|
||||
'driver' => 'sqlite',
|
||||
@ -44,7 +44,7 @@ function select($filename = '')
|
||||
{
|
||||
static $current_filename = DB_FILENAME;
|
||||
|
||||
if ($filename !== '' && in_array($filename, get_all())) {
|
||||
if (ENABLE_MULTIPLE_DB && $filename !== '' && in_array($filename, get_all())) {
|
||||
$current_filename = $filename;
|
||||
$_SESSION['config'] = \Model\Config\get_all();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user