Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/financial#120 - Fix CiviCRM base URL on Joomla frontend #16761

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
];
}

}