From 8ee006e73bef6df3b6002f686bcec40647729371 Mon Sep 17 00:00:00 2001 From: Web Access Date: Wed, 10 Feb 2016 18:33:29 +0530 Subject: [PATCH] CRM-18010: Ensure type of each report filters --- CRM/Report/Form.php | 7 +++++++ CRM/Report/Form/Activity.php | 1 + CRM/Report/Form/ActivitySummary.php | 2 ++ CRM/Report/Form/Contact/CurrentEmployer.php | 3 +++ CRM/Report/Form/Contact/Relationship.php | 2 ++ CRM/Report/Form/Contribute/Bookkeeping.php | 5 +++++ CRM/Report/Form/Contribute/History.php | 1 + CRM/Report/Form/Contribute/Repeat.php | 1 + CRM/Report/Form/Contribute/SoftCredit.php | 1 + CRM/Report/Form/Contribute/Sybunt.php | 1 + CRM/Report/Form/Contribute/TopDonor.php | 5 +++++ CRM/Report/Form/Event/ParticipantListing.php | 5 +++++ CRM/Report/Form/Mailing/Bounce.php | 1 + CRM/Report/Form/Member/ContributionDetail.php | 3 +++ CRM/Report/Form/Member/Lapse.php | 1 + CRM/Report/Form/Member/Summary.php | 2 ++ CRM/Report/Form/Pledge/Detail.php | 2 ++ CRM/Report/Form/Pledge/Pbnp.php | 2 ++ 18 files changed, 45 insertions(+) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 350ab376f2..dd348ac510 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -1665,6 +1665,7 @@ class CRM_Report_Form extends CRM_Core_Form { 'tagid' => array( 'name' => 'tag_id', 'title' => ts('Tag'), + 'type' => CRM_Utils_Type::T_INT, 'tag' => TRUE, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contactTags, @@ -1682,6 +1683,7 @@ class CRM_Report_Form extends CRM_Core_Form { 'gid' => array( 'name' => 'group_id', 'title' => ts('Group'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::nestedGroup(), @@ -1760,6 +1762,11 @@ class CRM_Report_Form extends CRM_Core_Form { public function whereClause(&$field, $op, $value, $min, $max) { $type = CRM_Utils_Type::typeToString(CRM_Utils_Array::value('type', $field)); + + // CRM-18010: Ensure type of each report filters + if (!$type) { + trigger_error('Type is not defined for field ' . $field['name'], E_USER_WARNING); + } $clause = NULL; switch ($op) { diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index 672d16edcb..a1500f9b56 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -250,6 +250,7 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { ), 'status_id' => array( 'title' => ts('Activity Status'), + 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus(), ), diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index d31d5d8028..fd1da6cba9 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -135,11 +135,13 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { ), 'status_id' => array( 'title' => ts('Activity Status'), + 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus(), ), 'priority_id' => array( 'title' => ts('Priority'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), ), diff --git a/CRM/Report/Form/Contact/CurrentEmployer.php b/CRM/Report/Form/Contact/CurrentEmployer.php index 56e003213d..94b2587086 100644 --- a/CRM/Report/Form/Contact/CurrentEmployer.php +++ b/CRM/Report/Form/Contact/CurrentEmployer.php @@ -192,11 +192,13 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { 'filters' => array( 'country_id' => array( 'title' => ts('Country'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(NULL, FALSE), ), 'state_province_id' => array( 'title' => ts('State/Province'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), ), @@ -209,6 +211,7 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { 'gid' => array( 'name' => 'group_id', 'title' => ts('Group'), + 'type' => CRM_Utils_Type::T_INT, 'group' => TRUE, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::staticGroup(), diff --git a/CRM/Report/Form/Contact/Relationship.php b/CRM/Report/Form/Contact/Relationship.php index 92ef86431e..79644b2dee 100644 --- a/CRM/Report/Form/Contact/Relationship.php +++ b/CRM/Report/Form/Contact/Relationship.php @@ -261,11 +261,13 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { 'filters' => array( 'country_id' => array( 'title' => ts('Country'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), ), 'state_province_id' => array( 'title' => ts('State/Province'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), ), diff --git a/CRM/Report/Form/Contribute/Bookkeeping.php b/CRM/Report/Form/Contribute/Bookkeeping.php index b8e854fd29..2e82d86456 100644 --- a/CRM/Report/Form/Contribute/Bookkeeping.php +++ b/CRM/Report/Form/Contribute/Bookkeeping.php @@ -190,11 +190,13 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { ), 'credit_accounting_code' => array( 'title' => ts('Financial Account Code - Credit'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'), ), 'debit_name' => array( 'title' => ts('Financial Account Name - Debit'), + 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(), 'name' => 'id', @@ -202,6 +204,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { ), 'credit_name' => array( 'title' => ts('Financial Account Name - Credit'), + 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(), ), @@ -218,6 +221,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'filters' => array( 'financial_type_id' => array( 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), ), @@ -288,6 +292,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'filters' => array( 'payment_instrument_id' => array( 'title' => ts('Payment Method'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), ), diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index dd030e020f..cbc2de59e8 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -253,6 +253,7 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { ), 'financial_type_id' => array( 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), ), diff --git a/CRM/Report/Form/Contribute/Repeat.php b/CRM/Report/Form/Contribute/Repeat.php index 4adb3cc61d..c4e844b444 100644 --- a/CRM/Report/Form/Contribute/Repeat.php +++ b/CRM/Report/Form/Contribute/Repeat.php @@ -217,6 +217,7 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form { ), 'financial_type_id' => array( 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), ), diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index d5474f4703..7a4afff37d 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -218,6 +218,7 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { 'id' => array( 'name' => 'id', 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), ), diff --git a/CRM/Report/Form/Contribute/Sybunt.php b/CRM/Report/Form/Contribute/Sybunt.php index b8a664b589..60d4ea9ce6 100644 --- a/CRM/Report/Form/Contribute/Sybunt.php +++ b/CRM/Report/Form/Contribute/Sybunt.php @@ -224,6 +224,7 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { ), 'financial_type_id' => array( 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), ), diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index 1a515f4606..945c7074d5 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -139,10 +139,12 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { 'filters' => array( 'sort_name' => array( 'title' => ts('Participant Name'), + 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', ), 'id' => array( 'title' => ts('Contact ID'), + 'type' => CRM_Utils_Type::T_INT, 'no_display' => TRUE, ), 'birth_date' => array( @@ -151,9 +153,11 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { ), 'contact_type' => array( 'title' => ts('Contact Type'), + 'type' => CRM_Utils_Type::T_STRING, ), 'contact_sub_type' => array( 'title' => ts('Contact Subtype'), + 'type' => CRM_Utils_Type::T_STRING, ), 'receive_date' => array( 'default' => 'this.year', @@ -174,6 +178,7 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { 'financial_type_id' => array( 'name' => 'financial_type_id', 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), ), diff --git a/CRM/Report/Form/Event/ParticipantListing.php b/CRM/Report/Form/Event/ParticipantListing.php index b26974d464..5de0add791 100644 --- a/CRM/Report/Form/Event/ParticipantListing.php +++ b/CRM/Report/Form/Event/ParticipantListing.php @@ -217,6 +217,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { 'sid' => array( 'name' => 'status_id', 'title' => ts('Participant Status'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), ), @@ -278,6 +279,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { 'eid' => array( 'name' => 'event_type_id', 'title' => ts('Event Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'), ), @@ -331,6 +333,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { ), 'financial_type_id' => array( 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), ), @@ -343,6 +346,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { ), 'payment_instrument_id' => array( 'title' => ts('Payment Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), ), @@ -361,6 +365,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { 'price_field_value_id' => array( 'name' => 'price_field_value_id', 'title' => ts('Fee Level'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->getPriceLevels(), ), diff --git a/CRM/Report/Form/Mailing/Bounce.php b/CRM/Report/Form/Mailing/Bounce.php index cf7f8ce1bf..4f8438a48b 100644 --- a/CRM/Report/Form/Mailing/Bounce.php +++ b/CRM/Report/Form/Mailing/Bounce.php @@ -137,6 +137,7 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { 'filters' => array( 'bounce_reason' => array( 'title' => ts('Bounce Reason'), + 'type' => CRM_Utils_Type::T_STRING, ), 'time_stamp' => array( 'title' => ts('Bounce Date'), diff --git a/CRM/Report/Form/Member/ContributionDetail.php b/CRM/Report/Form/Member/ContributionDetail.php index c2d2fe243f..8ead99bd24 100644 --- a/CRM/Report/Form/Member/ContributionDetail.php +++ b/CRM/Report/Form/Member/ContributionDetail.php @@ -195,6 +195,7 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'financial_type_id' => array( 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), ), @@ -207,6 +208,7 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { ), 'payment_instrument_id' => array( 'title' => ts('Payment Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), ), @@ -252,6 +254,7 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { 'filters' => array( 'ordinality' => array( 'title' => ts('Contribution Ordinality'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => array( 0 => 'First by Contributor', diff --git a/CRM/Report/Form/Member/Lapse.php b/CRM/Report/Form/Member/Lapse.php index 882342fe2b..cc45121c13 100644 --- a/CRM/Report/Form/Member/Lapse.php +++ b/CRM/Report/Form/Member/Lapse.php @@ -102,6 +102,7 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { 'tid' => array( 'name' => 'id', 'title' => ts('Membership Types'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType(), ), diff --git a/CRM/Report/Form/Member/Summary.php b/CRM/Report/Form/Member/Summary.php index 56279ecb28..99d5183705 100644 --- a/CRM/Report/Form/Member/Summary.php +++ b/CRM/Report/Form/Member/Summary.php @@ -100,11 +100,13 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { ), 'membership_type_id' => array( 'title' => ts('Membership Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType(), ), 'status_id' => array( 'title' => ts('Membership Status'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), ), diff --git a/CRM/Report/Form/Pledge/Detail.php b/CRM/Report/Form/Pledge/Detail.php index 3e8e934107..ddf69d413a 100644 --- a/CRM/Report/Form/Pledge/Detail.php +++ b/CRM/Report/Form/Pledge/Detail.php @@ -155,11 +155,13 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { 'sid' => array( 'name' => 'status_id', 'title' => ts('Pledge Status'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('contribution_status'), ), 'financial_type_id' => array( 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), ), diff --git a/CRM/Report/Form/Pledge/Pbnp.php b/CRM/Report/Form/Pledge/Pbnp.php index 197866b554..80d56f7a90 100644 --- a/CRM/Report/Form/Pledge/Pbnp.php +++ b/CRM/Report/Form/Pledge/Pbnp.php @@ -113,6 +113,7 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { ), 'financial_type_id' => array( 'title' => ts('Financial Type'), + 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), ), @@ -165,6 +166,7 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { 'gid' => array( 'name' => 'group_id', 'title' => ts('Group'), + 'type' => CRM_Utils_Type::T_INT, 'group' => TRUE, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::staticGroup(), -- 2.25.1