本文整理汇总了PHP中CRM_Activity_BAO_Activity::copyExtendedActivityData方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::copyExtendedActivityData方法的具体用法?PHP CRM_Activity_BAO_Activity::copyExtendedActivityData怎么用?PHP CRM_Activity_BAO_Activity::copyExtendedActivityData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Activity_BAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_BAO_Activity::copyExtendedActivityData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _convertToCaseActivity
/**
* @param array $params
*
* @return array
*/
public static function _convertToCaseActivity($params)
{
if (!$params['activityID'] || !$params['caseID']) {
return array('error_msg' => 'required params missing.');
}
$otherActivity = new CRM_Activity_DAO_Activity();
$otherActivity->id = $params['activityID'];
if (!$otherActivity->find(TRUE)) {
return array('error_msg' => 'activity record is missing.');
}
$actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time);
// Create new activity record.
$mainActivity = new CRM_Activity_DAO_Activity();
$mainActVals = array();
CRM_Core_DAO::storeValues($otherActivity, $mainActVals);
// Get new activity subject.
if (!empty($params['newSubject'])) {
$mainActVals['subject'] = $params['newSubject'];
}
$mainActivity->copyValues($mainActVals);
$mainActivity->id = NULL;
$mainActivity->activity_date_time = $actDateTime;
// Make sure this is current revision.
$mainActivity->is_current_revision = TRUE;
// Drop all relations.
$mainActivity->parent_id = $mainActivity->original_id = NULL;
$mainActivity->save();
$mainActivityId = $mainActivity->id;
CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
$mainActivity->free();
// Mark previous activity as deleted. If it was a non-case activity
// then just change the subject.
if (in_array($params['mode'], array('move', 'file'))) {
$caseActivity = new CRM_Case_DAO_CaseActivity();
$caseActivity->case_id = $params['caseID'];
$caseActivity->activity_id = $otherActivity->id;
if ($params['mode'] == 'move' || $caseActivity->find(TRUE)) {
$otherActivity->is_deleted = 1;
} else {
$otherActivity->subject = ts('(Filed on case %1)', array(1 => $params['caseID'])) . ' ' . $otherActivity->subject;
}
$otherActivity->activity_date_time = $actDateTime;
$otherActivity->save();
$caseActivity->free();
}
$otherActivity->free();
$targetContacts = array();
if (!empty($params['targetContactIds'])) {
$targetContacts = array_unique(explode(',', $params['targetContactIds']));
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$sourceContactID = CRM_Activity_BAO_Activity::getSourceContactID($params['activityID']);
$src_params = array('activity_id' => $mainActivityId, 'contact_id' => $sourceContactID, 'record_type_id' => $sourceID);
CRM_Activity_BAO_ActivityContact::create($src_params);
foreach ($targetContacts as $key => $value) {
$targ_params = array('activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $targetID);
CRM_Activity_BAO_ActivityContact::create($targ_params);
}
// typically this will be empty, since assignees on another case may be completely different
$assigneeContacts = array();
if (!empty($params['assigneeContactIds'])) {
$assigneeContacts = array_unique(explode(',', $params['assigneeContactIds']));
}
foreach ($assigneeContacts as $key => $value) {
$assigneeParams = array('activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $assigneeID);
CRM_Activity_BAO_ActivityContact::create($assigneeParams);
}
// Attach newly created activity to case.
$caseActivity = new CRM_Case_DAO_CaseActivity();
$caseActivity->case_id = $params['caseID'];
$caseActivity->activity_id = $mainActivityId;
$caseActivity->save();
$error_msg = $caseActivity->_lastError;
$caseActivity->free();
$params['mainActivityId'] = $mainActivityId;
CRM_Activity_BAO_Activity::copyExtendedActivityData($params);
return array('error_msg' => $error_msg, 'newId' => $mainActivity->id);
}
示例2: mergeCases
//.........这里部分代码省略.........
$mainActivityTarget->contact_id = $otherTargetActivity->contact_id;
if ($mainActivityTarget->contact_id == $otherContactId) {
$mainActivityTarget->contact_id = $mainContactId;
}
//avoid duplicate object.
if (!$mainActivityTarget->find(TRUE)) {
$mainActivityTarget->save();
}
$mainActivityTarget->free();
}
$otherTargetActivity->free();
//migrate assignee activities.
$otherAssigneeActivity = new CRM_Activity_DAO_ActivityContact();
$otherAssigneeActivity->activity_id = $otherActivityId;
$otherAssigneeActivity->record_type_id = $assigneeID;
$otherAssigneeActivity->find();
while ($otherAssigneeActivity->fetch()) {
$mainAssigneeActivity = new CRM_Activity_DAO_ActivityContact();
$mainAssigneeActivity->activity_id = $mainActivityId;
$mainAssigneeActivity->record_type_id = $assigneeID;
$mainAssigneeActivity->contact_id = $otherAssigneeActivity->contact_id;
if ($mainAssigneeActivity->contact_id == $otherContactId) {
$mainAssigneeActivity->contact_id = $mainContactId;
}
//avoid duplicate object.
if (!$mainAssigneeActivity->find(TRUE)) {
$mainAssigneeActivity->save();
}
$mainAssigneeActivity->free();
}
$otherAssigneeActivity->free();
// copy custom fields and attachments
$aparams = array('activityID' => $otherActivityId, 'mainActivityId' => $mainActivityId);
CRM_Activity_BAO_Activity::copyExtendedActivityData($aparams);
}
//copy case relationship.
if ($duplicateContacts) {
//migrate relationship records.
$otherRelationship = new CRM_Contact_DAO_Relationship();
$otherRelationship->case_id = $otherCaseId;
$otherRelationship->find();
$otherRelationshipIds = array();
while ($otherRelationship->fetch()) {
$otherRelVals = array();
$updateOtherRel = FALSE;
CRM_Core_DAO::storeValues($otherRelationship, $otherRelVals);
$mainRelationship = new CRM_Contact_DAO_Relationship();
$mainRelationship->copyValues($otherRelVals);
$mainRelationship->id = NULL;
$mainRelationship->case_id = $mainCaseId;
if ($mainRelationship->contact_id_a == $otherContactId) {
$updateOtherRel = TRUE;
$mainRelationship->contact_id_a = $mainContactId;
}
//case creator change only when we merge user contact.
if ($mainRelationship->contact_id_b == $otherContactId) {
//do not change creator for change client.
if (!$changeClient) {
$updateOtherRel = TRUE;
$mainRelationship->contact_id_b = $currentUserId ? $currentUserId : $mainContactId;
}
}
$mainRelationship->end_date = CRM_Utils_Date::isoToMysql($otherRelationship->end_date);
$mainRelationship->start_date = CRM_Utils_Date::isoToMysql($otherRelationship->start_date);
//avoid duplicate object.
if (!$mainRelationship->find(TRUE)) {
示例3: endPostProcess
/**
* Process the form submission.
*
*
* @param CRM_Core_Form $form
* @param array $params
* @param $activity
*/
public static function endPostProcess(&$form, &$params, $activity)
{
if (!empty($params['start_date'])) {
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
}
$caseType = CRM_Utils_Array::first($form->_caseType);
$caseId = CRM_Utils_Array::first($form->_caseId);
if (!$caseType && $caseId) {
$caseType = CRM_Case_BAO_Case::getCaseType($caseId, 'title');
}
if (!$form->_currentlyViewedContactId || !$form->_currentUserId || !$caseId || !$caseType) {
CRM_Core_Error::fatal('Required parameter missing for ChangeCaseType - end post processing');
}
$config = CRM_Core_Config::singleton();
$params['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
$activity->status_id = $params['status_id'];
$params['priority_id'] = CRM_Core_OptionGroup::getValue('priority', 'Normal', 'name');
$activity->priority_id = $params['priority_id'];
// 1. save activity subject with new start date
$currentStartDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'start_date'), $config->dateformatFull);
$newStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Date::mysqlToIso($params['start_date']), $config->dateformatFull);
$subject = 'Change Case Start Date from ' . $currentStartDate . ' to ' . $newStartDate;
$activity->subject = $subject;
$activity->save();
// 2. initiate xml processor
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 0, 'activity_date_time' => $params['start_date'], 'caseID' => $caseId, 'caseType' => $caseType, 'activityTypeName' => 'Change Case Start Date', 'activitySetName' => 'standard_timeline', 'resetTimeline' => 1);
$xmlProcessor->run($caseType, $xmlProcessorParams);
// 2.5 Update open case activity date
// Multiple steps since revisioned
if ($form->openCaseActivityId) {
$abao = new CRM_Activity_BAO_Activity();
$oldParams = array('id' => $form->openCaseActivityId);
$oldActivityDefaults = array();
$oldActivity = $abao->retrieve($oldParams, $oldActivityDefaults);
// save the old values
require_once 'api/v3/utils.php';
$openCaseParams = array();
//@todo calling api functions directly is not supported
_civicrm_api3_object_to_array($oldActivity, $openCaseParams);
// update existing revision
$oldParams = array('id' => $form->openCaseActivityId, 'is_current_revision' => 0);
$oldActivity = new CRM_Activity_DAO_Activity();
$oldActivity->copyValues($oldParams);
$oldActivity->save();
// change some params for the new one
unset($openCaseParams['id']);
$openCaseParams['activity_date_time'] = $params['start_date'];
$openCaseParams['target_contact_id'] = $oldActivityDefaults['target_contact'];
$openCaseParams['assignee_contact_id'] = $oldActivityDefaults['assignee_contact'];
$session = CRM_Core_Session::singleton();
$openCaseParams['source_contact_id'] = $session->get('userID');
// original_id always refers to the first activity, so only update if null (i.e. this is the second revision)
$openCaseParams['original_id'] = $openCaseParams['original_id'] ? $openCaseParams['original_id'] : $form->openCaseActivityId;
$newActivity = CRM_Activity_BAO_Activity::create($openCaseParams);
if (is_a($newActivity, 'CRM_Core_Error')) {
CRM_Core_Error::fatal('Unable to update Open Case activity');
} else {
// Create linkage to case
$caseActivityParams = array('activity_id' => $newActivity->id, 'case_id' => $caseId);
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
$caseActivityParams = array('activityID' => $form->openCaseActivityId, 'mainActivityId' => $newActivity->id);
CRM_Activity_BAO_Activity::copyExtendedActivityData($caseActivityParams);
}
}
// 3.status msg
$params['statusMsg'] = ts('Case Start Date changed successfully.');
}