Fixed a couple of problems in installation procedures.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 17 Jan 2015 19:03:22 +0000 (20:03 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 17 Jan 2015 19:03:22 +0000 (20:03 +0100)
admin/create_coy.php
includes/current_user.inc
includes/db/connect_db_mysql.inc
includes/db/connect_db_mysqli.inc
includes/prefs/sysprefs.inc
install/index.php
install/isession.inc

index 80c747152cc75335d1c15016d9feb2ce6abce6a0..0366e76c2a382de99b970a4e52f1957d7eb6ddb9 100644 (file)
@@ -127,6 +127,8 @@ function handle_submit($selected_id)
                        display_error(_("Error creating Database: ") . $conn['dbname'] . _(", Please create it manually"));
                        $error = true;
                } else {
+                       if (strncmp(db_get_version(), "5.6", 3) >= 0) 
+                               db_query("SET sql_mode = ''");
                        if (!db_import($path_to_root.'/sql/'.get_post('coa'), $conn, $selected_id)) {
                                display_error(_('Cannot create new company due to bugs in sql file.'));
                                $error = true;
index 4f5e7898b4297302a1626a72c82c557ad9b00cf9..89b475fd6d6c83573e1c40c1d8a75afa841ed73e 100644 (file)
@@ -473,12 +473,18 @@ function user_show_codes()
 
 function user_date_format()
 {
-       return $_SESSION["wa_current_user"]->prefs->date_format();
+  global $SysPrefs;
+
+       return isset($_SESSION["wa_current_user"]) ?
+         $_SESSION["wa_current_user"]->prefs->date_format() : $SysPrefs->dflt_date_fmt;
 }
 
 function user_date_display()
 {
-       return $_SESSION["wa_current_user"]->prefs->date_display();
+  global $SysPrefs;
+
+       return isset($_SESSION["wa_current_user"]) ?
+         $_SESSION["wa_current_user"]->prefs->date_display() : $SysPres->dflt_date_sep;
 }
 
 function user_date_sep()
@@ -488,12 +494,14 @@ function user_date_sep()
 
 function user_tho_sep()
 {
-       return $_SESSION["wa_current_user"]->prefs->tho_sep();
+       return isset($_SESSION["wa_current_user"]) ?
+               $_SESSION["wa_current_user"]->prefs->tho_sep() : 0;
 }
 
 function user_dec_sep()
 {
-       return $_SESSION["wa_current_user"]->prefs->dec_sep();
+       return isset($_SESSION["wa_current_user"]) ?
+               $_SESSION["wa_current_user"]->prefs->dec_sep() : 0;
 }
 
 function user_theme()
index 301d49ddac1f55c796c7ada8f41c80ed59389c05..f4dda47c6cef590e95f1af592c83b34dcae4e8c8 100644 (file)
@@ -183,8 +183,7 @@ function db_create_db($connection)
 {
        $db = mysql_connect($connection["host"] ,
                $connection["dbuser"], $connection["dbpassword"]);
-       if (strncmp(db_get_version(), "5.6", 3) >= 0) 
-               db_query("SET sql_mode = ''");
+
        if (!mysql_select_db($connection["dbname"], $db))
        {
                $sql = "CREATE DATABASE IF NOT EXISTS " . $connection["dbname"] . "";
index 8900598a674cf172a182848c253323e09ef28086..7359a85c6f731bd0629764361ea3eca42ff87fca 100644 (file)
@@ -182,11 +182,10 @@ function db_field_name($result, $n)
 function db_create_db($connection)
 {
        $db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]);
-       if (strncmp(db_get_version(), "5.6", 3) >= 0) 
-               db_query("SET sql_mode = ''");
+
        if (!mysqli_select_db($db, $connection["dbname"]))
        {
-               $sql = "CREATE DATABASE IF NOT EXISTS " . $connection["dbname"] . "";
+               $sql = "CREATE DATABASE IF NOT EXISTS `" . $connection["dbname"] . "`";
                if (!mysqli_query($db, $sql) || !mysqli_select_db($db, $connection["dbname"]))
                        return 0;
        }
index bf68576823f16072319ffbdb224f34a1d16a7cf4..ee3fa70bafeadaf36193265ae5f4e5f43776d472 100644 (file)
@@ -21,7 +21,8 @@ class sys_prefs
                global $path_to_root;
 
                include $path_to_root.'/config.default.php';
-               include $path_to_root.'/config.php';
+               if (file_exists($path_to_root.'/config.php'))
+                       include $path_to_root.'/config.php';
 
                // set system wide preferences
                foreach(get_defined_vars() as $name => $value)
index f617dfffdf6b0be9bbd2c7f1855047ab33c8a380..91fa338411ac134266ff19454e10d0f77c4e5f60 100644 (file)
@@ -122,6 +122,9 @@ function install_connect_db() {
        $db = db_create_db($conn);
        if (!$db) {
                display_error(_("Cannot connect to database. User or password is invalid or you have no permittions to create database."));
+       } else {
+               if (strncmp(db_get_version(), "5.6", 3) >= 0) 
+                       db_query("SET sql_mode = ''");
        }
        return $db;
 }
@@ -292,6 +295,7 @@ elseif(get_post('install_coas'))
                        'pass' => $_POST['pass'],
                        'name' => $_POST['name'],
                        'admin' => $_POST['admin'],
+                       'lang' => $_POST['lang']
                ));
                if (do_install()) {
                        $_POST['Page'] = 6;
index acf14202d4b5f37e77c287ef48c56d60e792888e..8084317208d37d628abb8f42e620ca9e38a779ba 100644 (file)
@@ -86,6 +86,9 @@ header("Cache-control: private");
 
 include_once($path_to_root . "/config.default.php");
 
+$_SESSION['SysPrefs'] = new sys_prefs();
+$SysPrefs = &$_SESSION['SysPrefs'];
+
 $inst_langs = array(
   'C' => array ( 'name' => 'English',  'code' => 'C',          'encoding' => 'iso-8859-1'),
   'ar_EG' => array ( 'name' => 'Arabic',       'code' => 'ar_EG',      'encoding' => 'utf-8', 'rtl' => true),
@@ -119,6 +122,7 @@ if (!isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_
        $l = array_search_value($i_lang, $inst_langs,  'code');
        $_SESSION['language'] = new language($l['name'], $l['code'], $l['encoding'],
         isset($l['rtl']) ? 'rtl' : 'ltr');
+
 }
 if (!isset($installed_languages))
        $installed_languages = array();
@@ -150,8 +154,6 @@ html_cleanup($_POST);
 html_cleanup($_REQUEST);
 html_cleanup($_SERVER);
 
-$SysPrefs = &$_SESSION['SysPrefs'];
-
 // POST vars cleanup needed for direct reuse.
 // We quote all values later with db_escape() before db update.
        $_POST = strip_quotes($_POST);