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;
}
}
'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');