From: unknown Date: Fri, 5 Sep 2014 15:39:36 +0000 (+0100) Subject: Replaced function call getallConnected events function with getEntitiesForParent... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a99e6f73655c5f9d8ea4699a0a00bf73e07b53b3;p=civicrm-core.git Replaced function call getallConnected events function with getEntitiesForParent and removed it from RecurringEntity --- diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index af46f98218..0cd9c2c715 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -366,18 +366,6 @@ class CRM_Core_Form_RecurringEntity { } } } - - static public function getAllConnectedEvents($parentId=''){ - if(!empty($parentId)){ - $query = " - SELECT GROUP_CONCAT(entity_id) as entity_id - FROM civicrm_recurring_entity - WHERE parent_id = ".$parentId; - $dao = CRM_Core_DAO::executeQuery($query); - $dao->fetch(); - } - return $dao; - } static function getListOfCurrentAndFutureEvents($ids=''){ if(isset($ids) and !empty($ids)){ diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index 5210b98513..94a64bd55a 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -278,10 +278,14 @@ class CRM_Event_BAO_Query { } $thisEventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($value, 'civicrm_event'); if($thisEventHasParent){ - $getAllConnections = CRM_Core_Form_RecurringEntity::getAllConnectedEvents($thisEventHasParent); - if($getAllConnections->entity_id){ + $getAllConnections = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($thisEventHasParent, 'civicrm_event'); + $allEventIds = array(); + foreach($getAllConnections as $key => $val){ + $allEventIds[] = $val['id']; + } + if(!empty($allEventIds)){ $op = "IN"; - $value = "($getAllConnections->entity_id)"; + $value = "(".implode(",", $allEventIds).")"; } } $query->_where[$grouping][] = "civicrm_event.id $op {$value}"; diff --git a/CRM/Event/Form/ManageEvent/Repeat.php b/CRM/Event/Form/ManageEvent/Repeat.php index 7d8546e930..a6b05de124 100644 --- a/CRM/Event/Form/ManageEvent/Repeat.php +++ b/CRM/Event/Form/ManageEvent/Repeat.php @@ -62,27 +62,31 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { * Get connected event information list */ //Get all connected event ids - $allEventIds = CRM_Core_Form_RecurringEntity::getAllConnectedEvents($checkParentExistsForThisId); - if($allEventIds->entity_id){ - //echo "
"; print_r($eventIds);
-        //list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
-        $params = array();
-        $query = "
-          SELECT *
-          FROM civicrm_event
-          WHERE id IN (".$allEventIds->entity_id.")
-          ORDER BY start_date asc
-           ";
+      //$allEventIds = CRM_Core_Form_RecurringEntity::getAllConnectedEvents($checkParentExistsForThisId);
+      $allEventIdsArray = CRM_Core_BAo_RecurringEntity::getEntitiesForParent($checkParentExistsForThisId, 'civicrm_event');
+      $allEventIds = array();
+      if(!empty($allEventIdsArray)){
+        foreach($allEventIdsArray as $key => $val){
+          $allEventIds[] = $val['id'];
+        }
+        if(!empty($allEventIds)){
+          $params = array();
+          $query = "
+            SELECT *
+            FROM civicrm_event
+            WHERE id IN (".implode(",", $allEventIds).")
+            ORDER BY start_date asc
+             ";
 
-        $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
-        //$permissions = CRM_Event_BAO_Event::checkPermission();
-        while($dao->fetch()){
-//          if(in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])){
-          if($dao->id){
-            $manageEvent[$dao->id] = array();
-            CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
+          $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
+          $permissions = CRM_Event_BAO_Event::checkPermission();
+          while($dao->fetch()){
+            if(in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])){
+              $manageEvent[$dao->id] = array();
+              CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
+            }
           }
-        }
+        }  
         $this->assign('rows', $manageEvent);
       }
     }else{