/** * Run dashboard. * * @return void */ public function run() { // Add dashboard js and css $resources = CRM_Core_Resources::singleton(); $resources->addScriptFile('civicrm', 'js/jquery/jquery.dashboard.js', 0, 'html-header', FALSE); $resources->addStyleFile('civicrm', 'css/dashboard.css'); $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject); CRM_Utils_System::setTitle(ts('CiviCRM Home')); $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($resetCache) { CRM_Core_BAO_Dashboard::resetDashletCache($contactID); } // call hook to get html from other modules // ignored but needed to prevent warnings $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW; $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement); if (is_array($html)) { $this->assign_by_ref('hookContent', $html); $this->assign('hookContentPlacement', $contentPlacement); } $communityMessages = CRM_Core_CommunityMessages::create(); if ($communityMessages->isEnabled()) { $message = $communityMessages->pick(); if ($message) { $this->assign('communityMessages', $communityMessages->evalMarkup($message['markup'])); } } return parent::run(); }
/** * Run dashboard * * @return none * @access public */ function run() { $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject); if ($resetCache) { CRM_Core_BAO_Dashboard::resetDashletCache(); } CRM_Utils_System::setTitle(ts('CiviCRM Home')); $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); // call hook to get html from other modules // ignored but needed to prevent warnings $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW; $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement); if (is_array($html)) { $this->assign_by_ref('hookContent', $html); $this->assign('hookContentPlacement', $contentPlacement); } //check that default FROM email address, owner (domain) organization name and default mailbox are configured. $fromEmailOK = TRUE; $ownerOrgOK = TRUE; $defaultMailboxOK = TRUE; // Don't put up notices if user doesn't have administer CiviCRM permission if (CRM_Core_Permission::check('administer CiviCRM')) { $destination = CRM_Utils_System::url('civicrm/dashboard', 'reset=1', FALSE, NULL, FALSE); $destination = urlencode($destination); list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE); if (!$domainEmailAddress || $domainEmailAddress == '*****@*****.**') { $fixEmailUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}"); $this->assign('fixEmailUrl', $fixEmailUrl); $fromEmailOK = FALSE; } $domain = CRM_Core_BAO_Domain::getDomain(); $domainName = $domain->name; if (!$domainName || $domainName == 'Default Domain Name') { $fixOrgUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}"); $this->assign('fixOrgUrl', $fixOrgUrl); $ownerOrgOK = FALSE; } $config = CRM_Core_Config::singleton(); if (in_array('CiviMail', $config->enableComponents) && CRM_Core_BAO_MailSettings::defaultDomain() == "FIXME.ORG") { $fixDefaultMailbox = CRM_Utils_System::url('civicrm/admin/mailSettings', "reset=1&civicrmDestination={$destination}"); $this->assign('fixDefaultMailbox', $fixDefaultMailbox); $defaultMailboxOK = FALSE; } } $this->assign('fromEmailOK', $fromEmailOK); $this->assign('ownerOrgOK', $ownerOrgOK); $this->assign('defaultMailboxOK', $defaultMailboxOK); return parent::run(); }
/** * Run dashboard * * @return none * @access public */ function run() { $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject); if ($resetCache) { require_once 'CRM/Core/BAO/Dashboard.php'; CRM_Core_BAO_Dashboard::resetDashletCache(); } CRM_Utils_System::setTitle(ts('CiviCRM Home')); $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); // call hook to get html from other modules require_once 'CRM/Utils/Hook.php'; $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW; // ignored but needed to prevent warnings $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement); if (is_array($html)) { $this->assign_by_ref('hookContent', $html); $this->assign('hookContentPlacement', $contentPlacement); } return parent::run(); }
/** * Reset navigation for all contacts * * @param integer $contactID - reset only entries belonging to that contact ID */ static function resetNavigation($contactID = NULL) { $params = array(); $query = "UPDATE civicrm_setting SET value = NULL WHERE name='navigation'"; if ($contactID) { $query .= " AND contact_id = %1"; $params[1] = array($contactID, 'Integer'); } else { $query .= " AND contact_id IS NOT NULL"; } CRM_Core_DAO::executeQuery($query, $params); CRM_Core_BAO_Cache::deleteGroup('navigation'); // also reset the dashlet cache in case permissions have changed etc CRM_Core_BAO_Dashboard::resetDashletCache($contactID); }
/** * Run dashboard * * @return void * @access public */ function run() { // Add dashboard js and css $resources = CRM_Core_Resources::singleton(); $resources->addScriptFile('civicrm', 'packages/jquery/plugins/jquery.dashboard.js', 0, 'html-header', FALSE); $resources->addStyleFile('civicrm', 'packages/jquery/css/dashboard.css'); $config = CRM_Core_Config::singleton(); // Add dashlet-specific js files // TODO: Need a much better way of managing on-the-fly js requirements. Require.js perhaps? // Checking if a specific dashlet is enabled is a pain and including the js here sucks anyway // So here's a compromise: if (in_array('CiviCase', $config->enableComponents)) { $resources->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); } $resetCache = CRM_Utils_Request::retrieve('resetCache', 'Positive', CRM_Core_DAO::$_nullObject); CRM_Utils_System::setTitle(ts('CiviCRM Home')); $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($resetCache) { CRM_Core_BAO_Dashboard::resetDashletCache($contactID); } // call hook to get html from other modules // ignored but needed to prevent warnings $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW; $html = CRM_Utils_Hook::dashboard($contactID, $contentPlacement); if (is_array($html)) { $this->assign_by_ref('hookContent', $html); $this->assign('hookContentPlacement', $contentPlacement); } //check that default FROM email address, owner (domain) organization name and default mailbox are configured. $fromEmailOK = TRUE; $ownerOrgOK = TRUE; $defaultMailboxOK = TRUE; // Don't put up notices if user doesn't have administer CiviCRM permission if (CRM_Core_Permission::check('administer CiviCRM')) { $destination = CRM_Utils_System::url('civicrm/dashboard', 'reset=1', FALSE, NULL, FALSE); $destination = urlencode($destination); list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE); if (!$domainEmailAddress || $domainEmailAddress == '*****@*****.**') { $fixEmailUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}"); $this->assign('fixEmailUrl', $fixEmailUrl); $fromEmailOK = FALSE; } $domain = CRM_Core_BAO_Domain::getDomain(); $domainName = $domain->name; if (!$domainName || $domainName == 'Default Domain Name') { $fixOrgUrl = CRM_Utils_System::url("civicrm/admin/domain", "action=update&reset=1&civicrmDestination={$destination}"); $this->assign('fixOrgUrl', $fixOrgUrl); $ownerOrgOK = FALSE; } if (in_array('CiviMail', $config->enableComponents) && CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG") { $fixDefaultMailbox = CRM_Utils_System::url('civicrm/admin/mailSettings', "reset=1&civicrmDestination={$destination}"); $this->assign('fixDefaultMailbox', $fixDefaultMailbox); $defaultMailboxOK = FALSE; } } $this->assign('fromEmailOK', $fromEmailOK); $this->assign('ownerOrgOK', $ownerOrgOK); $this->assign('defaultMailboxOK', $defaultMailboxOK); $communityMessages = CRM_Core_CommunityMessages::create(); if ($communityMessages->isEnabled()) { $message = $communityMessages->pick(); if ($message) { $this->assign('communityMessages', $communityMessages->evalMarkup($message['markup'])); } } return parent::run(); }
/** * Reset navigation for all contacts or a specified contact. * * @param int $contactID * Reset only entries belonging to that contact ID. * * @return string */ public static function resetNavigation($contactID = NULL) { $newKey = CRM_Utils_String::createRandom(self::CACHE_KEY_STRLEN, CRM_Utils_String::ALPHANUMERIC); if (!$contactID) { $query = "UPDATE civicrm_setting SET value = '{$newKey}' WHERE name='navigation' AND contact_id IS NOT NULL"; CRM_Core_DAO::executeQuery($query); CRM_Core_BAO_Cache::deleteGroup('navigation'); } else { // before inserting check if contact id exists in db // this is to handle weird case when contact id is in session but not in db $contact = new CRM_Contact_DAO_Contact(); $contact->id = $contactID; if ($contact->find(TRUE)) { CRM_Core_BAO_Setting::setItem($newKey, CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'navigation', NULL, $contactID, $contactID); } } // also reset the dashlet cache in case permissions have changed etc // FIXME: decouple this CRM_Core_BAO_Dashboard::resetDashletCache($contactID); return $newKey; }