Merge pull request #4883 from totten/master-cs4
[civicrm-core.git] / CRM / Utils / Check.php
index 288a78f0e9f02846a8008b9b8bb9d07f3b694d0f..0d91df745b6208a74bde69144b03a4921e7e78a9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -33,7 +33,7 @@
  *
  */
 class CRM_Utils_Check {
-  CONST
+  const
     // How often to run checks and notify admins about issues.
     CHECK_TIMER = 86400;
 
@@ -51,7 +51,7 @@ class CRM_Utils_Check {
    *
    * @return CRM_Utils_Check
    */
-  static function &singleton() {
+  public static function &singleton() {
     if (!isset(self::$_singleton)) {
       self::$_singleton = new CRM_Utils_Check();
     }
@@ -88,6 +88,8 @@ class CRM_Utils_Check {
    * 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) {
@@ -113,17 +115,29 @@ class CRM_Utils_Check {
    * plugin status page or the Drupal admin/reports/status path.
    *
    * @return array of messages
-   * @see Drupal's hook_requirements() -
-   * https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_requirements
+   * @link https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_requirements
    */
   public function checkAll() {
-    $security = new CRM_Utils_Check_Security();
-    $env = new CRM_Utils_Check_Env();
-    $messages = array_merge(
-      $security->checkAll(),
-      $env->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;
   }
 
-}
\ No newline at end of file
+}