From a5611c8ef237e6c80d559e9bad84803e893fc830 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Wed, 6 Mar 2013 21:53:02 -0800 Subject: [PATCH] fix notices for PHP 5.4 --- CRM/ACL/BAO/ACL.php | 3 +- CRM/Contact/Form/Task/EmailCommon.php | 7 +++- CRM/Core/BAO/LabelFormat.php | 2 +- CRM/Core/BAO/PaperSize.php | 2 +- CRM/Core/DAO.php | 2 +- CRM/Event/Form/Search.php | 18 ++++----- CRM/Report/Form/Event/Income.php | 55 ++++++++++++++------------- CRM/Utils/PDF/Label.php | 4 +- 8 files changed, 49 insertions(+), 44 deletions(-) diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 53e01fa48c..0562921998 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -500,7 +500,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { $rule->query($query); while ($rule->fetch()) { - $results[$rule->id] = &$rule->toArray(); + $results[$rule->id] = $rule->toArray(); } return $results; @@ -699,7 +699,6 @@ SELECT count( a.id ) } public static function whereClause($type, &$tables, &$whereTables, $contactID = NULL) { - $acls = CRM_ACL_BAO_Cache::build($contactID); //CRM_Core_Error::debug( "a: $contactID", $acls ); diff --git a/CRM/Contact/Form/Task/EmailCommon.php b/CRM/Contact/Form/Task/EmailCommon.php index c668220ffa..2694d6a8dd 100644 --- a/CRM/Contact/Form/Task/EmailCommon.php +++ b/CRM/Contact/Form/Task/EmailCommon.php @@ -402,8 +402,11 @@ class CRM_Contact_Form_Task_EmailCommon { CRM_Core_Session::setStatus(ts('One message was sent successfully.', array('plural' => '%count messages were sent successfully.', 'count' => $count_success)), ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $count_success)), 'success'); } - //Display the name and number of contacts for those email is not sent. - $emailsNotSent = array_diff_assoc($form->_allContactDetails, $form->_contactDetails); + // Display the name and number of contacts for those email is not sent. + // php 5.4 throws out a notice since the values of these below arrays are arrays. + // the behavior is not documented in the php manual, but it does the right thing + // suppressing the notices to get things in good shape going forward + $emailsNotSent = @array_diff_assoc($form->_allContactDetails, $form->_contactDetails); if ($emailsNotSent) { $not_sent = array(); diff --git a/CRM/Core/BAO/LabelFormat.php b/CRM/Core/BAO/LabelFormat.php index 08f8ac64dd..1830c2a81d 100644 --- a/CRM/Core/BAO/LabelFormat.php +++ b/CRM/Core/BAO/LabelFormat.php @@ -230,7 +230,7 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * @return int Group ID (null if Group ID doesn't exist) * @access private */ - private function _getGid() { + private static function _getGid() { if (!self::$_gid) { self::$_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'label_format', 'id', 'name'); if (!self::$_gid) { diff --git a/CRM/Core/BAO/PaperSize.php b/CRM/Core/BAO/PaperSize.php index b47bf396fd..dab00f4beb 100644 --- a/CRM/Core/BAO/PaperSize.php +++ b/CRM/Core/BAO/PaperSize.php @@ -75,7 +75,7 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { * @return int Group ID (null if Group ID doesn't exist) * @access private */ - private function _getGid() { + private static function _getGid() { if (!self::$_gid) { self::$_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'paper_size', 'id', 'name'); if (!self::$_gid) { diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 2b480de37e..e54678e1a0 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1142,7 +1142,7 @@ FROM civicrm_domain * Given the component id, compute the contact id * since its used for things like send email */ - public function &getContactIDsFromComponent(&$componentIDs, $tableName) { + public static function &getContactIDsFromComponent(&$componentIDs, $tableName) { $contactIDs = array(); if (empty($componentIDs)) { diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index fa45618700..3a66de255b 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -21,7 +21,7 @@ | with this program; if not, contact CiviCRM LLC | | at info[AT]civicrm[DOT]org. If you have questions about the | | GNU Affero General Public License or the licensing of CiviCRM, | - | see the CiviCRM license FAQ at http://civicrm.org/licensing | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ */ @@ -157,9 +157,9 @@ class CRM_Event_Form_Search extends CRM_Core_Form { $this->_done = FALSE; $this->defaults = array(); - /* - * we allow the controller to set force/reset externally, useful when we are being - * driven by the wizard framework + /* + * we allow the controller to set force/reset externally, useful when we are being + * driven by the wizard framework */ $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE); @@ -237,9 +237,9 @@ class CRM_Event_Form_Search extends CRM_Core_Form { CRM_Event_BAO_Query::buildSearchForm($this); - /* - * add form checkboxes for each row. This is needed out here to conform to QF protocol - * of all elements being declared in builQuickForm + /* + * add form checkboxes for each row. This is needed out here to conform to QF protocol + * of all elements being declared in builQuickForm */ $rows = $this->get('rows'); if (is_array($rows)) { @@ -402,7 +402,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form { // check actionName and if next, then do not repeat a search, since we are going to the next page // hack, make sure we reset the task values - $stateMachine = &$this->controller->getStateMachine(); + $stateMachine = $this->controller->getStateMachine(); $formName = $stateMachine->getTaskFormName(); $this->controller->resetPage($formName); return; @@ -445,7 +445,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form { ); $controller->setEmbedded(TRUE); - $query = &$selector->getQuery(); + $query = $selector->getQuery(); if ($this->_context == 'user') { $query->setSkipPermission(TRUE); } diff --git a/CRM/Report/Form/Event/Income.php b/CRM/Report/Form/Event/Income.php index 2b082f3e34..e7c31416f0 100644 --- a/CRM/Report/Form/Event/Income.php +++ b/CRM/Report/Form/Event/Income.php @@ -39,8 +39,9 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { protected $_summary = NULL; protected $_noFields = TRUE; - - protected $_add2groupSupported = FALSE; + + protected $_add2groupSupported = FALSE; + function __construct() { $this->_columns = array( @@ -58,7 +59,7 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { ), ), ); - + parent::__construct(); } @@ -98,22 +99,22 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { $sql = " SELECT civicrm_event.id as event_id, civicrm_event.title as event_title, - civicrm_event.max_participants as max_participants, + civicrm_event.max_participants as max_participants, civicrm_event.start_date as start_date, - civicrm_event.end_date as end_date, - civicrm_option_value.label as event_type, + civicrm_event.end_date as end_date, + civicrm_option_value.label as event_type, SUM(civicrm_participant.fee_amount) as total, COUNT(civicrm_participant.id) as participant FROM civicrm_event - LEFT JOIN civicrm_option_value + LEFT JOIN civicrm_option_value ON ( civicrm_event.event_type_id = civicrm_option_value.value AND civicrm_option_value.option_group_id = {$optionGroupId} ) - LEFT JOIN civicrm_participant ON ( civicrm_event.id = civicrm_participant.event_id + LEFT JOIN civicrm_participant ON ( civicrm_event.id = civicrm_participant.event_id {$activeParticipantClause} AND civicrm_participant.is_test = 0 ) - WHERE civicrm_event.id IN( {$eventID}) - + WHERE civicrm_event.id IN( {$eventID}) + GROUP BY civicrm_event.id "; $eventDAO = CRM_Core_DAO::executeQuery($sql); @@ -135,8 +136,8 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { FROM civicrm_participant - WHERE civicrm_participant.event_id IN( {$eventID}) AND - civicrm_participant.is_test = 0 + WHERE civicrm_participant.event_id IN( {$eventID}) AND + civicrm_participant.is_test = 0 {$activeParticipantClause} GROUP BY civicrm_participant.event_id "; @@ -148,15 +149,15 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { //Count the Participant by Role ID for Event $role = " - SELECT civicrm_participant.role_id as ROLEID, - COUNT( civicrm_participant.id ) as participant, + SELECT civicrm_participant.role_id as ROLEID, + COUNT( civicrm_participant.id ) as participant, SUM(civicrm_participant.fee_amount) as amount, civicrm_participant.event_id as event_id FROM civicrm_participant WHERE civicrm_participant.event_id IN ( {$eventID}) AND - civicrm_participant.is_test = 0 + civicrm_participant.is_test = 0 {$activeParticipantClause} GROUP BY civicrm_participant.role_id, civicrm_participant.event_id "; @@ -189,15 +190,15 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { //Count the Participant by status ID for Event $status = " - SELECT civicrm_participant.status_id as STATUSID, - COUNT( civicrm_participant.id ) as participant, + SELECT civicrm_participant.status_id as STATUSID, + COUNT( civicrm_participant.id ) as participant, SUM(civicrm_participant.fee_amount) as amount, civicrm_participant.event_id as event_id FROM civicrm_participant WHERE civicrm_participant.event_id IN ({$eventID}) AND - civicrm_participant.is_test = 0 + civicrm_participant.is_test = 0 {$activeParticipantClause} GROUP BY civicrm_participant.status_id, civicrm_participant.event_id "; @@ -215,8 +216,8 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { //Count the Participant by payment instrument ID for Event //e.g. Credit Card, Check,Cash etc $paymentInstrument = " - SELECT c.payment_instrument_id as INSTRUMENT, - COUNT( c.id ) as participant, + SELECT c.payment_instrument_id as INSTRUMENT, + COUNT( c.id ) as participant, SUM(civicrm_participant.fee_amount) as amount, civicrm_participant.event_id as event_id @@ -274,7 +275,7 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { $this->_limit = ($pageId - 1) * self::ROW_COUNT_LIMIT; } - function setPager() { + function setPager($rowCount = self::ROW_COUNT_LIMIT) { $params = array( 'total' => $this->_rowsFound, 'rowCount' => self::ROW_COUNT_LIMIT, @@ -307,15 +308,15 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { $this->_params['id_value'][] = $key; } $noSelection = TRUE; - } - + } + $this->_rowsFound = count($this->_params['id_value']); //set pager and limit if output mode is html if ($this->_outputMode == 'html') { $this->limit(); $this->setPager(); - + $showEvents = array(); $count = 0; $numRows = $this->_limit; @@ -325,7 +326,7 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { if (!isset($this->_params['id_value'][$numRows])) { break; } - + $showEvents[] = $this->_params['id_value'][$numRows]; $count++; $numRows++; @@ -334,12 +335,12 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event { $events = CRM_Event_PseudoConstant::event(NULL, NULL, "is_template IS NULL OR is_template = 0" ); - + $showEvents = array_diff(array_keys($events), $this->_params['id_value']); } $this->buildEventReport($showEvents); - + } else { $this->buildEventReport($this->_params['id_value']); diff --git a/CRM/Utils/PDF/Label.php b/CRM/Utils/PDF/Label.php index 35b7e07148..20fef72064 100644 --- a/CRM/Utils/PDF/Label.php +++ b/CRM/Utils/PDF/Label.php @@ -61,6 +61,8 @@ class CRM_Utils_PDF_Label extends TCPDF { public $width; // Height of label public $height; + // Line Height of label - used in event code + public $lineHeight = 0; // Space between text and left edge of label public $paddingLeft; // Space between text and top edge of label @@ -124,7 +126,7 @@ class CRM_Utils_PDF_Label extends TCPDF { $value = $this->format[$name]; $metric = $this->format['metric']; } - else { + else { $value = CRM_Utils_Array::value($name, $this->defaults); $metric = $this->defaults['metric']; } -- 2.25.1