CRM-13737 drupal integration - Use basename fn to extract last dir in the url as...
[civicrm-core.git] / CRM / Utils / System / Joomla.php
index 4269731b53906da7d06c24f7301e9a2f16a53259..0f635aacb86ab2cfec02b7be38bcd9085d6023a7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -471,7 +471,7 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
     jimport('joomla.application.component.helper');
     jimport('joomla.database.table');
 
-    $JUserTable = &JTable::getInstance('User', 'JTable');
+    $JUserTable = JTable::getInstance('User', 'JTable');
 
     $db = $JUserTable->getDbo();
     $query = $db->getQuery(TRUE);
@@ -526,7 +526,7 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
   function setUserSession($data) {
     list($userID, $ufID) = $data;
     $user = new JUser( $ufID );
-    $session = &JFactory::getSession();
+    $session = JFactory::getSession();
     $session->set('user', $user);
 
     parent::setUserSession($data);
@@ -602,7 +602,7 @@ 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.legacy.php';
     }
     require $joomlaBase . '/libraries/import.php';
     require $joomlaBase . '/libraries/joomla/event/dispatcher.php';
@@ -686,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);
+  }
 }