Changed badge hook to be called with metadata in labelCreator
authorMaggie <maggie.epps@gmail.com>
Fri, 2 May 2014 03:04:00 +0000 (23:04 -0400)
committerMaggie <maggie.epps@gmail.com>
Fri, 2 May 2014 03:04:00 +0000 (23:04 -0400)
CRM/Badge/BAO/Badge.php
CRM/Utils/Hook.php

index db0352adb561a7d7eef912970d7d39284ea0797c..4c38a0d4896bf9330ff6116cd42d68157b1f882c 100644 (file)
@@ -64,12 +64,9 @@ class CRM_Badge_BAO_Badge {
       $this->border = "LTRB";
     }
 
-    $order = 1;
     foreach ($participants as $participant) {
-      CRM_Utils_Hook::alterBadge($order, $this, $layoutInfo, $participant);
       $formattedRow = self::formatLabel($participant, $layoutInfo);
       $this->pdf->AddPdfLabel($formattedRow);
-      $order + 1;
     }
 
     $this->pdf->Output(CRM_Utils_String::munge($layoutInfo['title'], '_', 64) . '.pdf', 'D');
@@ -156,6 +153,9 @@ class CRM_Badge_BAO_Badge {
   }
 
   public function labelCreator(&$formattedRow, $cellspacing = 0) {
+    //call hook alterBadge
+    CRM_Utils_Hook::alterBadge($formattedRow['labelFormat'], $this, $formattedRow,$formattedRow['values']);
+
     $this->lMarginLogo = 18;
     $this->tMarginName = 20;
 
index bb810a3f99798f9bc74facc8345a2e96c13bb59d..8727dd9c8835045e08d078c87c3d980306cf23e5 100644 (file)
@@ -1463,14 +1463,15 @@ abstract class CRM_Utils_Hook {
   /**
    * This hook is invoked when building a CiviCRM name badge.
    *
+   * @param string $labelName string referencing name of badge format
    * @param object $label    reference to the label object
    * @param array  $format   array of format data
    * @param array  $participant array of participant values
    *
    * @return null the return value is ignored
    */
-  static function alterBadge($participant_number, &$label, &$format, &$participant) {
-    return self::singleton()->invoke(4, $participant_number, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge');
+  static function alterBadge($labelName, &$label, &$format, &$participant) {
+    return self::singleton()->invoke(4, $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge');
   }