CRM-12274
authorDonald A. Lobo <lobo@civicrm.org>
Tue, 23 Apr 2013 22:36:20 +0000 (15:36 -0700)
committerDonald A. Lobo <lobo@civicrm.org>
Tue, 23 Apr 2013 22:36:20 +0000 (15:36 -0700)
----------------------------------------
* CRM-12274: Merge activity tables into one unified table activity contact table
  http://issues.civicrm.org/jira/browse/CRM-12274

CRM/Activity/BAO/Activity.php
api/v3/examples/ParticipantPaymentGet.php
tests/phpunit/api/v3/ParticipantPaymentTest.php

index a9ddc03677c4b56eb67db1538cb2875a5b980fcd..57b7c1e4d43c7aacaf489e396b1b188a54019fb9 100644 (file)
@@ -625,7 +625,9 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity {
     $session = CRM_Core_Session::singleton();
     $id = $session->get('userID');
     if (!$id) {
-      $id = $activity->source_contact_id;
+      $activityContacts = CRM_Core_PseudoConstant::activityContacts('name');
+      $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
+      $id = self::getActivityContact($activity->id. $sourceID);
     }
     $logParams = array(
       'entity_table' => 'civicrm_activity',
@@ -1696,7 +1698,6 @@ WHERE      activity.id IN ($activityIds)";
     $activityStatuses = CRM_Core_OptionGroup::values('activity_status');
 
     while ($dao->fetch()) {
-      //$activities[$dao->activity_id]['source_contact_id'] = $dao->source_contact_id;
       $activities[$dao->activity_id]['id'] = $dao->activity_id;
       $activities[$dao->activity_id]['activity_type_id'] = $dao->activity_type_id;
       $activities[$dao->activity_id]['subject'] = $dao->subject;
@@ -2166,6 +2167,8 @@ AND cl.modified_id  = c.id
     // delete activity if there is no record in
     // civicrm_activity_contact
     // pointing to any other contact record.
+    // FIXME: this will be an awful query, figure out what function does
+    // and clean up
     $activity = new CRM_Activity_DAO_Activity();
     $activity->source_contact_id = $contactId;
     $activity->find();
index 6024d1a8bac05f5ce536d8c7a7cf75328d9c8e37..13a068d179eb43a766c885c8efa4e0b3fe20cea0 100644 (file)
@@ -8,6 +8,7 @@ $params = array(
   'participant_id' => 4,
   'contribution_id' => 1,
   'version' => 3,
+  'debug' => 1,
 );
 
   $result = civicrm_api( 'participant_payment','get',$params );
@@ -22,6 +23,10 @@ function participant_payment_get_expectedresult(){
 
   $expectedResult = array( 
   'is_error' => 0,
+  'undefined_fields' => array( 
+      '0' => 'participant_id',
+      '1' => 'contribution_id',
+    ),
   'version' => 3,
   'count' => 1,
   'id' => 1,
@@ -32,6 +37,11 @@ function participant_payment_get_expectedresult(){
           'contribution_id' => '1',
         ),
     ),
+  'xdebug' => array( 
+      'peakMemory' => 31758384,
+      'memory' => 31463600,
+      'timeIndex' => '45.313442230225',
+    ),
 );
 
   return $expectedResult  ;
index ce1b9e2adbbe78f0fc60aa391c140b3bc5bf3681..be967dfe0bb074b9e12830207752ae4a62323d5d 100644 (file)
@@ -396,6 +396,7 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
       'participant_id' => $this->_participantID4,
       'contribution_id' => $contributionID,
       'version' => $this->_apiversion,
+      'debug' => 1,
     );
 
     $result = civicrm_api('participant_payment', 'get', $params);