本文整理汇总了PHP中CRM_Activity_BAO_Activity::deleteActivity方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::deleteActivity方法的具体用法?PHP CRM_Activity_BAO_Activity::deleteActivity怎么用?PHP CRM_Activity_BAO_Activity::deleteActivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Activity_BAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_BAO_Activity::deleteActivity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return void
*/
public function postProcess()
{
$deletedActivities = 0;
foreach ($this->_activityHolderIds as $activityId['id']) {
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']);
if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) {
$deletedActivities++;
}
}
CRM_Core_Session::setStatus($deletedActivities, ts('Deleted Activities'), "success");
CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info");
}
示例2: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
$deletedActivities = 0;
foreach ($this->_activityHolderIds as $activityId['id']) {
require_once 'CRM/Case/BAO/Case.php';
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']);
if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) {
$deletedActivities++;
}
}
$status = array(ts('Deleted Activities: %1', array(1 => $deletedActivities)), ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))));
CRM_Core_Session::setStatus($status);
}
示例3: postProcess
/**
* Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess()
{
$deleted = $failed = 0;
foreach ($this->_activityHolderIds as $activityId['id']) {
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']);
if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) {
$deleted++;
} else {
$failed++;
}
}
if ($deleted) {
$msg = ts('%count activity deleted.', array('plural' => '%count activities deleted.', 'count' => $deleted));
CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
}
if ($failed) {
CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
}
}
示例4: civicrm_api3_activity_delete
/**
* Delete a specified Activity.
*
* @param array $params
* Array holding 'id' of activity to be deleted.
*
* @throws API_Exception
*
* @return array
* API result array
*/
function civicrm_api3_activity_delete($params)
{
if (CRM_Activity_BAO_Activity::deleteActivity($params)) {
return civicrm_api3_create_success(1, $params, 'Activity', 'delete');
} else {
throw new API_Exception('Could not delete Activity');
}
}
示例5: deleteParticipant
/**
* Delete the record that are associated with this participation
*
* @param int $id id of the participation to delete
*
* @return void
* @access public
* @static
*/
static function deleteParticipant($id)
{
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
//delete activity record
require_once "CRM/Activity/BAO/Activity.php";
$params = array('source_record_id' => $id, 'activity_type_id' => 5);
// activity type id for event registration
CRM_Activity_BAO_Activity::deleteActivity($params);
// delete the participant payment record
// we need to do this since the cascaded constraints
// dont work with join tables
require_once 'CRM/Event/BAO/ParticipantPayment.php';
$p = array('participant_id' => $id);
CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p);
// cleanup line items.
require_once 'CRM/Price/BAO/LineItem.php';
$participantsId = array();
$participantsId = self::getAdditionalParticipantIds($id);
$participantsId[] = $id;
CRM_Price_BAO_LineItem::deleteLineItems($participantsId, 'civicrm_participant');
$participant = new CRM_Event_DAO_Participant();
$participant->id = $id;
$participant->delete();
$transaction->commit();
// delete the recently created Participant
require_once 'CRM/Utils/Recent.php';
$participantRecent = array('id' => $id, 'type' => 'Participant');
CRM_Utils_Recent::del($participantRecent);
return $participant;
}
示例6: deleteCase
/**
* Delete the record that are associated with this case
* record are deleted from case
* @param int $caseId id of the case to delete
*
* @return void
* @access public
* @static
*/
static function deleteCase($caseId, $moveToTrash = false)
{
//delete activities
$activities = self::getCaseActivityDates($caseId);
if ($activities) {
require_once "CRM/Activity/BAO/Activity.php";
foreach ($activities as $value) {
CRM_Activity_BAO_Activity::deleteActivity($value, $moveToTrash);
}
}
if (!$moveToTrash) {
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
}
require_once 'CRM/Case/DAO/Case.php';
$case =& new CRM_Case_DAO_Case();
$case->id = $caseId;
if (!$moveToTrash) {
$result = $case->delete();
$transaction->commit();
} else {
$result = $case->is_deleted = 1;
$case->save();
}
if ($result) {
// remove case from recent items.
$caseRecent = array('id' => $caseId, 'type' => 'Case');
require_once 'CRM/Utils/Recent.php';
CRM_Utils_Recent::del($caseRecent);
return true;
}
return false;
}
示例7: civicrm_activity_delete
/**
* Delete a specified Activity.
* @param CRM_Activity $activity Activity object to be deleted
*
* @return void|CRM_Core_Error An error if 'activityName or ID' is invalid,
* permissions are insufficient, etc.
*
* @access public
*
*/
function civicrm_activity_delete(&$params)
{
_civicrm_initialize();
$errors = array();
//check for various error and required conditions
$errors = _civicrm_activity_check_params($params);
if (!empty($errors)) {
return $errors;
}
if (CRM_Activity_BAO_Activity::deleteActivity($params)) {
return civicrm_create_success();
} else {
return civicrm_create_error(ts('Could not delete activity'));
}
}
示例8: deleteMembership
/**
* Function to delete membership.
*
* @param int $membershipId membership id that needs to be deleted
*
* @static
*
* @return $results no of deleted Membership on success, false otherwise
* @access public
*/
static function deleteMembership($membershipId)
{
CRM_Utils_Hook::pre('delete', 'Membership', $membershipId, CRM_Core_DAO::$_nullArray);
$transaction = new CRM_Core_Transaction();
$results = NULL;
//delete activity record
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
$params = array();
$deleteActivity = false;
$membershipActivities = array('Membership Signup', 'Membership Renewal', 'Change Membership Status', 'Change Membership Type', 'Membership Renewal Reminder');
foreach ($membershipActivities as $membershipActivity) {
$activityId = array_search($membershipActivity, $activityTypes);
if ($activityId) {
$params['activity_type_id'][] = $activityId;
$deleteActivity = true;
}
}
if ($deleteActivity) {
$params['source_record_id'] = $membershipId;
CRM_Activity_BAO_Activity::deleteActivity($params);
}
self::deleteMembershipPayment($membershipId);
$membership = new CRM_Member_DAO_Membership();
$membership->id = $membershipId;
$results = $membership->delete();
$transaction->commit();
CRM_Utils_Hook::post('delete', 'Membership', $membership->id, $membership);
// delete the recently created Membership
$membershipRecent = array('id' => $membershipId, 'type' => 'Membership');
CRM_Utils_Recent::del($membershipRecent);
return $results;
}
示例9: deleteCase
/**
* Delete the record that are associated with this case
* record are deleted from case
*
* @param int $caseId id of the case to delete
*
* @param bool $moveToTrash
*
* @return bool is successful
* @access public
* @static
*/
static function deleteCase($caseId, $moveToTrash = FALSE)
{
CRM_Utils_Hook::pre('delete', 'Case', $caseId, CRM_Core_DAO::$_nullArray);
//delete activities
$activities = self::getCaseActivityDates($caseId);
if ($activities) {
foreach ($activities as $value) {
CRM_Activity_BAO_Activity::deleteActivity($value, $moveToTrash);
}
}
if (!$moveToTrash) {
$transaction = new CRM_Core_Transaction();
}
$case = new CRM_Case_DAO_Case();
$case->id = $caseId;
if (!$moveToTrash) {
$result = $case->delete();
$transaction->commit();
} else {
$result = $case->is_deleted = 1;
$case->save();
}
if ($result) {
// CRM-7364, disable relationships
self::enableDisableCaseRelationships($caseId, FALSE);
CRM_Utils_Hook::post('delete', 'Case', $caseId, $case);
// remove case from recent items.
$caseRecent = array('id' => $caseId, 'type' => 'Case');
CRM_Utils_Recent::del($caseRecent);
return TRUE;
}
return FALSE;
}
示例10: deleteContribution
/**
* Delete the indirect records associated with this contribution first
*
* @return $results no of deleted Contribution on success, false otherwise
* @access public
* @static
*/
static function deleteContribution($id)
{
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$results = null;
//delete activity record
require_once "CRM/Activity/BAO/Activity.php";
$params = array('source_record_id' => $id, 'activity_type_id' => 6);
// activity type id for contribution
CRM_Activity_BAO_Activity::deleteActivity($params);
//delete billing address if exists for this contribution.
self::deleteAddress($id);
//update pledge and pledge payment, CRM-3961
require_once 'CRM/Pledge/BAO/Payment.php';
CRM_Pledge_BAO_Payment::resetPledgePayment($id);
// remove entry from civicrm_price_set_entity, CRM-5095
require_once 'CRM/Price/BAO/Set.php';
if (CRM_Price_BAO_Set::getFor('civicrm_contribution', $id)) {
CRM_Price_BAO_Set::removeFrom('civicrm_contribution', $id);
}
// cleanup line items.
require_once 'CRM/Price/BAO/Field.php';
require_once 'CRM/Event/BAO/ParticipantPayment.php';
$participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $id, 'participant_id', 'contribution_id');
// delete any related entity_financial_trxn and financial_trxn records.
require_once 'CRM/Core/BAO/FinancialTrxn.php';
CRM_Core_BAO_FinancialTrxn::deleteFinancialTrxn($id, 'civicrm_contribution');
if ($participantId) {
require_once 'CRM/Price/BAO/LineItem.php';
CRM_Price_BAO_LineItem::deleteLineItems($participantId, 'civicrm_participant');
} else {
require_once 'CRM/Price/BAO/LineItem.php';
CRM_Price_BAO_LineItem::deleteLineItems($id, 'civicrm_contribution');
}
$dao = new CRM_Contribute_DAO_Contribution();
$dao->id = $id;
$results = $dao->delete();
$transaction->commit();
CRM_Utils_Hook::post('delete', 'Contribution', $dao->id, $dao);
// delete the recently created Contribution
require_once 'CRM/Utils/Recent.php';
$contributionRecent = array('id' => $id, 'type' => 'Contribution');
CRM_Utils_Recent::del($contributionRecent);
return $results;
}
示例11: deleteContribution
/**
* Delete the indirect records associated with this contribution first.
*
* @param int $id
*
* @return mixed|null
* $results no of deleted Contribution on success, false otherwise
*/
public static function deleteContribution($id)
{
CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
$transaction = new CRM_Core_Transaction();
$results = NULL;
//delete activity record
$params = array('source_record_id' => $id, 'activity_type_id' => 6);
CRM_Activity_BAO_Activity::deleteActivity($params);
//delete billing address if exists for this contribution.
self::deleteAddress($id);
//update pledge and pledge payment, CRM-3961
CRM_Pledge_BAO_PledgePayment::resetPledgePayment($id);
// remove entry from civicrm_price_set_entity, CRM-5095
if (CRM_Price_BAO_PriceSet::getFor('civicrm_contribution', $id)) {
CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution', $id);
}
// cleanup line items.
$participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $id, 'participant_id', 'contribution_id');
// delete any related entity_financial_trxn, financial_trxn and financial_item records.
CRM_Core_BAO_FinancialTrxn::deleteFinancialTrxn($id);
if ($participantId) {
CRM_Price_BAO_LineItem::deleteLineItems($participantId, 'civicrm_participant');
} else {
CRM_Price_BAO_LineItem::deleteLineItems($id, 'civicrm_contribution');
}
//delete note.
$note = CRM_Core_BAO_Note::getNote($id, 'civicrm_contribution');
$noteId = key($note);
if ($noteId) {
CRM_Core_BAO_Note::del($noteId, FALSE);
}
$dao = new CRM_Contribute_DAO_Contribution();
$dao->id = $id;
$results = $dao->delete();
$transaction->commit();
CRM_Utils_Hook::post('delete', 'Contribution', $dao->id, $dao);
// delete the recently created Contribution
$contributionRecent = array('id' => $id, 'type' => 'Contribution');
CRM_Utils_Recent::del($contributionRecent);
return $results;
}
示例12: postProcess
/**
* Process the form submission.
*
*
* @param array $params
*
* @return void
*/
public function postProcess($params = NULL)
{
$transaction = new CRM_Core_Transaction();
if ($this->_action & CRM_Core_Action::DELETE) {
$statusMsg = NULL;
//block deleting activities which affects
//case attributes.CRM-4543
$activityCondition = " AND v.name IN ('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date')";
$caseAttributeActivities = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, $activityCondition);
if (!array_key_exists($this->_activityTypeId, $caseAttributeActivities)) {
$params = array('id' => $this->_activityId);
$activityDelete = CRM_Activity_BAO_Activity::deleteActivity($params, TRUE);
if ($activityDelete) {
$statusMsg = ts('The selected activity has been moved to the Trash. You can view and / or restore deleted activities by checking "Deleted Activities" from the Case Activities search filter (under Manage Case).<br />');
}
} else {
$statusMsg = ts("Selected Activity cannot be deleted.");
}
$tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus('', $statusMsg, 'info');
return;
}
if ($this->_action & CRM_Core_Action::RENEW) {
$statusMsg = NULL;
$params = array('id' => $this->_activityId);
$activityRestore = CRM_Activity_BAO_Activity::restoreActivity($params);
if ($activityRestore) {
$statusMsg = ts('The selected activity has been restored.<br />');
}
CRM_Core_Session::setStatus('', $statusMsg, 'info');
return;
}
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
//set parent id if its edit mode
if ($parentId = CRM_Utils_Array::value('parent_id', $this->_defaults)) {
$params['parent_id'] = $parentId;
}
// store the dates with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
$params['activity_type_id'] = $this->_activityTypeId;
// format with contact (target contact) values
if (isset($params['target_contact_id'])) {
$params['target_contact_id'] = explode(',', $params['target_contact_id']);
} else {
$params['target_contact_id'] = array();
}
// format activity custom data
if (!empty($params['hidden_custom'])) {
if ($this->_activityId) {
// unset custom fields-id from params since we want custom
// fields to be saved for new activity.
foreach ($params as $key => $value) {
$match = array();
if (preg_match('/^(custom_\\d+_)(\\d+)$/', $key, $match)) {
$params[$match[1] . '-1'] = $params[$key];
// for autocomplete transfer hidden value instead of label
if ($params[$key] && isset($params[$key . '_id'])) {
$params[$match[1] . '-1_id'] = $params[$key . '_id'];
unset($params[$key . '_id']);
}
unset($params[$key]);
}
}
}
// build custom data getFields array
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_activityId, 'Activity');
}
// assigning formatted value
if (!empty($params['assignee_contact_id'])) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
if (isset($this->_activityId)) {
// activity which hasn't been modified by a user yet
if ($this->_defaults['is_auto'] == 1) {
$params['is_auto'] = 0;
}
// always create a revision of an case activity. CRM-4533
$newActParams = $params;
// add target contact values in update mode
if (empty($params['target_contact_id']) && !empty($this->_defaults['target_contact'])) {
$newActParams['target_contact_id'] = $this->_defaults['target_contact'];
}
}
if (!isset($newActParams)) {
// add more attachments if needed for old activity
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity');
//.........这里部分代码省略.........
示例13: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess($params = null)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted sucessfully."));
return;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
//set activity type id
if (!CRM_Utils_Array::value('activity_type_id', $params)) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', false, false, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', false, false, null, null, true));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// assigning formated value to related variable
if (CRM_Utils_Array::value('target_contact_id', $params)) {
$params['target_contact_id'] = explode(',', $params['target_contact_id']);
} else {
$params['target_contact_id'] = array();
}
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
} else {
$params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
// format target params
if (!$this->_single) {
$params['target_contact_id'] = $this->_contactIds;
}
$activityAssigned = array();
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($this->_activityId);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// create follow up activity if needed
$followupStatus = '';
if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = "A followup activity has been scheduled.";
}
// send copy to assignee contacts.CRM-4509
$mailStatus = '';
$config =& CRM_Core_Config::singleton();
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id']) && $config->activityAssigneeNotification) {
$mailToContacts = array();
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, true, false);
//build an associative array with unique email addresses.
foreach ($activityAssigned as $id => $dnc) {
if (isset($id) && array_key_exists($id, $assigneeContacts)) {
$mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
}
}
if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
//include attachments while sendig a copy of activity.
$attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
require_once "CRM/Case/BAO/Case.php";
$result = CRM_Case_BAO_Case::sendActivityCopy(null, $activity->id, $mailToContacts, $attachments, null);
$mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
}
}
// set status message
//.........这里部分代码省略.........
示例14: civicrm_api3_activity_delete
/**
* Delete a specified Activity.
*
* @param array $params array holding 'id' of activity to be deleted
* {@getfields activity_delete}
*
* @return void|CRM_Core_Error An error if 'activityName or ID' is invalid,
* permissions are insufficient, etc. or CiviCRM success array
*
*
*
* @example ActivityDelete.php Standard Delete Example
*
*
*/
function civicrm_api3_activity_delete($params)
{
if (CRM_Activity_BAO_Activity::deleteActivity($params)) {
return civicrm_api3_create_success(1, $params, 'activity', 'delete');
} else {
return civicrm_api3_create_error('Could not delete activity');
}
}
示例15: postProcess
/**
* Function to process the form
*
* @access public
*
* @return void
*/
public function postProcess($params = NULL)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams, $moveToTrash);
// delete tags for the entity
$tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted successfully."), ts('Record Deleted'), 'success');
return;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
//set activity type id
if (empty($params['activity_type_id'])) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (!empty($params['hidden_custom']) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// format with contact (target contact) values
if (isset($params['contact'][1])) {
$params['target_contact_id'] = explode(',', $params['contact'][1]);
} else {
$params['target_contact_id'] = array();
}
// assigning formated value to related variable
if (!empty($params['assignee_contact_id'])) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
// civicrm-10043 - 14/12/13
if (!empty($params['followup_assignee_contact_id'])) {
$params['followup_assignee_contact_id'] = explode(',', $params['followup_assignee_contact_id']);
} else {
$params['followup_assignee_contact_id'] = array();
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
// format target params
if (!$this->_single) {
$params['target_contact_id'] = $this->_contactIds;
}
$activity = array();
if (!empty($params['is_multi_activity']) && !CRM_Utils_Array::crmIsEmptyArray($params['target_contact_id'])) {
$targetContacts = $params['target_contact_id'];
foreach ($targetContacts as $targetContactId) {
$params['target_contact_id'] = array($targetContactId);
// save activity
$activity[] = $this->processActivity($params);
}
} else {
// save activity
$activity = $this->processActivity($params);
}
return array('activity' => $activity);
}