From 361fb6c0ea67ded937c0154f490733aea59d6d09 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Thu, 21 Mar 2013 20:43:41 -0700 Subject: [PATCH] fix notices and PHP 5.4 warnings --- CRM/Contribute/BAO/Contribution/Utils.php | 6 +-- CRM/Custom/Form/Option.php | 50 +++++++++++++++-------- CRM/Utils/Mail.php | 19 +++++---- 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index fedd339a41..37db9cd461 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -183,7 +183,7 @@ class CRM_Contribute_BAO_Contribution_Utils { // determine if express + recurring and direct accordingly if ($paymentParams['is_recur'] == 1) { if (is_object($payment)) { - $result = &$payment->createRecurringPayments($paymentParams); + $result = $payment->createRecurringPayments($paymentParams); } else { CRM_Core_Error::fatal($paymentObjError); @@ -191,7 +191,7 @@ class CRM_Contribute_BAO_Contribution_Utils { } else { if (is_object($payment)) { - $result = &$payment->doExpressCheckout($paymentParams); + $result = $payment->doExpressCheckout($paymentParams); } else { CRM_Core_Error::fatal($paymentObjError); @@ -227,7 +227,7 @@ class CRM_Contribute_BAO_Contribution_Utils { } } if (is_object($payment)) { - $result = &$payment->doDirectPayment($paymentParams); + $result = $payment->doDirectPayment($paymentParams); } else { CRM_Core_Error::fatal($paymentObjError); diff --git a/CRM/Custom/Form/Option.php b/CRM/Custom/Form/Option.php index fb34d50ad0..ae97f4330e 100644 --- a/CRM/Custom/Form/Option.php +++ b/CRM/Custom/Form/Option.php @@ -250,7 +250,7 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { $temp = array(); if (empty($form->_id)) { $query = " -SELECT count(*) +SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND label = %2"; @@ -262,7 +262,7 @@ SELECT count(*) } $query = " -SELECT count(*) +SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND value = %2"; @@ -279,7 +279,7 @@ SELECT count(*) //check label duplicates within a custom field $query = " -SELECT count(*) +SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND id != %2 @@ -294,7 +294,7 @@ SELECT count(*) //check value duplicates within a custom field $query = " -SELECT count(*) +SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND id != %2 @@ -309,7 +309,7 @@ SELECT count(*) } $query = " -SELECT data_type +SELECT data_type FROM civicrm_custom_field WHERE id = %1"; $params = array(1 => array($fieldId, 'Integer')); @@ -363,7 +363,7 @@ SELECT data_type if (!empty($fields["value"])) { $params = array(1 => array($fields['value'], 'String')); $query = " -SELECT count(*) +SELECT count(*) FROM civicrm_state_province WHERE name = %1 OR abbreviation = %1"; @@ -414,19 +414,27 @@ SELECT count(*) } $fieldValues = array('option_group_id' => $this->_optionGroupID); - $customOption->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, $params['weight'], $fieldValues); + $customOption->weight = + CRM_Utils_Weight::updateOtherWeights( + 'CRM_Core_DAO_OptionValue', + $oldWeight, + $params['weight'], + $fieldValues); $customOption->option_group_id = $this->_optionGroupID; $customField = new CRM_Core_DAO_CustomField(); $customField->id = $this->_fid; - if ($customField->find(TRUE) && - ($customField->html_type == 'CheckBox' || + if ( + $customField->find(TRUE) && + ( + $customField->html_type == 'CheckBox' || $customField->html_type == 'AdvMulti-Select' || $customField->html_type == 'Multi-Select' ) ) { - $defVal = explode(CRM_Core_DAO::VALUE_SEPARATOR, + $defVal = explode( + CRM_Core_DAO::VALUE_SEPARATOR, substr($customField->default_value, 1, -1) ); if (CRM_Utils_Array::value('default_value', $params)) { @@ -437,7 +445,10 @@ SELECT count(*) else { $defVal[] = $customOption->value; } - $customField->default_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $defVal) . CRM_Core_DAO::VALUE_SEPARATOR; + $customField->default_value = + CRM_Core_DAO::VALUE_SEPARATOR . + implode(CRM_Core_DAO::VALUE_SEPARATOR, $defVal) . + CRM_Core_DAO::VALUE_SEPARATOR; $customField->save(); } } @@ -449,7 +460,10 @@ SELECT count(*) } } - $customField->default_value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $tempVal) . CRM_Core_DAO::VALUE_SEPARATOR; + $customField->default_value = + CRM_Core_DAO::VALUE_SEPARATOR . + implode(CRM_Core_DAO::VALUE_SEPARATOR, $tempVal) . + CRM_Core_DAO::VALUE_SEPARATOR; $customField->save(); } } @@ -481,14 +495,18 @@ SELECT count(*) $customOption->save(); - CRM_Core_Session::setStatus(ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label)), '', 'success'); + $msg = ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label)); + CRM_Core_Session::setStatus($msg, '', 'success'); $buttonName = $this->controller->getButtonName(); $session = CRM_Core_Session::singleton(); if ($buttonName == $this->getButtonName('next', 'new')) { - CRM_Core_Session::setStatus(ts(' You can add another option.'), '', 'info'); - $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field/option', + CRM_Core_Session::setStatus(ts('You can add another option.'), '', 'info'); + $session->replaceUserContext( + CRM_Utils_System::url( + 'civicrm/admin/custom/group/field/option', 'reset=1&action=add&fid=' . $this->_fid . '&gid=' . $this->_gid - )); + ) + ); } } } diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index 389fd2b374..acde69a715 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -72,7 +72,8 @@ class CRM_Utils_Mail { CRM_Utils_Hook::alterMailParams($params); // check if any module has aborted mail sending - if (CRM_Utils_Array::value('abortMailSend', $params) || + if ( + CRM_Utils_Array::value('abortMailSend', $params) || !CRM_Utils_Array::value('toEmail', $params) ) { return FALSE; @@ -93,10 +94,12 @@ class CRM_Utils_Mail { $headers = array_merge($headers, $params['headers']); } $headers['From'] = $params['from']; - $headers['To'] = self::formatRFC822Email(CRM_Utils_Array::value('toName', $params), - CRM_Utils_Array::value('toEmail', $params), - FALSE - ); + $headers['To'] = + self::formatRFC822Email( + CRM_Utils_Array::value('toName', $params), + CRM_Utils_Array::value('toEmail', $params), + FALSE + ); $headers['Cc'] = CRM_Utils_Array::value('cc', $params); $headers['Bcc'] = CRM_Utils_Array::value('bcc', $params); $headers['Subject'] = CRM_Utils_Array::value('subject', $params); @@ -104,8 +107,10 @@ class CRM_Utils_Mail { $headers['Content-Disposition'] = 'inline'; $headers['Content-Transfer-Encoding'] = '8bit'; $headers['Return-Path'] = CRM_Utils_Array::value('returnPath', $params); + // CRM-11295: Omit reply-to headers if empty; this avoids issues with overzealous mailservers $replyTo = CRM_Utils_Array::value('replyTo', $params, $from); + if (!empty($replyTo)) { $headers['Reply-To'] = $replyTo; } @@ -171,15 +176,15 @@ class CRM_Utils_Mail { $result = NULL; $mailer = CRM_Core_Config::getMailer(); - CRM_Core_Error::ignoreException(); if (is_object($mailer)) { + CRM_Core_Error::ignoreException(); $result = $mailer->send($to, $headers, $message); CRM_Core_Error::setCallback(); if (is_a($result, 'PEAR_Error')) { $message = self::errorMessage($mailer, $result); // append error message in case multiple calls are being made to // this method in the course of sending a batch of messages. - CRM_Core_Session::setStatus(ts($message), ts('Mailing Error'), 'error'); + CRM_Core_Session::setStatus($message, ts('Mailing Error'), 'error'); return FALSE; } // CRM-10699 -- 2.25.1