Skip to content

Commit

Permalink
Restrict inactive Dashlet query to Dashlets in the current domain
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwach committed Sep 11, 2019
1 parent b999b43 commit d3eb2e9
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions CRM/Core/BAO/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,30 @@ public static function saveDashletChanges($columns, $contactID = NULL) {
}
}

// Disable inactive widgets
// Find dashlets in this domain.
$domainDashlets = civicrm_api3('Dashboard', 'get', [
'return' => array('id'),
'domain_id' => CRM_Core_Config::domainID(),
]);

// Get the array of IDs.
$domainDashletIDs = [];
if ($domainDashlets['is_error'] == 0) {
foreach ($domainDashlets['values'] as $domainDashlet) {
$domainDashletIDs[] = $domainDashlet['id'];
}
}

// Restrict query to Dashlets in this domain.
$domainDashletClause = !empty($domainDashletIDs) ? "dashboard_id IN (" . implode(',', $domainDashletIDs) . ")" : '(1)';

// Disable inactive widgets.
$dashletClause = $dashletIDs ? "dashboard_id NOT IN (" . implode(',', $dashletIDs) . ")" : '(1)';
$updateQuery = "UPDATE civicrm_dashboard_contact
SET is_active = 0
WHERE $dashletClause AND contact_id = {$contactID}";
WHERE $domainDashletClause
AND $dashletClause
AND contact_id = {$contactID}";

CRM_Core_DAO::executeQuery($updateQuery);
}
Expand Down

0 comments on commit d3eb2e9

Please sign in to comment.