CRM-21262 - Add a system check for the resource URL
authorJon goldberg <jon@palantetech.coop>
Wed, 4 Oct 2017 21:17:36 +0000 (17:17 -0400)
committerJon goldberg <jon@palantetech.coop>
Wed, 4 Oct 2017 21:17:36 +0000 (17:17 -0400)
CRM/Utils/Check/Component/Env.php

index 583e09409ddd33868a7269cd2c63fed1260b576f..4cab77bfaf0f2219bca7adb52006db6dba44d1e2 100644 (file)
@@ -883,4 +883,27 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component {
     return $messages;
   }
 
+  /**
+   * Check that the resource URL points to the correct location.
+   * @return array
+   */
+  public function checkResourceUrl() {
+    $messages = array();
+    // Does arrow.png exist where we expect it?
+    $arrowUrl = CRM_Core_Config::singleton()->userFrameworkResourceURL . 'packages/jquery/css/images/arrow.png';
+    $headers = get_headers($arrowUrl);
+    $fileExists = stripos($headers[0], "200 OK") ? 1 : 0;
+    if (!$fileExists) {
+      $messages[] = new CRM_Utils_Check_Message(
+        __FUNCTION__,
+        ts('The Resource URL is not set correctly. Please set the <a href="%1">CiviCRM Resource URL</a>.',
+          array(1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1'))),
+        ts('Incorrect Resource URL'),
+        \Psr\Log\LogLevel::ERROR,
+        'fa-server'
+      );
+    }
+    return $messages;
+  }
+
 }