Fixed logout error when setting show users online.
[fa-stable.git] / admin / create_coy.php
index 21861a0f83c8bb9343f4be3fb3956824b89ef3c2..f500feb9cd26b85ca6c17684cf1179286b197bbf 100644 (file)
@@ -41,7 +41,10 @@ function check_data()
        global $db_connections, $tb_pref_counter, $selected_id;
 
        if ($_POST['name'] == "" || $_POST['host'] == "" || $_POST['dbuser'] == "" || $_POST['dbname'] == "")
-               return false;
+       {
+               display_error(_("Database settings are not specified."));
+               return false;
+       }
 
        foreach($db_connections as $id=>$con)
        {
@@ -281,11 +284,6 @@ function display_company_edit($selected_id)
 {
        global $def_coy, $db_connections, $tb_pref_counter;
 
-       if ($selected_id != -1)
-               $n = $selected_id;
-       else
-               $n = count($db_connections);
-
        start_form();
 
        start_table(TABLESTYLE2);
@@ -309,9 +307,17 @@ function display_company_edit($selected_id)
                hidden('dbpassword', $_POST['dbpassword']);
        }
        else
+       {
                $_POST['tbpref'] = $tb_pref_counter."_";
+               // Insert the current settings as default
+               $conn = $db_connections[user_company()];
+               $_POST['host']  = $conn['host'];
+               $_POST['dbuser']  = $conn['dbuser'];
+               $_POST['dbpassword']  = $conn['dbpassword'];
+               $_POST['dbname']  = $conn['dbname'];
+       }
        text_row_ex(_("Company"), 'name', 30);
-       text_row_ex(_("Host"), 'host', 30);
+       text_row_ex(_("Host"), 'host', 30, 60);
        text_row_ex(_("Database User"), 'dbuser', 30);
        if ($selected_id == -1)
                text_row_ex(_("Database Password"), 'dbpassword', 30);