Skip to content
Snippets Groups Projects
Commit 031fa0b4 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #1153 from kurund/CRM-12967

added hook_civicrm_alterBarcode which allows users to change the data en...
parents fc11e61e 9399901d
No related branches found
No related tags found
No related merge requests found
...@@ -196,9 +196,14 @@ class CRM_Badge_BAO_Badge { ...@@ -196,9 +196,14 @@ class CRM_Badge_BAO_Badge {
'stretchtext' => 0, 'stretchtext' => 0,
); );
$data = array(); $data = $formattedRow['values'];
$data['current_value'] = $formattedRow['values']['contact_id'] . '-' . $formattedRow['values']['participant_id']; $data['current_value'] = $formattedRow['values']['contact_id'] . '-' . $formattedRow['values']['participant_id'];
$this->pdf->write1DBarcode($data['current_value'], 'C128', $x, $y + $this->pdf->height - 10, '', 12, 0.4, $style, 'B');
// call hook alterBarcode
CRM_Utils_Hook::alterBarcode($data);
$this->pdf->write1DBarcode($data['current_value'], 'C128', $x, $y + $this->pdf->height - 10, '',
12, 0.4, $style, 'B');
} }
} }
......
...@@ -181,7 +181,8 @@ abstract class CRM_Utils_Hook { ...@@ -181,7 +181,8 @@ abstract class CRM_Utils_Hook {
foreach ($civiModules as $civiModule) { foreach ($civiModules as $civiModule) {
if (!file_exists($civiModule['filePath'])) { if (!file_exists($civiModule['filePath'])) {
CRM_Core_Session::setStatus( CRM_Core_Session::setStatus(
ts( 'Error loading module file (%1). Please restore the file or disable the module.', array(1 => $civiModule['filePath']) ), ts( 'Error loading module file (%1). Please restore the file or disable the module.',
array(1 => $civiModule['filePath']) ),
ts( 'Warning'), 'error'); ts( 'Warning'), 'error');
continue; continue;
} }
...@@ -230,7 +231,8 @@ abstract class CRM_Utils_Hook { ...@@ -230,7 +231,8 @@ abstract class CRM_Utils_Hook {
* @access public * @access public
*/ */
static function grantAssessment( &$params ) { static function grantAssessment( &$params ) {
return self::singleton( )->invoke( 1, $params, self::$_nullObject , self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_grantAssessment' ); return self::singleton( )->invoke( 1, $params, self::$_nullObject , self::$_nullObject,
self::$_nullObject, self::$_nullObject, 'civicrm_grantAssessment' );
} }
/** /**
...@@ -394,7 +396,8 @@ abstract class CRM_Utils_Hook { ...@@ -394,7 +396,8 @@ abstract class CRM_Utils_Hook {
* This hook is called when rendering the dashboard (q=civicrm/dashboard) * This hook is called when rendering the dashboard (q=civicrm/dashboard)
* *
* @param int $contactID - the contactID for whom the dashboard is being rendered * @param int $contactID - the contactID for whom the dashboard is being rendered
* @param int $contentPlacement - (output parameter) where should the hook content be displayed relative to the activity list * @param int $contentPlacement - (output parameter) where should the hook content be displayed
* relative to the activity list
* *
* @return string the html snippet to include in the dashboard * @return string the html snippet to include in the dashboard
* @access public * @access public
...@@ -443,7 +446,8 @@ abstract class CRM_Utils_Hook { ...@@ -443,7 +446,8 @@ abstract class CRM_Utils_Hook {
* @access public * @access public
*/ */
static function buildAmount($pageType, &$form, &$amount) { static function buildAmount($pageType, &$form, &$amount) {
return self::singleton()->invoke(3, $pageType, $form, $amount, self::$_nullObject, self::$_nullObject, 'civicrm_buildAmount'); return self::singleton()->invoke(3, $pageType, $form, $amount, self::$_nullObject,
self::$_nullObject, 'civicrm_buildAmount');
} }
/** /**
...@@ -574,14 +578,17 @@ abstract class CRM_Utils_Hook { ...@@ -574,14 +578,17 @@ abstract class CRM_Utils_Hook {
} }
/** /**
* This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox, adv multiselect) * This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox,
* adv multiselect)
* *
* @param int $customFieldID - the custom field ID * @param int $customFieldID - the custom field ID
* @param array $options - the current set of options for that custom field. * @param array $options - the current set of options for that custom field.
* You can add/remove existing options. * You can add/remove existing options.
* Important: This array may contain meta-data about the field that is needed elsewhere, so it is important to be careful to not overwrite the array. * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
* to be careful to not overwrite the array.
* Only add/edit/remove the specific field options you intend to affect. * Only add/edit/remove the specific field options you intend to affect.
* @param boolean $detailedFormat - if true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format * @param boolean $detailedFormat - if true,
* the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
*/ */
static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE) { static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE) {
return self::singleton()->invoke(3, $customFieldID, $options, $detailedFormat, return self::singleton()->invoke(3, $customFieldID, $options, $detailedFormat,
...@@ -599,9 +606,11 @@ abstract class CRM_Utils_Hook { ...@@ -599,9 +606,11 @@ abstract class CRM_Utils_Hook {
* - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported. * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
* @param array $tasks - the current set of tasks for that custom field. * @param array $tasks - the current set of tasks for that custom field.
* You can add/remove existing tasks. * You can add/remove existing tasks.
* Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup'). * Each task needs to have a title (eg 'title' => ts( 'Add Contacts to Group')) and a class
* (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
* Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ). * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
* The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be found in CRM/$objectType/Task.php. * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
* found in CRM/$objectType/Task.php.
*/ */
static function searchTasks($objectType, &$tasks) { static function searchTasks($objectType, &$tasks) {
return self::singleton()->invoke(2, $objectType, $tasks, return self::singleton()->invoke(2, $objectType, $tasks,
...@@ -632,7 +641,8 @@ abstract class CRM_Utils_Hook { ...@@ -632,7 +641,8 @@ abstract class CRM_Utils_Hook {
} }
/** /**
* This hook is called when composing the array of membershipTypes and their cost during a membership registration (new or renewal). * This hook is called when composing the array of membershipTypes and their cost during a membership registration
* (new or renewal).
* Note the hook is called on initial page load and also reloaded after submit (PRG pattern). * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
* You can use it to alter the membership types when first loaded, or after submission * You can use it to alter the membership types when first loaded, or after submission
* (for example if you want to gather data in the form and use it to alter the fees). * (for example if you want to gather data in the form and use it to alter the fees).
...@@ -651,7 +661,8 @@ abstract class CRM_Utils_Hook { ...@@ -651,7 +661,8 @@ abstract class CRM_Utils_Hook {
* This hook is called when rendering the contact summary * This hook is called when rendering the contact summary
* *
* @param int $contactID - the contactID for whom the summary is being rendered * @param int $contactID - the contactID for whom the summary is being rendered
* @param int $contentPlacement - (output parameter) where should the hook content be displayed relative to the existing content * @param int $contentPlacement - (output parameter) where should the hook content be displayed relative to
* the existing content
* *
* @return string the html snippet to include in the contact summary * @return string the html snippet to include in the contact summary
* @access public * @access public
...@@ -718,7 +729,8 @@ abstract class CRM_Utils_Hook { ...@@ -718,7 +729,8 @@ abstract class CRM_Utils_Hook {
/** /**
* This hook is called when an email is about to be sent by CiviCRM. * This hook is called when an email is about to be sent by CiviCRM.
* *
* @param array $params - array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers, attachments (array) * @param array $params - array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
* returnPath, replyTo, headers, attachments (array)
* @param string $context - the context in which the hook is being invoked, eg 'civimail' * @param string $context - the context in which the hook is being invoked, eg 'civimail'
*/ */
static function alterMailParams(&$params, $context = NULL) { static function alterMailParams(&$params, $context = NULL) {
...@@ -733,7 +745,8 @@ abstract class CRM_Utils_Hook { ...@@ -733,7 +745,8 @@ abstract class CRM_Utils_Hook {
* *
* @param int $caseID - the case ID * @param int $caseID - the case ID
* *
* @return array of data to be displayed, where the key is a unique id to be used for styling (div id's) and the value is an array with keys 'label' and 'value' specifying label/value pairs * @return array of data to be displayed, where the key is a unique id to be used for styling (div id's)
* and the value is an array with keys 'label' and 'value' specifying label/value pairs
* @access public * @access public
*/ */
static function caseSummary($caseID) { static function caseSummary($caseID) {
...@@ -873,7 +886,8 @@ abstract class CRM_Utils_Hook { ...@@ -873,7 +886,8 @@ abstract class CRM_Utils_Hook {
* This hook is called after a row has been processed and the * This hook is called after a row has been processed and the
* record (and associated records imported * record (and associated records imported
* *
* @param string $object - object being imported (for now Contact only, later Contribution, Activity, Participant and Member) * @param string $object - object being imported (for now Contact only, later Contribution, Activity,
* Participant and Member)
* @param string $usage - hook usage/location (for now process only, later mapping and others) * @param string $usage - hook usage/location (for now process only, later mapping and others)
* @param string $objectRef - import record object * @param string $objectRef - import record object
* @param array $params - array with various key values: currently * @param array $params - array with various key values: currently
...@@ -980,9 +994,9 @@ abstract class CRM_Utils_Hook { ...@@ -980,9 +994,9 @@ abstract class CRM_Utils_Hook {
* @param array $result (reference) has two fields * @param array $result (reference) has two fields
* contactID - the new (or same) contactID * contactID - the new (or same) contactID
* action - 3 possible values: * action - 3 possible values:
* CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
* CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
* CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
* *
* @return null * @return null
* @access public * @access public
...@@ -1074,7 +1088,8 @@ abstract class CRM_Utils_Hook { ...@@ -1074,7 +1088,8 @@ abstract class CRM_Utils_Hook {
/** /**
* This hook is called when a module-extension is installed. * This hook is called when a module-extension is installed.
* Each module will receive hook_civicrm_install during its own installation (but not during the installation of unrelated modules). * Each module will receive hook_civicrm_install during its own installation (but not during the
* installation of unrelated modules).
*/ */
static function install() { static function install() {
return self::singleton()->invoke(0, self::$_nullObject, return self::singleton()->invoke(0, self::$_nullObject,
...@@ -1086,7 +1101,8 @@ abstract class CRM_Utils_Hook { ...@@ -1086,7 +1101,8 @@ abstract class CRM_Utils_Hook {
/** /**
* This hook is called when a module-extension is uninstalled. * This hook is called when a module-extension is uninstalled.
* Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the uninstallation of unrelated modules). * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
* uninstallation of unrelated modules).
*/ */
static function uninstall() { static function uninstall() {
return self::singleton()->invoke(0, self::$_nullObject, return self::singleton()->invoke(0, self::$_nullObject,
...@@ -1098,7 +1114,8 @@ abstract class CRM_Utils_Hook { ...@@ -1098,7 +1114,8 @@ abstract class CRM_Utils_Hook {
/** /**
* This hook is called when a module-extension is re-enabled. * This hook is called when a module-extension is re-enabled.
* Each module will receive hook_civicrm_enable during its own re-enablement (but not during the re-enablement of unrelated modules). * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
* re-enablement of unrelated modules).
*/ */
static function enable() { static function enable() {
return self::singleton()->invoke(0, self::$_nullObject, return self::singleton()->invoke(0, self::$_nullObject,
...@@ -1110,7 +1127,8 @@ abstract class CRM_Utils_Hook { ...@@ -1110,7 +1127,8 @@ abstract class CRM_Utils_Hook {
/** /**
* This hook is called when a module-extension is disabled. * This hook is called when a module-extension is disabled.
* Each module will receive hook_civicrm_disable during its own disablement (but not during the disablement of unrelated modules). * Each module will receive hook_civicrm_disable during its own disablement (but not during the
* disablement of unrelated modules).
*/ */
static function disable() { static function disable() {
return self::singleton()->invoke(0, self::$_nullObject, return self::singleton()->invoke(0, self::$_nullObject,
...@@ -1149,7 +1167,8 @@ abstract class CRM_Utils_Hook { ...@@ -1149,7 +1167,8 @@ abstract class CRM_Utils_Hook {
/** /**
* This hook is called when an email has been successfully sent by CiviCRM, but not on an error. * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
* *
* @param array $params - the mailing parameters array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers, attachments (array) * @param array $params - the mailing parameters array fields include: groupName, from, toName, toEmail,
* subject, cc, bcc, text, html, returnPath, replyTo, headers, attachments (array)
*/ */
static function postEmailSend(&$params) { static function postEmailSend(&$params) {
return self::singleton()->invoke(1, $params, return self::singleton()->invoke(1, $params,
...@@ -1232,7 +1251,8 @@ abstract class CRM_Utils_Hook { ...@@ -1232,7 +1251,8 @@ abstract class CRM_Utils_Hook {
* @access public * @access public
*/ */
static function entityTypes(&$entityTypes) { static function entityTypes(&$entityTypes) {
return self::singleton()->invoke(1, $entityTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes' return self::singleton()->invoke(1, $entityTypes, self::$_nullObject, self::$_nullObject,
self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes'
); );
} }
...@@ -1243,7 +1263,8 @@ abstract class CRM_Utils_Hook { ...@@ -1243,7 +1263,8 @@ abstract class CRM_Utils_Hook {
* @return void * @return void
*/ */
static function buildProfile($name) { static function buildProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_buildProfile'); return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
self::$_nullObject, 'civicrm_buildProfile');
} }
/** /**
...@@ -1253,7 +1274,8 @@ abstract class CRM_Utils_Hook { ...@@ -1253,7 +1274,8 @@ abstract class CRM_Utils_Hook {
* @return void * @return void
*/ */
static function validateProfile($name) { static function validateProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_validateProfile'); return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
self::$_nullObject, 'civicrm_validateProfile');
} }
/** /**
...@@ -1263,7 +1285,8 @@ abstract class CRM_Utils_Hook { ...@@ -1263,7 +1285,8 @@ abstract class CRM_Utils_Hook {
* @return void * @return void
*/ */
static function processProfile($name) { static function processProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_processProfile'); return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
self::$_nullObject, 'civicrm_processProfile');
} }
/** /**
...@@ -1273,7 +1296,8 @@ abstract class CRM_Utils_Hook { ...@@ -1273,7 +1296,8 @@ abstract class CRM_Utils_Hook {
* @return void * @return void
*/ */
static function viewProfile($name) { static function viewProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_viewProfile'); return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
self::$_nullObject, 'civicrm_viewProfile');
} }
/** /**
...@@ -1283,6 +1307,21 @@ abstract class CRM_Utils_Hook { ...@@ -1283,6 +1307,21 @@ abstract class CRM_Utils_Hook {
* @return void * @return void
*/ */
static function searchProfile($name) { static function searchProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile'); return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject,
self::$_nullObject, 'civicrm_searchProfile');
}
/**
* This hook is called before encoding data in barcode
*
* @param array $data associated array of values available for encoding
* @param string $type type of barcode, classic barcode or QRcode
* @param string $context where this hooks is invoked.
*
* @return void
*/
static function alterBarcode( &$data, $type = 'barcode', $context = 'name_badge' ) {
return self::singleton()->invoke(3, $data, $type, $context, self::$_nullObject,
self::$_nullObject, 'civicrm_alterBarcode');
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment