+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
*/
/**
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;
}
}
* When a user accesses their dashboard for the first time, set up
* the default dashlets.
*
+ * @param bool $flatFormat
+ *
* @return array
- * Array of dashboard_id's
+ * Array of dashboard_id's
+ * @throws \CiviCRM_API3_Exception
*/
public static function initializeDashlets($flatFormat = FALSE) {
$dashlets = array();
'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');
foreach ($defaults as $name => $column) {
- if (!empty($allDashlets[$name])) {
+ if (!empty($allDashlets[$name]) && !empty($allDashlets[$name]['id'])) {
$defaultDashlets[$name] = array(
'dashboard_id' => $allDashlets[$name]['id'],
'is_active' => 1,