コード例 #1
0
/**
 * Output navigation script tag
 *
 * @param array $params
 *   - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
 * @param object $smarty the Smarty object
 *
 * @return string HTML
 */
function smarty_function_crmNavigationMenu($params, &$smarty)
{
    $config = CRM_Core_Config::singleton();
    //check if logged in user has access CiviCRM permission and build menu
    $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
    if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
        $buildNavigation = FALSE;
    }
    if ($config->userFrameworkFrontend) {
        $buildNavigation = FALSE;
    }
    if ($buildNavigation) {
        $session = CRM_Core_Session::singleton();
        $contactID = $session->get('userID');
        if ($contactID) {
            // These params force the browser to refresh the js file when switching user, domain, or language
            // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url
            // We end the string with .js to trick apache mods into sending pro-caching headers
            // @see CRM_Admin_Page_AJAX::getNavigationMenu
            $lang = $config->lcMessages;
            $domain = CRM_Core_Config::domainID();
            $key = CRM_Core_BAO_Navigation::getCacheKey($contactID);
            $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}.js");
            return '<script type="text/javascript" src="' . $src . '"></script>';
        }
    }
    return '';
}
コード例 #2
0
/**
 * Output navigation script tag
 *
 * @param array $params
 *   - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
 * @param CRM_Core_Smarty $smarty
 *   The Smarty object.
 *
 * @return string
 *   HTML
 */
function smarty_function_crmNavigationMenu($params, &$smarty)
{
    $config = CRM_Core_Config::singleton();
    //check if logged in user has access CiviCRM permission and build menu
    $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
    if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
        $buildNavigation = FALSE;
    }
    if ($config->userFrameworkFrontend) {
        $buildNavigation = FALSE;
    }
    if ($buildNavigation) {
        $session = CRM_Core_Session::singleton();
        $contactID = $session->get('userID');
        if ($contactID) {
            // These params force the browser to refresh the js file when switching user, domain, or language
            // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url
            // @see CRM_Admin_Page_AJAX::getNavigationMenu
            $lang = $config->lcMessages;
            $domain = CRM_Core_Config::domainID();
            $key = CRM_Core_BAO_Navigation::getCacheKey($contactID);
            $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}");
            // CRM-15493 QFkey needed for quicksearch bar - must be unique on each page refresh so adding it directly to markup
            $qfKey = CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE);
            return '<script id="civicrm-navigation-menu" type="text/javascript" src="' . $src . '" data-qfkey=' . json_encode($qfKey) . '></script>';
        }
    }
    return '';
}
/**
 * Generate the nav menu
 *
 * @param array $params
 *   - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
 * @param object $smarty the Smarty object
 *
 * @return string HTML
 */
function smarty_function_crmNavigationMenu($params, &$smarty)
{
    //check if logged in user has access CiviCRM permission and build menu
    $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
    if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
        $buildNavigation = FALSE;
    }
    if ($buildNavigation) {
        $session = CRM_Core_Session::singleton();
        $contactID = $session->get('userID');
        if ($contactID) {
            $navigation = CRM_Core_BAO_Navigation::createNavigation($contactID);
            $smarty->assign('navigation', $navigation);
            return $smarty->fetch('CRM/common/Navigation.tpl');
        }
    }
    return '';
}
コード例 #4
0
 /**
  * Retrieve the settings values from db.
  *
  * @param $defaults
  *
  * @return array
  */
 public static function retrieve(&$defaults)
 {
     $domain = new CRM_Core_DAO_Domain();
     //we are initializing config, really can't use, CRM-7863
     $urlVar = 'q';
     if (defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla') {
         $urlVar = 'task';
     }
     if (CRM_Core_Config::isUpgradeMode()) {
         $domain->selectAdd('config_backend');
     } elseif (CRM_Utils_Array::value($urlVar, $_GET) == 'admin/modules/list/confirm') {
         $domain->selectAdd('config_backend', 'locales');
     } else {
         $domain->selectAdd('config_backend, locales, locale_custom_strings');
     }
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(TRUE);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         if ($defaults === FALSE || !is_array($defaults)) {
             $defaults = array();
             return FALSE;
         }
         $skipVars = self::skipVars();
         foreach ($skipVars as $skip) {
             if (array_key_exists($skip, $defaults)) {
                 unset($defaults[$skip]);
             }
         }
         // check if there are any locale strings
         if ($domain->locale_custom_strings) {
             $defaults['localeCustomStrings'] = unserialize($domain->locale_custom_strings);
         } else {
             $defaults['localeCustomStrings'] = NULL;
         }
         // are we in a multi-language setup?
         $multiLang = $domain->locales ? TRUE : FALSE;
         // set the current language
         $lcMessages = NULL;
         $session = CRM_Core_Session::singleton();
         // on multi-lang sites based on request and civicrm_uf_match
         if ($multiLang) {
             $lcMessagesRequest = CRM_Utils_Request::retrieve('lcMessages', 'String', $this);
             $languageLimit = array();
             if (array_key_exists('languageLimit', $defaults) && is_array($defaults['languageLimit'])) {
                 $languageLimit = $defaults['languageLimit'];
             }
             if (in_array($lcMessagesRequest, array_keys($languageLimit))) {
                 $lcMessages = $lcMessagesRequest;
                 //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
                 CRM_Core_BAO_Cache::deleteGroup('navigation');
             } else {
                 $lcMessagesRequest = NULL;
             }
             if (!$lcMessagesRequest) {
                 $lcMessagesSession = $session->get('lcMessages');
                 if (in_array($lcMessagesSession, array_keys($languageLimit))) {
                     $lcMessages = $lcMessagesSession;
                 } else {
                     $lcMessagesSession = NULL;
                 }
             }
             if ($lcMessagesRequest) {
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(TRUE)) {
                     $ufm->language = $lcMessages;
                     $ufm->save();
                 }
                 $session->set('lcMessages', $lcMessages);
             }
             if (!$lcMessages and $session->get('userID')) {
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(TRUE) && in_array($ufm->language, array_keys($languageLimit))) {
                     $lcMessages = $ufm->language;
                 }
                 $session->set('lcMessages', $lcMessages);
             }
         }
         global $dbLocale;
         // try to inherit the language from the hosting CMS
         if (!empty($defaults['inheritLocale'])) {
             // FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
             $dbLocale = $multiLang ? "_{$defaults['lcMessages']}" : '';
             $lcMessages = CRM_Utils_System::getUFLocale();
             if ($domain->locales and !in_array($lcMessages, explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales))) {
                 $lcMessages = NULL;
             }
         }
         if (empty($lcMessages)) {
             //CRM-11993 - if a single-lang site, use default
             $lcMessages = CRM_Utils_Array::value('lcMessages', $defaults);
         }
         // set suffix for table names - use views if more than one language
         $dbLocale = $multiLang ? "_{$lcMessages}" : '';
         // FIXME: an ugly hack to fix CRM-4041
         global $tsLocale;
         $tsLocale = $lcMessages;
         // FIXME: as bad aplace as any to fix CRM-5428
         // (to be moved to a sane location along with the above)
         if (function_exists('mb_internal_encoding')) {
             mb_internal_encoding('UTF-8');
         }
     }
     // dont add if its empty
     if (!empty($defaults)) {
         // retrieve directory and url preferences also
         CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences($defaults);
         // Pickup enabled-components from settings table if found.
         $enableComponents = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
         if (!empty($enableComponents)) {
             $defaults['enableComponents'] = $enableComponents;
             $components = CRM_Core_Component::getComponents();
             $enabledComponentIDs = array();
             foreach ($defaults['enableComponents'] as $name) {
                 $enabledComponentIDs[] = $components[$name]->componentID;
             }
             $defaults['enableComponentIDs'] = $enabledComponentIDs;
         }
     }
 }
