timer('check_' . __CLASS__, self::CHECK_TIMER)) { // Best attempt at re-securing folders $config = CRM_Core_Config::singleton(); $config->cleanup(0, FALSE); if ($messages === NULL) { $messages = $this->checkAll(); } foreach ($messages as $message) { CRM_Core_Session::setStatus($message->getMessage(), $message->getTitle()); } } } } /** * Throw an exception if any of the checks fail * * @param array|NULL $messages list of CRM_Utils_Check_Message; or NULL if the default list should be fetched * * @throws Exception */ public function assertValid($messages = NULL) { if ($messages === NULL) { $messages = $this->checkAll(); } if (!empty($messages)) { $messagesAsArray = array(); foreach ($messages as $message) { $messagesAsArray[] = $message->toArray(); } throw new Exception('There are configuration problems with this installation: ' . print_r($messagesAsArray, TRUE)); } } /** * Run some sanity checks. * * This could become a hook so that CiviCRM can run both built-in * configuration & sanity checks, and modules/extensions can add * their own checks. * * We might even expose the results of these checks on the Wordpress * plugin status page or the Drupal admin/reports/status path. * * @return array * of messages * @link https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_requirements */ public function checkAll() { $checks = array(); $checks[] = new CRM_Utils_Check_Security(); $checks[] = new CRM_Utils_Check_Env(); $compInfo = CRM_Core_Component::getEnabledComponents(); foreach ($compInfo as $compObj) { switch ($compObj->info['name']) { case 'CiviCase': $checks[] = new CRM_Utils_Check_Case(CRM_Case_XMLRepository::singleton(), CRM_Case_PseudoConstant::caseType('name')); break; default: } } $messages = array(); foreach ($checks as $check) { $messages = array_merge($messages, $check->checkAll()); } return $messages; } }