public function GetDashboard() { $sDashboardDefinition = @file_get_contents($this->sDashboardFile); if ($sDashboardDefinition !== false) { $bCustomized = false; // Search for an eventual user defined dashboard, overloading the existing one $oUDSearch = new DBObjectSearch('UserDashboard'); $oUDSearch->AddCondition('user_id', UserRights::GetUserId(), '='); $oUDSearch->AddCondition('menu_code', $this->sMenuId, '='); $oUDSet = new DBObjectSet($oUDSearch); if ($oUDSet->Count() > 0) { // Assuming there is at most one couple {user, menu}! $oUserDashboard = $oUDSet->Fetch(); $sDashboardDefinition = $oUserDashboard->Get('contents'); $bCustomized = true; } $oDashboard = new RuntimeDashboard($this->sMenuId); $oDashboard->FromXml($sDashboardDefinition); $oDashboard->SetCustomFlag($bCustomized); } else { $oDashboard = null; } return $oDashboard; }
$sDashboardId = utils::ReadParam('dashboard_id', '', false, 'raw_data'); $oDashboard = new RuntimeDashboard($sDashboardId); $oDashboard->Revert(); // trigger a reload of the current page since the dashboard just changed $oPage->add_ready_script("window.location.href=window.location.href;"); // reloads the page, doing a GET even if we arrived via a POST break; case 'render_dashboard': $sDashboardId = utils::ReadParam('dashboard_id', '', false, 'raw_data'); $aParams = array(); $aParams['layout_class'] = utils::ReadParam('layout_class', ''); $aParams['title'] = utils::ReadParam('title', '', false, 'raw_data'); $aParams['cells'] = utils::ReadParam('cells', array(), false, 'raw_data'); $aParams['auto_reload'] = utils::ReadParam('auto_reload', false); $aParams['auto_reload_sec'] = utils::ReadParam('auto_reload_sec', 300); $oDashboard = new RuntimeDashboard($sDashboardId); $oDashboard->FromParams($aParams); $oDashboard->Render($oPage, true); break; case 'dashlet_creation_dlg': $sOQL = utils::ReadParam('oql', '', false, 'raw_data'); RuntimeDashboard::GetDashletCreationDlgFromOQL($oPage, $sOQL); break; case 'add_dashlet': $oForm = RuntimeDashboard::GetDashletCreationForm(); $aValues = $oForm->ReadParams(); $sDashletClass = $aValues['dashlet_class']; $sMenuId = $aValues['menu_id']; if (is_subclass_of($sDashletClass, 'Dashlet')) { $oDashlet = new $sDashletClass(new ModelReflectionRuntime(), 0); $oDashlet->FromParams($aValues);