Alternate Joomla! fix - move to CMS override
authoreileen <emcnaughton@wikimedia.org>
Fri, 13 Mar 2020 00:56:06 +0000 (13:56 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 13 Mar 2020 00:56:06 +0000 (13:56 +1300)
CRM/Utils/System/Base.php
CRM/Utils/System/Joomla.php

index c49b8afba2db3caa8499066acbe59a2f7a67da3b..233390e4f3ec3b9877d269c330262b55d93b39d0 100644 (file)
@@ -667,13 +667,9 @@ abstract class CRM_Utils_System_Base {
       $baseURL = str_replace('http://', 'https://', $baseURL);
     }
 
-    if ($config->userFramework == 'Joomla') {
-      $userFrameworkResourceURL = $baseURL . "components/com_civicrm/civicrm/";
-    }
-    elseif ($config->userFramework == 'WordPress') {
-      $userFrameworkResourceURL = CIVICRM_PLUGIN_URL . "civicrm/";
-    }
-    elseif ($this->is_drupal) {
+    // @todo this function is only called / code is only reached when is_drupal is true - move this to the drupal classes
+    // and don't implement here.
+    if ($this->is_drupal) {
       // Drupal setting
       // check and see if we are installed in sites/all (for D5 and above)
       // we dont use checkURL since drupal generates an error page and throws
index 84437d481f805ced97c7694ddd7b2f0696602ee3..380fb3774bfbbe9226ff8351a4e0fb9c38667099 100644 (file)
@@ -879,4 +879,41 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
     ];
   }
 
+  /**
+   * Determine the location of the CiviCRM source tree.
+   *
+   * FIXME:
+   *  1. This was pulled out from a bigger function. It should be split
+   *     into even smaller pieces and marked abstract.
+   *  2. This would be easier to compute by a calling a CMS API, but
+   *     for whatever reason we take the hard way.
+   *
+   * @return array
+   *   - url: string. ex: "http://example.com/sites/all/modules/civicrm"
+   *   - path: string. ex: "/var/www/sites/all/modules/civicrm"
+   */
+  public function getCiviSourceStorage() {
+    global $civicrm_root;
+    if (!defined('CIVICRM_UF_BASEURL')) {
+      throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
+    }
+    $baseURL = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/');
+    if (CRM_Utils_System::isSSL()) {
+      $baseURL = str_replace('http://', 'https://', $baseURL);
+    }
+
+    // For Joomla CiviCRM Core files always live within the admistrator folder and $base_url is different on the frontend compared to the backend.
+    if (strpos($baseURL, 'administrator') === FALSE) {
+      $userFrameworkResourceURL = $baseURL . "administrator/components/com_civicrm/civicrm/";
+    }
+    else {
+      $userFrameworkResourceURL = $baseURL . "components/com_civicrm/civicrm/";
+    }
+
+    return [
+      'url' => CRM_Utils_File::addTrailingSlash($userFrameworkResourceURL, '/'),
+      'path' => CRM_Utils_File::addTrailingSlash($civicrm_root),
+    ];
+  }
+
 }