本文整理汇总了PHP中CRM_Activity_BAO_Activity::createActivityTarget方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::createActivityTarget方法的具体用法?PHP CRM_Activity_BAO_Activity::createActivityTarget怎么用?PHP CRM_Activity_BAO_Activity::createActivityTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Activity_BAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_BAO_Activity::createActivityTarget方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createActivities
function createActivities($form, $html_message, $contactIds)
{
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
$activityParams = array('source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'details' => $html_message);
if ($form->_activityId) {
$activityParams += array('id' => $form->_activityId);
}
if ($form->_cid) {
$activity = CRM_Activity_BAO_Activity::create($activityParams);
} else {
// create Print PDF activity for each selected contact. CRM-6886
$activityIds = array();
foreach ($contactIds as $contactId) {
$activityID = CRM_Activity_BAO_Activity::create($activityParams);
$activityIds[$contactId] = $activityID->id;
}
}
foreach ($form->_contactIds as $contactId) {
$activityTargetParams = array('activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id, 'target_contact_id' => $contactId);
CRM_Activity_BAO_Activity::createActivityTarget($activityTargetParams);
}
}
示例2: _convertToCaseActivity
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']));
}
foreach ($targetContacts as $key => $value) {
$targ_params = array('activity_id' => $mainActivityId, 'target_contact_id' => $value);
CRM_Activity_BAO_Activity::createActivityTarget($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, 'assignee_contact_id' => $value);
CRM_Activity_BAO_Activity::createActivityAssignment($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);
}
示例3: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
static function postProcess(&$form)
{
$formValues = $form->controller->exportValues($form->getName());
// process message template
require_once 'CRM/Core/BAO/MessageTemplates.php';
if (CRM_Utils_Array::value('saveTemplate', $formValues) || CRM_Utils_Array::value('updateTemplate', $formValues)) {
$messageTemplate = array('msg_text' => NULL, 'msg_html' => $formValues['html_message'], 'msg_subject' => NULL, 'is_active' => true);
if ($formValues['saveTemplate']) {
$messageTemplate['msg_title'] = $formValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
if ($formValues['template'] && $formValues['updateTemplate']) {
$messageTemplate['id'] = $formValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
}
require_once 'dompdf/dompdf_config.inc.php';
$html = '<html><head><style>body { margin: 56px; }</style></head><body>';
require_once 'api/v2/Contact.php';
require_once 'CRM/Utils/Token.php';
$tokens = array();
CRM_Utils_Hook::tokens($tokens);
$categories = array_keys($tokens);
$html_message = $formValues['html_message'];
//time being hack to strip ' '
//from particular letter line, CRM-6798
self::formatMessage($html_message);
require_once 'CRM/Activity/BAO/Activity.php';
$messageToken = CRM_Activity_BAO_Activity::getTokens($html_message);
$returnProperties = array();
if (isset($messageToken['contact'])) {
foreach ($messageToken['contact'] as $key => $value) {
$returnProperties[$value] = 1;
}
}
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing = new CRM_Mailing_BAO_Mailing();
if (defined('CIVICRM_MAIL_SMARTY')) {
require_once 'CRM/Core/Smarty/resources/String.php';
civicrm_smarty_register_string_resource();
}
$first = TRUE;
foreach ($form->_contactIds as $item => $contactId) {
$params = array('contact_id' => $contactId);
list($contact) = $mailing->getDetails($params, $returnProperties, false);
if (civicrm_error($contact)) {
$notSent[] = $contactId;
continue;
}
$tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contact[$contactId], true, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact[$contactId], $categories, true);
if (defined('CIVICRM_MAIL_SMARTY')) {
$smarty = CRM_Core_Smarty::singleton();
// also add the contact tokens to the template
$smarty->assign_by_ref('contact', $contact);
$tokenHtml = $smarty->fetch("string:{$tokenHtml}");
}
if ($first == TRUE) {
$first = FALSE;
$html .= $tokenHtml;
} else {
$html .= "<div STYLE='page-break-after: always'></div>{$tokenHtml}";
}
}
$html .= '</body></html>';
require_once 'CRM/Activity/BAO/Activity.php';
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
$activityParams = array('source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'details' => $html_message);
if ($form->_activityId) {
$activityParams += array('id' => $form->_activityId);
}
if ($form->_cid) {
$activity = CRM_Activity_BAO_Activity::create($activityParams);
} else {
// create Print PDF activity for each selected contact. CRM-6886
$activityIds = array();
foreach ($form->_contactIds as $contactId) {
$activityID = CRM_Activity_BAO_Activity::create($activityParams);
$activityIds[$contactId] = $activityID->id;
}
}
foreach ($form->_contactIds as $contactId) {
$activityTargetParams = array('activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id, 'target_contact_id' => $contactId);
CRM_Activity_BAO_Activity::createActivityTarget($activityTargetParams);
}
require_once 'CRM/Utils/PDF/Utils.php';
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", 'portrait', 'letter');
// we need to call the hook manually here since we redirect and never
// go back to CRM/Core/Form.php
CRM_Utils_Hook::postProcess(get_class($form), $form);
CRM_Utils_System::civiExit(1);
//.........这里部分代码省略.........
示例4: convertToCaseActivity
static function convertToCaseActivity()
{
$params = array('caseID', 'activityID', 'contactID', 'newSubject', 'targetContactIds', 'mode');
foreach ($params as $param) {
${$param} = CRM_Utils_Array::value($param, $_POST);
}
if (!$activityID || !$caseID) {
echo json_encode(array('error_msg' => 'required params missing.'));
CRM_Utils_System::civiExit();
}
require_once "CRM/Activity/DAO/Activity.php";
$otherActivity = new CRM_Activity_DAO_Activity();
$otherActivity->id = $activityID;
if (!$otherActivity->find(true)) {
echo json_encode(array('error_msg' => 'activity record is missing.'));
CRM_Utils_System::civiExit();
}
$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($newSubject)) {
$mainActVals['subject'] = $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;
require_once 'CRM/Activity/BAO/Activity.php';
CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
$mainActivity->free();
//mark previous activity as deleted.
if (in_array($mode, array('move', 'file'))) {
$otherActivity->activity_date_time = $actDateTime;
$otherActivity->is_deleted = 1;
$otherActivity->save();
}
$otherActivity->free();
require_once "CRM/Activity/BAO/Activity.php";
$targetContacts = array();
if (!empty($targetContactIds)) {
$targetContacts = array_unique(explode(',', $targetContactIds));
}
foreach ($targetContacts as $key => $value) {
$params = array('activity_id' => $mainActivityId, 'target_contact_id' => $value);
CRM_Activity_BAO_Activity::createActivityTarget($params);
}
//attach newly created activity to case.
require_once "CRM/Case/DAO/CaseActivity.php";
$caseActivity = new CRM_Case_DAO_CaseActivity();
$caseActivity->case_id = $caseID;
$caseActivity->activity_id = $mainActivityId;
$caseActivity->save();
$error_msg = $caseActivity->_lastError;
$caseActivity->free();
echo json_encode(array('error_msg' => $error_msg));
CRM_Utils_System::civiExit();
}