X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Finst_upgrade.php;h=20a056557e80d07fc16c263376f77b612ca7898a;hb=07a0b37ca7360c5dbb058f5a0ba4c5752671dda7;hp=9141808debec6d073754a488a8164527e1f844ef;hpb=b17df731b4bb055c2fdd568bc4be9e5caa0ee07b;p=fa-stable.git diff --git a/admin/inst_upgrade.php b/admin/inst_upgrade.php index 9141808d..20a05655 100644 --- a/admin/inst_upgrade.php +++ b/admin/inst_upgrade.php @@ -1,15 +1,15 @@ . + See the License here . ***********************************************************************/ -$page_security = 20; +$page_security = 'SA_SOFTWAREUPGRADE'; $path_to_root=".."; include_once($path_to_root . "/includes/session.inc"); @@ -29,7 +29,7 @@ include_once($path_to_root . "/includes/ui.inc"); // function check_table($pref, $table, $field=null, $properties=null) { - $fields = db_query("SHOW COLUMNS FROM ".$pref.$table); + $fields = @db_query("SHOW COLUMNS FROM ".$pref.$table); if (!$fields) return 1; // no such table or error @@ -96,15 +96,20 @@ function upgrade_step($index, $conn) $force = get_post('force_'.$index); if ($force || get_post('install_'.$index)) { - if (!$inst->installed($pref) || $force) + $state = $inst->installed($pref); + if (!$state || $force) { - // if(!$inst->pre_check($pref)) return false; + if (!$inst->pre_check($pref)) return false; if ($sql != '') $ret &= db_import($path_to_root.'/sql/'.$sql, $conn, $force); $ret &= $inst->install($pref, $force); - } + } else + if ($state!==true) { + display_error(_("Upgrade cannot be done because database has been already partially upgraded. Please downgrade database to clean previous version or try forced upgrade.")); + $ret = false; + } } return $ret; } @@ -134,13 +139,8 @@ if (get_post('Upgrade')) ." '".$conn['name']."'"); continue; } - // create security backup - if ($conn['tbpref'] != "") - $filename = $conn['dbname'] . "_" . $conn['tbpref'] . date("Ymd_Hi") . ".sql"; - else - $filename = $conn['dbname'] . "_" . date("Ymd_Hi") . ".sql"; - - db_export($conn, $filename, 'no', 'Security backup before upgrade', $conn['tbpref']); + // create security backup + db_backup($conn, 'no', 'Security backup before upgrade', $conn['tbpref']); // apply all upgrade data foreach ($installers as $i => $inst) { @@ -156,7 +156,13 @@ if (get_post('Upgrade')) if (!$ret) break; } if($ret) + { // re-read the prefs + global $path_to_root; + include_once($path_to_root . "/admin/db/users_db.inc"); + $user = get_user_by_login($_SESSION["wa_current_user"]->username); + $_SESSION["wa_current_user"]->prefs = new user_prefs($user); display_notification(_('All companies data has been successfully updated')); + } $Ajax->activate('_page_body'); } @@ -167,6 +173,7 @@ $th = array(_("Version"), _("Description"), _("Sql file"), _("Install"), table_header($th); $k = 0; //row colour counter +$partial = 0; foreach($installers as $i => $inst) { alt_table_row_color($k); @@ -177,14 +184,27 @@ foreach($installers as $i => $inst) // this is checked only for first (site admin) company, // but in fact we should always upgrade all data sets after // source upgrade. - if ($inst->installed(TB_PREF)) + $check = $inst->installed(TB_PREF); + if ($check === true) label_cell(_("Installed")); - else - check_cells(null,'install_'.$i, 0); + else + if (!$check) + check_cells(null,'install_'.$i, 0); + else { + label_cell("" + . sprintf(_("Partially installed (%s)"), $check) . ""); + $partial++; + } + check_cells(null,'force_'.$i, 0); end_row(); } end_table(1); +if ($partial!=0) { + display_note(_("Database upgrades marked as partially installed cannot be installed automatically. +You have to clean database manually to enable them, or try to perform forced upgrade.")); + br(); +} submit_center('Upgrade', _('Upgrade system'), true, _('Save database and perform upgrade'), 'process'); end_form();