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

Make token usage the responsibality of the form

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6.3
    • Fix Version/s: 4.7
    • Component/s: None
    • Labels:
      None

      Description

      The tokens added to the form are dependant of the type of forms. So have membership-related forms the membership-tokens, while event-related forms add the eventTokens, this on top of the contactTokens which are added by some forms.
      This makes finding out which tokens are added to which fields is difficult.

      Currently for example two ways are used in the CRM_Mailing_BAO_Mailing::commonLetterCompose() function.

      if (CRM_Utils_System::getClassName($form) == 'CRM_Mailing_Form_Upload') {
            $tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens);
          }
          //@todo move this fn onto the form
          if (CRM_Utils_System::getClassName($form) == 'CRM_Contribute_Form_Task_PDFLetter') {
            $tokens = array_merge(CRM_Core_SelectValues::contributionTokens(), $tokens);
          }
      
          if (method_exists($form, 'listTokens')) {
            $tokens = array_merge($form->listTokens(), $tokens);
          } 
      

      Actually that last method is the cleanest, and allows us to remove the if clauses. So lets refactor this to do this (at least) for this method in one call.

      I'll create a PR, but i'll add this on top of https://issues.civicrm.org/jira/browse/CRM-16706 Since those will conflict.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mallezie Tim Mallezie
                Reporter:
                mallezie Tim Mallezie
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: