2022-12-05 18:11:32 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 OpenXE project
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Xentral\Components\Database\Exception\QueryFailureException;
|
|
|
|
|
|
|
|
class upgrade {
|
|
|
|
|
|
|
|
function __construct($app, $intern = false) {
|
|
|
|
$this->app = $app;
|
|
|
|
if ($intern)
|
|
|
|
return;
|
|
|
|
|
|
|
|
$this->app->ActionHandlerInit($this);
|
|
|
|
$this->app->ActionHandler("list", "upgrade_overview");
|
|
|
|
$this->app->DefaultActionHandler("list");
|
|
|
|
$this->app->ActionHandlerListen($app);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Install() {
|
|
|
|
/* Fill out manually later */
|
|
|
|
}
|
|
|
|
|
|
|
|
function upgrade_overview() {
|
|
|
|
|
|
|
|
$submit = $this->app->Secure->GetPOST('submit');
|
|
|
|
$verbose = $this->app->Secure->GetPOST('details_anzeigen') === '1';
|
2022-12-06 21:05:41 +01:00
|
|
|
$db_verbose = $this->app->Secure->GetPOST('db_details_anzeigen') === '1';
|
2022-12-05 18:11:32 +01:00
|
|
|
$force = $this->app->Secure->GetPOST('erzwingen') === '1';
|
|
|
|
|
2022-12-13 19:23:37 +01:00
|
|
|
$this->app->Tpl->Set('DETAILS_ANZEIGEN', $verbose?"checked":"");
|
|
|
|
$this->app->Tpl->Set('DB_DETAILS_ANZEIGEN', $db_verbose?"checked":"");
|
|
|
|
|
2022-12-05 18:11:32 +01:00
|
|
|
include("../upgrade/upgrade.php");
|
|
|
|
|
2022-12-06 21:05:41 +01:00
|
|
|
$logfile = "../upgrade/data/upgrade.log";
|
|
|
|
upgrade_set_out_file_name($logfile);
|
|
|
|
|
|
|
|
$this->app->Tpl->Set('UPGRADE_VISIBLE', "hidden");
|
|
|
|
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "hidden");
|
|
|
|
|
2022-12-14 16:18:06 +01:00
|
|
|
//function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection, bool $origin) {
|
2022-12-09 08:13:12 +01:00
|
|
|
|
2022-12-13 19:23:37 +01:00
|
|
|
$directory = dirname(getcwd())."/upgrade";
|
|
|
|
|
2022-12-06 21:05:41 +01:00
|
|
|
switch ($submit) {
|
|
|
|
case 'check_upgrade':
|
|
|
|
$this->app->Tpl->Set('UPGRADE_VISIBLE', "");
|
|
|
|
unlink($logfile);
|
2022-12-14 16:18:06 +01:00
|
|
|
upgrade_main($directory,$verbose,true,false,false,true,false,$force,false,false);
|
2022-12-06 21:05:41 +01:00
|
|
|
break;
|
|
|
|
case 'do_upgrade':
|
|
|
|
unlink($logfile);
|
2022-12-14 16:18:06 +01:00
|
|
|
upgrade_main($directory,$verbose,true,true,false,true,true,$force,false,false);
|
2022-12-06 21:05:41 +01:00
|
|
|
break;
|
|
|
|
case 'check_db':
|
|
|
|
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
|
|
|
|
unlink($logfile);
|
2022-12-14 16:18:06 +01:00
|
|
|
upgrade_main($directory,$db_verbose,false,false,false,true,false,$force,false,false);
|
2022-12-06 21:05:41 +01:00
|
|
|
break;
|
|
|
|
case 'do_db_upgrade':
|
|
|
|
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
|
|
|
|
unlink($logfile);
|
2022-12-14 16:18:06 +01:00
|
|
|
upgrade_main($directory,$db_verbose,false,false,false,true,true,$force,false,false);
|
2022-12-06 21:05:41 +01:00
|
|
|
break;
|
|
|
|
case 'refresh':
|
|
|
|
break;
|
2022-12-05 18:11:32 +01:00
|
|
|
}
|
|
|
|
|
2022-12-06 21:05:41 +01:00
|
|
|
// Read results
|
|
|
|
$result = file_get_contents($logfile);
|
2022-12-05 18:11:32 +01:00
|
|
|
$this->app->Tpl->Set('CURRENT', $this->app->erp->Revision());
|
2022-12-06 21:05:41 +01:00
|
|
|
$this->app->Tpl->Set('OUTPUT_FROM_CLI',nl2br($result));
|
2022-12-05 18:11:32 +01:00
|
|
|
$this->app->Tpl->Parse('PAGE', "upgrade.tpl");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-13 19:23:37 +01:00
|
|
|
|