simplified the create database options

This commit is contained in:
Matthew Vale 2015-12-01 10:33:51 +00:00
parent db1e53296e
commit 4ea9c8abc3
2 changed files with 14 additions and 19 deletions

View File

@ -54,7 +54,8 @@ include "root.php";
public $db_name;
public $db_username;
public $db_password;
public $db_create_option = 'none';
public $db_create;
public $db_create_reuse_auth;
public $db_create_username;
public $db_create_password;
@ -203,11 +204,10 @@ include "root.php";
protected function create_database() {
require $this->config_php;
$this->write_progress("Creating database as " . $this->db_type);
if($this->create_db_option == 'same')
if($this->db_create_reuse_auth)
{
$this->create_db_option = 'user';
$this->create_db_username = $this->db_username;
$this->create_db_password = $this->db_username_password;
$this->db_create_username = $this->db_username;
$this->db_create_password = $this->db_username_password;
}
$function = "create_database_" . $this->db_type;
$this->$function();
@ -294,7 +294,7 @@ include "root.php";
}
protected function create_database_pgsql() {
if ($this->db_create_option == 'user') {
if ($this->db_create) {
//Attempt to create new PG role and database
try {
if (strlen($this->db_port) == 0) { $this->db_port = "5432"; }
@ -371,7 +371,7 @@ include "root.php";
$connect_string = '';
$connect_username = $this->db_username;
$connect_password = $this->db_password;
if ($this->db_create_option == 'user') {
if ($this->db_create) {
$connect_username = $this->db_create_username;
$connect_password = $this->db_create_password;
}
@ -395,7 +395,7 @@ include "root.php";
}
//create the table, user and set the permissions only if the db_create_username was provided
if ($this->db_create_option == 'user') {
if ($this->db_create) {
//select the mysql database
try {
$this->dbh->query("USE mysql;");

View File

@ -242,17 +242,12 @@
echo " Create Database Options\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <label class='radio'><input type='radio' name='db_create_option' value='none'";
if($db_create_option=='none') { echo " checked='checked'"; }
echo "/>Do not create database</label>\n";
echo " <label class='radio'><input type='radio' name='db_create_option' value='same'";
if($db_create_option=='same') { echo " checked='checked'"; }
echo "/>Create database using above username/password</label>\n";
echo " <label class='radio'><input type='radio' name='db_create_option' value='user'";
if($db_create_option=='user') { echo " checked='checked'"; }
echo "/>Create database using below username/password</label>\n";
echo "<br />\n";
echo "Choose whether to create the database\n";
echo " <label class='radio'><input type='checkbox' name='db_create' value='1'";
if($db_create=='1') { echo " checked='checked'"; }
echo "/>Create the database</label>\n";
echo " <label class='radio'><input type='checkbox' name='db_create_reuse_auth' value='1'";
if($db_create_reuse_auth=='1') { echo " checked='checked'"; }
echo "/>Create database using the username and password above</label>\n";
echo "</td>\n";
echo "</tr>\n";