From: Kurund Jalmi Date: Tue, 9 Jul 2013 18:54:36 +0000 (+0530) Subject: added support for participant and custom data of type participant tokens CRM-12965 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ea92162285c3d8fce50e56a959c9f86f93edea47;p=civicrm-core.git added support for participant and custom data of type participant tokens CRM-12965 --- diff --git a/CRM/Badge/Form/Layout.php b/CRM/Badge/Form/Layout.php index 861e194057..240fde3703 100644 --- a/CRM/Badge/Form/Layout.php +++ b/CRM/Badge/Form/Layout.php @@ -74,7 +74,9 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form { // get the tokens $contactTokens = CRM_Core_SelectValues::contactTokens(); $eventTokens = CRM_Core_SelectValues::eventTokens(); - $tokens = array_merge($contactTokens, $eventTokens); + $participantTokens = CRM_Core_SelectValues::participantTokens(); + + $tokens = array_merge($contactTokens, $eventTokens, $participantTokens); asort($tokens); $fontSizes = CRM_Core_BAO_LabelFormat::getFontSizes(); @@ -116,12 +118,7 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form { * @return None */ function setDefaultValues() { - if (isset($this->_id) && empty($this->_values)) { - $this->_values = array(); - $params = array('id' => $this->_id); - CRM_Badge_BAO_Layout::retrieve($params, $this->_values); - - + if (isset($this->_id)) { $defaults = array_merge($this->_values, CRM_Badge_BAO_Layout::getDecodedData($this->_values['data'])); } diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index f3672d8234..88739eccfb 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -657,7 +657,7 @@ class CRM_Core_SelectValues { 'is_bulkmail', 'group', 'tag', 'contact_sub_type', 'note', 'is_deceased', 'deceased_date', 'legal_identifier', 'contact_sub_type', 'user_unique_id', ); - $customFields = array(); + $customFields = CRM_Core_BAO_CustomField::getFields('Individual'); $customFieldsAddress = CRM_Core_BAO_CustomField::getFields('Address'); $customFields = $customFields + $customFieldsAddress; @@ -697,6 +697,44 @@ class CRM_Core_SelectValues { return $tokens; } + /** + * different type of Participant Tokens + * + * @static + * return array + */ + static function &participantTokens() { + static $tokens = NULL; + if (!$tokens) { + $exportFields = CRM_Event_BAO_Participant::exportableFields(); + + $values = array_merge(array_keys($exportFields)); + unset($values[0]); + + // skipping some tokens for time being. + $skipTokens = array( + 'event_id', 'participant_is_pay_later', 'participant_is_test', 'participant_contact_id', + 'participant_fee_currency', 'participant_campaign_id', 'participant_status', 'participant_discount_name', + ); + + $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); + + foreach ($values as $key => $val) { + if (in_array($val, $skipTokens)) { + continue; + } + //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734 + if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) { + $tokens["{participant.$val}"] = CRM_Utils_Array::value($customFieldId, $customFields) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : ''; + } + else { + $tokens["{participant.$val}"] = $exportFields[$val]['title']; + } + } + } + return $tokens; + } + /** * get qf mappig for all date parts. * diff --git a/CRM/Event/Form/Task/Badge.php b/CRM/Event/Form/Task/Badge.php index c4a5d1839a..c7e9a559ae 100644 --- a/CRM/Event/Form/Task/Badge.php +++ b/CRM/Event/Form/Task/Badge.php @@ -124,13 +124,16 @@ class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task { if (key($token) == 'contact') { $element = $token['contact'][0]; } - else { + elseif (key($token) == 'event') { $element = $token['event'][0]; //FIX ME - we need to standardize event token names if (!strpos($element, 'event_')) { $element = 'event_' . $element; } } + elseif (key($token) == 'participant') { + $element = $token['participant'][0]; + } // build returnproperties for query $returnProperties[$element] = 1;