Merge pull request #1238 from sfe-ev/CRM-12995_amend
[civicrm-core.git] / api / v3 / Activity.php
index 32a6ae3ac46176d9b260a71e6ec084989b935c17..1c14d94fd3adb461ade75b24c47131bf75d70019 100644 (file)
@@ -187,19 +187,23 @@ function _civicrm_api3_activity_create_spec(&$params) {
     'name' => 'assignee_id',
     'title' => 'assigned to',
     'type' => 1,
-    'FKClassName' => 'CRM_Activity_DAO_ActivityAssignment',
+    'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
   );
   $params['target_contact_id'] = array(
     'name' => 'target_id',
     'title' => 'Activity Target',
     'type' => 1,
-    'FKClassName' => 'CRM_Activity_DAO_ActivityTarget',
+    'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
   );
-  $params['activity_status_id'] = array(
-    'name' => 'status_id',
-    'title' => 'Status Id',
-    'type' => 1,
+
+  $params['source_contact_id'] = array(
+      'name' => 'source_contact_id',
+      'title' => 'Activity Source Contact',
+      'type' => 1,
+      'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
+      'api.default' => 'user_contact_id',
   );
+
 }
 
 /**
@@ -240,7 +244,7 @@ function civicrm_api3_activity_get($params) {
       $returns[$returnkey] = $v;
     }
   }
-
+  $returns['source_contact_id'] = 1;
   foreach ($returns as $n => $v) {
     switch ($n) {
       case 'assignee_contact_id':
@@ -273,6 +277,8 @@ function civicrm_api3_activity_get($params) {
   return civicrm_api3_create_success($activities, $params, 'activity', 'get');
 }
 
+
+
 /**
  * Delete a specified Activity.
  *
@@ -389,26 +395,6 @@ SELECT  count(*)
     return civicrm_api3_create_error('Invalid Activity Type ID');
   }
 
-  // check for activity status is passed in
-  // note this should all be removed in favour of wrapper layer validation
-  // needs testing
-  if (isset($params['activity_status_id'])) {
-    $activityStatus = CRM_Core_PseudoConstant::activityStatus();
-
-    if (is_numeric($params['activity_status_id']) && !array_key_exists($params['activity_status_id'], $activityStatus)) {
-      return civicrm_api3_create_error('Invalid Activity Status');
-    }
-    elseif (!is_numeric($params['activity_status_id'])) {
-      $statusId = array_search($params['activity_status_id'], $activityStatus);
-
-      if (!is_numeric($statusId)) {
-        return civicrm_api3_create_error('Invalid Activity Status');
-      }
-    }
-  }
-
-
-
   // check for activity duration minutes
   // this should be validated @ the wrapper layer not here
   // needs testing