From 0d8afee278524bae3856993b85abe3e4208ea065 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 21 Jan 2014 16:57:22 -0800 Subject: [PATCH] CRM-14106 - Regex targeting inline conditonal statements Pattern used: =\s*CRM_Utils_Array::value\s*\([ ]*(['"$0-9][^,]*),\s*(\$[^ )]*)\s*\)\s*\? = \!empty\($2\[$1\]\) \? --- CRM/Admin/Form/Preferences.php | 2 +- CRM/Campaign/Form/Survey/TabHeader.php | 2 +- CRM/Contact/BAO/Query.php | 2 +- CRM/Contact/Form/DedupeRules.php | 2 +- CRM/Contact/Form/Relationship.php | 2 +- CRM/Contribute/BAO/Contribution.php | 2 +- CRM/Contribute/BAO/ContributionPage.php | 2 +- CRM/Contribute/Form.php | 2 +- CRM/Contribute/Form/ContributionPage/Amount.php | 2 +- CRM/Contribute/Form/ContributionPage/Settings.php | 2 +- CRM/Contribute/Form/ContributionPage/TabHeader.php | 2 +- CRM/Core/BAO/FinancialTrxn.php | 6 +++--- CRM/Core/BAO/Location.php | 4 ++-- CRM/Core/Menu.php | 4 ++-- CRM/Core/SelectValues.php | 4 ++-- CRM/Event/Form/ManageEvent/Fee.php | 4 ++-- CRM/Event/Form/ManageEvent/Registration.php | 4 ++-- CRM/Event/Form/ManageEvent/TabHeader.php | 4 ++-- CRM/Event/Form/Participant.php | 2 +- CRM/Event/Form/Registration/Confirm.php | 2 +- CRM/Logging/ReportSummary.php | 2 +- CRM/Member/BAO/Membership.php | 2 +- CRM/Member/Form/Membership.php | 2 +- CRM/Member/Form/MembershipBlock.php | 6 +++--- CRM/Pledge/BAO/PledgeBlock.php | 2 +- CRM/Price/BAO/PriceField.php | 2 +- CRM/Report/Form.php | 4 ++-- CRM/Report/Form/Contribute/Summary.php | 4 ++-- CRM/Report/Form/Pledge/Detail.php | 2 +- CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php | 2 +- CRM/Utils/OpenFlashChart.php | 6 +++--- api/v3/Contact.php | 4 ++-- api/v3/Contribution.php | 2 +- api/v3/utils.php | 2 +- bin/deprecated/EmailProcessor.php | 2 +- 35 files changed, 50 insertions(+), 50 deletions(-) diff --git a/CRM/Admin/Form/Preferences.php b/CRM/Admin/Form/Preferences.php index eb67551fd8..2794f78f5c 100644 --- a/CRM/Admin/Form/Preferences.php +++ b/CRM/Admin/Form/Preferences.php @@ -258,7 +258,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { break; case 'checkbox': - $this->_config->$settingName = CRM_Utils_Array::value($settingName, $this->_params) ? 1 : 0; + $this->_config->$settingName = !empty($this->_params[$settingName]) ? 1 : 0; break; case 'text': diff --git a/CRM/Campaign/Form/Survey/TabHeader.php b/CRM/Campaign/Form/Survey/TabHeader.php index 77378a7893..015778821e 100644 --- a/CRM/Campaign/Form/Survey/TabHeader.php +++ b/CRM/Campaign/Form/Survey/TabHeader.php @@ -93,7 +93,7 @@ class CRM_Campaign_Form_Survey_TabHeader { } if ($surveyID) { - $reset = CRM_Utils_Array::value('reset', $_GET) ? 'reset=1&' : ''; + $reset = !empty($_GET['reset']) ? 'reset=1&' : ''; foreach ($tabs as $key => $value) { if (!isset($tabs[$key]['qfKey'])) { diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 061c0933af..e313c4a62c 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -1385,7 +1385,7 @@ class CRM_Contact_BAO_Query { foreach ($formValues as $id => $values) { if ($id == 'privacy') { if (is_array($formValues['privacy'])) { - $op = CRM_Utils_Array::value('do_not_toggle', $formValues['privacy']) ? '=' : '!='; + $op = !empty($formValues['privacy']['do_not_toggle']) ? '=' : '!='; foreach ($formValues['privacy'] as $key => $value) { if ($value) { $params[] = array($key, $op, $value, 0, 0); diff --git a/CRM/Contact/Form/DedupeRules.php b/CRM/Contact/Form/DedupeRules.php index 94b90ef20b..e3215b7931 100644 --- a/CRM/Contact/Form/DedupeRules.php +++ b/CRM/Contact/Form/DedupeRules.php @@ -244,7 +244,7 @@ UPDATE civicrm_dedupe_rule_group continue; } list($table, $field) = explode('.', CRM_Utils_Array::value("where_$count", $values)); - $length = CRM_Utils_Array::value("length_$count", $values) ? CRM_Utils_Array::value("length_$count", $values) : NULL; + $length = !empty($values["length_$count"]) ? CRM_Utils_Array::value("length_$count", $values) : NULL; $weight = $values["weight_$count"]; if ($table and $field) { $ruleDao = new CRM_Dedupe_DAO_Rule(); diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index 12076b252a..d65ae542dd 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -623,7 +623,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { //fixes for CRM-7985 //only if the relationship has been toggled to enable /disable if (CRM_Utils_Array::value('is_active', $params) != $this->_enabled) { - $active = CRM_Utils_Array::value('is_active', $params) ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; + $active = !empty($params['is_active']) ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_relationshipId, $active); } } diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index b8aca464da..812ad5455e 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2742,7 +2742,7 @@ WHERE contribution_id = %1 "; } elseif ($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatus) && $params['prevContribution']->is_pay_later) { - $financialTypeID = CRM_Utils_Array::value('financial_type_id', $params) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id; + $financialTypeID = !empty($params['financial_type_id']) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id; if ($params['contribution']->contribution_status_id == array_search('Cancelled', $contributionStatus)) { $params['trxnParams']['to_financial_account_id'] = NULL; $params['trxnParams']['total_amount'] = - $params['total_amount']; diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 83031675a9..45e72eb880 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -334,7 +334,7 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio list($ccDisplayName, $ccEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($values['related_contact']); $ccMailId = "{$ccDisplayName} <{$ccEmail}>"; - $values['cc_receipt'] = CRM_Utils_Array::value('cc_receipt', $values) ? ($values['cc_receipt'] . ',' . $ccMailId) : $ccMailId; + $values['cc_receipt'] = !empty($values['cc_receipt']) ? ($values['cc_receipt'] . ',' . $ccMailId) : $ccMailId; // reset primary-email in the template $tplParams['email'] = $ccEmail; diff --git a/CRM/Contribute/Form.php b/CRM/Contribute/Form.php index c6c5244094..f7e7792ff9 100644 --- a/CRM/Contribute/Form.php +++ b/CRM/Contribute/Form.php @@ -89,7 +89,7 @@ class CRM_Contribute_Form extends CRM_Core_Form { } elseif ($this->_action & CRM_Core_Action::UPDATE) { if (CRM_Utils_Array::value('contact_id', $defaults) || CRM_Utils_Array::value('created_id', $defaults)) { - $contactID = CRM_Utils_Array::value('created_id', $defaults) ? $defaults['created_id'] : $defaults['contact_id']; + $contactID = !empty($defaults['created_id']) ? $defaults['created_id'] : $defaults['contact_id']; $this->assign('created_id', $contactID); $this->assign('organisationId', $contactID); } diff --git a/CRM/Contribute/Form/ContributionPage/Amount.php b/CRM/Contribute/Form/ContributionPage/Amount.php index 0f3b69dc68..44f5715418 100644 --- a/CRM/Contribute/Form/ContributionPage/Amount.php +++ b/CRM/Contribute/Form/ContributionPage/Amount.php @@ -736,7 +736,7 @@ SELECT id } if ($deleteAmountBlk ) { - $priceField = CRM_Utils_Array::value('price_field_id', $params)?$params['price_field_id']:CRM_Utils_Array::value('price_field_other', $params); + $priceField = !empty($params['price_field_id']) ?$params['price_field_id']:CRM_Utils_Array::value('price_field_other', $params); if ($priceField) { $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $priceField, 'price_set_id'); CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID,0); diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index 33e2dbd3a4..9f966f957b 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -329,7 +329,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); $params['is_credit_card_only'] = CRM_Utils_Array::value('is_credit_card_only', $params, FALSE); $params['honor_block_is_active'] = CRM_Utils_Array::value('honor_block_is_active', $params, FALSE); - $params['is_for_organization'] = CRM_Utils_Array::value('is_organization', $params) ? CRM_Utils_Array::value('is_for_organization', $params, FALSE) : 0; + $params['is_for_organization'] = !empty($params['is_organization']) ? CRM_Utils_Array::value('is_for_organization', $params, FALSE) : 0; $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time'], TRUE); $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], TRUE); diff --git a/CRM/Contribute/Form/ContributionPage/TabHeader.php b/CRM/Contribute/Form/ContributionPage/TabHeader.php index 12dfd39bea..bec94c9fd9 100644 --- a/CRM/Contribute/Form/ContributionPage/TabHeader.php +++ b/CRM/Contribute/Form/ContributionPage/TabHeader.php @@ -143,7 +143,7 @@ class CRM_Contribute_Form_ContributionPage_TabHeader { } if ($contribPageId) { - $reset = CRM_Utils_Array::value('reset', $_GET) ? 'reset=1&' : ''; + $reset = !empty($_GET['reset']) ? 'reset=1&' : ''; foreach ($tabs as $key => $value) { if (!isset($tabs[$key]['qfKey'])) { diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index f8c46ce15c..898ded8c7b 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -311,8 +311,8 @@ WHERE ceft.entity_id = %1"; $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $financialAccountType = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id']); $accountRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND label IN ('Premiums Inventory Account is', 'Cost of Sales Account is')"); - $toFinancialAccount = CRM_Utils_Array::value('isDeleted', $params) ? 'Premiums Inventory Account is' : 'Cost of Sales Account is'; - $fromFinancialAccount = CRM_Utils_Array::value('isDeleted', $params) ? 'Cost of Sales Account is': 'Premiums Inventory Account is'; + $toFinancialAccount = !empty($params['isDeleted']) ? 'Premiums Inventory Account is' : 'Cost of Sales Account is'; + $fromFinancialAccount = !empty($params['isDeleted']) ? 'Cost of Sales Account is': 'Premiums Inventory Account is'; $accountRelationship = array_flip($accountRelationship); $financialtrxn = array( 'to_financial_account_id' => $financialAccountType[$accountRelationship[$toFinancialAccount]], @@ -446,4 +446,4 @@ WHERE pp.participant_id = {$entityId} AND ft.to_financial_account_id != {$toFina } return $value; } -} \ No newline at end of file +} diff --git a/CRM/Core/BAO/Location.php b/CRM/Core/BAO/Location.php index 44e06bbfdd..41e6a50f28 100644 --- a/CRM/Core/BAO/Location.php +++ b/CRM/Core/BAO/Location.php @@ -106,8 +106,8 @@ class CRM_Core_BAO_Location extends CRM_Core_DAO { foreach (array( 'phone', 'email', 'im', 'address') as $loc) { - $locBlock["{$loc}_id"] = CRM_Utils_Array::value(0, $location["$loc"]) ? $location["$loc"][0]->id : NULL; - $locBlock["{$loc}_2_id"] = CRM_Utils_Array::value(1, $location["$loc"]) ? $location["$loc"][1]->id : NULL; + $locBlock["{$loc}_id"] = !empty($location["$loc"][0]) ? $location["$loc"][0]->id : NULL; + $locBlock["{$loc}_2_id"] = !empty($location["$loc"][1]) ? $location["$loc"][1]->id : NULL; } $countNull = 0; diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php index 06958e4973..355b976a50 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -275,7 +275,7 @@ class CRM_Core_Menu { continue; } - $query = CRM_Utils_Array::value('path_arguments', $item) ? str_replace(',', '&', $item['path_arguments']) . '&reset=1' : 'reset=1'; + $query = !empty($item['path_arguments']) ? str_replace(',', '&', $item['path_arguments']) . '&reset=1' : 'reset=1'; $value = array( 'title' => $item['title'], @@ -456,7 +456,7 @@ class CRM_Core_Menu { if (array_key_exists($currentPath, $menu) && isset($menu[$currentPath]['title']) ) { - $urlVar = CRM_Utils_Array::value('path_arguments', $menu[$currentPath]) ? '&' . $menu[$currentPath]['path_arguments'] : ''; + $urlVar = !empty($menu[$currentPath]['path_arguments']) ? '&' . $menu[$currentPath]['path_arguments'] : ''; $crumbs[] = array( 'title' => $menu[$currentPath]['title'], 'url' => CRM_Utils_System::url($currentPath, diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 677834bf41..877f00982a 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -667,7 +667,7 @@ class CRM_Core_SelectValues { } //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) { - $tokens["{contact.$val}"] = CRM_Utils_Array::value($customFieldId, $customFields) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : ''; + $tokens["{contact.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : ''; } else { // Support legacy token names @@ -726,7 +726,7 @@ class CRM_Core_SelectValues { } //keys for $tokens should be constant. $token Values are changed for Custom Fields. CRM-3734 if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($val)) { - $tokens["{participant.$val}"] = CRM_Utils_Array::value($customFieldId, $customFields) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : ''; + $tokens["{participant.$val}"] = !empty($customFields[$customFieldId]) ? $customFields[$customFieldId]['label'] . " :: " . $customFields[$customFieldId]['groupTitle'] : ''; } else { $tokens["{participant.$val}"] = $exportFields[$val]['title']; diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index a20003ddb4..61ec49e7e9 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -671,8 +671,8 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { } } - $discountPriceSets = CRM_Utils_Array::value('discount_price_set', $this->_defaultValues) ? $this->_defaultValues['discount_price_set']: array(); - $discountFieldIDs = CRM_Utils_Array::value('discount_option_id', $this->_defaultValues) ? $this->_defaultValues['discount_option_id']: array(); + $discountPriceSets = !empty($this->_defaultValues['discount_price_set']) ? $this->_defaultValues['discount_price_set']: array(); + $discountFieldIDs = !empty($this->_defaultValues['discount_option_id']) ? $this->_defaultValues['discount_option_id']: array(); if (CRM_Utils_Array::value('is_discount', $params) == 1) { // if there are discounted set of label / values, // create custom options for them diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index d1f0189b4f..65d2f86809 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -518,7 +518,7 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } } else { - $customPreId = CRM_Utils_Array::value('custom_pre_id', $values) ? $values['custom_pre_id'] : NULL; + $customPreId = !empty($values['custom_pre_id']) ? $values['custom_pre_id'] : NULL; } //check whether the additional custom pre profile is of type 'Individual' and its subtypes if (!empty($customPreId)) { @@ -546,7 +546,7 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } } else { - $customPostId = CRM_Utils_Array::value('custom_post_id', $values) ? $values['custom_post_id'] : NULL; + $customPostId = !empty($values['custom_post_id']) ? $values['custom_post_id'] : NULL; } //check whether the additional custom post profile is of type 'Individual' and its subtypes if (!empty($customPostId)) { diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 2de811aeca..03151fc964 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -139,7 +139,7 @@ WHERE e.id = %1 case 'ScheduleReminders': $class = 'reminder'; - $new = CRM_Utils_Array::value('new', $_GET) ? '&new=1' : ''; + $new = !empty($_GET['new']) ? '&new=1' : ''; break; default: @@ -156,7 +156,7 @@ WHERE e.id = %1 } if ($eventID) { - $reset = CRM_Utils_Array::value('reset', $_GET) ? 'reset=1&' : ''; + $reset = !empty($_GET['reset']) ? 'reset=1&' : ''; foreach ($tabs as $key => $value) { if (!isset($tabs[$key]['qfKey'])) { diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index bbf750ca2c..4620daf142 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1449,7 +1449,7 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} ); $contributionParams['currency'] = $config->defaultCurrency; $contributionParams['non_deductible_amount'] = 'null'; - $contributionParams['receipt_date'] = CRM_Utils_Array::value('send_receipt', $params) ? CRM_Utils_Array::value('receive_date', $params) : 'null'; + $contributionParams['receipt_date'] = !empty($params['send_receipt']) ? CRM_Utils_Array::value('receive_date', $params) : 'null'; $recordContribution = array( 'contact_id', 'financial_type_id', 'payment_instrument_id', 'trxn_id', diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 8f62300322..01f969f600 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -600,7 +600,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $pending = TRUE; //get the participant statuses. $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'"); - $status = CRM_Utils_Array::value('is_pay_later', $value) ? 'Pending from pay later' : 'Pending from incomplete transaction'; + $status = !empty($value['is_pay_later']) ? 'Pending from pay later' : 'Pending from incomplete transaction'; $value['participant_status_id'] = $value['participant_status'] = array_search($status, $pendingStatuses); } } diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index fcd11ce945..cc4deb5e6c 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -346,7 +346,7 @@ ORDER BY log_civicrm_entity_log_date DESC {$this->_limit}"; function getEntityValue($id, $entity, $logDate) { if (CRM_Utils_Array::value('bracket_info', $this->_logTables[$entity])) { if (CRM_Utils_Array::value('entity_column', $this->_logTables[$entity]['bracket_info'])) { - $logTable = CRM_Utils_Array::value('table_name', $this->_logTables[$entity]) ? $this->_logTables[$entity]['table_name'] : $entity; + $logTable = !empty($this->_logTables[$entity]['table_name']) ? $this->_logTables[$entity]['table_name'] : $entity; $sql = " SELECT {$this->_logTables[$entity]['bracket_info']['entity_column']} FROM `{$this->loggingDB}`.{$logTable} diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 9ca03859f7..3aed00e50d 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1356,7 +1356,7 @@ AND civicrm_membership.is_test = %2"; } } - $index = CRM_Utils_Array::value('is_separate_payment', $memBlockDetails) ? 2 : 1; + $index = !empty($memBlockDetails['is_separate_payment']) ? 2 : 1; if (!CRM_Utils_Array::value($index, $errors)) { if (isset($membershipParams['onbehalf']) && diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index d1b90814a9..7cba16ba13 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1493,7 +1493,7 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; $this->assign('amount', $params['total_amount']); } - $params['contribution_status_id'] = CRM_Utils_Array::value('is_recur', $paymentParams) ? 2 : 1; + $params['contribution_status_id'] = !empty($paymentParams['is_recur']) ? 2 : 1; $params['receive_date'] = $now; $params['invoice_id'] = $this->_params['invoiceID']; $params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)', diff --git a/CRM/Member/Form/MembershipBlock.php b/CRM/Member/Form/MembershipBlock.php index 33717a6efc..895982f61f 100644 --- a/CRM/Member/Form/MembershipBlock.php +++ b/CRM/Member/Form/MembershipBlock.php @@ -375,7 +375,7 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults); if (!CRM_Utils_Array::value('id', $editedResults)) { $fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245)); - $fieldParams['label'] = CRM_Utils_Array::value('new_title', $params) ? $params['new_title'] : ts('Membership'); + $fieldParams['label'] = !empty($params['new_title']) ? $params['new_title'] : ts('Membership'); if (!CRM_Utils_Array::value('mem_price_field_id', $params)) { CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, array('price_set_id' => $priceSetID)); } @@ -387,8 +387,8 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa $fieldParams['is_active'] = 1; $fieldParams['html_type'] = 'Radio'; - $fieldParams['is_required'] = CRM_Utils_Array::value('is_required', $params) ? 1 : 0; - $fieldParams['is_display_amounts'] = CRM_Utils_Array::value('display_min_fee', $params) ? 1 : 0; + $fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0; + $fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0; $rowCount = 1; $options = array(); if (CRM_Utils_Array::value('id', $fieldParams)) { diff --git a/CRM/Pledge/BAO/PledgeBlock.php b/CRM/Pledge/BAO/PledgeBlock.php index 155c54fec3..907b42837a 100644 --- a/CRM/Pledge/BAO/PledgeBlock.php +++ b/CRM/Pledge/BAO/PledgeBlock.php @@ -291,7 +291,7 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock { $frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units'); foreach ($freqUnitVals as $key => $val) { if (array_key_exists($val, $frequencyUnits)) { - $freqUnits[$val] = CRM_Utils_Array::value('is_pledge_interval', $pledgeBlock) ? "{$frequencyUnits[$val]}(s)" : $frequencyUnits[$val]; + $freqUnits[$val] = !empty($pledgeBlock['is_pledge_interval']) ? "{$frequencyUnits[$val]}(s)" : $frequencyUnits[$val]; } } $form->addElement('select', 'pledge_frequency_unit', NULL, $freqUnits); diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 39ab84d7cb..a9938882d6 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -344,7 +344,7 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { foreach ($customOption as $opId => $opt) { if ($field->is_display_amounts) { - $opt['label'] = CRM_Utils_Array::value('label', $opt) ? $opt['label'] : ''; + $opt['label'] = !empty($opt['label']) ? $opt['label'] : ''; $opt['label'] = '' . CRM_Utils_Money::format($opt[$valueFieldName]) . ' ' . $opt['label'] . ''; } $count = CRM_Utils_Array::value('count', $opt, ''); diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 6246e400d6..9c2b954dcb 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -2452,10 +2452,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params), CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params) ); - $from_time_format = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params) ? 'h' : 'd'; + $from_time_format = !empty($this->_params["{$fieldName}_from_time"]) ? 'h' : 'd'; $from = CRM_Utils_Date::customFormat($from, null, array($from_time_format)); - $to_time_format = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params) ? 'h' : 'd'; + $to_time_format = !empty($this->_params["{$fieldName}_to_time"]) ? 'h' : 'd'; $to = CRM_Utils_Date::customFormat($to, null, array($to_time_format)); if ($from || $to) { diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 3548ae6724..d15b69fae7 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -609,8 +609,8 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ if (CRM_Utils_Array::value('charts', $this->_params)) { if (CRM_Utils_Array::value('receive_date', $this->_params['group_bys'])) { - $contrib = CRM_Utils_Array::value('total_amount', $this->_params['fields']) ? TRUE : FALSE; - $softContrib = CRM_Utils_Array::value('soft_amount', $this->_params['fields']) ? TRUE : FALSE; + $contrib = !empty($this->_params['fields']['total_amount']) ? TRUE : FALSE; + $softContrib = !empty($this->_params['fields']['soft_amount']) ? TRUE : FALSE; foreach ($rows as $key => $row) { if ($row['civicrm_contribution_receive_date_subtotal']) { diff --git a/CRM/Report/Form/Pledge/Detail.php b/CRM/Report/Form/Pledge/Detail.php index 6df25dba72..45c46d4b23 100644 --- a/CRM/Report/Form/Pledge/Detail.php +++ b/CRM/Report/Form/Pledge/Detail.php @@ -498,7 +498,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { $row = array(); foreach ($this->_columnHeaders as $columnKey => $columnValue) { if (array_key_exists($columnKey, $value)) { - $row[$columnKey] = CRM_Utils_Array::value($columnKey, $value) ? $value[$columnKey] : ''; + $row[$columnKey] = !empty($value[$columnKey]) ? $value[$columnKey] : ''; } } $rows[] = $row; diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php b/CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php index 14aef46389..764807cdda 100644 --- a/CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php +++ b/CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php @@ -322,7 +322,7 @@ class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p foreach ($customOption as $opId => $opt) { if ($field->is_display_amounts) { - $opt['label'] = CRM_Utils_Array::value('label', $opt) ? $opt['label'] . ' - ' : ''; + $opt['label'] = !empty($opt['label']) ? $opt['label'] . ' - ' : ''; $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]); } $count = CRM_Utils_Array::value('count', $opt, ''); diff --git a/CRM/Utils/OpenFlashChart.php b/CRM/Utils/OpenFlashChart.php index f6ebf15a74..22f57b83b3 100644 --- a/CRM/Utils/OpenFlashChart.php +++ b/CRM/Utils/OpenFlashChart.php @@ -74,7 +74,7 @@ class CRM_Utils_OpenFlashChart { } // get the required data. - $chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart'); + $chartTitle = !empty($params['legend']) ? $params['legend'] : ts('Bar Chart'); $xValues = $yValues = array(); $xValues = array_keys($values[0]); @@ -203,7 +203,7 @@ class CRM_Utils_OpenFlashChart { foreach ($allValues as $label => $value) { $values[] = new pie_value((double)$value, $label); } - $graphTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Pie Chart'); + $graphTitle = !empty($params['legend']) ? $params['legend'] : ts('Pie Chart'); //get the currency. $config = CRM_Core_Config::singleton(); @@ -315,7 +315,7 @@ class CRM_Utils_OpenFlashChart { $count++; } - $chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart'); + $chartTitle = !empty($params['legend']) ? $params['legend'] : ts('Bar Chart'); //set y axis parameters. $yMin = 0; diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 15bd089958..674270f5b5 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -263,8 +263,8 @@ function civicrm_api3_contact_delete($params) { if ($contactID == $session->get('userID')) { return civicrm_api3_create_error('This contact record is linked to the currently logged in user account - and cannot be deleted.'); } - $restore = CRM_Utils_Array::value('restore', $params) ? $params['restore'] : FALSE; - $skipUndelete = CRM_Utils_Array::value('skip_undelete', $params) ? $params['skip_undelete'] : FALSE; + $restore = !empty($params['restore']) ? $params['restore'] : FALSE; + $skipUndelete = !empty($params['skip_undelete']) ? $params['skip_undelete'] : FALSE; // CRM-12929 // restrict permanent delete if a contact has financial trxn associated with it diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 63322f70e6..203bd5432c 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -143,7 +143,7 @@ function _civicrm_api3_contribution_create_spec(&$params) { */ function civicrm_api3_contribution_delete($params) { - $contributionID = CRM_Utils_Array::value('contribution_id', $params) ? $params['contribution_id'] : $params['id']; + $contributionID = !empty($params['contribution_id']) ? $params['contribution_id'] : $params['id']; if (CRM_Contribute_BAO_Contribution::deleteContribution($contributionID)) { return civicrm_api3_create_success(array($contributionID => 1)); } diff --git a/api/v3/utils.php b/api/v3/utils.php index 7b0dc167ef..ad2f2e4f90 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -475,7 +475,7 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti } } - $skipPermissions = CRM_Utils_Array::value('check_permissions', $params)? 0 :1; + $skipPermissions = !empty($params['check_permissions']) ? 0 :1; list($entities, $options) = CRM_Contact_BAO_Query::apiQuery( $newParams, diff --git a/bin/deprecated/EmailProcessor.php b/bin/deprecated/EmailProcessor.php index 3770b10d9d..83143b06e3 100644 --- a/bin/deprecated/EmailProcessor.php +++ b/bin/deprecated/EmailProcessor.php @@ -103,7 +103,7 @@ else { // check if the script is being used for civimail processing or email to // activity processing. - $isCiviMail = CRM_Utils_Array::value('emailtoactivity', $_REQUEST) ? FALSE : TRUE; + $isCiviMail = !empty($_REQUEST['emailtoactivity']) ? FALSE : TRUE; CRM_Utils_Mail_EmailProcessor::process($isCiviMail); $lock->release(); -- 2.25.1