From b500fbeadefe6122267eed3d8cba2001b4b10c51 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 5 May 2014 09:05:12 -0700 Subject: [PATCH] CRM-14559 make remaining instances of adding the hex(01) to forms explicit & add todo to remove --- CRM/Campaign/BAO/Query.php | 5 +++- CRM/Contact/BAO/ContactType.php | 27 ++++++++++++++----- CRM/Contact/Form/Search/Basic.php | 6 ++++- CRM/Contact/Form/Search/Criteria.php | 5 +++- CRM/Contact/Form/Search/Custom/Basic.php | 5 +++- .../Form/Search/Custom/MultipleValues.php | 5 +++- CRM/Core/Page/Basic.php | 6 +++-- 7 files changed, 46 insertions(+), 13 deletions(-) diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php index 09c021da6c..40b572c41b 100755 --- a/CRM/Campaign/BAO/Query.php +++ b/CRM/Campaign/BAO/Query.php @@ -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') ); diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 1cc4976bc1..26b2a711d3 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -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 = "- {$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); diff --git a/CRM/Contact/Form/Search/Basic.php b/CRM/Contact/Form/Search/Basic.php index b8197dd9ee..f14088f771 100644 --- a/CRM/Contact/Form/Search/Basic.php +++ b/CRM/Contact/Form/Search/Basic.php @@ -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, diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 1681d4c11c..fa4b01ba40 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -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, diff --git a/CRM/Contact/Form/Search/Custom/Basic.php b/CRM/Contact/Form/Search/Custom/Basic.php index 4605a3b53a..9be5725abc 100644 --- a/CRM/Contact/Form/Search/Custom/Basic.php +++ b/CRM/Contact/Form/Search/Custom/Basic.php @@ -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 diff --git a/CRM/Contact/Form/Search/Custom/MultipleValues.php b/CRM/Contact/Form/Search/Custom/MultipleValues.php index bc360a3be2..d8908a9bfe 100644 --- a/CRM/Contact/Form/Search/Custom/MultipleValues.php +++ b/CRM/Contact/Form/Search/Custom/MultipleValues.php @@ -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 diff --git a/CRM/Core/Page/Basic.php b/CRM/Core/Page/Basic.php index c15145f3af..710a405cfe 100644 --- a/CRM/Core/Page/Basic.php +++ b/CRM/Core/Page/Basic.php @@ -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()) { -- 2.25.1