X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSystem%2FJoomla.php;h=19b03bf9172d58e7c4d29a2eb57bfca9a8ea6f39;hb=2efcf0c212127e3281834edf26b64d2bbd5e0bb5;hp=673c62112976cf5fdc87565c0083b5462a28f3b4;hpb=6a4880350680e1e4d20e5c8a622a791f926ca750;p=civicrm-core.git diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 673c621129..19b03bf917 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -261,11 +261,6 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { * @access public */ public function addScriptUrl($url, $region) { - if ($region == 'html-header') { - $document = JFactory::getDocument(); - $document->addScript($url); - return TRUE; - } return FALSE; } @@ -282,11 +277,6 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { * @access public */ public function addScript($code, $region) { - if ($region == 'html-header') { - $document = JFactory::getDocument(); - $document->addScriptDeclaration($code); - return TRUE; - } return FALSE; } @@ -475,7 +465,7 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { 'pass' => $password, ); } - CRM_Utils_System::loadBootStrap($bootStrapParams); + CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, FALSE); } jimport('joomla.application.component.helper'); @@ -526,6 +516,22 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { return FALSE; } + /** + * Set a init session with user object + * + * @param array $data array with user specific data + * + * @access public + */ + function setUserSession($data) { + list($userID, $ufID) = $data; + $user = new JUser( $ufID ); + $session = &JFactory::getSession(); + $session->set('user', $user); + + parent::setUserSession($data); + } + /** * Set a message in the UF to display to a user * @@ -581,13 +587,13 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { * @param $loadUser boolean load cms user? * @param $throwError throw error on failure? */ - function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE) { + function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL, $loadDefines = TRUE) { // Setup the base path related constant. $joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))); // load BootStrap here if needed // We are a valid Joomla entry point. - if ( ! defined( '_JEXEC' ) ) { + if ( ! defined( '_JEXEC' ) && $loadDefines ) { define('_JEXEC', 1); define('DS', DIRECTORY_SEPARATOR); define('JPATH_BASE', $joomlaBase . '/administrator'); @@ -595,12 +601,28 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { } // Get the framework. + if (file_exists($joomlaBase . '/libraries/import.legacy.php')) { + require $joomlaBase . '/libraries/import.legacy.php'; + } require $joomlaBase . '/libraries/import.php'; require $joomlaBase . '/libraries/joomla/event/dispatcher.php'; - require $joomlaBase . '/libraries/joomla/environment/uri.php'; - require $joomlaBase . '/libraries/joomla/application/component/helper.php'; require $joomlaBase . '/configuration.php'; + // Files may be in different places depending on Joomla version + if ( !defined('JVERSION') ) { + require $joomlaBase . '/libraries/cms/version/version.php'; + $jversion = new JVersion; + define('JVERSION', $jversion->getShortVersion()); + } + + if( version_compare(JVERSION, '3.0', 'lt') ) { + require $joomlaBase . '/libraries/joomla/environment/uri.php'; + require $joomlaBase . '/libraries/joomla/application/component/helper.php'; + } + else { + require $joomlaBase . '/libraries/joomla/uri/uri.php'; + } + jimport('joomla.application.cli'); return TRUE; @@ -664,9 +686,31 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { $loginURL .= 'index.php?option=com_users&view=login'; return $loginURL; } - + public function getLoginDestination(&$form) { return; } + + /** + * Return default Site Settings + * @return array array + * - $url, (Joomla - non admin url) + * - $siteName, + * - $siteRoot + */ + function getDefaultSiteSettings($dir){ + $config = CRM_Core_Config::singleton(); + $url = preg_replace( + '|/administrator|', + '', + $config->userFrameworkBaseURL + ); + $siteRoot = preg_replace( + '|/media/civicrm/.*$|', + '', + $config->imageUploadDir + ); + return array($url, NULL, $siteRoot); + } }