Replaced function call getallConnected events function with getEntitiesForParent...
authorunknown <priyanka.karan26@gmail.com>
Fri, 5 Sep 2014 15:39:36 +0000 (16:39 +0100)
committerdeepak-srivastava <deepak.srivastava.0303@gmail.com>
Fri, 3 Oct 2014 08:55:15 +0000 (09:55 +0100)
CRM/Core/Form/RecurringEntity.php
CRM/Event/BAO/Query.php
CRM/Event/Form/ManageEvent/Repeat.php

index af46f982183a39fadac88d589164de5bdf655f76..0cd9c2c715c51e21b687d23b2113a618cbfdd2b4 100644 (file)
@@ -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)){
index 5210b985139009724e08f3e98b86c1cf7816e276..94a64bd55a1089ef85ae3454e54cb28d083d89f8 100644 (file)
@@ -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}";
index 7d8546e930f04b989a70fa5b8482fa6179faf4c4..a6b05de124348f5c7d36a645a7e475794dd89160 100644 (file)
@@ -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 "<pre>"; 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{