$mailingFormatProperties = array();
if ($mailingFormat) {
- $mailingFormatProperties = self::getReturnProperties($mailingFormat);
+ $mailingFormatProperties = CRM_Utils_Token::getReturnProperties($mailingFormat);
$returnProperties = array_merge($returnProperties, $mailingFormatProperties);
}
//we should not consider addressee for data exists, CRM-6025
$pdf->Output($fileName, 'D');
}
- /**
- * Create the array of returnProperties
- *
- * @param string $format format for which return properties build
- *
- * @return array of returnProperties
- */
- public function getReturnProperties(&$format) {
- $returnProperties = array();
- $matches = array();
- preg_match_all('/(?<!\{|\\\\)\{(\w+\.\w+)\}(?!\})/',
- $format,
- $matches,
- PREG_PATTERN_ORDER
- );
- if ($matches[1]) {
- foreach ($matches[1] as $token) {
- list($type, $name) = preg_split('/\./', $token, 2);
- if ($name) {
- $returnProperties["{$name}"] = 1;
- }
- }
- }
-
- return $returnProperties;
- }
-
/**
* @param $rows
*/
//get the address format sequence from the config file
$addressReturnProperties = CRM_Contact_Form_Task_LabelCommon::getAddressReturnProperties();
- //build the returnproperties
+ //build the return properties
$returnProperties = array('display_name' => 1, 'contact_type' => 1, 'prefix_id' => 1);
$mailingFormat = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'mailing_format'
$mailingFormatProperties = array();
if ($mailingFormat) {
- $mailingFormatProperties = CRM_Contact_Form_Task_LabelCommon::regexReturnProperties($mailingFormat);
+ $mailingFormatProperties = CRM_Utils_Token::getReturnProperties($mailingFormat);
$returnProperties = array_merge($returnProperties, $mailingFormatProperties);
}
return array($rows, $tokenFields);
}
- /**
- * Extract the return properties from the mailing format
- * @todo I'm placing bets this is a duplicate of code elsewhere - find & merge
- * @param unknown_type $format
- * @return multitype:number
- */
- public function regexReturnProperties(&$format) {
- $returnProperties = array();
- $matches = array();
- preg_match_all('/(?<!\{|\\\\)\{(\w+\.\w+)\}(?!\})/',
- $format,
- $matches,
- PREG_PATTERN_ORDER
- );
- if ($matches[1]) {
- foreach ($matches[1] as $token) {
- list($type, $name) = preg_split('/\./', $token, 2);
- if ($name) {
- $returnProperties["{$name}"] = 1;
- }
- }
- }
-
- return $returnProperties;
- }
-
/**
* Get array of return properties for address fields required for mailing label
* @return array return properites for address e.g
$$elem = $smarty->fetch("string:{$$elem}");
}
+ //@todo - this next section is a duplicate of function CRM_Utils_Token::getTokens
$matches = array();
preg_match_all('/(?<!\{|\\\\)\{(\w+\.\w+)\}(?!\})/',
$body_subject,
}
}
+ // @todo this (along with the copy-&-paste chunk above is a commonly repeated chunk of code & should be in a re-usable function
$messageSubject = CRM_Utils_Token::replaceContactTokens($body_subject, $contact, FALSE, $subjectToken);
$messageSubject = CRM_Utils_Token::replaceDomainTokens($messageSubject, $domain, TRUE, $subjectToken);
$messageSubject = CRM_Utils_Token::replaceComponentTokens($messageSubject, $contact, $subjectToken, TRUE);
'source_record_id' => $dao->entityID,
);
$activity = CRM_Activity_BAO_Activity::create($activityParams);
-
+
//file reminder on case if source activity is a case activity
if (!empty($dao->case_id)) {
$caseActivityParams = array();
return $tokens;
}
+ /**
+ * Function to determine which values to retrieve to insert into tokens. The heavy resemblance between this function
+ * and getTokens appears to be historical rather than intentional and should be reviewed
+ * @param $string
+ * @return array fields to pass in as return properties when populating token
+ *
+ */
+ public static function getReturnProperties(&$string) {
+ $returnProperties = array();
+ $matches = array();
+ preg_match_all('/(?<!\{|\\\\)\{(\w+\.\w+)\}(?!\})/',
+ $string,
+ $matches,
+ PREG_PATTERN_ORDER
+ );
+ if ($matches[1]) {
+ foreach ($matches[1] as $token) {
+ list($type, $name) = preg_split('/\./', $token, 2);
+ if ($name) {
+ $returnProperties["{$name}"] = 1;
+ }
+ }
+ }
+
+ return $returnProperties;
+ }
+
/**
* Gives required details of contacts in an indexed array format so we
* can iterate in a nice loop and do token evaluation