/** * System Check API. * * @param array $params * * @return array * API result descriptor; return items are alert codes/messages * @see civicrm_api3_create_success * @see civicrm_api3_create_error * @throws API_Exception */ function civicrm_api3_system_check($params) { $returnValues = array(); $messages = CRM_Utils_Check::singleton()->checkAll(CRM_Utils_Array::value('show_hushed', $params)); foreach ($messages as $msg) { $returnValues[] = $msg->toArray(); } // Spec: civicrm_api3_create_success($values = 1, $params = array(), $entity = NULL, $action = NULL) return civicrm_api3_create_success($returnValues, $params, 'System', 'Check'); }
/** * This function takes care of all the things common to all * pages. This typically involves assigning the appropriate smarty * variable :) * * @return void|string * The content generated by running this page */ public function run() { if ($this->_embedded) { return NULL; } self::$_template->assign('mode', $this->_mode); $pageTemplateFile = $this->getHookedTemplateFileName(); self::$_template->assign('tplFile', $pageTemplateFile); // invoke the pagRun hook, CRM-3906 CRM_Utils_Hook::pageRun($this); if ($this->_print) { if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON))) { $content = self::$_template->fetch('CRM/common/snippet.tpl'); } else { $content = self::$_template->fetch('CRM/common/print.tpl'); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); if ($this->_print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) { $this->ajaxResponse['content'] = $content; CRM_Core_Page_AJAX::returnJsonResponse($this->ajaxResponse); } else { echo $content; } CRM_Utils_System::civiExit(); } $config = CRM_Core_Config::singleton(); // Intermittent alert to admins CRM_Utils_Check::singleton()->showPeriodicAlerts(); if ($this->useLivePageJS && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE)) { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header'); } $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl'); // Render page header if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); echo CRM_Utils_System::theme($content, $this->_print); }
/** * Common setup functions for all unit tests. */ protected function setUp() { $session = CRM_Core_Session::singleton(); $session->set('userID', NULL); $this->errorScope = CRM_Core_TemporaryErrorScope::useException(); // REVERT // Use a temporary file for STDIN $GLOBALS['stdin'] = tmpfile(); if ($GLOBALS['stdin'] === FALSE) { echo "Couldn't open temporary file\n"; exit(1); } // Get and save a connection to the database $this->_dbconn = $this->getConnection(); // reload database before each test // $this->_populateDB(); // "initialize" CiviCRM to avoid problems when running single tests // FIXME: look at it closer in second stage $GLOBALS['civicrm_setting']['domain']['fatalErrorHandler'] = 'CiviUnitTestCase_fatalErrorHandler'; $GLOBALS['civicrm_setting']['domain']['backtrace'] = 1; // disable any left-over test extensions CRM_Core_DAO::executeQuery('DELETE FROM civicrm_extension WHERE full_name LIKE "test.%"'); // reset all the caches CRM_Utils_System::flushCache(); // initialize the object once db is loaded \Civi::reset(); $config = CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance // when running unit tests, use mockup user framework $this->hookClass = CRM_Utils_Hook::singleton(); // Make sure the DB connection is setup properly $config->userSystem->setMySQLTimeZone(); $env = new CRM_Utils_Check_Component_Env(); CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime()); // clear permissions stub to not check permissions $config->userPermissionClass->permissions = NULL; //flush component settings CRM_Core_Component::getEnabledComponents(TRUE); error_reporting(E_ALL); $this->_sethtmlGlobals(); }
/** * This function takes care of all the things common to all * pages. This typically involves assigning the appropriate * smarty variable :) * * @return string The content generated by running this page */ function run() { if ($this->_embedded) { return; } self::$_template->assign('mode', $this->_mode); $pageTemplateFile = $this->getHookedTemplateFileName(); self::$_template->assign('tplFile', $pageTemplateFile); // invoke the pagRun hook, CRM-3906 CRM_Utils_Hook::pageRun($this); if ($this->_print) { if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM))) { $content = self::$_template->fetch('CRM/common/snippet.tpl'); } else { $content = self::$_template->fetch('CRM/common/print.tpl'); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); if ($this->_print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } else { echo $content; } CRM_Utils_System::civiExit(); } $config = CRM_Core_Config::singleton(); // TODO: Is there a better way to ensure these actions don't happen during AJAX requests? if (empty($_GET['snippet'])) { // Version check and intermittent alert to admins CRM_Utils_VersionCheck::singleton()->versionAlert(); CRM_Utils_Check::singleton()->showPeriodicAlerts(); // Debug msg once per hour if ($config->debug && CRM_Core_Permission::check('administer CiviCRM') && CRM_Core_Session::singleton()->timer('debug_alert', 3600)) { $msg = ts('Warning: Debug is enabled in <a href="%1">system settings</a>. This should not be enabled on production servers.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/debug', 'reset=1'))); CRM_Core_Session::setStatus($msg, ts('Debug Mode')); } } $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl'); // Render page header if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); echo CRM_Utils_System::theme($content, $this->_print); return; }
public static function setUpBeforeClass() { static::_populateDB(TRUE); // also set this global hack $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array(); $env = new CRM_Utils_Check_Env(); CRM_Utils_Check::singleton()->assertValid($env->checkMysqlTime()); }
/** * System Check API. * * @param array $params * * @return array * API result descriptor; return items are alert codes/messages * @see civicrm_api3_create_success * @see civicrm_api3_create_error * @throws API_Exception */ function civicrm_api3_system_check($params) { // array(array('name'=> $, 'severity'=>$, ...)) $id = 1; $returnValues = array(); // array(CRM_Utils_Check_Message) $messages = CRM_Utils_Check::singleton()->checkAll(); foreach ($messages as $msg) { $returnValues[] = $msg->toArray() + array('id' => $id++); } return _civicrm_api3_basic_array_get('systemCheck', $params, $returnValues, "id", array('id', 'name', 'message', 'title', 'severity', 'is_visible')); }