Fix Joomla permissions warning
authorlarssandergreen <lars@wildsight.ca>
Sun, 2 Jul 2023 19:21:31 +0000 (13:21 -0600)
committerlarssandergreen <lars@wildsight.ca>
Sun, 2 Jul 2023 19:21:31 +0000 (13:21 -0600)
CRM/Core/Permission/Joomla.php

index 1a3e333e4047ad5d01317bf345e5351f28ceb64e..1be3a31d639e53308cf5ff833016e7c232fc39ab 100644 (file)
@@ -53,23 +53,13 @@ class CRM_Core_Permission_Joomla extends CRM_Core_Permission_Base {
     // not execute hooks if joomla is not loaded
     if (defined('_JEXEC')) {
       $user = JFactory::getUser($userId);
-      $api_key    = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
+      $api_key = CRM_Utils_Request::retrieve('api_key', 'String');
 
       // If we are coming from REST we don't have a user but we do have the api_key for a user.
       if ($user->id === 0 && !is_null($api_key)) {
-        // This is a codeblock copied from /Civicrm/Utils/REST
-        $uid = NULL;
-        if (!$uid) {
-          $store = NULL;
-
-          $contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
-
-          if ($contact_id) {
-            $uid = CRM_Core_BAO_UFMatch::getUFId($contact_id);
-          }
-          $user = JFactory::getUser($uid);
-
-        }
+        $contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
+        $uid = ($contact_id) ? CRM_Core_BAO_UFMatch::getUFId($contact_id) : NULL;
+        $user = JFactory::getUser($uid);
       }
 
       return $user->authorise($translated[0], $translated[1]);