From d0fc33e2c79d47854c7f201c90d3fc6a4dbf5714 Mon Sep 17 00:00:00 2001 From: Maggie Date: Thu, 1 May 2014 13:37:24 -0400 Subject: [PATCH] Wrote hook to allow customization of badges--included participant numbering --- CRM/Badge/BAO/Badge.php | 3 +++ CRM/Utils/Hook.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CRM/Badge/BAO/Badge.php b/CRM/Badge/BAO/Badge.php index ad2fcacd99..db0352adb5 100644 --- a/CRM/Badge/BAO/Badge.php +++ b/CRM/Badge/BAO/Badge.php @@ -64,9 +64,12 @@ 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'); diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index be3d2d421d..bb810a3f99 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1460,6 +1460,20 @@ abstract class CRM_Utils_Hook { self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile'); } + /** + * This hook is invoked when building a CiviCRM name badge. + * + * @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'); + } + + /** * This hook is called before encoding data in barcode * -- 2.25.1