コード例 #5
0
 static function retrieveDirectoryAndURLPreferences(&$params, $setInConfig = FALSE)
 {
     if ($setInConfig) {
         $config = CRM_Core_Config::singleton();
     }
     $isJoomla = defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla' ? TRUE : FALSE;
     if (CRM_Core_Config::isUpgradeMode() && !$isJoomla) {
         $currentVer = CRM_Core_BAO_Domain::version();
         if (version_compare($currentVer, '4.1.alpha1') < 0) {
             return;
         }
     }
     $sql = "\nSELECT name, group_name, value\nFROM   civicrm_setting\nWHERE  ( group_name = %1\nOR       group_name = %2 )\nAND domain_id = %3\n";
     $sqlParams = array(1 => array(self::DIRECTORY_PREFERENCES_NAME, 'String'), 2 => array(self::URL_PREFERENCES_NAME, 'String'), 3 => array(CRM_Core_Config::domainID(), 'Integer'));
     $dao = CRM_Core_DAO::executeQuery($sql, $sqlParams, TRUE, NULL, FALSE, TRUE, TRUE);
     if (is_a($dao, 'DB_Error')) {
         if (CRM_Core_Config::isUpgradeMode()) {
             // seems like this is a 4.0 -> 4.1 upgrade, so we suppress this error and continue
             // hack to set the resource base url so that js/ css etc is loaded correctly
             if ($isJoomla) {
                 $params['userFrameworkResourceURL'] = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/') . str_replace('administrator', '', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', 'userFrameworkResourceURL', 'value', 'name'));
             }
             return;
         } else {
             echo "Fatal DB error, exiting, seems like your schema does not have civicrm_setting table\n";
             exit;
         }
     }
     while ($dao->fetch()) {
         $value = self::getOverride($dao->group_name, $dao->name, NULL);
         if ($value === NULL && $dao->value) {
             $value = unserialize($dao->value);
             if ($dao->group_name == self::DIRECTORY_PREFERENCES_NAME) {
                 $value = CRM_Utils_File::absoluteDirectory($value);
             } else {
                 // CRM-7622: we need to remove the language part
                 $value = CRM_Utils_System::absoluteURL($value, TRUE);
             }
         }
         // CRM-10931, If DB doesn't have any value, carry on with any default value thats already available
         if (!isset($value) && CRM_Utils_Array::value($dao->name, $params)) {
             $value = $params[$dao->name];
         }
         $params[$dao->name] = $value;
         if ($setInConfig) {
             $config->{$dao->name} = $value;
         }
     }
 }
コード例 #6
0
 /**
  * Show the message about CiviCRM versions
  *
  * @param obj: $template (reference)
  */
 static function versionCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     $versionCheck = CRM_Utils_VersionCheck::singleton();
     $newerVersion = $versionCheck->newerVersion();
     $template->assign('newer_civicrm_version', $newerVersion);
 }
コード例 #7
0
 /**
  * Print an unhandled exception
  *
  * @param $e
  */
 function reportException(Exception $e)
 {
     CRM_Core_Error::debug_var('CRM_Queue_ErrorPolicy_reportException', CRM_Core_Error::formatTextException($e));
     $response = array('is_error' => 1, 'is_continue' => 0);
     $config = CRM_Core_Config::singleton();
     if ($config->backtrace || CRM_Core_Config::isUpgradeMode()) {
         $response['exception'] = CRM_Core_Error::formatHtmlException($e);
     } else {
         $response['exception'] = htmlentities($e->getMessage());
     }
     global $activeQueueRunner;
     if (is_object($activeQueueRunner)) {
         $response['last_task_title'] = $activeQueueRunner->lastTaskTitle;
     }
     CRM_Utils_JSON::output($response);
 }
