From bdd49e3826fad29cc02081b07a81eda3455d126a Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 5 Jan 2015 16:23:02 +1300 Subject: [PATCH] CRM-15779 remove duplicate code block --- CRM/Contact/Form/Task/Label.php | 29 +------------------------- CRM/Contact/Form/Task/LabelCommon.php | 30 ++------------------------- CRM/Core/BAO/ActionSchedule.php | 4 +++- CRM/Utils/Token.php | 27 ++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 57 deletions(-) diff --git a/CRM/Contact/Form/Task/Label.php b/CRM/Contact/Form/Task/Label.php index c64fc95296..8924401ad9 100644 --- a/CRM/Contact/Form/Task/Label.php +++ b/CRM/Contact/Form/Task/Label.php @@ -138,7 +138,7 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { $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 @@ -397,33 +397,6 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { $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('/(? 1, 'contact_type' => 1, 'prefix_id' => 1); $mailingFormat = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format' @@ -110,7 +110,7 @@ class CRM_Contact_Form_Task_LabelCommon { $mailingFormatProperties = array(); if ($mailingFormat) { - $mailingFormatProperties = CRM_Contact_Form_Task_LabelCommon::regexReturnProperties($mailingFormat); + $mailingFormatProperties = CRM_Utils_Token::getReturnProperties($mailingFormat); $returnProperties = array_merge($returnProperties, $mailingFormatProperties); } @@ -255,32 +255,6 @@ class CRM_Contact_Form_Task_LabelCommon { 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('/(?fetch("string:{$$elem}"); } + //@todo - this next section is a duplicate of function CRM_Utils_Token::getTokens $matches = array(); preg_match_all('/(? $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(); diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index d31b55771c..4d1499dc83 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -1059,6 +1059,33 @@ class CRM_Utils_Token { 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('/(?