summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/js/setup.js20
-rw-r--r--core/templates/installation.php30
-rw-r--r--lib/setup.php45
3 files changed, 33 insertions, 62 deletions
diff --git a/core/js/setup.js b/core/js/setup.js
index 6ef20673f10..3fb895cc414 100644
--- a/core/js/setup.js
+++ b/core/js/setup.js
@@ -1,27 +1,20 @@
$(document).ready(function() {
- // Hide the PostgreSQL config div if needed:
- if(!$('#pgsql').is(':checked')) {
- $('#use_postgresql').hide();
- }
-
$('#datadirField').hide(250);
if($('#hasSQLite').val()=='true'){
$('#databaseField').hide(250);
+ $('#use_other_db').slideUp(250);
}
$('#sqlite').click(function() {
- $('#use_mysql').slideUp(250);
- $('#use_postgresql').slideUp(250);
+ $('#use_other_db').slideUp(250);
});
$('#mysql').click(function() {
- $('#use_mysql').slideDown(250);
- $('#use_postgresql').slideUp(250);
+ $('#use_other_db').slideDown(250);
});
$('#pgsql').click(function() {
- $('#use_postgresql').slideDown(250);
- $('#use_mysql').slideUp(250);
+ $('#use_other_db').slideDown(250);
});
$('#showAdvanced').click(function() {
@@ -30,9 +23,4 @@ $(document).ready(function() {
$('#databaseField').slideToggle(250);
}
});
-
- // Hide the MySQL config div if needed :
- if($('#dbtype').val()=='sqlite') {
- $('#databaseField').hide();
- }
});
diff --git a/core/templates/installation.php b/core/templates/installation.php
index f7352e1fd53..e9f7daf7b89 100644
--- a/core/templates/installation.php
+++ b/core/templates/installation.php
@@ -23,10 +23,11 @@
</fieldset>
<fieldset id='databaseField'>
+ <?php if($_['hasMySQL'] or $_['hasPostgreSQL']) $hasOtherDB = true; //other than SQLite ?>
<legend><?php echo $l->t( 'Configure the database' ); ?></legend>
<?php if($_['hasSQLite']): ?>
<input type='hidden' id='hasSQLite' value='true' />
- <?php if(!$_['hasMySQL'] and !$_['hasPostgreSQL']): ?>
+ <?php if(!$hasOtherDB): ?>
<p><?php echo $l->t( 'SQLite will be used.' ); ?></p>
<input type="hidden" id="dbtype" name="dbtype" value="sqlite" />
<?php else: ?>
@@ -42,33 +43,28 @@
<?php else: ?>
<label class="mysql" for="mysql">MySQL</label><input type="radio" name="dbtype" value='mysql' id="mysql" <?php OC_Helper::init_radio('dbtype','pgsql', 'mysql', 'sqlite'); ?>/>
<?php endif; ?>
- <div id="use_mysql">
- <input type="text" name="dbuser" id="dbuser" value="<?php print OC_Helper::init_var('dbuser'); ?>" placeholder="<?php echo $l->t( 'Database user' ); ?>" required />
- <input type="password" name="dbpass" id="dbpass" value="<?php print OC_Helper::init_var('dbpass'); ?>" placeholder="<?php echo $l->t( 'Database password' ); ?>" />
- <input type="text" name="dbname" id="dbname" value="<?php print OC_Helper::init_var('dbname'); ?>" placeholder="<?php echo $l->t( 'Database name' ); ?>" required />
- <input type="text" name="dbhost" id="dbhost" value="<?php print OC_Helper::init_var('dbhost', 'localhost'); ?>" placeholder="<?php echo $l->t( 'Host' ); ?>" required />
- <input type="text" name="dbtableprefix" id="dbtableprefix" value="<?php print OC_Helper::init_var('dbtableprefix', 'oc_'); ?>" placeholder="<?php echo $l->t( 'Table prefix' ); ?>" />
-
- </div>
<?php endif; ?>
<?php if($_['hasPostgreSQL']): ?>
- <input type='hidden' id='hasPostgreSQL' value='true'/>
- <?php if(!$_['hasSQLite'] and !$_['hasSQLite']): ?>
+ <?php if(!$_['hasSQLite'] and !$_['hasMySQL']): ?>
<p><?php echo $l->t( 'PostgreSQL will be used.' ); ?></p>
<input type="hidden" id="dbtype" name="dbtype" value="pgsql" />
<?php else: ?>
<p><label class="pgsql" for="pgsql">PostgreSQL</label><input type="radio" name="dbtype" value='pgsql' id="pgsql" <?php OC_Helper::init_radio('dbtype','pgsql', 'mysql', 'sqlite'); ?>/></p>
<?php endif; ?>
- <div id="use_postgresql">
- <input type="text" name="pg_dbuser" id="pg_dbuser" value="<?php print OC_Helper::init_var('dbuser'); ?>" placeholder="<?php echo $l->t( 'Database user' ); ?>" required />
- <input type="password" name="pg_dbpass" id="pg_dbpass" value="<?php print OC_Helper::init_var('dbpass'); ?>" placeholder="<?php echo $l->t( 'PostgreSQL password' ); ?>" />
- <input type="text" name="pg_dbname" id="pg_dbname" value="<?php print OC_Helper::init_var('dbname'); ?>" placeholder="<?php echo $l->t( 'Database name' ); ?>" required />
- <input type="text" name="pg_dbhost" id="pg_dbhost" value="<?php print OC_Helper::init_var('dbhost', 'localhost'); ?>" placeholder="<?php echo $l->t( 'Host' ); ?>" required />
- <input type="text" name="pg_dbtableprefix" id="pg_dbtableprefix" value="<?php print OC_Helper::init_var('dbtableprefix', 'oc_'); ?>" placeholder="<?php echo $l->t( 'Table prefix' ); ?>" />
+ <?php endif; ?>
+
+ <?php if($hasOtherDB): ?>
+ <div id="use_other_db">
+ <input type="text" name="dbuser" id="dbuser" value="<?php print OC_Helper::init_var('dbuser'); ?>" placeholder="<?php echo $l->t( 'Database user' ); ?>" required />
+ <input type="password" name="dbpass" id="dbpass" value="<?php print OC_Helper::init_var('dbpass'); ?>" placeholder="<?php echo $l->t( 'Database password' ); ?>" />
+ <input type="text" name="dbname" id="dbname" value="<?php print OC_Helper::init_var('dbname'); ?>" placeholder="<?php echo $l->t( 'Database name' ); ?>" required />
+ <input type="text" name="dbhost" id="dbhost" value="<?php print OC_Helper::init_var('dbhost', 'localhost'); ?>" placeholder="<?php echo $l->t( 'Host' ); ?>" required />
+ <input type="text" name="dbtableprefix" id="dbtableprefix" value="<?php print OC_Helper::init_var('dbtableprefix', 'oc_'); ?>" placeholder="<?php echo $l->t( 'Table prefix' ); ?>" />
</div>
<?php endif; ?>
+
</fieldset>
<a id='showAdvanced'><strong><?php echo $l->t( 'Advanced' ); ?> ▾</strong></a>
diff --git a/lib/setup.php b/lib/setup.php
index 04a65d01265..192fd134608 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -46,39 +46,26 @@ class OC_Setup {
$error[] = 'STEP 2 : data directory path is not set.';
}
- if($dbtype=='mysql') { //mysql needs more config options
+ if($dbtype=='mysql' or $dbtype=='pgsql') { //mysql and postgresql needs more config options
+ if($dbtype=='mysql')
+ $dbprettyname = 'MySQL';
+ else
+ $dbprettyname = 'PostgreSQL';
+
if(empty($options['dbuser'])) {
- $error[] = 'STEP 3 : MySQL database user is not set.';
+ $error[] = "STEP 3 : $dbprettyname database user is not set.";
}
if(empty($options['dbpass'])) {
- $error[] = 'STEP 3 : MySQL database password is not set.';
+ $error[] = "STEP 3 : $dbprettyname database password is not set.";
}
if(empty($options['dbname'])) {
- $error[] = 'STEP 3 : MySQL database name is not set.';
+ $error[] = "STEP 3 : $dbprettyname database name is not set.";
}
if(empty($options['dbhost'])) {
- $error[] = 'STEP 3 : MySQL database host is not set.';
+ $error[] = "STEP 3 : $dbprettyname database host is not set.";
}
if(!isset($options['dbtableprefix'])) {
- $error[] = 'STEP 3 : MySQL database table prefix is not set.';
- }
- }
-
- if($dbtype=='pgsql') { //postgresql needs more config options
- if(empty($options['pg_dbuser'])) {
- $error[] = 'STEP 3 : PostgreSQL database user is not set.';
- }
- if(empty($options['pg_dbpass'])) {
- $error[] = 'STEP 3 : PostgreSQL database password is not set.';
- }
- if(empty($options['pg_dbname'])) {
- $error[] = 'STEP 3 : PostgreSQL database name is not set.';
- }
- if(empty($options['pg_dbhost'])) {
- $error[] = 'STEP 3 : PostgreSQL database host is not set.';
- }
- if(!isset($options['pg_dbtableprefix'])) {
- $error[] = 'STEP 3 : PostgreSQL database table prefix is not set.';
+ $error[] = "STEP 3 : $dbprettyname database table prefix is not set.";
}
}
@@ -150,11 +137,11 @@ class OC_Setup {
}
}
elseif($dbtype == 'pgsql') {
- $dbuser = $options['pg_dbuser'];
- $dbpass = $options['pg_dbpass'];
- $dbname = $options['pg_dbname'];
- $dbhost = $options['pg_dbhost'];
- $dbtableprefix = $options['pg_dbtableprefix'];
+ $dbuser = $options['dbuser'];
+ $dbpass = $options['dbpass'];
+ $dbname = $options['dbname'];
+ $dbhost = $options['dbhost'];
+ $dbtableprefix = $options['dbtableprefix'];
OC_CONFIG::setValue('dbname', $dbname);
OC_CONFIG::setValue('dbhost', $dbhost);
OC_CONFIG::setValue('dbtableprefix', $dbtableprefix);