コード例 #8
0
ファイル: Resources.php プロジェクト: nganivet/civicrm-core
 /**
  * Get or set the single instance of CRM_Core_Resources.
  *
  * @param CRM_Core_Resources $instance
  *   New copy of the manager.
  * @return CRM_Core_Resources
  */
 public static function singleton(CRM_Core_Resources $instance = NULL)
 {
     if ($instance !== NULL) {
         self::$_singleton = $instance;
     }
     if (self::$_singleton === NULL) {
         $sys = CRM_Extension_System::singleton();
         $cache = new CRM_Utils_Cache_SqlGroup(array('group' => 'js-strings', 'prefetch' => FALSE));
         self::$_singleton = new CRM_Core_Resources($sys->getMapper(), $cache, CRM_Core_Config::isUpgradeMode() ? NULL : 'resCacheCode');
     }
     return self::$_singleton;
 }
コード例 #9
0
ファイル: Setting.php プロジェクト: kidaa30/yes
 /**
  * Civicrm_setting didn't exist before 4.1.alpha1 and this function helps taking decisions during upgrade
  *
  * @return bool
  */
 public static function isUpgradeFromPreFourOneAlpha1()
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         $currentVer = CRM_Core_BAO_Domain::version();
         if (version_compare($currentVer, '4.1.alpha1') < 0) {
             return TRUE;
         }
     }
     return FALSE;
 }
コード例 #10
0
ファイル: UFGroup.php プロジェクト: rollox/civicrm-core
 /**
  * Get the uf group for a module.
  *
  * @param string $moduleName
  *   Module name.
  * @param int $count
  *   No to increment the weight.
  * @param bool $skipPermission
  * @param int $op
  *   Which operation (view, edit, create, etc) to check permission for.
  * @param array|NULL $returnFields list of UFGroup fields to return; NULL for default
  *
  * @return array
  *   array of ufgroups for a module
  */
 public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW, $returnFields = NULL)
 {
     $selectFields = array('id', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type');
     if (!CRM_Core_Config::isUpgradeMode()) {
         // CRM-13555, since description field was added later (4.4), and to avoid any problems with upgrade
         $selectFields[] = 'description';
     }
     if (!empty($returnFields)) {
         $selectFields = array_merge($returnFields, array_diff($selectFields, $returnFields));
     }
     $queryString = 'SELECT civicrm_uf_group.' . implode(', civicrm_uf_group.', $selectFields) . '
                     FROM civicrm_uf_group
                     LEFT JOIN civicrm_uf_join ON (civicrm_uf_group.id = uf_group_id)';
     $p = array();
     if ($moduleName) {
         $queryString .= ' AND civicrm_uf_group.is_active = 1
                           WHERE civicrm_uf_join.module = %2';
         $p[2] = array($moduleName, 'String');
     }
     // add permissioning for profiles only if not registration
     if (!$skipPermission) {
         $permissionClause = CRM_Core_Permission::ufGroupClause($op, 'civicrm_uf_group.');
         if (strpos($queryString, 'WHERE') !== FALSE) {
             $queryString .= " AND {$permissionClause} ";
         } else {
             $queryString .= " {$permissionClause} ";
         }
     }
     $queryString .= ' ORDER BY civicrm_uf_join.weight, civicrm_uf_group.title';
     $dao = CRM_Core_DAO::executeQuery($queryString, $p);
     $ufGroups = array();
     while ($dao->fetch()) {
         //skip mix profiles in user Registration / User Account
         if (($moduleName == 'User Registration' || $moduleName == 'User Account') && CRM_Core_BAO_UFField::checkProfileType($dao->id)) {
             continue;
         }
         foreach ($selectFields as $key => $field) {
             if ($field == 'id') {
                 continue;
             }
             $ufGroups[$dao->id][$field] = $dao->{$field};
         }
     }
     // Allow other modules to alter/override the UFGroups.
     CRM_Utils_Hook::buildUFGroupsForModule($moduleName, $ufGroups);
     return $ufGroups;
 }
コード例 #11
0
ファイル: Smarty.php プロジェクト: kidaa30/yes
 private function initialize()
 {
     $config = CRM_Core_Config::singleton();
     if (isset($config->customTemplateDir) && $config->customTemplateDir) {
         $this->template_dir = array_merge(array($config->customTemplateDir), $config->templateDir);
     } else {
         $this->template_dir = $config->templateDir;
     }
     $this->compile_dir = $config->templateCompileDir;
     // check and ensure it is writable
     // else we sometime suppress errors quietly and this results
     // in blank emails etc
     if (!is_writable($this->compile_dir)) {
         echo "CiviCRM does not have permission to write temp files in {$this->compile_dir}, Exiting";
         exit;
     }
     //Check for safe mode CRM-2207
     if (ini_get('safe_mode')) {
         $this->use_sub_dirs = FALSE;
     } else {
         $this->use_sub_dirs = TRUE;
     }
     $customPluginsDir = NULL;
     if (isset($config->customPHPPathDir)) {
         $customPluginsDir = $config->customPHPPathDir . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
         if (!file_exists($customPluginsDir)) {
             $customPluginsDir = NULL;
         }
     }
     if ($customPluginsDir) {
         $this->plugins_dir = array($customPluginsDir, $config->smartyDir . 'plugins', $config->pluginsDir);
     } else {
         $this->plugins_dir = array($config->smartyDir . 'plugins', $config->pluginsDir);
     }
     // add the session and the config here
     $session = CRM_Core_Session::singleton();
     $this->assign_by_ref('config', $config);
     $this->assign_by_ref('session', $session);
     // check default editor and assign to template
     $defaultWysiwygEditor = $session->get('defaultWysiwygEditor');
     if (!$defaultWysiwygEditor && !CRM_Core_Config::isUpgradeMode()) {
         $defaultWysiwygEditor = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id');
         // For logged-in users, store it in session to reduce db calls
         if ($session->get('userID')) {
             $session->set('defaultWysiwygEditor', $defaultWysiwygEditor);
         }
     }
     $this->assign('defaultWysiwygEditor', $defaultWysiwygEditor);
     global $tsLocale;
     $this->assign('tsLocale', $tsLocale);
     // CRM-7163 hack: we don’t display langSwitch on upgrades anyway
     if (!CRM_Core_Config::isUpgradeMode()) {
         $this->assign('langSwitch', CRM_Core_I18n::languages(TRUE));
     }
     $this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
     $this->load_filter('pre', 'resetExtScope');
     $this->assign('crmPermissions', new CRM_Core_Smarty_Permissions());
 }
コード例 #12
0
ファイル: Schema.php プロジェクト: hguru/224Civi
 static function triggerInfo(&$info, $tableName = NULL)
 {
     // get the current supported locales
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     if (empty($domain->locales)) {
         return;
     }
     $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
     $locale = array_pop($locales);
     // CRM-10027
     if (count($locales) == 0) {
         return;
     }
     $currentVer = CRM_Core_BAO_Domain::version(TRUE);
     if ($currentVer && CRM_Core_Config::isUpgradeMode()) {
         // take exact version so that proper schema structure file in invoked
         $latest = self::getLatestSchema($currentVer);
         require_once "CRM/Core/I18n/SchemaStructure_{$latest}.php";
         $class = "CRM_Core_I18n_SchemaStructure_{$latest}";
     } else {
         $class = 'CRM_Core_I18n_SchemaStructure';
     }
     $columns =& $class::columns();
     foreach ($columns as $table => $hash) {
         if ($tableName && $tableName != $table) {
             continue;
         }
         $trigger = array();
         foreach ($hash as $column => $_) {
             $trigger[] = "IF NEW.{$column}_{$locale} IS NOT NULL THEN";
             foreach ($locales as $old) {
                 $trigger[] = "IF NEW.{$column}_{$old} IS NULL THEN SET NEW.{$column}_{$old} = NEW.{$column}_{$locale}; END IF;";
             }
             foreach ($locales as $old) {
                 $trigger[] = "ELSEIF NEW.{$column}_{$old} IS NOT NULL THEN";
                 foreach (array_merge($locales, array($locale)) as $loc) {
                     if ($loc == $old) {
                         continue;
                     }
                     $trigger[] = "IF NEW.{$column}_{$loc} IS NULL THEN SET NEW.{$column}_{$loc} = NEW.{$column}_{$old}; END IF;";
                 }
             }
             $trigger[] = 'END IF;';
         }
         $sql = implode(' ', $trigger);
         $info[] = array('table' => array($table), 'when' => 'BEFORE', 'event' => array('UPDATE'), 'sql' => $sql);
     }
     // take care of the ON INSERT triggers
     foreach ($columns as $table => $hash) {
         $trigger = array();
         foreach ($hash as $column => $_) {
             $trigger[] = "IF NEW.{$column}_{$locale} IS NOT NULL THEN";
             foreach ($locales as $old) {
                 $trigger[] = "SET NEW.{$column}_{$old} = NEW.{$column}_{$locale};";
             }
             foreach ($locales as $old) {
                 $trigger[] = "ELSEIF NEW.{$column}_{$old} IS NOT NULL THEN";
                 foreach (array_merge($locales, array($locale)) as $loc) {
                     if ($loc == $old) {
                         continue;
                     }
                     $trigger[] = "SET NEW.{$column}_{$loc} = NEW.{$column}_{$old};";
                 }
             }
             $trigger[] = 'END IF;';
         }
         $sql = implode(' ', $trigger);
         $info[] = array('table' => array($table), 'when' => 'BEFORE', 'event' => array('INSERT'), 'sql' => $sql);
     }
 }
コード例 #13
0
 /**
  * Retrieve the settings values from db.
  *
  * @param $defaults
  *
  * @return array
  */
 public static function retrieve(&$defaults)
 {
     $domain = new CRM_Core_DAO_Domain();
     //we are initializing config, really can't use, CRM-7863
     $urlVar = 'q';
     if (defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla') {
         $urlVar = 'task';
     }
     if (CRM_Core_Config::isUpgradeMode()) {
         $domain->selectAdd('config_backend');
     } else {
         $domain->selectAdd('config_backend, locales');
     }
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(TRUE);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         if ($defaults === FALSE || !is_array($defaults)) {
             $defaults = array();
             return FALSE;
         }
         $skipVars = self::skipVars();
         foreach ($skipVars as $skip) {
             if (array_key_exists($skip, $defaults)) {
                 unset($defaults[$skip]);
             }
         }
         CRM_Core_BAO_ConfigSetting::applyLocale(Civi::settings($domain->id), $domain->locales);
     }
 }
コード例 #14
0
ファイル: Invoke.php プロジェクト: kidaa30/yes
 /**
  * Show the message about CiviCRM versions.
  *
  * @param CRM_Core_Smarty $template
  */
 public static function versionCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     $newerVersion = $securityUpdate = NULL;
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'versionAlert', NULL, 1) & 1) {
         $newerVersion = CRM_Utils_VersionCheck::singleton()->isNewerVersionAvailable();
     }
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'securityUpdateAlert', NULL, 3) & 1) {
         $securityUpdate = CRM_Utils_VersionCheck::singleton()->isSecurityUpdateAvailable();
     }
     $template->assign('newer_civicrm_version', $newerVersion);
     $template->assign('security_update', $securityUpdate);
 }
