diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index 3bbeaaf25..29fef433a 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -102,7 +102,8 @@ abstract class Dashboard $oReflection = new ReflectionClass($sLayoutClass); if (!$oReflection->isAbstract()) { - $aInfo = $sLayoutClass::GetInfo(); + $aCallSpec = array($sLayoutClass, 'GetInfo'); + $aInfo = call_user_func($aCallSpec); $oPage->add(''); // title="" on either the img or the label does nothing ! } } @@ -127,7 +128,8 @@ abstract class Dashboard $oReflection = new ReflectionClass($sDashletClass); if (!$oReflection->isAbstract()) { - $aInfo = $sDashletClass::GetInfo(); + $aCallSpec = array($sDashletClass, 'GetInfo'); + $aInfo = call_user_func($aCallSpec); $oPage->add(''); } } diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php index ce2368056..1321f0653 100644 --- a/application/menunode.class.inc.php +++ b/application/menunode.class.inc.php @@ -25,6 +25,7 @@ require_once(APPROOT.'/application/utils.inc.php'); require_once(APPROOT.'/application/template.class.inc.php'); +require_once(APPROOT."/application/user.dashboard.class.inc.php"); /** @@ -803,34 +804,57 @@ class DashboardMenuNode extends MenuNode if ($this->sDashboardFile == '') return ''; return parent::GetHyperlink($aExtraParams); } - - public function RenderContent(WebPage $oPage, $aExtraParams = array()) + + protected function GetDashboard() { $sDashboardDefinition = @file_get_contents($this->sDashboardFile); if ($sDashboardDefinition !== 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'); + } + $oDashboard = new RuntimeDashboard($this->sMenuId); $oDashboard->FromXml($sDashboardDefinition); + } + else + { + $oDashboard = null; + } + return $oDashboard; + } + + public function RenderContent(WebPage $oPage, $aExtraParams = array()) + { + $oDashboard = $this->GetDashboard(); + if ($oDashboard != null) + { $oDashboard->Render($oPage, false, $aExtraParams); } else { - $oPage->p("Error: failed to load template file: '{$this->sDashboardFile}'"); // No need to translate ? + $oPage->p("Error: failed to load dashboard file: '{$this->sDashboardFile}'"); } } public function RenderEditor(WebPage $oPage) { - $sDashboardDefinition = @file_get_contents($this->sDashboardFile); - if ($sDashboardDefinition !== false) + $oDashboard = $this->GetDashboard(); + if ($oDashboard != null) { - $oDashboard = new RuntimeDashboard($this->sMenuId); - $oDashboard->FromXml($sDashboardDefinition); $oDashboard->RenderEditor($oPage); } else { - $oPage->p("Error: failed to load template file: '{$this->sDashboardFile}'"); // No need to translate ? + $oPage->p("Error: failed to load dashboard file: '{$this->sDashboardFile}'"); } } } diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 3fe6b430d..deb4abd7a 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -648,6 +648,7 @@ class Config 'application/transaction.class.inc.php', 'application/menunode.class.inc.php', 'application/user.preferences.class.inc.php', + 'application/user.dashboard.class.inc.php', 'application/audit.rule.class.inc.php', 'application/query.class.inc.php', // Romain - That's dirty, because those classes are in fact part of the core