From afa0b07c805cd8e256b931ef1a0048de4c533125 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Mon, 15 Dec 2014 19:37:56 +0530 Subject: [PATCH] QA fixes Round 2 --- CRM/Activity/BAO/Query.php | 23 ++--- CRM/Contact/BAO/Query.php | 17 ++-- CRM/Contact/Form/Search/Advanced.php | 14 ++- CRM/Contribute/BAO/Query.php | 61 +++++-------- CRM/Contribute/Form/Search.php | 9 +- CRM/Core/BAO/Mapping.php | 2 +- CRM/Core/SelectValues.php | 2 + CRM/Event/BAO/Query.php | 2 +- api/v3/utils.php | 85 ++++++++++++++----- .../CRM/Contribute/Form/Search/Common.tpl | 2 +- xml/schema/Contribute/Contribution.xml | 2 +- xml/schema/Event/Event.xml | 1 - xml/schema/Event/Participant.xml | 2 +- 13 files changed, 135 insertions(+), 87 deletions(-) diff --git a/CRM/Activity/BAO/Query.php b/CRM/Activity/BAO/Query.php index 3007e30e8e..ae50def5cc 100644 --- a/CRM/Activity/BAO/Query.php +++ b/CRM/Activity/BAO/Query.php @@ -199,19 +199,11 @@ class CRM_Activity_BAO_Query { switch ($name) { case 'activity_type_id': - case 'activity_type': case 'activity_status_id': - case 'activity_status': case 'activity_engagement_level': case 'activity_subject': case 'activity_id': - if (!$value) { - break; - } $qillName = $name; - if (in_array($name, array('activity_type_id'))) { - $name = $qillName = $name . '_id'; - } if (in_array($name, array('activity_engagement_level', 'activity_id'))) { $name = $qillName = str_replace('activity_', '', $name); } @@ -221,16 +213,19 @@ class CRM_Activity_BAO_Query { } $dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String'; - if (in_array($name, array('activity_type', 'activity_status'))) { - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$name.label", $op, $value, $dataType); - } - else { - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.$name", $op, $value, $dataType); - } + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.$name", $op, $value, $dataType); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op); $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value)); break; + case 'activity_type': + case 'activity_status': + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$name.label", $op, $value, 'String'); + list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op); + $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); + $query->_tables[$name] = $query->_whereTables[$name] = 1; + break; + case 'activity_survey_id': if (!$value) { break; diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index d7a2f9b39d..5abf9ea27e 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -612,7 +612,9 @@ class CRM_Contact_BAO_Query { if ( (substr($name, 0, 12) == 'participant_') || (substr($name, 0, 7) == 'pledge_') || - (substr($name, 0, 5) == 'case_') + (substr($name, 0, 5) == 'case_') || + (substr($name, 0, 13) == 'contribution_') || + (substr($name, 0, 8) == 'payment_') ) { continue; } @@ -1542,7 +1544,10 @@ class CRM_Contact_BAO_Query { return $result; } - if ($apiEntity && substr($id, 0, strlen($apiEntity)) != $apiEntity) { + if ($apiEntity && + (substr($id, 0, strlen($apiEntity)) != $apiEntity) && + (substr($id, 0, 10) != 'financial_' && substr($id, 0, 8) != 'payment_') + ) { $id = $apiEntity . '_' . $id; } @@ -1619,6 +1624,7 @@ class CRM_Contact_BAO_Query { (substr($values[0], 0, 7) == 'pledge_') || (substr($values[0], 0, 5) == 'case_') || (substr($values[0], 0, 10) == 'financial_') || + (substr($values[0], 0, 8) == 'payment_') || (substr($values[0], 0, 11) == 'membership_') ) { return; @@ -5640,6 +5646,7 @@ AND displayRelType.is_active = 1 static function buildQillForFieldValue($daoName, $fieldName, $fieldValue, $op, $pseduoExtraParam = array()) { $pseduoOptions = CRM_Core_PseudoConstant::get($daoName, $fieldName, $pseduoExtraParam = array()); + $qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators(); if ($fieldName == 'activity_type_id') { $pseduoOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); } @@ -5653,7 +5660,6 @@ AND displayRelType.is_active = 1 $fieldValue = implode(', ', $fieldValue); } } - return array($op, $fieldValue); } elseif (is_array($fieldValue)) { $qillString = array(); @@ -5664,13 +5670,14 @@ AND displayRelType.is_active = 1 foreach ((array)$fieldValue as $val) { $qillString[] = $pseduoOptions[$val]; } - return array($op, implode(', ', $qillString)); + $fieldValue = implode(', ', $qillString); } else { if (array_key_exists($fieldValue, $pseduoOptions)) { $fieldValue = $pseduoOptions[$fieldValue]; } - return array($op, $fieldValue); } + + return array(CRM_Utils_Array::value($op, $qillOperators, $op), $fieldValue); } } diff --git a/CRM/Contact/Form/Search/Advanced.php b/CRM/Contact/Form/Search/Advanced.php index a9aad9c576..32cae3ba63 100644 --- a/CRM/Contact/Form/Search/Advanced.php +++ b/CRM/Contact/Form/Search/Advanced.php @@ -364,7 +364,19 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { } } - foreach (array('financial_type_id', 'contribution_soft_credit_type_id', 'contribution_status', 'contribution_source', 'contribution_trxn_id', 'activity_type_id', 'status_id', 'activity_subject', 'participant_status_id', 'participant_role_id') as $element) { + $specialParams = array( + 'financial_type_id', + 'contribution_soft_credit_type_id', + 'contribution_status', + 'contribution_source', + 'contribution_trxn_id', + 'activity_type_id', + 'status_id', + 'activity_subject', + 'participant_status_id', + 'participant_role_id' + ); + foreach ($specialParams as $element) { $value = CRM_Utils_Array::value($element, $this->_formValues); if ($value) { if (is_array($value)) { diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 19df0a5a2e..cd48798018 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -125,21 +125,13 @@ class CRM_Contribute_BAO_Query { } // get payment instrument - if (!empty($query->_returnProperties['contribution_payment_instrument'])) { + if (!empty($query->_returnProperties['payment_instrument'])) { $query->_select['payment_instrument'] = "contribution_payment_instrument.label as payment_instrument"; $query->_element['payment_instrument'] = 1; $query->_tables['civicrm_contribution'] = 1; $query->_tables['contribution_payment_instrument'] = 1; } - // get payment instrument id - if (!empty($query->_returnProperties['payment_instrument_id'])) { - $query->_select['payment_instrument_id'] = "contribution_payment_instrument.value as payment_instrument_id"; - $query->_element['payment_instrument_id'] = 1; - $query->_tables['civicrm_contribution'] = 1; - $query->_tables['contribution_payment_instrument'] = 1; - } - if (!empty($query->_returnProperties['check_number'])) { $query->_select['contribution_check_number'] = "civicrm_contribution.check_number as contribution_check_number"; $query->_element['contribution_check_number'] = 1; @@ -217,13 +209,12 @@ class CRM_Contribute_BAO_Query { */ public static function where(&$query) { $grouping = NULL; - self::initializeAnySoftCreditClause($query); foreach (array_keys($query->_params) as $id) { if (empty($query->_params[$id][0])) { continue; } - if (substr($query->_params[$id][0], 0, 13) == 'contribution_' || substr($query->_params[$id][0], 0, 10) == 'financial_') { + if (substr($query->_params[$id][0], 0, 13) == 'contribution_' || substr($query->_params[$id][0], 0, 10) == 'financial_' || substr($query->_params[$id][0], 0, 8) == 'payment_') { if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) { $query->_useDistinct = TRUE; } @@ -254,7 +245,7 @@ class CRM_Contribute_BAO_Query { list($name, $op, $value, $grouping, $wildcard) = $values; $quoteValue = NULL; - $fields = self::getFields(); + $fields = array_merge(CRM_Contribute_BAO_Contribution::fields(), self::getFields()); if (!empty($value) && !is_array($value)) { $quoteValue = "\"$value\""; @@ -316,28 +307,17 @@ class CRM_Contribute_BAO_Query { return; case 'financial_type_id': - case 'financial_type': case 'contribution_page_id': case 'contribution_status_id': case 'contribution_id': case 'contribution_currency_type': case 'contribution_currency': case 'contribution_source': - case 'contribution_payment_instrument_id': case 'contribution_trxn_id': case (strpos($name, '_amount') !== FALSE): case (strpos($name, '_date') !== FALSE): - if (!$value) { - break; - } $qillName = $name; $pseudoExtraParam = NULL; - if (in_array($name, array('financial_type'))) { - $name = $name . "_id"; - } - if (in_array($name, array('financial_type_id', 'contribution_payment_instrument_id'))) { - $qillName = str_replace('_id', '', $name); - } if ((strpos($name, '_amount') !== FALSE) || (strpos($name, '_date') !== FALSE) || in_array($name, array( 'contribution_id', @@ -345,7 +325,6 @@ class CRM_Contribute_BAO_Query { 'contribution_source', 'contribution_trxn_id', 'contribution_check_number', - 'contribution_payment_instrument_id' ) ) ) { @@ -367,6 +346,15 @@ class CRM_Contribute_BAO_Query { $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; return; + case 'financial_type': + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fields[$name]['where'], $op, $value, 'String'); + CRM_Core_Error::debug( '$query', $query->_where[$grouping] ); + list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', $name, $value, $op); + $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); + $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; + $query->_tables['civicrm_financial_type'] = $query->_whereTables['civicrm_financial_type'] = 1; + return; + case 'contribution_page': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fields[$name]['where'], $op, $value, 'String'); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', $name, $value, $op); @@ -375,25 +363,24 @@ class CRM_Contribute_BAO_Query { $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; return; + case 'payment_instrument': + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("contribution_payment_instrument.value", $op, $value, 'Int'); + list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', 'payment_instrument_id', $value, $op); + $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); + $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; + $query->_tables['contribution_payment_instrument'] = $query->_whereTables['contribution_payment_instrument'] = 1; + return; + case 'contribution_status': - case 'contribution_payment_instrument': - if (!$value) { - break; - } $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$name.label", $op, $value, 'String'); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', $name, $value, $op); - if ($name == 'contribution_payment_instrument') { - $name = 'payment_instrument'; - } $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; + $query->_tables[$name] = $query->_whereTables[$name] = 1; break; case 'contribution_pcp_made_through_id': case 'contribution_soft_credit_type_id': - if (!$value) { - break; - } $qillName = $name; if ($name == 'contribution_pcp_made_through_id') { $qillName = $name = 'pcp_id'; @@ -792,8 +779,7 @@ class CRM_Contribute_BAO_Query { 'cancel_date' => 1, 'total_amount' => 1, 'accounting_code' => 1, - 'contribution_payment_instrument' => 1, - 'payment_instrument_id' => 1, + 'payment_instrument' => 1, 'check_number' => 1, 'non_deductible_amount' => 1, 'fee_amount' => 1, @@ -881,8 +867,7 @@ class CRM_Contribute_BAO_Query { FALSE, array('class' => 'crm-select2') ); - - $form->add('select', 'contribution_payment_instrument_id', + $form->add('select', 'payment_instrument', ts('Payment Instrument'), array( '' => ts('- any -') diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index b8035c8c6b..d34a4ae25e 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -269,7 +269,14 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $config = CRM_Core_Config::singleton(); if (!empty($_POST)) { - foreach (array('financial_type_id', 'contribution_soft_credit_type_id', 'contribution_status_id', 'contribution_source', 'contribution_trxn_id') as $element) { + $specialParams = array( + 'financial_type_id', + 'contribution_soft_credit_type_id', + 'contribution_status_id', + 'contribution_source', + 'contribution_trxn_id' + ); + foreach ($specialParams as $element) { $value = CRM_Utils_Array::value($element, $this->_formValues); if ($value) { if (is_array($value)) { diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index cbca237afb..9337342398 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -1039,7 +1039,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { if ($v[0] == 'Contribution' && substr($fldName, 0, 7) != 'custom_' && substr($fldName, 0, 10) != 'financial_' - ) { + && substr($fldName, 0, 8) != 'payment_') { if (substr($fldName, 0, 13) != 'contribution_') { $fldName = 'contribution_' . $fldName; } diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 5a31958955..f08f5fb8f0 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -859,7 +859,9 @@ class CRM_Core_SelectValues { '>=' => '≥', '<=' => '≤', 'IN' => ts('In'), + 'NOT IN' => ts('Not In'), 'LIKE' => ts('Like'), + 'NOT LIKE' => ts('Not Like'), 'RLIKE' => ts('Regex'), 'IS EMPTY' => ts('Is Empty'), 'IS NOT EMPTY' => ts('Not Empty'), diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index f53d09b201..7da21df521 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -244,7 +244,7 @@ class CRM_Event_BAO_Query { */ public static function whereClauseSingle(&$values, &$query) { list($name, $op, $value, $grouping, $wildcard) = $values; - $fields = CRM_Event_BAO_Participant::exportableFields(); + $fields = array_merge(self::fields(), CRM_Event_BAO_Event::fields(), CRM_Event_BAO_Participant::exportableFields()); switch ($name) { case 'event_start_date_low': diff --git a/api/v3/utils.php b/api/v3/utils.php index 8d72eaa2d9..f52d1a76ec 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1400,34 +1400,33 @@ function _civicrm_api3_validate_fields($entity, $action, &$params, $fields, $err $fields = array_intersect_key($fields, $params); foreach ($fields as $fieldName => $fieldInfo) { //In some case $params[$fieldName] holds Array value in this format Array([operator] => [value]) - $fieldValue = CRM_Utils_Array::value($fieldName, $params); - $op = NULL; - if (!empty($fieldValue) && is_array($fieldValue) && in_array(key($fieldValue), CRM_Core_DAO::acceptedSQLOperators())) { - $op = key($fieldValue); - $fieldValue = CRM_Utils_Array::value($op, $fieldValue);; - } + switch (CRM_Utils_Array::value('type', $fieldInfo)) { case CRM_Utils_Type::T_INT: //field is of type integer - _civicrm_api3_validate_integer($fieldValue, $fieldName, $fieldInfo, $entity); + _civicrm_api3_validate_integer($params, $fieldName, $fieldInfo, $entity); break; case 4: case 12: case CRM_Utils_Type::T_TIMESTAMP: //field is of type date or datetime - _civicrm_api3_validate_date($params, $fieldName, $fieldValue, $fieldInfo); + _civicrm_api3_validate_date($params, $fieldName, $fieldInfo); break; case 32://blob - _civicrm_api3_validate_html($fieldValue, $fieldName, $fieldInfo); + _civicrm_api3_validate_html($params, $fieldName, $fieldInfo); break; case CRM_Utils_Type::T_STRING: - _civicrm_api3_validate_string($fieldValue, $fieldName, $fieldInfo, $entity); + _civicrm_api3_validate_string($params, $fieldName, $fieldInfo, $entity); break; case CRM_Utils_Type::T_MONEY: + list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName); + if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) { + break; + } if (!CRM_Utils_Rule::money($fieldValue) && !empty($fieldValue)) { throw new Exception($fieldName . " is not a valid amount: " . $params[$fieldName]); } @@ -1445,14 +1444,9 @@ function _civicrm_api3_validate_fields($entity, $action, &$params, $fields, $err } if (!empty($fieldInfo['api.unique'])) { $params['entity'] = $entity; - _civicrm_api3_validate_uniquekey($params, $fieldName, $fieldValue, $fieldInfo); + _civicrm_api3_validate_uniquekey($params, $fieldName, $fieldInfo); } } - - $params[$fieldName] = $fieldValue; - if (!is_null($op)) { - $params[$fieldName] = array($op => $fieldValue); - } } } @@ -1474,7 +1468,11 @@ function _civicrm_api3_validate_fields($entity, $action, &$params, $fields, $err * Array of fields from getfields function. * @throws Exception */ -function _civicrm_api3_validate_date(&$params, &$fieldName, &$fieldValue, &$fieldInfo) { +function _civicrm_api3_validate_date(&$params, &$fieldName, &$fieldInfo) { + list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName); + if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) { + return; + } //should we check first to prevent it from being copied if they have passed in sql friendly format? if (!empty($params[$fieldInfo['name']])) { $fieldValue = _civicrm_api3_getValidDate($fieldValue, $fieldInfo['name'], $fieldInfo['type']); @@ -1482,6 +1480,13 @@ function _civicrm_api3_validate_date(&$params, &$fieldName, &$fieldValue, &$fiel if ((CRM_Utils_Array::value('name', $fieldInfo) != $fieldName) && !empty($fieldValue)) { $fieldValue = _civicrm_api3_getValidDate($fieldValue, $fieldName, $fieldInfo['type']); } + + if (!empty($op)) { + $params[$fieldName][$op] = $fieldValue; + } + else { + $params[$fieldName] = $fieldValue; + } } /** @@ -1541,7 +1546,11 @@ function _civicrm_api3_validate_constraint(&$fieldValue, &$fieldName, &$fieldInf * Array of fields from getfields function. * @throws Exception */ -function _civicrm_api3_validate_uniquekey(&$params, &$fieldName, &$fieldValue, &$fieldInfo) { +function _civicrm_api3_validate_uniquekey(&$params, &$fieldName, &$fieldInfo) { + list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName); + if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) { + return; + } $existing = civicrm_api($params['entity'], 'get', array( 'version' => $params['version'], $fieldName => $fieldValue, @@ -1807,13 +1816,18 @@ function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) { * @param string $entity * @throws API_Exception */ -function _civicrm_api3_validate_integer(&$fieldValue, &$fieldName, &$fieldInfo, $entity) { +function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $entity) { + list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName); + if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) { + return; + } + if (!empty($fieldValue)) { // if value = 'user_contact_id' (or similar), replace value with contact id if (!is_numeric($fieldValue) && is_scalar($fieldValue)) { $realContactId = _civicrm_api3_resolve_contactID($fieldValue); if ('unknown-user' === $realContactId) { - throw new API_Exception("\"$fieldName\" \"{$params[$fieldName]}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldName, "type" => "integer")); + throw new API_Exception("\"$fieldName\" \"{$fieldValue}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldName,"type"=>"integer")); } elseif (is_numeric($realContactId)) { $fieldValue = $realContactId; } @@ -1877,7 +1891,11 @@ function _civicrm_api3_resolve_contactID($contactIdExpr) { * * @throws API_Exception */ -function _civicrm_api3_validate_html(&$fieldValue, &$fieldName, $fieldInfo) { +function _civicrm_api3_validate_html(&$params, &$fieldName, $fieldInfo) { + list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName); + if (strpos($op, 'NULL') || strpos($op, 'EMPTY')) { + return; + } if ($fieldValue) { if (!CRM_Utils_Rule::xssString($fieldValue)) { throw new API_Exception('Illegal characters in input (potential scripting attack)', array("field"=>$fieldName,"error_code"=>"xss")); @@ -1897,7 +1915,11 @@ function _civicrm_api3_validate_html(&$fieldValue, &$fieldName, $fieldInfo) { * @throws API_Exception * @throws Exception */ -function _civicrm_api3_validate_string(&$fieldValue, &$fieldName, &$fieldInfo, $entity) { +function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $entity) { + list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName); + if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) { + return; + } // If fieldname exists in params $fieldValue = !empty($fieldValue) ? $fieldValue : ''; if(!is_array($fieldValue)){ @@ -2070,3 +2092,22 @@ function _civicrm_api3_deprecation_check($entity, $result = array()) { } } } + +/** + * In some case $params[$fieldName] holds Array value in this format Array([operator] => [value]) + * So this function returns the actual field value + * + * @param array $params + * @param string $fieldName + * @return string|int|boolean|date|null + */ +function _civicrm_api3_field_value_check(&$params, $fieldName) { + $fieldValue = CRM_Utils_Array::value($fieldName, $params); + $op = NULL; + + if (!empty($fieldValue) && is_array($fieldValue) && in_array(key($fieldValue), CRM_Core_DAO::acceptedSQLOperators())) { + $op = key($fieldValue); + $fieldValue = CRM_Utils_Array::value($op, $fieldValue); + } + return array($fieldValue, $op); +} diff --git a/templates/CRM/Contribute/Form/Search/Common.tpl b/templates/CRM/Contribute/Form/Search/Common.tpl index 09c820a441..9cf89c97a8 100644 --- a/templates/CRM/Contribute/Form/Search/Common.tpl +++ b/templates/CRM/Contribute/Form/Search/Common.tpl @@ -41,7 +41,7 @@

- {$form.contribution_payment_instrument_id.html|crmAddClass:twenty} + {$form.payment_instrument.html|crmAddClass:twenty}
{$form.contribution_check_number.label}
diff --git a/xml/schema/Contribute/Contribution.xml b/xml/schema/Contribute/Contribution.xml index c6c320652d..226c85871b 100644 --- a/xml/schema/Contribute/Contribution.xml +++ b/xml/schema/Contribute/Contribution.xml @@ -77,7 +77,7 @@ financial_type_id - Financial Type + Financial Type ID false int unsigned FK to Financial Type for (total_amount - non_deductible_amount). diff --git a/xml/schema/Event/Event.xml b/xml/schema/Event/Event.xml index 3583e5b4f2..fb07045f9a 100644 --- a/xml/schema/Event/Event.xml +++ b/xml/schema/Event/Event.xml @@ -71,7 +71,6 @@ event_type_id Event Type 0 - true event_type diff --git a/xml/schema/Event/Participant.xml b/xml/schema/Event/Participant.xml index 1b67e43a62..e4d0bfbffe 100644 --- a/xml/schema/Event/Participant.xml +++ b/xml/schema/Event/Participant.xml @@ -102,7 +102,7 @@ true varchar 128 - true + false NULL Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role. 1.7 -- 2.25.1