コード例 #15
0
ファイル: I18n.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Lookup the raw translation of a string (without any extra escaping or interpolation).
  *
  * @param string $text
  * @param string|NULL $domain
  * @param int|NULL $count
  * @param string $plural
  * @param string $context
  *
  * @return string
  */
 protected function crm_translate_raw($text, $domain, $count, $plural, $context)
 {
     // gettext domain for extensions
     $domain_changed = FALSE;
     if (!empty($domain) && $this->_phpgettext) {
         if ($this->setGettextDomain($domain)) {
             $domain_changed = TRUE;
         }
     }
     // do all wildcard translations first
     if (!isset(Civi::$statics[__CLASS__]) || !array_key_exists($this->locale, Civi::$statics[__CLASS__])) {
         if (defined('CIVICRM_DSN') && !CRM_Core_Config::isUpgradeMode()) {
             Civi::$statics[__CLASS__][$this->locale] = CRM_Core_BAO_WordReplacement::getLocaleCustomStrings($this->locale);
         } else {
             Civi::$statics[__CLASS__][$this->locale] = array();
         }
     }
     $stringTable = Civi::$statics[__CLASS__][$this->locale];
     $exactMatch = FALSE;
     if (isset($stringTable['enabled']['exactMatch'])) {
         foreach ($stringTable['enabled']['exactMatch'] as $search => $replace) {
             if ($search === $text) {
                 $exactMatch = TRUE;
                 $text = $replace;
                 break;
             }
         }
     }
     if (!$exactMatch && isset($stringTable['enabled']['wildcardMatch'])) {
         $search = array_keys($stringTable['enabled']['wildcardMatch']);
         $replace = array_values($stringTable['enabled']['wildcardMatch']);
         $text = str_replace($search, $replace, $text);
     }
     // dont translate if we've done exactMatch already
     if (!$exactMatch) {
         // use plural if required parameters are set
         if (isset($count) && isset($plural)) {
             if ($this->_phpgettext) {
                 $text = $this->_phpgettext->ngettext($text, $plural, $count);
             } else {
                 // if the locale's not set, we do ngettext work by hand
                 // if $count == 1 then $text = $text, else $text = $plural
                 if ($count != 1) {
                     $text = $plural;
                 }
             }
             // expand %count in translated string to $count
             $text = strtr($text, array('%count' => $count));
             // if not plural, but the locale's set, translate
         } elseif ($this->_phpgettext) {
             if ($context) {
                 $text = $this->_phpgettext->pgettext($context, $text);
             } else {
                 $text = $this->_phpgettext->translate($text);
             }
         }
     }
     if ($domain_changed) {
         $this->setGettextDomain('civicrm');
     }
     return $text;
 }
コード例 #16
0
ファイル: Invoke.php プロジェクト: rameshrr99/civicrm-core
 /**
  * Show status in the footer
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     $statusSeverity = 0;
     $statusMessage = ts('System status OK');
     // TODO: get status from CRM_Utils_Check, if cached
     $template->assign('footer_status_severity', $statusSeverity);
     $template->assign('footer_status_message', $statusMessage);
 }
コード例 #17
0
 /**
  * Get or set the single instance of CRM_Core_Resources.
  *
  * @param CRM_Core_Resources $instance
  *   New copy of the manager.
  * @return CRM_Core_Resources
  */
 public static function singleton(CRM_Core_Resources $instance = NULL)
 {
     if ($instance !== NULL) {
         self::$_singleton = $instance;
     }
     if (self::$_singleton === NULL) {
         $sys = CRM_Extension_System::singleton();
         $cache = Civi::cache('js_strings');
         self::$_singleton = new CRM_Core_Resources($sys->getMapper(), $cache, CRM_Core_Config::isUpgradeMode() ? NULL : 'resCacheCode');
     }
     return self::$_singleton;
 }
コード例 #18
0
 /**
  * Get a list of triggers for the contact table.
  *
  * @see hook_civicrm_triggerInfo
  * @see CRM_Core_DAO::triggerRebuild
  * @see http://issues.civicrm.org/jira/browse/CRM-10554
  *
  * @param $info
  * @param null $tableName
  */
 public static function triggerInfo(&$info, $tableName = NULL)
 {
     //during upgrade, first check for valid version and then create triggers
     //i.e the columns created_date and modified_date are introduced in 4.3.alpha1 so dont create triggers for older version
     if (CRM_Core_Config::isUpgradeMode()) {
         $currentVer = CRM_Core_BAO_Domain::version(TRUE);
         //if current version is less than 4.3.alpha1 dont create below triggers
         if (version_compare($currentVer, '4.3.alpha1') < 0) {
             return;
         }
     }
     // Update timestamp for civicrm_contact itself
     if ($tableName == NULL || $tableName == self::getTableName()) {
         $info[] = array('table' => array(self::getTableName()), 'when' => 'BEFORE', 'event' => array('INSERT'), 'sql' => "\nSET NEW.created_date = CURRENT_TIMESTAMP;\n");
     }
     // Update timestamp when modifying closely related core tables
     $relatedTables = array('civicrm_address', 'civicrm_email', 'civicrm_im', 'civicrm_phone', 'civicrm_website');
     self::generateTimestampTriggers($info, $tableName, $relatedTables, 'contact_id');
     // Update timestamp when modifying related custom-data tables
     $customGroupTables = array();
     $customGroupDAO = CRM_Core_BAO_CustomGroup::getAllCustomGroupsByBaseEntity('Contact');
     $customGroupDAO->is_multiple = 0;
     $customGroupDAO->find();
     while ($customGroupDAO->fetch()) {
         $customGroupTables[] = $customGroupDAO->table_name;
     }
     if (!empty($customGroupTables)) {
         self::generateTimestampTriggers($info, $tableName, $customGroupTables, 'entity_id');
     }
     // Update phone table to populate phone_numeric field
     if (!$tableName || $tableName == 'civicrm_phone') {
         // Define stored sql function needed for phones
         CRM_Core_DAO::executeQuery(self::DROP_STRIP_FUNCTION_43);
         CRM_Core_DAO::executeQuery(self::CREATE_STRIP_FUNCTION_43);
         $info[] = array('table' => array('civicrm_phone'), 'when' => 'BEFORE', 'event' => array('INSERT', 'UPDATE'), 'sql' => "\nSET NEW.phone_numeric = civicrm_strip_non_numeric(NEW.phone);\n");
     }
 }
