From: eileenmcnaugton Date: Mon, 7 Mar 2016 12:08:59 +0000 (+1300) Subject: CRM-18172 only load up dashlets relevant to the current domain X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5f3f6ec335ed67341a02a82727e63453492e3cbe;p=civicrm-core.git CRM-18172 only load up dashlets relevant to the current domain --- diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index e42bf80bfa..c8df7cbdc7 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -107,29 +107,30 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { public static function getContactDashlets($flatFormat = FALSE, $contactID = NULL) { $dashlets = array(); - if (!$contactID) { - $contactID = CRM_Core_Session::singleton()->get('userID'); - } - // Get contact dashboard dashlets. $hasDashlets = FALSE; $dao = new CRM_Contact_DAO_DashboardContact(); - $dao->contact_id = $contactID; + $dao->contact_id = $contactID ? $contactID : CRM_Core_Session::singleton()->getLoggedInContactID(); $dao->orderBy('column_no asc, weight asc'); $dao->find(); + + // The available list will only include those which are valid for the domain. + $availableDashlets = self::getDashlets(); while ($dao->fetch()) { // When a dashlet is removed, it stays in the table with status disabled, // so even if a user decides not to have any dashlets show, they will still // have records in the table to indicate that we are not newly initializing. - $hasDashlets = TRUE; - if (!$flatFormat) { - if ($dao->is_active) { - // append weight so that order is preserved. - $dashlets[$dao->column_no]["{$dao->weight}-{$dao->dashboard_id}"] = $dao->is_minimized; + if ((!empty($availableDashlets[$dao->dashboard_id]) && $availableDashlets[$dao->dashboard_id]['is_active'])) { + $hasDashlets = TRUE; + if (!$flatFormat) { + if ($dao->is_active) { + // append weight so that order is preserved. + $dashlets[$dao->column_no]["{$dao->weight}-{$dao->dashboard_id}"] = $dao->is_minimized; + } + } + else { + $dashlets[$dao->dashboard_id] = $dao->dashboard_id; } - } - else { - $dashlets[$dao->dashboard_id] = $dao->dashboard_id; } } @@ -162,7 +163,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { 'domain_id' => CRM_Core_Config::domainID(), 'option.limit' => 0, )); - $contactID = CRM_Core_Session::singleton()->get('userID'); + $contactID = CRM_Core_Session::singleton()->getLoggedInContactID(); $allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']); $defaultDashlets = array(); $defaults = array('blog' => 1, 'getting-started' => '0');