Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-17038

Custom Tokens in greetings not replaced

    Details

    • Documentation Required?:
      None
    • Funding Source:
      Paid Issue Queue
    • Payment Status:
      Paid

      Description

      Custom tokens won't get replaced when used in greetings. Neither those with custom keys/categories nor those added to "contact" key.

      keyname.tokenname shaped toekns won't get to replaceHookTokens() because only contact key is handled. And contact key's custom token's get escaped before replaceHookTokens() is called.

      Line 1464 ff. say

           if (!empty($remainingTokens['contact'])) {
              // Fill the return properties array
              $greetingTokens = $remainingTokens['contact'];
              reset($greetingTokens);
              $greetingsReturnProperties = array();
              while (list($key) = each($greetingTokens)) {
                $props = array_flip(CRM_Utils_Array::value($key, $greetingTokens));
                $props = array_fill_keys(array_keys($props), 1);
      

      As from what I know about the tokens array structure this seems to result in faulty array handling. And for god's sake custom token's shouldn't be bound to »contact« category. So changing the first three lines of the above to

           if (!empty($remainingTokens)) {
              // Fill the return properties array
              $greetingTokens = $remainingTokens;
      

      allows handling of custom tokens in custom categories and fixes errors reported in http://civicrm.stackexchange.com/questions/2004/error-for-token-php-related-to-greeting-tokens?rq=1 Civi's SE.

      Could someone review and comment on this plz.

      Thanks for this cool peace of software!

        Attachments

          Activity

            People

            • Assignee:
              jitendra.purohit Jitendra Purohit
              Reporter:
              nielo Niels Heinemann
            • Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m