コード例 #19
0
ファイル: Invoke.php プロジェクト: nielosz/civicrm-core
 /**
  * Show status in the footer (admin only)
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode() || !CRM_Core_Permission::check('administer CiviCRM')) {
         return;
     }
     // always use cached results - they will be refreshed by the session timer
     $status = Civi::settings()->get('systemStatusCheckResult');
     $template->assign('footer_status_severity', $status);
     $template->assign('footer_status_message', CRM_Utils_Check::toStatusLabel($status));
 }
コード例 #20
0
ファイル: AJAX.php プロジェクト: prashantgajare/civicrm-core
 /**
  * Performing any view-layer filtering on result and send to client.
  */
 static function _return($op, $result)
 {
     if ($result['is_error']) {
         if (is_object($result['exception'])) {
             CRM_Core_Error::debug_var("CRM_Queue_Page_AJAX_{$op}_error", CRM_Core_Error::formatTextException($result['exception']));
             $config = CRM_Core_Config::singleton();
             if ($config->backtrace || CRM_Core_Config::isUpgradeMode()) {
                 $result['exception'] = CRM_Core_Error::formatHtmlException($result['exception']);
             } else {
                 $result['exception'] = $result['exception']->getMessage();
             }
         } else {
             CRM_Core_Error::debug_var("CRM_Queue_Page_AJAX_{$op}_error", $result);
         }
     }
     CRM_Utils_JSON::output($result);
 }
コード例 #21
0
ファイル: Smarty.php プロジェクト: bhirsch/voipdev
 /**
  * class constructor
  *
  * @return CRM_Core_Smarty
  * @access private
  */
 function __construct()
 {
     parent::__construct();
     $config =& CRM_Core_Config::singleton();
     if (isset($config->customTemplateDir) && $config->customTemplateDir) {
         $this->template_dir = array($config->customTemplateDir, $config->templateDir);
     } else {
         $this->template_dir = $config->templateDir;
     }
     $this->compile_dir = $config->templateCompileDir;
     //Check for safe mode CRM-2207
     if (ini_get('safe_mode')) {
         $this->use_sub_dirs = false;
     } else {
         $this->use_sub_dirs = true;
     }
     $this->plugins_dir = array($config->smartyDir . 'plugins', $config->pluginsDir);
     // add the session and the config here
     $session =& CRM_Core_Session::singleton();
     $this->assign_by_ref('config', $config);
     $this->assign_by_ref('session', $session);
     // check default editor and assign to template, store it in session to reduce db calls
     $defaultWysiwygEditor = $session->get('defaultWysiwygEditor');
     if (!$defaultWysiwygEditor && !CRM_Core_Config::isUpgradeMode()) {
         require_once 'CRM/Core/BAO/Preferences.php';
         $defaultWysiwygEditor = CRM_Core_BAO_Preferences::value('editor_id');
         $session->set('defaultWysiwygEditor', $defaultWysiwygEditor);
     }
     $this->assign('defaultWysiwygEditor', $defaultWysiwygEditor);
     global $tsLocale;
     $this->assign('langSwitch', CRM_Core_I18n::languages(true));
     $this->assign('tsLocale', $tsLocale);
     //check if logged in use has access CiviCRM permission and build menu
     require_once 'CRM/Core/Permission.php';
     $buildNavigation = CRM_Core_Permission::check('access CiviCRM');
     $this->assign('buildNavigation', $buildNavigation);
     if (!CRM_Core_Config::isUpgradeMode() && $buildNavigation) {
         require_once 'CRM/Core/BAO/Navigation.php';
         $contactID = $session->get('userID');
         if ($contactID) {
             $navigation =& CRM_Core_BAO_Navigation::createNavigation($contactID);
             $this->assign('navigation', $navigation);
         }
     }
     $this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
     $printerFriendly = CRM_Utils_System::makeURL('snippet', false, false) . '2';
     $this->assign('printerFriendly', $printerFriendly);
 }
