Created
January 16, 2024 12:43
-
-
Save jitendrapurohit/8db52cca43bb899c14c65704e51696b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/components/com_civicrm/civicrm.php b/components/com_civicrm/civicrm.php | |
index 73bf821ae4..3381c99a19 100644 | |
--- a/components/com_civicrm/civicrm.php | |
+++ b/components/com_civicrm/civicrm.php | |
@@ -5,6 +5,8 @@ | |
defined('_JEXEC') or die('No direct access allowed'); | |
+use Joomla\CMS\Factory; | |
+ | |
define('CIVICRM_SETTINGS_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'civicrm.settings.php'); | |
include_once CIVICRM_SETTINGS_PATH; | |
@@ -48,10 +50,18 @@ | |
function civicrm_invoke() { | |
civicrm_initialize(); | |
+ if (JVERSION >= 4 && empty($_REQUEST)) { | |
+ $menu = Factory::getApplication()->getMenu(); | |
+ $menuItem = $menu->getActive(); | |
+ if (isset($menuItem) && !empty($menuItem->id) && !empty($menuItem->alias) && !empty($menuItem->query) && $menuItem->component == 'com_civicrm') { | |
+ $_REQUEST = $menuItem->query; | |
+ $_REQUEST['Itemid'] = $menuItem->id; | |
+ } | |
+ } | |
+ | |
// add all the values from the itemId param | |
// overrride the GET values if conflict | |
if (!empty($_REQUEST['Itemid'])) { | |
- $component = JComponentHelper::getComponent('com_civicrm'); | |
$app = JFactory::getApplication(); | |
$menu = $app->getMenu(); | |
$params = $menu->getParams($app->input->get('Itemid')); | |
@@ -83,3 +93,29 @@ | |
define('CIVICRM_UF_HEAD', TRUE); | |
CRM_Core_Invoke::invoke($args); | |
} | |
+ | |
+if (JVERSION >= 4) { | |
+ | |
+ class CivicrmRouter extends Joomla\CMS\Component\Router\RouterBase { | |
+ public function build(&$query) { | |
+ | |
+ if (!empty($query['Itemid'])) { | |
+ $menu = Factory::getApplication()->getMenu(); | |
+ $menuItem = $menu->getActive(); | |
+ if (isset($menuItem) && $menuItem->component != 'com_civicrm') { | |
+ return []; | |
+ } | |
+ if ($menuItem->query['view'] == $query['view'] && isset($query['id']) && $menuItem->query['id'] == (int) $query['id']) { | |
+ $_REQUEST = array_merge($_REQUEST, $query); | |
+ civicrm_invoke(); | |
+ } | |
+ } | |
+ return []; | |
+ } | |
+ | |
+ public function parse(&$segments) { | |
+ return []; | |
+ } | |
+ } | |
+} | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment