From b1f4e63799958446b4d1d97ea792f92ecc863123 Mon Sep 17 00:00:00 2001
From: Ravish Nair <ravish.nair@webaccess.co.in>
Date: Tue, 29 Oct 2013 19:22:16 +0530
Subject: [PATCH] -- CRM-13220 fix for joomla

---
 CRM/ACL/BAO/ACL.php | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php
index 755d843ae6..ea17556c6b 100644
--- a/CRM/ACL/BAO/ACL.php
+++ b/CRM/ACL/BAO/ACL.php
@@ -822,6 +822,7 @@ SELECT g.*
 
     $acls = CRM_ACL_BAO_Cache::build($contactID);
 
+    $ids = array();
     if (!empty($acls)) {
       $aclKeys = array_keys($acls);
       $aclKeys = implode(',', $aclKeys);
@@ -842,9 +843,7 @@ ORDER BY a.object_id
 ";
         $params = array(1 => array($tableName, 'String'));
         $dao = CRM_Core_DAO::executeQuery($query, $params);
-        $aclFound = FALSE;
         while ($dao->fetch()) {
-          $aclFound = TRUE;
           if ($dao->object_id) {
             if (self::matchType($type, $dao->operation)) {
               $ids[] = $dao->object_id;
@@ -861,22 +860,16 @@ ORDER BY a.object_id
             break;
           }
         }
-
-        if (!$aclFound) {
-          if (!empty($includedGroups) &&
-            is_array($includedGroups)
-          ) {
-            $ids = $includedGroups;
-          }
-          else {
-            $ids = array();
-          }
-        }
-
         $cache->set($cacheKey, $ids);
       }
     }
 
+    if (empty($ids) && !empty($includedGroups) &&
+      is_array($includedGroups)
+    ) {
+      $ids = $includedGroups;
+    }
+
     CRM_Utils_Hook::aclGroup($type, $contactID, $tableName, $allGroups, $ids);
 
     return $ids;
-- 
GitLab