Merge pull request #8980 from ergonlogic/dev/CRM-19308
[civicrm-core.git] / CRM / Utils / DeprecatedUtils.php
index 93f9b37829a1401edbb0209bff517da2a7dcc091..9b65c3c68aa78b6029b8db8f584ff55c8af1cba9 100644 (file)
@@ -3,7 +3,7 @@
   +--------------------------------------------------------------------+
   | CiviCRM version 4.7                                                |
   +--------------------------------------------------------------------+
-  | Copyright CiviCRM LLC (c) 2004-2016                                |
+  | Copyright CiviCRM LLC (c) 2004-2017                                |
   +--------------------------------------------------------------------+
   | This file is a part of CiviCRM.                                    |
   |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  */
 
 /*
@@ -450,7 +450,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
               }
 
               if ($errorMsg) {
-                return civicrm_api3_create_error($errorMsg, $value[$key]);
+                return civicrm_api3_create_error($errorMsg);
               }
 
               // finally get soft credit contact id.
@@ -523,7 +523,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
             }
           }
           else {
-            return civicrm_api3_create_error('No match found for specified contact in contribution data. Row was skipped.', 'pledge_payment');
+            return civicrm_api3_create_error('No match found for specified contact in pledge payment data. Row was skipped.');
           }
         }
         else {
@@ -539,7 +539,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
               $contributionContactID = $params['contribution_contact_id'] = $values['contribution_contact_id'] = $contact->id;
             }
             else {
-              return civicrm_api3_create_error('No match found for specified contact in contribution data. Row was skipped.', 'pledge_payment');
+              return civicrm_api3_create_error('No match found for specified contact in pledge payment data. Row was skipped.');
             }
           }
           else {
@@ -551,21 +551,21 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
 
               // check if only one contact is found
               if (count($matchedIDs) > 1) {
-                return civicrm_api3_create_error($error['error_message']['message'], 'pledge_payment');
+                return civicrm_api3_create_error($error['error_message']['message']);
               }
               else {
                 $contributionContactID = $params['contribution_contact_id'] = $values['contribution_contact_id'] = $matchedIDs[0];
               }
             }
             else {
-              return civicrm_api3_create_error('No match found for specified contact in contribution data. Row was skipped.', 'pledge_payment');
+              return civicrm_api3_create_error('No match found for specified contact in contribution data. Row was skipped.');
             }
           }
         }
 
         if (!empty($params['pledge_id'])) {
           if (CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $params['pledge_id'], 'contact_id') != $contributionContactID) {
-            return civicrm_api3_create_error('Invalid Pledge ID provided. Contribution row was skipped.', 'pledge_payment');
+            return civicrm_api3_create_error('Invalid Pledge ID provided. Contribution row was skipped.');
           }
           $values['pledge_id'] = $params['pledge_id'];
         }
@@ -575,10 +575,10 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
           $pledgeDetails = CRM_Pledge_BAO_Pledge::getContactPledges($contributionContactID);
 
           if (empty($pledgeDetails)) {
-            return civicrm_api3_create_error('No open pledges found for this contact. Contribution row was skipped.', 'pledge_payment');
+            return civicrm_api3_create_error('No open pledges found for this contact. Contribution row was skipped.');
           }
           elseif (count($pledgeDetails) > 1) {
-            return civicrm_api3_create_error('This contact has more than one open pledge. Unable to determine which pledge to apply the contribution to. Contribution row was skipped.', 'pledge_payment');
+            return civicrm_api3_create_error('This contact has more than one open pledge. Unable to determine which pledge to apply the contribution to. Contribution row was skipped.');
           }
 
           // this mean we have only one pending / in progress pledge
@@ -593,7 +593,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
           $values['pledge_payment_id'] = $pledgePaymentDetails['id'];
         }
         else {
-          return civicrm_api3_create_error('Contribution and Pledge Payment amount mismatch for this record. Contribution row was skipped.', 'pledge_payment');
+          return civicrm_api3_create_error('Contribution and Pledge Payment amount mismatch for this record. Contribution row was skipped.');
         }
         break;
 
@@ -1527,7 +1527,9 @@ function _civicrm_api3_deprecated_activity_buildmailparams($result, $activityTyp
   $params['activity_type_id'] = $activityTypeID;
 
   $params['status_id'] = 2;
-  $params['source_contact_id'] = $params['assignee_contact_id'] = $result['from']['id'];
+  if (!empty($result['from']['id'])) {
+    $params['source_contact_id'] = $params['assignee_contact_id'] = $result['from']['id'];
+  }
   $params['target_contact_id'] = array();
   $keys = array('to', 'cc', 'bcc');
   foreach ($keys as $key) {