mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 20:18:52 +02:00
Refactor Core Update (+3 squashed commit)
Squashed commit: [e1cbfe93f] Refactor Core Update [41ec2adf7] Refactor Core Update [ca6cefca3] Refactor Core Update
This commit is contained in:
@@ -8,11 +8,11 @@
|
||||
namespace Combodo\iTop\CoreUpdate\Controller;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\TwigBase\Controller\Controller;
|
||||
use Combodo\iTop\CoreUpdate\Service\CoreUpdater;
|
||||
use Combodo\iTop\DBTools\Service\DBToolsUtils;
|
||||
use Combodo\iTop\FilesInformation\Service\FileNotExistException;
|
||||
use Combodo\iTop\FilesInformation\Service\FilesInformation;
|
||||
use Combodo\iTop\TwigBase\Controller\Controller;
|
||||
use Dict;
|
||||
use Exception;
|
||||
use IssueLog;
|
||||
@@ -22,61 +22,63 @@ use utils;
|
||||
|
||||
class AjaxController extends Controller
|
||||
{
|
||||
const LOCAL_DIR = __DIR__;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->InitFromModule();
|
||||
}
|
||||
|
||||
public function OperationCanUpdateCore()
|
||||
{
|
||||
$aParams = array();
|
||||
public function OperationCanUpdateCore()
|
||||
{
|
||||
$aParams = array();
|
||||
|
||||
try
|
||||
{
|
||||
$bCanUpdateCore = FilesInformation::CanUpdateCore($sMessage);
|
||||
$aParams['bStatus'] = $bCanUpdateCore;
|
||||
if ($bCanUpdateCore)
|
||||
{
|
||||
$aParams['sMessage'] = Dict::S('iTopUpdate:UI:CanCoreUpdate:Yes');
|
||||
}
|
||||
else
|
||||
{
|
||||
$aParams['sMessage'] = Dict::Format('iTopUpdate:UI:CanCoreUpdate:No', $sMessage);
|
||||
}
|
||||
}
|
||||
catch (FileNotExistException $e)
|
||||
{
|
||||
$aParams['bStatus'] = false;
|
||||
$aParams['sMessage'] = Dict::Format('iTopUpdate:UI:CanCoreUpdate:ErrorFileNotExist', $e->getMessage());
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$aParams['bStatus'] = false;
|
||||
$aParams['sMessage'] = Dict::Format('iTopUpdate:UI:CanCoreUpdate:Error', $e->getMessage());
|
||||
}
|
||||
try
|
||||
{
|
||||
$bCanUpdateCore = FilesInformation::CanUpdateCore($sMessage);
|
||||
$aParams['bStatus'] = $bCanUpdateCore;
|
||||
if ($bCanUpdateCore)
|
||||
{
|
||||
$aParams['sMessage'] = Dict::S('iTopUpdate:UI:CanCoreUpdate:Yes');
|
||||
}
|
||||
else
|
||||
{
|
||||
$aParams['sMessage'] = Dict::Format('iTopUpdate:UI:CanCoreUpdate:No', $sMessage);
|
||||
}
|
||||
} catch (FileNotExistException $e)
|
||||
{
|
||||
$aParams['bStatus'] = false;
|
||||
$aParams['sMessage'] = Dict::Format('iTopUpdate:UI:CanCoreUpdate:ErrorFileNotExist', $e->getMessage());
|
||||
} catch (Exception $e)
|
||||
{
|
||||
$aParams['bStatus'] = false;
|
||||
$aParams['sMessage'] = Dict::Format('iTopUpdate:UI:CanCoreUpdate:Error', $e->getMessage());
|
||||
}
|
||||
|
||||
$this->DisplayJSONPage($aParams);
|
||||
}
|
||||
$this->DisplayJSONPage($aParams);
|
||||
}
|
||||
|
||||
public function OperationGetItopDiskSpace()
|
||||
{
|
||||
$aParams = array();
|
||||
$aParams['iItopDiskSpace'] = FilesInformation::GetItopDiskSpace();
|
||||
$aParams['sItopDiskSpace'] = utils::BytesToFriendlyFormat($aParams['iItopDiskSpace']);
|
||||
$this->DisplayJSONPage($aParams);
|
||||
}
|
||||
public function OperationGetItopDiskSpace()
|
||||
{
|
||||
$aParams = array();
|
||||
$aParams['iItopDiskSpace'] = FilesInformation::GetItopDiskSpace();
|
||||
$aParams['sItopDiskSpace'] = utils::BytesToFriendlyFormat($aParams['iItopDiskSpace']);
|
||||
$this->DisplayJSONPage($aParams);
|
||||
}
|
||||
|
||||
public function OperationGetDBDiskSpace()
|
||||
{
|
||||
$aParams = array();
|
||||
$aParams['iDBDiskSpace'] = DBToolsUtils::GetDatabaseSize();
|
||||
$aParams['sDBDiskSpace'] = utils::BytesToFriendlyFormat($aParams['iDBDiskSpace']);
|
||||
$this->DisplayJSONPage($aParams);
|
||||
}
|
||||
public function OperationGetDBDiskSpace()
|
||||
{
|
||||
$aParams = array();
|
||||
$aParams['iDBDiskSpace'] = DBToolsUtils::GetDatabaseSize();
|
||||
$aParams['sDBDiskSpace'] = utils::BytesToFriendlyFormat($aParams['iDBDiskSpace']);
|
||||
$this->DisplayJSONPage($aParams);
|
||||
}
|
||||
|
||||
public function OperationGetCurrentVersion()
|
||||
{
|
||||
$aParams = array();
|
||||
$aParams['sVersion'] = Dict::Format('UI:iTopVersion:Long', ITOP_APPLICATION, ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE);
|
||||
$this->DisplayJSONPage($aParams);
|
||||
}
|
||||
public function OperationGetCurrentVersion()
|
||||
{
|
||||
$aParams = array();
|
||||
$aParams['sVersion'] = Dict::Format('UI:iTopVersion:Long', ITOP_APPLICATION, ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE);
|
||||
$this->DisplayJSONPage($aParams);
|
||||
}
|
||||
|
||||
public function OperationEnterMaintenance()
|
||||
{
|
||||
@@ -85,8 +87,7 @@ class AjaxController extends Controller
|
||||
{
|
||||
SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
catch (Exception $e)
|
||||
} catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("EnterMaintenance: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
@@ -102,8 +103,7 @@ class AjaxController extends Controller
|
||||
{
|
||||
SetupUtils::ExitReadOnlyMode();
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
catch (Exception $e)
|
||||
} catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("ExitMaintenance: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
@@ -112,22 +112,21 @@ class AjaxController extends Controller
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
|
||||
public function OperationBackup()
|
||||
{
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
CoreUpdater::Backup();
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("Backup: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
$iResponseCode = 500;
|
||||
}
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
public function OperationBackup()
|
||||
{
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
CoreUpdater::Backup();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("Backup: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
$iResponseCode = 500;
|
||||
}
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
|
||||
public function OperationFilesArchive()
|
||||
{
|
||||
@@ -136,8 +135,7 @@ class AjaxController extends Controller
|
||||
{
|
||||
CoreUpdater::CreateItopArchive();
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
catch (Exception $e)
|
||||
} catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("FilesArchive: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
@@ -146,39 +144,71 @@ class AjaxController extends Controller
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
|
||||
public function OperationCopyFiles()
|
||||
{
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
CoreUpdater::CopyCoreFiles();
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("CopyFiles: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
$iResponseCode = 500;
|
||||
}
|
||||
public function OperationCopyFiles()
|
||||
{
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
CoreUpdater::CopyCoreFiles();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("CopyFiles: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
$iResponseCode = 500;
|
||||
}
|
||||
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
|
||||
public function OperationCompile()
|
||||
{
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
CoreUpdater::Compile();
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("Compile: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
$iResponseCode = 500;
|
||||
}
|
||||
public function OperationCheckCompile()
|
||||
{
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
CoreUpdater::CheckCompile();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("Compile: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
$iResponseCode = 500;
|
||||
}
|
||||
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
|
||||
public function OperationCompile()
|
||||
{
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
CoreUpdater::Compile();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("Compile: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
$iResponseCode = 500;
|
||||
}
|
||||
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
|
||||
public function OperationUpdateDatabase()
|
||||
{
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
CoreUpdater::UpdateDatabase();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
{
|
||||
IssueLog::Error("Compile: ".$e->getMessage());
|
||||
$aParams['sError'] = $e->getMessage();
|
||||
$iResponseCode = 500;
|
||||
}
|
||||
|
||||
$this->DisplayJSONPage($aParams, $iResponseCode);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user