diff --git a/admin/configure.php b/admin/configure.php index a7fd6e86..6d8c9044 100644 --- a/admin/configure.php +++ b/admin/configure.php @@ -53,7 +53,8 @@ function civicrm_setup() { } $extractdir = $adminPath; - JArchive::extract($archivename, $extractdir); + $archive = new Joomla\Archive\Archive; + $archive->extract($archivename, $extractdir); } $scratchDir = JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'civicrm'; @@ -173,7 +174,7 @@ function civicrm_source($fileName, $lineMode = FALSE) { } if (!$lineMode) { - $string = JFile::read($fileName); + $string = file_get_contents($fileName); //get rid of comments starting with # and -- $string = preg_replace("/^#[^\n]*$/m", "\n", $string); @@ -233,7 +234,7 @@ function civicrm_config($frontend = FALSE, $siteKey) { $params['baseURL'] = $liveSite . '/'; } - $str = JFile::read($adminPath . DIRECTORY_SEPARATOR . + $str = file_get_contents($adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . diff --git a/admin/plugins/civicrm/civicrm.php b/admin/plugins/civicrm/civicrm.php index e404e3a1..751bd94d 100755 --- a/admin/plugins/civicrm/civicrm.php +++ b/admin/plugins/civicrm/civicrm.php @@ -85,8 +85,7 @@ function onUserAfterDelete($user, $succes, $msg) { * @since 1.6 */ public function onUserLogin($user, $options = array()) { - $app = JFactory::getApplication(); - if ($app->isAdmin()) { + if (self::isAdminBackend()) { $jUser = JFactory::getUser(); $jId = $jUser->get('id'); self::civicrmResetNavigation($jId); @@ -125,4 +124,27 @@ public function civicrmResetNavigation($jId = NULL) { CRM_Core_BAO_Navigation::resetNavigation($cId); } + /** + * Determine if we are in the Joomla administrator backend + * + * @return boolean True if in the Joomla Administrator backend otherwise false + */ + private function isAdminBackend() { + $app = JFactory::getApplication(); + + // Determine if we are in the Joomla administrator backend + // In Joomla 3.7+ the isClient() method is used. In earlier versions use the isAdmin() method (deprecated in Joomla 4.0). + if (method_exists($app, 'isClient')) { + $isAdmin = $app->isClient('administrator'); + } + elseif (method_exists($app, 'isAdmin')) { + $isAdmin = $app->isAdmin(); + } + else { + throw new RuntimeException("CiviCRM User Plugin error: no method found to determine Joomla client interface."); + } + + return $isAdmin; + } + } diff --git a/script.civicrm.php b/script.civicrm.php index 8c8be863..c25d5bbf 100644 --- a/script.civicrm.php +++ b/script.civicrm.php @@ -83,8 +83,21 @@ function install($parent) { '; } - //install and enable plugins - $manifest = $parent->get("manifest"); + // Install and enable plugins + + // Get the installer manifest. Use the getManifest() method if it exists (Joomla 3.4+) + // If not then use get("manifest") (deprecated in Joomla 4.0). + if (method_exists($parent, 'getManifest')) { + $manifest = $parent->getManifest(); + } + elseif (method_exists($parent, 'get')) { + $manifest = $parent->get("manifest"); + } + else { + echo "No method found to get Joomla installer manifest."; + exit(); + } + $parent = $parent->getParent(); $source = $parent->getPath("source"); $installer = new JInstaller(); @@ -130,7 +143,7 @@ function install($parent) { WHERE $columnElement IN ($plgList) AND $columnType = 'plugin' "); - $db->query(); + $db->execute(); echo $content; } @@ -179,7 +192,6 @@ function setDefaultPermissions() { $db->setQuery('SELECT rules FROM #__assets WHERE name = ' . $db->quote('com_civicrm')); $assetRules = json_decode((string ) $db->loadResult()); - if (count($assetRules) > 1) { return; } @@ -268,7 +280,7 @@ function setDefaultPermissions() { ' WHERE name = ' . $db->quote('com_civicrm') ); - if (!$db->query()) { + if (!$db->execute()) { echo 'Seems like setting default actions failed
'; } }