X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FMapping.php;h=7ec58dbafec9c05b28c1a598988d2db5183e4dba;hb=36f057c25d06a6372e9762c0931ff97a89144a4f;hp=a9b5c9a9914bde72fa7ef237a880ef7152131559;hpb=b319421df58cfbeb99ca3016a8315b56690458ba;p=civicrm-core.git diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index a9b5c9a991..7ec58dbafe 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -100,13 +100,13 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * contact object. the params array could contain additional unused name/value * pairs * - * @param array $params (reference) an assoc array of name/value pairs + * @param array $params an array of name/value pairs * * @return object CRM_Core_DAO_Mapper object on success, otherwise null * @access public * @static */ - static function add(&$params) { + static function add($params) { $mapping = new CRM_Core_DAO_Mapping(); $mapping->copyValues($params); $mapping->save(); @@ -119,6 +119,8 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * * @params string $mappingTypeId mapping type id * + * @param $mappingTypeId + * * @return array $mapping array of mapping name * @access public * @static @@ -141,10 +143,11 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * * @params int $mappingId mapping id * + * @param $mappingId + * * @return array $mappingFields array of mapping fields * @access public * @static - * */ static function getMappingFields($mappingId) { //mapping is to be loaded from database @@ -202,8 +205,10 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * * @params $mapTypeId string mapping Type * - * @return boolean + * @param $nameField + * @param $mapTypeId * + * @return boolean */ static function checkMapping($nameField, $mapTypeId) { $mapping = new CRM_Core_DAO_Mapping(); @@ -222,9 +227,9 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * * @params int $smartGroupId smart group id * - * @return $returnFields associated array of elements + * @param $smartGroupId * - * @static + * @return array $returnFields associated array of elements@static * @public */ static function getFormattedFields($smartGroupId) { @@ -258,6 +263,13 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * @params mixed $columnCount column count is int for and array for search builder * @params int $blockCount block count (no of blocks shown) * + * @param $form + * @param string $mappingType + * @param null $mappingId + * @param $columnNo + * @param int $blockCount + * @param null $exportMode + * * @return void * @access public * @static @@ -829,7 +841,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } //Fix for Search Builder if ($mappingType == 'Export') { - if (!isset($mappingId)) { + if (!isset($mappingId) || $i >= count(reset($mappingName))) { if (isset($formValues['mapper']) && isset($formValues['mapper'][$x][$i][1]) && array_key_exists($formValues['mapper'][$x][$i][1], $relationshipTypes) @@ -927,6 +939,11 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * @relationshipTypeId related relationship type id * @return $groupTitle all custom field titles */ + /** + * @param $relationshipTypeId + * + * @return array + */ function getRelationTypeCustomGroupData($relationshipTypeId) { $customFields = CRM_Core_BAO_CustomField::getFields('Relationship', NULL, NULL, $relationshipTypeId, NULL, NULL); @@ -941,9 +958,10 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { /** * Function returns all Custom group Names * - * @param customfieldId related custom field id - * @return $customGroupName all custom group names - * @static + * @param related $customfieldId + * + * @internal param \related $customfieldId custom field id + * @return null|string $customGroupName all custom group names@static */ static function getCustomGroupName($customfieldId) { if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($customfieldId)) { @@ -964,12 +982,13 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * @params array $params associated array of submitted values * @params boolean $row row no of the fields * - * @return $returnFields formatted associated array of elements + * @param $params + * @param bool $row * - * @static + * @return array $returnFields formatted associated array of elements@static * @public */ - static function &formattedFields(&$params, $row = FALSE) { + static function formattedFields(&$params, $row = FALSE) { $fields = array(); if (empty($params) || !isset($params['mapper'])) { @@ -1020,6 +1039,37 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } } + // CRM-14563: we store checkbox, multi-select and adv-multi select custom field using separator, hence it + // needs special handling. + if ($cfID = CRM_Core_BAO_CustomField::getKeyID($v[1])) { + $isCustomField = TRUE; + $customFieldType = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'html_type'); + $specialHTMLType = array( + 'CheckBox', + 'Multi-Select', + 'AdvMulti-Select', + 'Multi-Select State/Province', + 'Multi-Select Country' + ); + + // override the operator to handle separator ( note: this might have some performance issues ) + if (in_array($customFieldType, $specialHTMLType)) { + // FIX ME: != and few other operators are not handled + $specialOperators = array('=', 'IN', 'LIKE'); + + if (in_array($params['operator'][$key][$k], $specialOperators)) { + $params['operator'][$key][$k] = 'RLIKE'; + } + } + } + + // CRM-14983: verify if values are comma separated convert to array + if (!is_array($value) && (strpos($value,',') !== false || strstr($value, '(')) && empty($isCustomField) && $params['operator'][$key][$k] == 'IN') { + preg_match('#\((.*?)\)#', $value, $match); + $tmpArray = explode(',', $match[1]); + $value = array_combine(array_values($tmpArray),array_values($tmpArray)); + } + if ($row) { $fields[] = array( $fldName, @@ -1066,6 +1116,11 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { return $fields; } + /** + * @param $params + * + * @return array + */ static function &returnProperties(&$params) { $fields = array( 'contact_type' => 1,