Skip to content

Commit

Permalink
Merge pull request #16761 from eileenmcnaughton/joomla
Browse files Browse the repository at this point in the history
dev/financial#120 - Fix CiviCRM base url on Joomla frontend
  • Loading branch information
totten authored Mar 13, 2020
2 parents 21f6ab9 + 38dab72 commit a84dc1a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
10 changes: 3 additions & 7 deletions CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,9 @@ public function getCiviSourceStorage() {
$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
Expand Down
37 changes: 37 additions & 0 deletions CRM/Utils/System/Joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -879,4 +879,41 @@ public function synchronizeUsers() {
];
}

/**
* 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),
];
}

}

0 comments on commit a84dc1a

Please sign in to comment.