Index: civicrm20compat.module =================================================================== --- civicrm20compat.module (revision 466) +++ civicrm20compat.module (working copy) @@ -96,6 +96,38 @@ function crm_get_option_values($obj) { return $obj; } + + function crm_create_activity_history(&$params) { + $error = _crm_check_history_params($params, 'Activity'); + if (is_a($error, 'CRM_Core_Error')) { + return $error; + } + $ids = array(); + $history = CRM_Core_BAO_History::create($params, $ids, 'Activity'); + return $history; + } + + function _crm_check_history_params(&$params, $type='Activity') { + static $required = array('entity_id'); + + // cannot create a contact with empty params + if (empty($params)) { + return _crm_error(ts('Input Parameters empty')); + } + + $valid = true; + foreach ($required as $requiredField) { + if (!CRM_Utils_Array::value($requiredField, $params)) { + $valid = false; + $error .= "$requiredField "; + } + } + + if (!$valid) { + return _crm_error(ts("Required fields $error not found for history")); + } + return true; + } } return TRUE; }