From 91bb24a715c5f5f3b0ca626886e3b6a1897a2b65 Mon Sep 17 00:00:00 2001 From: yashodha Date: Thu, 18 Jul 2013 15:08:00 +0530 Subject: [PATCH] CRM-9744, CRM-12531 --- CRM/Contribute/BAO/ContributionPage.php | 53 ++++++------ CRM/Contribute/BAO/ContributionSoft.php | 14 ++-- CRM/Contribute/Import/Field.php | 4 +- CRM/Contribute/Import/Form/MapField.php | 41 ++++----- CRM/Contribute/Import/Parser/Contribution.php | 23 +++-- CRM/Utils/DeprecatedUtils.php | 84 +++++++------------ 6 files changed, 100 insertions(+), 119 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index b6dc5c984b..929c253d0d 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -60,7 +60,7 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio * @param int $id id of the database record * @param boolean $is_active value we want to set the is_active field * - * @return Object DAO object on sucess, null otherwise + * @return Object DAO object on success, null otherwise * @static */ static function setIsActive($id, $is_active) { @@ -301,10 +301,10 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 'isShare' => CRM_Utils_Array::value('is_share', $values), ); - if ( $contributionTypeId = CRM_Utils_Array::value('financial_type_id', $values ) ) { + if ($contributionTypeId = CRM_Utils_Array::value('financial_type_id', $values)) { $tplParams['contributionTypeId'] = $contributionTypeId; - $tplParams['contributionTypeName'] = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_FinancialType', - $contributionTypeId ); + $tplParams['contributionTypeName'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', + $contributionTypeId); } if ($contributionPageId = CRM_Utils_Array::value('id', $values)) { @@ -340,8 +340,8 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 'entity_id' => $values['id'], ); $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); - $profileId = $OnBehalfProfile[0]; - $userID = $contactID; + $profileId = $OnBehalfProfile[0]; + $userID = $contactID; self::buildCustomDisplay($profileId, 'onBehalfProfile', $userID, $template, $params['onbehalf_profile'], $fieldTypes); } @@ -433,13 +433,13 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio $value = array(); if ($pageID) { CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $pageID, $value, array( - 'title', - 'is_email_receipt', - 'receipt_from_name', - 'receipt_from_email', - 'cc_receipt', - 'bcc_receipt', - )); + 'title', + 'is_email_receipt', + 'receipt_from_name', + 'receipt_from_email', + 'cc_receipt', + 'bcc_receipt', + )); } $isEmailReceipt = CRM_Utils_Array::value('is_email_receipt', $value[$pageID]); @@ -455,9 +455,9 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio $receiptFromEmail = $value[$pageID]['receipt_from_email']; } else { - $domainValues = CRM_Core_BAO_Domain::getNameAndEmail(); - $receiptFrom = "$domainValues[0] <$domainValues[1]>"; - $receiptFromName = $domainValues[0]; + $domainValues = CRM_Core_BAO_Domain::getNameAndEmail(); + $receiptFrom = "$domainValues[0] <$domainValues[1]>"; + $receiptFromName = $domainValues[0]; $receiptFromEmail = $domainValues[1]; } @@ -487,9 +487,9 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio if ($recur->id) { // in some cases its just recurringNotify() thats called for the first time and these urls don't get set. // like in PaypalPro, & therefore we set it here additionally. - $template = CRM_Core_Smarty::singleton(); + $template = CRM_Core_Smarty::singleton(); $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($recur->id, 'recur', 'obj'); - $url = $paymentProcessor->subscriptionURL($recur->id, 'recur'); + $url = $paymentProcessor->subscriptionURL($recur->id, 'recur'); $template->assign('cancelSubscriptionUrl', $url); $url = $paymentProcessor->subscriptionURL($recur->id, 'recur', 'billing'); @@ -525,9 +525,9 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio function buildCustomDisplay($gid, $name, $cid, &$template, &$params, $fieldTypes = NULL) { if ($gid) { if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $cid)) { - $values = array(); + $values = array(); $groupTitle = NULL; - $fields = CRM_Core_BAO_UFGroup::getFields($gid, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL); + $fields = CRM_Core_BAO_UFGroup::getFields($gid, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL); foreach ($fields as $k => $v) { if (!$groupTitle) { $groupTitle = $v["groupTitle"]; @@ -639,11 +639,11 @@ WHERE entity_table = 'civicrm_contribution_page' $premiumDao = CRM_Core_DAO::executeQuery($premiumQuery, CRM_Core_DAO::$_nullArray); while ($premiumDao->fetch()) { if ($premiumDao->id) { - $copyPremiumProduct = &CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_PremiumsProduct', array( - 'premiums_id' => $premiumDao->id, - ), array( - 'premiums_id' => $copyPremium->id, - )); + $copyPremiumProduct = & CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_PremiumsProduct', array( + 'premiums_id' => $premiumDao->id, + ), array( + 'premiums_id' => $copyPremium->id, + )); } } @@ -689,8 +689,7 @@ WHERE entity_table = 'civicrm_contribution_page' * @access public * @static */ - static function getSectionInfo($contribPageIds = array( - )) { + static function getSectionInfo($contribPageIds = array()) { $info = array(); $whereClause = NULL; if (is_array($contribPageIds) && !empty($contribPageIds)) { diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index b44489ad35..5e2895a383 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -42,7 +42,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio } /** - * funtion to add contribution soft credit record + * function to add contribution soft credit record * * @param array $params (reference ) an assoc array of name/value pairs * @@ -120,14 +120,15 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio while ($cs->fetch()) { if ($cs->amount > 0) { $count++; - $amount[] = $cs->amount; - $average[] = $cs->average; + $amount[] = $cs->amount; + $average[] = $cs->average; $currency[] = $cs->currency; } } if ($count > 0) { - return array(implode(', ', $amount), + return array( + implode(', ', $amount), implode(', ', $average), implode(', ', $currency), ); @@ -209,7 +210,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio } static function getSoftCreditType($contributionID) { - $query = " + $query = " SELECT id, pcp_id FROM civicrm_contribution_soft WHERE contribution_id = %1 @@ -230,8 +231,9 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio } return array($type, $id); } + /** - * Function to retrieve the list of soft contributons for given contact. + * Function to retrieve the list of soft contributions for given contact. * @param int $contact_id contact id * * @return array diff --git a/CRM/Contribute/Import/Field.php b/CRM/Contribute/Import/Field.php index 97140ae0bc..160f47421f 100644 --- a/CRM/Contribute/Import/Field.php +++ b/CRM/Contribute/Import/Field.php @@ -121,8 +121,8 @@ class CRM_Contribute_Import_Field { switch ($this->_name) { case 'contact_id': - // note: we validate extistence of the contact in API, upon - // insert (it would be too costlty to do a db call here) + // note: we validate existence of the contact in API, upon + // insert (it would be too costly to do a db call here) return CRM_Utils_Rule::integer($this->_value); case 'receive_date': diff --git a/CRM/Contribute/Import/Form/MapField.php b/CRM/Contribute/Import/Form/MapField.php index a45d17f8c5..22b4b4f64e 100644 --- a/CRM/Contribute/Import/Form/MapField.php +++ b/CRM/Contribute/Import/Form/MapField.php @@ -119,16 +119,16 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingRelation) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping); - $mappingName = $mappingName[1]; + $mappingName = $mappingName[1]; $mappingContactType = $mappingContactType[1]; - $mappingLocation = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingLocation)); - $mappingPhoneType = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingPhoneType)); - $mappingRelation = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingRelation)); + $mappingLocation = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingLocation)); + $mappingPhoneType = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingPhoneType)); + $mappingRelation = CRM_Utils_Array::value('1', CRM_Utils_Array::value(1, $mappingRelation)); //mapping is to be loaded from database - $params = array('id' => $savedMapping); - $temp = array(); + $params = array('id' => $savedMapping); + $temp = array(); $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp); $this->assign('loadedMapping', $mappingDetails->name); @@ -158,14 +158,13 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { //-------- end of saved mapping stuff --------- - $defaults = array(); - $mapperKeys = array_keys($this->_mapperFields); - $hasHeaders = !empty($this->_columnHeaders); - $headerPatterns = $this->get('headerPatterns'); - $dataPatterns = $this->get('dataPatterns'); + $defaults = array(); + $mapperKeys = array_keys($this->_mapperFields); + $hasHeaders = !empty($this->_columnHeaders); + $headerPatterns = $this->get('headerPatterns'); + $dataPatterns = $this->get('dataPatterns'); $hasLocationTypes = $this->get('fieldTypes'); - /* Initialize all field usages to false */ foreach ($mapperKeys as $key) { @@ -190,13 +189,13 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { $contactType = $contactTypes[$contactTypeId]; - // get imporatable fields for contact type + // get importable fields for contact type $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL); // get the Dedupe rule for this contact type and build soft credit array $ruleParams = array( 'contact_type' => $contactType, - 'used' => 'Unsupervised', + 'used' => 'Unsupervised', ); $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); $softCreditFields = array(); @@ -224,7 +223,7 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { $warning = 0; for ($i = 0; $i < $this->_columnCount; $i++) { - $sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', array(1 => $i)), NULL); + $sel = & $this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', array(1 => $i)), NULL); $jsSet = FALSE; if ($this->get('savedMapping')) { if (isset($mappingName[$i])) { @@ -241,7 +240,7 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { $js .= "{$formName}['mapper[$i][2]'].style.display = 'none';\n"; $js .= "{$formName}['mapper[$i][3]'].style.display = 'none';\n"; $defaults["mapper[$i]"] = array( - $mappingHeader[0], + CRM_Utils_Array::value(0, $mappingHeader), ($softField) ? $softField : "", (isset($locationId)) ? $locationId : "", (isset($phoneType)) ? $phoneType : "", @@ -358,7 +357,7 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization', ); $params = array( - 'used' => 'Unsupervised', + 'used' => 'Unsupervised', 'contact_type' => $contactTypes[$contactTypeId], ); list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params); @@ -376,7 +375,7 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { $requiredFields = array( 'contribution_contact_id' => ts('Contact ID'), 'total_amount' => ts('Total Amount'), - 'financial_type' => ts('Financial Type') + 'financial_type' => ts('Financial Type') ); foreach ($requiredFields as $field => $title) { @@ -386,7 +385,8 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { $self->_onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE ) { $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " $fieldMessage " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array( - 1 => $threshold)) . '
'; + 1 => $threshold + )) . '
'; } elseif ($self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE && !(in_array('invoice_id', $importKeys) || in_array('trxn_id', $importKeys) || @@ -399,7 +399,8 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { else { if ($self->_onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) { $errors['_qf_default'] .= ts('Missing required field: %1', array( - 1 => $title)) . '
'; + 1 => $title + )) . '
'; } } } diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index 14dce5b34e..21943c2b7a 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -73,18 +73,24 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa $fields = CRM_Contribute_BAO_Contribution::importableFields($this->_contactType, FALSE); $fields = array_merge($fields, - array('soft_credit' => array('title' => ts('Soft Credit'), - 'softCredit' => TRUE, - 'headerPattern' => '/Soft Credit/i', - )) + array( + 'soft_credit' => array( + 'title' => ts('Soft Credit'), + 'softCredit' => TRUE, + 'headerPattern' => '/Soft Credit/i', + ) + ) ); // add pledge fields only if its is enabled if (CRM_Core_Permission::access('CiviPledge')) { - $pledgeFields = array('pledge_payment' => array('title' => ts('Pledge Payment'), + $pledgeFields = array( + 'pledge_payment' => array( + 'title' => ts('Pledge Payment'), 'headerPattern' => '/Pledge Payment/i', ), - 'pledge_id' => array('title' => ts('Pledge ID'), + 'pledge_id' => array( + 'title' => ts('Pledge ID'), 'headerPattern' => '/Pledge ID/i', ), ); @@ -388,15 +394,14 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa 'contribution_id' => $ids['contribution'], ); - //FIXE ME: Need to fix this logic - $existingSoftCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dupeSoftCredit); + //FIX ME: Need to fix this logic + $existingSoftCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dupeSoftCredit['contribution_id']); if (CRM_Utils_Array::value('soft_credit_id', $existingSoftCredit)) { $formatted['softID'] = $existingSoftCredit['soft_credit_id']; } } $newContribution = CRM_Contribute_BAO_Contribution::create($formatted, $ids); - $this->_newContributions[] = $newContribution->id; //return soft valid since we need to show how soft credits were added diff --git a/CRM/Utils/DeprecatedUtils.php b/CRM/Utils/DeprecatedUtils.php index c6c23ddd9d..a5f8292792 100644 --- a/CRM/Utils/DeprecatedUtils.php +++ b/CRM/Utils/DeprecatedUtils.php @@ -25,8 +25,6 @@ +--------------------------------------------------------------------+ */ - - /* * These functions have been deprecated out of API v3 Utils folder as they are not part of the * API. Calling API functions directly is not supported & these functions are not called by any @@ -34,12 +32,8 @@ * */ - - require_once 'api/v3/utils.php'; - - /** * take the input parameter list as specified in the data model and * convert it into the same format that we use in QF and BAO object @@ -72,7 +66,7 @@ function _civicrm_api3_deprecated_participant_formatted_param($params, &$values, $values[$key] = $value; $type = $customFields[$customFieldID]['html_type']; if ($type == 'CheckBox' || $type == 'Multi-Select') { - $mulValues = explode(',', $value); + $mulValues = explode(',', $value); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); $values[$key] = array(); foreach ($mulValues as $v1) { @@ -94,7 +88,7 @@ function _civicrm_api3_deprecated_participant_formatted_param($params, &$values, elseif ($type == 'Select' || $type == 'Radio') { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); foreach ($customOption as $customFldID => $customValue) { - $val = CRM_Utils_Array::value('value', $customValue); + $val = CRM_Utils_Array::value('value', $customValue); $label = CRM_Utils_Array::value('label', $customValue); $label = strtolower($label); $value = strtolower(trim($value)); @@ -110,9 +104,9 @@ function _civicrm_api3_deprecated_participant_formatted_param($params, &$values, if (!CRM_Utils_Rule::integer($value)) { return civicrm_api3_create_error("contact_id not valid: $value"); } - $dao = new CRM_Core_DAO(); + $dao = new CRM_Core_DAO(); $qParams = array(); - $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = $value", + $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = $value", $qParams ); if (!$svq) { @@ -137,9 +131,9 @@ function _civicrm_api3_deprecated_participant_formatted_param($params, &$values, if (!CRM_Utils_Rule::integer($value)) { return civicrm_api3_create_error("Event ID is not valid: $value"); } - $dao = new CRM_Core_DAO(); + $dao = new CRM_Core_DAO(); $qParams = array(); - $svq = $dao->singleValueQuery("SELECT id FROM civicrm_event WHERE id = $value", + $svq = $dao->singleValueQuery("SELECT id FROM civicrm_event WHERE id = $value", $qParams ); if (!$svq) { @@ -244,7 +238,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F $values[$key] = $value; $type = $customFields[$customFieldID]['html_type']; if ($type == 'CheckBox' || $type == 'Multi-Select') { - $mulValues = explode(',', $value); + $mulValues = explode(',', $value); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); $values[$key] = array(); foreach ($mulValues as $v1) { @@ -270,7 +264,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F ) { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); foreach ($customOption as $customFldID => $customValue) { - $val = CRM_Utils_Array::value('value', $customValue); + $val = CRM_Utils_Array::value('value', $customValue); $label = CRM_Utils_Array::value('label', $customValue); $label = strtolower($label); $value = strtolower(trim($value)); @@ -286,9 +280,9 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F if (!CRM_Utils_Rule::integer($value)) { return civicrm_api3_create_error("contact_id not valid: $value"); } - $dao = new CRM_Core_DAO(); + $dao = new CRM_Core_DAO(); $qParams = array(); - $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = $value", + $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = $value", $qParams ); if (!$svq) { @@ -303,12 +297,12 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F //import contribution record according to select contact type require_once 'CRM/Contact/DAO/Contact.php'; $contactType = new CRM_Contact_DAO_Contact(); - //when insert mode check contact id or external identifire - if ($params['contribution_contact_id'] || $params['external_identifier']) { - if ($params['contribution_contact_id']) { - $contactType->id = $params['contribution_contact_id']; + //when insert mode check contact id or external identifier + if (!empty($params['contribution_contact_id']) || !empty($params['external_identifier'])) { + if (!empty($params['contribution_contact_id'])) { + $contactType->id = CRM_Utils_Array::value('contribution_contact_id', $params); } - elseif ($params['external_identifier']) { + elseif (!empty($params['external_identifier'])) { $contactType->external_identifier = $params['external_identifier']; } if ($contactType->find(TRUE)) { @@ -418,9 +412,6 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F if (!$contact->find(TRUE)) { $errorMsg = ts("No match found for specified Soft Credit contact data. Row was skipped."); } - elseif ($params['contact_type'] != $contact->contact_type) { - $errorMsg = ts("Soft Credit Contact Type is wrong: %1", array(1 => $contact->contact_type)); - } if ($errorMsg) { return civicrm_api3_create_error($errorMsg, 'soft_credit'); @@ -430,7 +421,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F $values['soft_credit_to'] = $contact->id; } else { - // get the contact id from dupicate contact rule, if more than one contact is returned + // get the contact id from duplicate contact rule, if more than one contact is returned // we should return error, since current interface allows only one-one mapping $softParams = $params['soft_credit']; @@ -696,7 +687,7 @@ function _civicrm_api3_deprecated_activity_formatted_param(&$params, &$values, $ $values[$key] = $value; $type = $customFields[$customFieldID]['html_type']; if ($type == 'CheckBox' || $type == 'Multi-Select') { - $mulValues = explode(',', $value); + $mulValues = explode(',', $value); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); $values[$key] = array(); foreach ($mulValues as $v1) { @@ -718,7 +709,7 @@ function _civicrm_api3_deprecated_activity_formatted_param(&$params, &$values, $ elseif ($type == 'Select' || $type == 'Radio') { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); foreach ($customOption as $customFldID => $customValue) { - $val = CRM_Utils_Array::value('value', $customValue); + $val = CRM_Utils_Array::value('value', $customValue); $label = CRM_Utils_Array::value('label', $customValue); $label = strtolower($label); $value = strtolower(trim($value)); @@ -769,8 +760,6 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { * Custom */ - - /* Cache the various object fields */ static $fields = NULL; @@ -786,8 +775,6 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { if (isset($values['contact_type'])) { /* we're an individual/household/org property */ - - $fields[$values['contact_type']] = CRM_Contact_DAO_Contact::fields(); _civicrm_api3_store_values($fields[$values['contact_type']], $values, $params); @@ -796,8 +783,7 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { if (isset($values['individual_prefix'])) { if (CRM_Utils_Array::value('prefix_id', $params)) { - $prefixes = array(); - $prefixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); + $prefixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'); $params['prefix'] = $prefixes[$params['prefix_id']]; } else { @@ -808,8 +794,7 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { if (isset($values['individual_suffix'])) { if (CRM_Utils_Array::value('suffix_id', $params)) { - $suffixes = array(); - $suffixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); + $suffixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'); $params['suffix'] = $suffixes[$params['suffix_id']]; } else { @@ -821,8 +806,8 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { //CRM-4575 if (isset($values['email_greeting'])) { if (CRM_Utils_Array::value('email_greeting_id', $params)) { - $emailGreetings = array(); - $emailGreetingFilter = array('contact_type' => CRM_Utils_Array::value('contact_type', $params), + $emailGreetingFilter = array( + 'contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'email_greeting', ); $emailGreetings = CRM_Core_PseudoConstant::greeting($emailGreetingFilter); @@ -837,8 +822,8 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { if (isset($values['postal_greeting'])) { if (CRM_Utils_Array::value('postal_greeting_id', $params)) { - $postalGreetings = array(); - $postalGreetingFilter = array('contact_type' => CRM_Utils_Array::value('contact_type', $params), + $postalGreetingFilter = array( + 'contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'postal_greeting', ); $postalGreetings = CRM_Core_PseudoConstant::greeting($postalGreetingFilter); @@ -852,8 +837,8 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { if (isset($values['addressee'])) { if (CRM_Utils_Array::value('addressee_id', $params)) { - $addressee = array(); - $addresseeFilter = array('contact_type' => CRM_Utils_Array::value('contact_type', $params), + $addresseeFilter = array( + 'contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'addressee', ); $addressee = CRM_Core_PseudoConstant::addressee($addresseeFilter); @@ -867,8 +852,7 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { if (isset($values['gender'])) { if (CRM_Utils_Array::value('gender_id', $params)) { - $genders = array(); - $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); + $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); $params['gender'] = $genders[$params['gender_id']]; } else { @@ -878,10 +862,8 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { } if (isset($values['preferred_communication_method'])) { - $comm = array(); - $preffComm = array(); - $pcm = array(); - $pcm = array_change_key_case(array_flip(CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method')), CASE_LOWER); + $comm = array(); + $pcm = array_change_key_case(array_flip(CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method')), CASE_LOWER); $preffComm = explode(',', $values['preferred_communication_method']); foreach ($preffComm as $v) { @@ -924,8 +906,6 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { if (isset($values['note'])) { /* add a note field */ - - if (!isset($params['note'])) { $params['note'] = array(); } @@ -961,7 +941,6 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) { /* check if it's a valid custom field id */ - if (!array_key_exists($customFieldID, $fields['custom'])) { return civicrm_api3_create_error('Invalid custom field ID'); } @@ -1174,7 +1153,6 @@ function _civicrm_api3_deprecated_duplicate_formatted_contact($params) { function _civicrm_api3_deprecated_validate_formatted_contact(&$params) { /* Look for offending email addresses */ - if (array_key_exists('email', $params)) { foreach ($params['email'] as $count => $values) { if (!is_array($values)) { @@ -1195,8 +1173,6 @@ function _civicrm_api3_deprecated_validate_formatted_contact(&$params) { } /* Validate custom data fields */ - - if (array_key_exists('custom', $params) && is_array($params['custom'])) { foreach ($params['custom'] as $key => $custom) { if (is_array($custom)) { @@ -1325,8 +1301,6 @@ function _civicrm_api3_deprecated_contact_check_custom_params($params, $csType = foreach ($params as $key => $value) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) { /* check if it's a valid custom field id */ - - if (!array_key_exists($customFieldID, $customFields)) { $errorMsg = "Invalid Custom Field Contact Type: {$params['contact_type']}"; -- 2.25.1