CRM-7139 Respect hook_token for contribution receipts

    Details

    • Type: Patch
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.2.5
    • Fix Version/s: 3.2.6
    • Component/s: CiviContribute
    • Labels:
      None

      Description

      Patch causes CiviCRM to respect tokens set during receipt function. It's basically the patch from issue 6054 cut against 3.2.5 but it looks like that patch got missed as there were two issues on that issue.

      I tried the patch & it applied cleanly against 3.3 too.

        Attachments

        1. msgtemplate.patch
          10 kB
          Eileen McNaughton
        2. new.patch
          4 kB
          Eileen McNaughton

          Activity

          [CRM-7139] Respect hook_token for contribution receipts
          Eileen McNaughton added a comment -

          Sorry,

          Patch causes CiviCRM to respect tokens SET VIA HOOK when sending out civicrm receipts

          Eileen McNaughton added a comment -

          Sorry - try this - difference is not using $tokens here

          @@ -399,6 +408,10 @@
          $mailing->body_text = $text;
          $mailing->body_html = $html;
          $tokens = $mailing->getTokens();
          + // get list of categories for hook calls
          + $hooktokens = array();
          + CRM_Utils_Hook::tokens( $hooktokens );
          + $categories = array_keys( $hooktokens );

          Rest is whitespace clean up which my editor keeps removing. I did keep re-adding it to clean up the patch but really - it wouldn't hurt to lose the spaces at the end of the lines would it? Save me 10 minutes each time I cut the patch...

          Sushant Paste added a comment -

          Tested r30989.

          leigh morresi added a comment -

          Failed to apply the patch here on 3.2.5

          $ cat new.patch |patch -p1
          (Stripping trailing CRs from patch.)
          patching file Core/BAO/MessageTemplates.php
          Hunk #1 FAILED at 74.
          Hunk #2 FAILED at 190.
          Hunk #3 FAILED at 202.
          Hunk #4 FAILED at 213.
          Hunk #5 FAILED at 257.
          Hunk #6 FAILED at 399.
          Hunk #7 FAILED at 428.
          7 out of 7 hunks FAILED – saving rejects to file Core/BAO/MessageTemplates.php.rej

          leigh morresi added a comment -

          My mistake! patch -p0 not -p1 sorry its late also testing.

          leigh morresi added a comment -

          Have tried both patches but does not seem to be functioning correctly

          My custom module is such..

          =============== snip ==============

          function civi_custom_membership_civicrm_tokens( &$tokens ) {
          touch('/tmp/hook.tokens');
          $tokens['test'] = array( 'test.hello' );
          }

          function civi_custom_membership_civicrm_tokenValues( &$values, &$contactIDs, $jobID ) {
          touch('/tmp/hook.tokenValues');
          if ( is_array( $contactIDs ) ) {
          $contactIDString = implode( ',', array_values( $contactIDs ) );
          $single = false;
          foreach ($contactIDs as $contact)

          { $values[$contact]['test.hello']= "Hello world!"; }


          } else

          { $single = true; $values['test.hello'] = "Hello world!"; }

          }
          =============== snip ==============

          When this runs, i get the two files in /tmp that shows the hook is being called correctly, however {$test.hello} in my template is never populated

            People

            • Assignee:
              Sushant Paste
              Reporter:
              Eileen McNaughton

              Dates

              • Created:
                Updated:
                Resolved: