added event tokens, CRM-12965
authorKurund Jalmi <kurund@civicrm.org>
Thu, 4 Jul 2013 09:28:23 +0000 (14:58 +0530)
committerKurund Jalmi <kurund@civicrm.org>
Thu, 4 Jul 2013 09:28:23 +0000 (14:58 +0530)
CRM/Badge/Form/Layout.php

index 351811f92ae083f0c0593fb0e1102c3bb4abcead..b851e6b35801f02ec2d7e31fb8bec16a1ed0cf0d 100644 (file)
@@ -64,14 +64,16 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
       CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'description'));
 
     // get the tokens
-    $tokens = CRM_Core_SelectValues::contactTokens();
+    $contactTokens = CRM_Core_SelectValues::contactTokens();
+    $eventTokens   = CRM_Core_SelectValues::eventTokens();
+    $tokens = array_merge($contactTokens, $eventTokens);
     asort($tokens);
 
     $fontSizes = CRM_Core_BAO_LabelFormat::getFontSizes();
     $fontNames = CRM_Core_BAO_LabelFormat::getFontNames('name_badge');
     $textAlignment = CRM_Core_BAO_LabelFormat::getTextAlignments();
 
-    $rowCount = 3;
+    $rowCount = 4;
     for ( $i =1; $i <= $rowCount; $i++ ) {
       $this->add('select', "token[$i]", ts('Token'), array('' => ts('- none -')) + $tokens);
       $this->add('select', "font_name[$i]", ts('Font Name'), $fontNames);
@@ -88,10 +90,6 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     $this->add('checkbox', 'is_default', ts('Default?'));
     $this->add('checkbox', 'is_active', ts('Enabled?'));
     $this->add('checkbox', 'is_reserved', ts('Reserved?'));
-
-    if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PrintLabel', $this->_id, 'is_reserved')) {
-      $this->freeze(array('title', 'description', 'is_active'));
-    }
   }
 
   /**
@@ -118,9 +116,8 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
       $defaults[$field] = get_object_vars($data[$field]);
     }
 
-    $defaults['add_barcode'] = $data['add_barcode'];
-    $defaults['barcode_alignment'] = $data['barcode_alignment'];
-    $defaults['label_format_id'] = $data['label_format_id'];
+    $defaults['add_barcode'] = CRM_Utils_Array::value('add_barcode', $data);
+    $defaults['barcode_alignment'] = CRM_Utils_Array::value('barcode_alignment', $data);
 
     if ($this->_action == CRM_Core_Action::DELETE && isset($defaults['title'])) {
       $this->assign('delName', $defaults['title']);