Merge pull request #4082 from monishdeb/CRM-14784
[civicrm-core.git] / CRM / Activity / Import / Parser / Activity.php
index def4d8e0ddf0096803dbfa8d22de79f25bed2a69..de2a9135645ea7bd8c92d0c27ad46d51293dd5b8 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -76,6 +76,10 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
     );
 
     $fields = array_merge($fields, array(
+      'source_contact_id' => array(
+        'title' => ts('Source Contact'),
+        'headerPattern' => '/Source.Contact?/i',
+      ),
       'activity_label' => array(
         'title' => ts('Activity Type Label'),
         'headerPattern' => '/(activity.)?type label?/i',
@@ -309,7 +313,7 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
           $params['target_contact_id'] = $cid;
           $params['version'] = 3;
           $newActivity = civicrm_api('activity', 'create', $params);
-          if (CRM_Utils_Array::value('is_error', $newActivity)) {
+          if (!empty($newActivity['is_error'])) {
             array_unshift($values, $newActivity['error_message']);
             return CRM_Import_Parser::ERROR;
           }
@@ -339,7 +343,7 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
           }
         }
 
-        if (CRM_Utils_Array::value('external_identifier', $params)) {
+        if (!empty($params['external_identifier'])) {
           if ($disp) {
             $disp .= "AND {$params['external_identifier']}";
           }
@@ -353,12 +357,12 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
       }
     }
     else {
-      if (CRM_Utils_Array::value('external_identifier', $params)) {
+      if (!empty($params['external_identifier'])) {
         $targetContactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
           $params['external_identifier'], 'id', 'external_identifier'
         );
 
-        if (CRM_Utils_Array::value('target_contact_id', $params) &&
+        if (!empty($params['target_contact_id']) &&
           $params['target_contact_id'] != $targetContactId
         ) {
           array_unshift($values, 'Mismatch of External identifier :' . $params['external_identifier'] . ' and Contact Id:' . $params['target_contact_id']);
@@ -375,7 +379,7 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
 
       $params['version'] = 3;
       $newActivity = civicrm_api('activity', 'create', $params);
-      if (CRM_Utils_Array::value('is_error', $newActivity)) {
+      if (!empty($newActivity['is_error'])) {
         array_unshift($values, $newActivity['error_message']);
         return CRM_Import_Parser::ERROR;
       }