CRM-14559 make remaining instances of adding the hex(01) to forms explicit & add...
authorEileen McNaughton <eileen@fuzion.co.nz>
Mon, 5 May 2014 16:05:12 +0000 (09:05 -0700)
committerEileen McNaughton <eileen@fuzion.co.nz>
Mon, 5 May 2014 16:05:12 +0000 (09:05 -0700)
CRM/Campaign/BAO/Query.php
CRM/Contact/BAO/ContactType.php
CRM/Contact/Form/Search/Basic.php
CRM/Contact/Form/Search/Criteria.php
CRM/Contact/Form/Search/Custom/Basic.php
CRM/Contact/Form/Search/Custom/MultipleValues.php
CRM/Core/Page/Basic.php

index 09c021da6c2dd2f5a28adbf4795edb94319c53d2..40b572c41bb64117e75df3cb6e5d6fd9b304b72d 100755 (executable)
@@ -326,7 +326,10 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
     $form->add('text', 'city', ts('City'), $attributes['city']);
     $form->add('text', 'postal_code', ts('Zip / Postal Code'), $attributes['postal_code']);
 
-    $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
+    //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
+    // this is loaded onto then replace with something like '__' & test
+    $separator = CRM_Core_DAO::VALUE_SEPARATOR;
+    $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE,
       array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2')
     );
index 1cc4976bc1637d576a76d6704392eab3c4d27e6f..26b2a711d38b4056dc34a29183a19004eda41549 100644 (file)
@@ -339,9 +339,21 @@ WHERE  type.name IS NOT NULL
     return !$delimiter ? $pairs : implode($delimiter, $pairs);
   }
 
-  static function &getSelectElements($all = FALSE,
-    $isSeperator = TRUE,
-    $seperator = CRM_Core_DAO::VALUE_SEPARATOR
+  /**
+   * Get a list of elements for select box
+   * Note that this used to default to using the hex(01) character - which results in an invalid character being used in form fields
+   * which was not handled well be anything that loaded & resaved the html (outside core)
+   * The use of this separator is now explicit in the calling functions as a step towards it's removal
+   *
+   * @param bool $all
+   * @param bool $isSeparator
+   * @param string $separator
+   *
+   * @return mixed
+   */
+  static function getSelectElements($all = FALSE,
+    $isSeparator = TRUE,
+    $separator = '__'
   ) {
     static $_cache = NULL;
 
@@ -350,7 +362,7 @@ WHERE  type.name IS NOT NULL
     }
 
     $argString = $all ? 'CRM_CT_GSE_1' : 'CRM_CT_GSE_0';
-    $argString .= $isSeperator ? '_1' : '_0';
+    $argString .= $isSeparator ? '_1' : '_0';
     if (!array_key_exists($argString, $_cache)) {
       $cache = CRM_Utils_Cache::singleton();
       $_cache[$argString] = $cache->get($argString);
@@ -378,7 +390,7 @@ AND   ( p.is_active = 1 OR p.id IS NULL )
         $dao = CRM_Core_DAO::executeQuery($sql);
         while ($dao->fetch()) {
           if (!empty($dao->parent_id)) {
-            $key   = $isSeperator ? $dao->parent_name . $seperator . $dao->child_name : $dao->child_name;
+            $key   = $isSeparator ? $dao->parent_name . $separator . $dao->child_name : $dao->child_name;
             $label = "-&nbsp;{$dao->child_label}";
             $pName = $dao->parent_name;
           }
@@ -505,7 +517,10 @@ WHERE  subtype.name IN ('" . implode("','", $subType) . "' )";
    */
   static function getCreateNewList() {
     $shortCuts = array();
-    $contactTypes = self::getSelectElements();
+    //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
+    // this is loaded onto then replace with something like '__' & test
+    $separator = CRM_Core_DAO::VALUE_SEPARATOR;
+    $contactTypes = self::getSelectElements(FALSE, TRUE, $separator);
     foreach ($contactTypes as $key => $value) {
       if ($key) {
         $typeValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $key);
index b8197dd9eec1d478835f953162b770a94ee0d1bb..f14088f7718b9b6a684d4103bcea5830cc4640e6 100644 (file)
@@ -69,8 +69,12 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search {
       'advanced_search_options'
     );
 
+    $shortCuts = array();
+    //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
+    // this is loaded onto then replace with something like '__' & test
+    $separator = CRM_Core_DAO::VALUE_SEPARATOR;
     if (!empty($searchOptions['contactType'])) {
-      $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
+      $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
       $this->add('select', 'contact_type',
         ts('is...'),
         $contactTypes,
index 1681d4c11c0c2e0a8bd72f257226701fc890834c..fa4b01ba40878efbf246c4aa16d02fd11760aa6f 100644 (file)
@@ -41,7 +41,10 @@ class CRM_Contact_Form_Search_Criteria {
 
     if ($form->_searchOptions['contactType']) {
       // add checkboxes for contact type
-      $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
+      //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
+      // this is loaded onto then replace with something like '__' & test
+      $separator = CRM_Core_DAO::VALUE_SEPARATOR;
+      $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
 
       if ($contactTypes) {
         $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE,
index 4605a3b53a64865f366e2dd9cabed242d2da9ff8..9be5725abc877c5a4fa3f184f10487b97ae2ecc0 100644 (file)
@@ -105,7 +105,10 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo
   }
 
   function buildForm(&$form) {
-    $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
+    //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
+    // this is loaded onto then replace with something like '__' & test
+    $separator = CRM_Core_DAO::VALUE_SEPARATOR;
+    $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     $form->add('select', 'contact_type', ts('Find...'), $contactTypes);
 
     // add select for groups
index bc360a3be23deb4dc63c7206b654b366252b0c69..d8908a9bfee30f869ebf6029e42ed26f38dcc131 100644 (file)
@@ -98,7 +98,10 @@ class CRM_Contact_Form_Search_Custom_MultipleValues extends CRM_Contact_Form_Sea
     $form->add('text', 'sort_name', ts('Contact Name'), TRUE);
 
     // add select for contact type
-    $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
+    //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
+    // this is loaded onto then replace with something like '__' & test
+    $separator = CRM_Core_DAO::VALUE_SEPARATOR;
+    $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     $form->add('select', 'contact_type', ts('Find...'), $contactTypes);
 
     // add select for groups
index c15145f3afbb0e75ac5ad80863f77d0628ce4464..710a405cfebd570fc157fd779e3469b4034cba25 100644 (file)
@@ -241,8 +241,10 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
       $object->orderBy($key . ' asc');
     }
 
-
-    $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
+    //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
+    // this is loaded onto then replace with something like '__' & test
+    $separator = CRM_Core_DAO::VALUE_SEPARATOR;
+    $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     // find all objects
     $object->find();
     while ($object->fetch()) {