コード例 #22
0
ファイル: Config.php プロジェクト: kcristiano/civicrm-core
 /**
  * Conditionally fire an event during the first page run.
  *
  * The install system is currently implemented several times, so it's hard to add
  * new installation logic. We use a poor-man's method to detect the first run.
  *
  * Situations to test:
  *  - New installation
  *  - Upgrade from an old version (predating first-run tracker)
  *  - Upgrade from an old version (with first-run tracking)
  */
 public function handleFirstRun()
 {
     // Ordinarily, we prefetch settings en masse and find that the system is already installed.
     // No extra SQL queries required.
     if (Civi::settings()->get('installed')) {
         return;
     }
     // Q: How should this behave during testing?
     if (defined('CIVICRM_TEST')) {
         return;
     }
     // If schema hasn't been loaded yet, then do nothing. Don't want to interfere
     // with the existing installers. NOTE: If we change the installer pageflow,
     // then we may want to modify this behavior.
     if (!CRM_Core_DAO::checkTableExists('civicrm_domain')) {
         return;
     }
     // If we're handling an upgrade, then the system has already been used, so this
     // is not the first run.
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     $dao = CRM_Core_DAO::executeQuery('SELECT version FROM civicrm_domain');
     while ($dao->fetch()) {
         if ($dao->version && version_compare($dao->version, CRM_Utils_System::version(), '<')) {
             return;
         }
     }
     // The installation flag is stored in civicrm_setting, which is domain-aware. The
     // flag could have been stored under a different domain.
     $dao = CRM_Core_DAO::executeQuery('
   SELECT domain_id, value FROM civicrm_setting
   WHERE is_domain = 1 AND name = "installed"
 ');
     while ($dao->fetch()) {
         $value = unserialize($dao->value);
         if (!empty($value)) {
             Civi::settings()->set('installed', 1);
             return;
         }
     }
     // OK, this looks new.
     Civi::service('dispatcher')->dispatch(\Civi\Core\Event\SystemInstallEvent::EVENT_NAME, new \Civi\Core\Event\SystemInstallEvent());
     Civi::settings()->set('installed', 1);
 }
コード例 #23
0
ファイル: Menu.php プロジェクト: bhirsch/civicrm
 static function &getNavigation($all = false)
 {
     CRM_Core_Error::fatal();
     if (!self::$_menuCache) {
         self::get('navigation');
     }
     if (CRM_Core_Config::isUpgradeMode()) {
         return array();
     }
     if (!array_key_exists('navigation', self::$_menuCache)) {
         // problem could be due to menu table empty. Just do a
         // menu store and try again
         self::store();
         // here we goo
         self::get('navigation');
         if (!array_key_exists('navigation', self::$_menuCache)) {
             CRM_Core_Error::fatal();
         }
     }
     $nav =& self::$_menuCache['navigation'];
     if (!$nav || !isset($nav['breadcrumb'])) {
         return null;
     }
     $values =& $nav['breadcrumb'];
     $config =& CRM_Core_Config::singleton();
     foreach ($values as $index => $item) {
         if (strpos(CRM_Utils_Array::value($config->userFrameworkURLVar, $_REQUEST), $item['path']) === 0) {
             $values[$index]['active'] = 'class="active"';
         } else {
             $values[$index]['active'] = '';
         }
         if ($values[$index]['parent']) {
             $parent = $values[$index]['parent'];
             // only reset if still a leaf
             if ($values[$parent]['class'] == 'leaf') {
                 $values[$parent]['class'] = 'collapsed';
             }
             // if a child or the parent is active, expand the menu
             if ($values[$index]['active'] || $values[$parent]['active']) {
                 $values[$parent]['class'] = 'expanded';
             }
             // make the parent inactive if the child is active
             if ($values[$index]['active'] && $values[$parent]['active']) {
                 $values[$parent]['active'] = '';
             }
         }
     }
     if (!$all) {
         // remove all collapsed menu items from the array
         foreach ($values as $weight => $v) {
             if ($v['parent'] && $values[$v['parent']]['class'] == 'collapsed') {
                 unset($values[$weight]);
             }
         }
     }
     // check permissions for the rest
     require_once 'CRM/Core/Permission.php';
     $activeChildren = array();
     foreach ($values as $weight => $v) {
         if (CRM_Core_Permission::checkMenuItem($v)) {
             if ($v['parent']) {
                 $activeChildren[] = $weight;
             }
         } else {
             unset($values[$weight]);
         }
     }
     // add the start / end tags
     $len = count($activeChildren) - 1;
     if ($len >= 0) {
         $values[$activeChildren[0]]['start'] = true;
         $values[$activeChildren[$len]]['end'] = true;
     }
     ksort($values, SORT_NUMERIC);
     $i18n =& CRM_Core_I18n::singleton();
     $i18n->localizeTitles($values);
     return $values;
 }
コード例 #24
0
 /**
  * Load all explicit settings that apply to this domain or contact.
  *
  * @return $this
  */
 public function loadValues()
 {
     // Note: Don't use DAO child classes. They require fields() which require
     // translations -- which are keyed off settings!
     $this->values = array();
     $this->combined = NULL;
     // Ordinarily, we just load values from `civicrm_setting`. But upgrades require care.
     // In v4.0 and earlier, all values were stored in `civicrm_domain.config_backend`.
     // In v4.1-v4.6, values were split between `civicrm_domain` and `civicrm_setting`.
     // In v4.7+, all values are stored in `civicrm_setting`.
     // Whenever a value is available in civicrm_setting, it will take precedence.
     $isUpgradeMode = \CRM_Core_Config::isUpgradeMode();
     if ($isUpgradeMode && empty($this->contactId) && \CRM_Core_DAO::checkFieldExists('civicrm_domain', 'config_backend', FALSE)) {
         $config_backend = \CRM_Core_DAO::singleValueQuery('SELECT config_backend FROM civicrm_domain WHERE id = %1', array(1 => array($this->domainId, 'Positive')));
         $oldSettings = \CRM_Upgrade_Incremental_php_FourSeven::convertBackendToSettings($this->domainId, $config_backend);
         \CRM_Utils_Array::extend($this->values, $oldSettings);
     }
     // Normal case. Aside: Short-circuit prevents unnecessary query.
     if (!$isUpgradeMode || \CRM_Core_DAO::checkTableExists('civicrm_setting')) {
         $dao = \CRM_Core_DAO::executeQuery($this->createQuery()->toSQL());
         while ($dao->fetch()) {
             $this->values[$dao->name] = $dao->value !== NULL ? unserialize($dao->value) : NULL;
         }
     }
     return $this;
 }
コード例 #25
0
ファイル: SettingsBag.php プロジェクト: nielosz/civicrm-core
 /**
  * Update the DB record for this setting.
  *
  * @param string $name
  *   The simple name of the setting.
  * @param mixed $value
  *   The new value of the setting.
  */
 protected function setDb($name, $value)
 {
     if (\CRM_Core_BAO_Setting::isUpgradeFromPreFourOneAlpha1()) {
         // civicrm_setting table is not going to be present.
         return;
     }
     $fields = array();
     $fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
     //We haven't traditionally validated inputs to setItem, so this breaks things.
     //foreach ($fieldsToSet as $settingField => &$settingValue) {
     //  self::validateSetting($settingValue, $fields['values'][$settingField]);
     //}
     $metadata = $fields['values'][$name];
     $dao = new \CRM_Core_DAO_Setting();
     $dao->name = $name;
     $dao->domain_id = $this->domainId;
     if ($this->contactId) {
         $dao->contact_id = $this->contactId;
         $dao->is_domain = 0;
     } else {
         $dao->is_domain = 1;
     }
     $dao->find(TRUE);
     if (isset($metadata['on_change'])) {
         foreach ($metadata['on_change'] as $callback) {
             call_user_func(\Civi\Core\Resolver::singleton()->get($callback), unserialize($dao->value), $value, $metadata, $this->domainId);
         }
     }
     if (!is_array($value) && \CRM_Utils_System::isNull($value)) {
         $dao->value = 'null';
     } else {
         $dao->value = serialize($value);
     }
     if (!isset(\Civi::$statics[__CLASS__]['upgradeMode'])) {
         \Civi::$statics[__CLASS__]['upgradeMode'] = \CRM_Core_Config::isUpgradeMode();
     }
     if (\Civi::$statics[__CLASS__]['upgradeMode'] && \CRM_Core_DAO::checkFieldExists('civicrm_setting', 'group_name')) {
         $dao->group_name = 'placeholder';
     }
     $dao->created_date = \CRM_Utils_Time::getTime('YmdHis');
     $session = \CRM_Core_Session::singleton();
     if (\CRM_Contact_BAO_Contact_Utils::isContactId($session->get('userID'))) {
         $dao->created_id = $session->get('userID');
     }
     if ($dao->id) {
         $dao->save();
     } else {
         // Cannot use $dao->save(); in upgrade mode (eg WP + Civi 4.4=>4.7), the DAO will refuse
         // to save the field `group_name`, which is required in older schema.
         \CRM_Core_DAO::executeQuery(\CRM_Utils_SQL_Insert::dao($dao)->toSQL());
     }
     $dao->free();
 }
コード例 #26
0
ファイル: Smarty.php プロジェクト: hyebahi/civicrm-core
 private function initialize()
 {
     $config = CRM_Core_Config::singleton();
     if (isset($config->customTemplateDir) && $config->customTemplateDir) {
         $this->template_dir = array_merge(array($config->customTemplateDir), $config->templateDir);
     } else {
         $this->template_dir = $config->templateDir;
     }
     $this->compile_dir = CRM_Utils_File::addTrailingSlash(CRM_Utils_File::addTrailingSlash($config->templateCompileDir) . $this->getLocale());
     CRM_Utils_File::createDir($this->compile_dir);
     CRM_Utils_File::restrictAccess($this->compile_dir);
     // check and ensure it is writable
     // else we sometime suppress errors quietly and this results
     // in blank emails etc
     if (!is_writable($this->compile_dir)) {
         echo "CiviCRM does not have permission to write temp files in {$this->compile_dir}, Exiting";
         exit;
     }
     //Check for safe mode CRM-2207
     if (ini_get('safe_mode')) {
         $this->use_sub_dirs = FALSE;
     } else {
         $this->use_sub_dirs = TRUE;
     }
     $customPluginsDir = NULL;
     if (isset($config->customPHPPathDir)) {
         $customPluginsDir = $config->customPHPPathDir . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
         if (!file_exists($customPluginsDir)) {
             $customPluginsDir = NULL;
         }
     }
     $smartyDir = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR;
     $pluginsDir = __DIR__ . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
     if ($customPluginsDir) {
         $this->plugins_dir = array($customPluginsDir, $smartyDir . 'plugins', $pluginsDir);
     } else {
         $this->plugins_dir = array($smartyDir . 'plugins', $pluginsDir);
     }
     // add the session and the config here
     $session = CRM_Core_Session::singleton();
     $this->assign_by_ref('config', $config);
     $this->assign_by_ref('session', $session);
     global $tsLocale;
     $this->assign('tsLocale', $tsLocale);
     // CRM-7163 hack: we don’t display langSwitch on upgrades anyway
     if (!CRM_Core_Config::isUpgradeMode()) {
         $this->assign('langSwitch', CRM_Core_I18n::languages(TRUE));
     }
     $this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
     $this->load_filter('pre', 'resetExtScope');
     $this->assign('crmPermissions', new CRM_Core_Smarty_Permissions());
 }
コード例 #27
0
ファイル: Invoke.php プロジェクト: nyimbi/civicrm-core
 /**
  * Show status in the footer
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     //  check date of last cache and compare to today's date
     $systemCheckDate = Civi::cache()->get('systemCheckDate');
     if ($systemCheckDate > strtotime("one day ago")) {
         $statusSeverity = Civi::cache()->get('systemCheckSeverity');
     }
     //  calls helper function in CRM_Utils_Check
     if (empty($statusSeverity)) {
         $statusSeverity = CRM_Utils_Check::checkAll(TRUE);
     }
     switch ($statusSeverity) {
         case 7:
             $statusMessage = ts('System Status: Emergency');
             break;
         case 6:
             $statusMessage = ts('System Status: Alert');
             break;
         case 5:
             $statusMessage = ts('System Status: Critical');
             break;
         case 4:
             $statusMessage = ts('System Status: Error');
             break;
         case 3:
             $statusMessage = ts('System Status: Warning');
             break;
         case 2:
             $statusMessage = ts('System Status: Notice');
             break;
         default:
             $statusMessage = ts('System Status: Ok');
     }
     // TODO: get status from CRM_Utils_Check, if cached
     $template->assign('footer_status_severity', $statusSeverity);
     $template->assign('footer_status_message', $statusMessage);
 }