Skip to content

Commit

Permalink
Release merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimyhuang committed Aug 7, 2024
2 parents f3ce157 + c5f6957 commit fffb34c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 21 deletions.
42 changes: 33 additions & 9 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,9 @@ static function getActivitySQLClause($contactID, $admin = FALSE, $caseId = NULL,
* @param array $attachments the array of attachments if any
* @param string $cc cc recepient
* @param string $bcc bcc recepient
* @param array $contactIds contact ids
* @param object form object for processing this email
* @param array $contactIds contact ids
* @param object $object form object for processing this email
* @param int parent id to save this activity
*
* @return array ( sent, activityId) if any email is sent and activityId
* @access public
Expand All @@ -1157,7 +1158,8 @@ static function sendEmail(
$cc = NULL,
$bcc = NULL,
&$contactIds = NULL,
&$object = NULL
&$object = NULL,
$parentId = NULL
) {
$class = is_object($object) ? get_class($object) : 'CRM_Activity_BAO_Activity';
if (empty($contactIds)) {
Expand Down Expand Up @@ -1217,6 +1219,12 @@ static function sendEmail(
// FIXME: check for name Completed and get ID from that lookup
'status_id' => 2,
);
if (!empty($parentId)) {
$exists = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $parentId, 'id');
if ($exists) {
$activityParams['parent_id'] = $parentId;
}
}

// CRM-5916: strip [case #…] before saving the activity (if present in subject)
$activityParams['subject'] = preg_replace('/\[case #([0-9a-h]{7})\] /', '', $activityParams['subject']);
Expand Down Expand Up @@ -1250,13 +1258,25 @@ static function sendEmail(
$returnProperties,
NULL, NULL, FALSE,
$flatten,
$class
$class,
TRUE
);
}

// call token hook
$tokens = array();
CRM_Utils_Hook::tokens($tokens);
if (!empty($details)) {
// prepare activity relative parameters
$details[0]['activity'] = array();
$details[0]['activity']['id'] = $activity->id;
foreach($activityParams as $idx => $val) {
if (isset($activity->$idx)) {
$details[0]['activity'][$idx] = $activity->$idx;
}
}
CRM_Utils_Hook::tokenValues($details, $contactIds, NULL, $tokens, __CLASS__.'::'.__METHOD__);
}
$categories = array_keys($tokens);

$escapeSmarty = FALSE;
Expand Down Expand Up @@ -1326,8 +1346,9 @@ static function sendEmail(
* @param int $toId to contact id
* @param int $templateId message template id
* @param int $check check if mail should be send on hold, desease or do not email
* @param int $parentId parent activity ID that will save this email activity
*/
public static function sendEmailTemplate($from, $toId, $template_id, $check = FALSE) {
public static function sendEmailTemplate($from, $toId, $templateId, $check = FALSE, $parentId = NULL) {
$returnProperties = array(
'sort_name' => 1,
'email' => 1,
Expand All @@ -1346,7 +1367,7 @@ public static function sendEmailTemplate($from, $toId, $template_id, $check = FA
else {
$fromId = NULL;
}
list($details) = CRM_Mailing_BAO_Mailing::getDetails($getDetails, $returnProperties, FALSE, FALSE);
list($details) = CRM_Mailing_BAO_Mailing::getDetails($getDetails, $returnProperties, FALSE, FALSE, NULL, TRUE);
if (!empty($details)) {
$toDetails = $details[$toId];
$contactIds = array($toId);
Expand All @@ -1358,7 +1379,7 @@ public static function sendEmailTemplate($from, $toId, $template_id, $check = FA
}

$toDetails = array($details[$toId]);
$params = array('id' => $template_id);
$params = array('id' => $templateId);
$template = array();
CRM_Core_BAO_MessageTemplates::retrieve($params, $template);
$subject = $template['msg_subject'];
Expand All @@ -1375,7 +1396,9 @@ public static function sendEmailTemplate($from, $toId, $template_id, $check = FA
NULL, // attachments
NULL, // cc
NULL, // bcc
$contactIds // contact_id
$contactIds, // contact_id
CRM_Core_DAO::$_nullObject, // object
$parentId, // parent_id
);
if ($sent) {
return TRUE;
Expand Down Expand Up @@ -1543,7 +1566,8 @@ public static function sendSMS(
$returnProperties,
NULL, NULL, FALSE,
$messageToken,
'CRM_Activity_BAO_Activity'
'CRM_Activity_BAO_Activity',
TRUE
);
}

Expand Down
3 changes: 3 additions & 0 deletions CRM/Activity/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@ public function postProcess($params = NULL) {
$this->beginPostProcess($params);

$activity = CRM_Activity_BAO_Activity::create($params);
if ($this->_action == CRM_Core_Action::ADD) {
$this->_activityId = $activity->id;
}

// add tags if exists
$tagParams = array();
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/ConfigSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static function skipVars() {
'userSystem',
'userFrameworkDSN',
'userFramework',
'userFrameworkBaseURL', 'userFrameworkClass', 'userHookClass',
'userFrameworkBaseURL', 'useFrameworkRelativeBase', 'userFrameworkClass', 'userHookClass',
'userPermissionClass', 'userFrameworkURLVar', 'userFrameworkVersion',
'newBaseURL', 'newBaseDir', 'newSiteName', 'configAndLogDir',
'qfKey', 'gettextResourceDir', 'cleanURL',
Expand Down
2 changes: 2 additions & 0 deletions CRM/Export/Form/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ function preProcess() {
}

$buttonName = $this->getButtonName('next');
// skip multiple query, but save export mode
if ($buttonName === $this->controller->getButtonName() || $this->get('prevAction') === 'back') {
$this->_exportMode = $this->get('exportMode');
return;
}
$customSearchID = $this->get('customSearchID');
Expand Down
7 changes: 5 additions & 2 deletions CRM/Mailing/BAO/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,8 @@ static function getDetails($contactIDs,
$returnProperties = NULL,
$skipOnHold = TRUE,
$skipDeceased = TRUE,
$extraParams = NULL
$extraParams = NULL,
$customHook = FALSE
) {
$params = array();
foreach ($contactIDs as $key => $contactID) {
Expand Down Expand Up @@ -2552,7 +2553,9 @@ static function getDetails($contactIDs,
}

// also call a hook and get token details
CRM_Utils_Hook::tokenValues($details[0], $contactIDs, NULL, array(), 'CRM_Mailing_BAO_Mailing_getDetails');
if (empty($customHook)) {
CRM_Utils_Hook::tokenValues($details[0], $contactIDs, NULL, array(), 'CRM_Mailing_BAO_Mailing_getDetails');
}
return $details;
}

Expand Down
20 changes: 12 additions & 8 deletions CRM/Utils/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,8 @@ public static function getTokens($string) {
* @param boolean $skipDeceased don't return deceased contact info.
* @param array $extraParams extra params
* @param array $tokens the list of tokens we've extracted from the content
* @param string $className context to call hook_tokenValues
* @param bool $customHook skip hook call
*
* @return array
* @access public
Expand All @@ -1034,7 +1036,8 @@ public static function getTokenDetails($contactIDs,
$skipDeceased = TRUE,
$extraParams = NULL,
$tokens = array(),
$className = NULL
$className = NULL,
$customHook = FALSE
) {
if (empty($contactIDs)) {
// putting a fatal here so we can track if/when this happens
Expand Down Expand Up @@ -1137,13 +1140,14 @@ public static function getTokenDetails($contactIDs,
}

// also call a hook and get token details
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::tokenValues($details[0],
$contactIDs,
NULL,
$tokens,
$className
);
if (empty($customHook)) {
CRM_Utils_Hook::tokenValues($details[0],
$contactIDs,
NULL,
$tokens,
$className
);
}
return $details;
}

Expand Down
2 changes: 1 addition & 1 deletion api/v3/CustomValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function civicrm_api3_custom_value_get($params) {
$id = $fieldNumber;
}
$values[$id]['entity_id'] = $getParams['entityID'];
if (CRM_Utils_Array::value('entityType', $getParams)) {
if (CRM_Utils_Array::value('entityType', $getParams) && empty($params['sequential'])) {
$values[$n]['entity_table'] = $getParams['entityType'];
}
//set 'latest' -useful for multi fields but set for single for consistency
Expand Down

0 comments on commit fffb34c

Please sign in to comment.