XML data from dashboard

This commit is contained in:
Eric Espie
2026-02-03 11:02:39 +01:00
parent b2041e3b63
commit 0b17e1f9b3
3 changed files with 60 additions and 17 deletions

View File

@@ -166,24 +166,11 @@ class DashboardController extends Controller
throw new SecurityException('Invalid dashboard file !');
}
if (!filter_var(appUserPreferences::GetPref('display_original_dashboard_'.$sDashboardId, false), FILTER_VALIDATE_BOOLEAN)) {
// Search for an eventual user defined dashboard
$oUDSearch = new DBObjectSearch('UserDashboard');
$oUDSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
$oUDSearch->AddCondition('menu_code', $sDashboardId, '=');
$oUDSet = new DBObjectSet($oUDSearch);
if ($oUDSet->Count() > 0) {
// Assuming there is at most one couple {user, menu}!
$oUserDashboard = $oUDSet->Fetch();
$sDashboardDefinition = $oUserDashboard->Get('contents');
} else {
$sDashboardDefinition = @file_get_contents($sDashboardFileSanitized);
}
} else {
$sDashboardDefinition = @file_get_contents($sDashboardFileSanitized);
}
/** @var \Combodo\iTop\Application\Dashboard\Dashboard $oDashboard */
$oDashboard = RuntimeDashboard::GetDashboard($sDashboardFile, $sDashboardId);
$sDashboardDefinition = $oDashboard->ToXML();
if (!is_null($oDashboard)) {
$oPage->TrashUnexpectedOutput();
$oPage->SetContentType('text/xml');