clean up (CRM-12697)
authoryashodha <yashodha.chaku@webaccess.co.in>
Wed, 29 May 2013 07:11:52 +0000 (12:41 +0530)
committeryashodha <yashodha.chaku@webaccess.co.in>
Wed, 29 May 2013 09:32:00 +0000 (15:02 +0530)
CRM/Activity/BAO/Activity.php
CRM/Campaign/BAO/Petition.php

index f78618e6366fbdd40d8acb9305663eec06d65e3a..dd54cfc8bb0f28f46c40964ec2bc1f57442720a5 100644 (file)
@@ -122,8 +122,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity {
       }
 
       $sourceContactId = self::getActivityContact($activity->id, $sourceID);
-      $defaults['source_contact_id'] =
-        $activity->source_contact_id = $sourceContactId;
+      $defaults['source_contact_id'] = $sourceContactId;
 
       if ($sourceContactId &&
         !CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
index d14f926156d135f17a691e9627b912ea29a7487d..59790ce5d835a2a024d85bfe6f48a7bd3f719cac 100644 (file)
@@ -388,11 +388,12 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
             IFNULL(gender_id,'') AS gender_id,
             IFNULL(state_province_id,'') AS state_province_id,
             IFNULL(country_id,'') as country_id,IFNULL(iso_code,'') as country_iso, IFNULL(civicrm_country.name,'') as country
-            FROM   civicrm_activity a, civicrm_survey, civicrm_contact
+            FROM (civicrm_activity a, civicrm_survey, civicrm_contact )
+            LEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = a.id AND  ac.record_type_id = %3 )
             LEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id  AND civicrm_address.is_primary = 1
             LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id
             WHERE
-            a.source_contact_id = civicrm_contact.id AND
+            ac.contact_id = civicrm_contact.id AND
             a.activity_type_id = civicrm_survey.activity_type_id AND
             civicrm_survey.id =  %1 AND
             a.source_record_id =  %1 ";
@@ -405,6 +406,10 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
     }
     $sql .= " ORDER BY  a.activity_date_time";
 
+    $activityContacts = CRM_Core_PseudoConstant::activityContacts('name');
+    $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
+    $params[3] = array($sourceID, 'Integer');
+
     $fields = array(
       'id', 'survey_id', 'contact_id',
       'activity_date_time', 'activity_type_id',
@@ -413,7 +418,6 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
       'state_province_id', 'country_iso', 'country',
     );
 
-
     $dao = CRM_Core_DAO::executeQuery($sql, $params);
     while ($dao->fetch()) {
       $row = array();