From d4c8a770b826a3fbd9ca781426f32e217a86c49a Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Wed, 20 Mar 2013 18:34:47 -0700 Subject: [PATCH] fix notices and strict warnings from PHP 5.4 in running webtests --- CRM/Dedupe/BAO/RuleGroup.php | 6 ++--- CRM/Import/Form/MapField.php | 2 +- CRM/Import/Page/AJAX.php | 2 +- CRM/Import/Parser/Contact.php | 44 +++++++++++++++++++++-------------- CRM/Utils/Date.php | 2 +- 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/CRM/Dedupe/BAO/RuleGroup.php b/CRM/Dedupe/BAO/RuleGroup.php index 01b981adf0..01298f45eb 100644 --- a/CRM/Dedupe/BAO/RuleGroup.php +++ b/CRM/Dedupe/BAO/RuleGroup.php @@ -353,10 +353,10 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { $this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : ''; } $query = "SELECT dedupe.id1, dedupe.id2, dedupe.weight - FROM dedupe JOIN civicrm_contact c1 ON dedupe.id1 = c1.id + FROM dedupe JOIN civicrm_contact c1 ON dedupe.id1 = c1.id JOIN civicrm_contact c2 ON dedupe.id2 = c2.id {$this->_aclFrom} LEFT JOIN civicrm_dedupe_exception exc ON dedupe.id1 = exc.contact_id1 AND dedupe.id2 = exc.contact_id2 - WHERE c1.contact_type = '{$this->contact_type}' AND + WHERE c1.contact_type = '{$this->contact_type}' AND c2.contact_type = '{$this->contact_type}' {$this->_aclWhere} AND weight >= {$this->threshold} AND exc.contact_id1 IS NULL"; } @@ -373,7 +373,7 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { * @return (rule field => weight) array and threshold associated to rule group * @access public */ - function dedupeRuleFieldsWeight($params) { + static function dedupeRuleFieldsWeight($params) { $rgBao = new CRM_Dedupe_BAO_RuleGroup(); $rgBao->used = $params['used']; $rgBao->contact_type = $params['contact_type']; diff --git a/CRM/Import/Form/MapField.php b/CRM/Import/Form/MapField.php index 2bae0df6e8..15df99eade 100644 --- a/CRM/Import/Form/MapField.php +++ b/CRM/Import/Form/MapField.php @@ -94,7 +94,7 @@ class CRM_Import_Form_MapField extends CRM_Core_Form { * @var array * @access protected */ - protected static $_formattedFieldNames; + protected $_formattedFieldNames; /** * on duplicate diff --git a/CRM/Import/Page/AJAX.php b/CRM/Import/Page/AJAX.php index 46401062a7..38d16c1f14 100644 --- a/CRM/Import/Page/AJAX.php +++ b/CRM/Import/Page/AJAX.php @@ -41,7 +41,7 @@ class CRM_Import_Page_AJAX { /** * Function to show import status */ - function status() { + static function status() { // make sure we get an id if (!isset($_GET['id'])) { return; diff --git a/CRM/Import/Parser/Contact.php b/CRM/Import/Parser/Contact.php index 86df1c22e3..b703f95e21 100644 --- a/CRM/Import/Parser/Contact.php +++ b/CRM/Import/Parser/Contact.php @@ -148,7 +148,11 @@ class CRM_Import_Parser_Contact extends CRM_Import_Parser { } //Relationship importables - $this->_relationships = $relations = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $this->_contactType, FALSE, 'label', TRUE, $this->_contactSubType); + $this->_relationships = $relations = + CRM_Contact_BAO_Relationship::getContactRelationshipType( + NULL, NULL, NULL, $this->_contactType, + FALSE, 'label', TRUE, $this->_contactSubType + ); asort($relations); foreach ($relations as $key => $var) { @@ -395,8 +399,15 @@ class CRM_Import_Parser_Contact extends CRM_Import_Parser { $errorMessage = NULL; + //CRM-5125 + //add custom fields for contact sub type + $csType = NULL; + if (!empty($this->_contactSubType)) { + $csType = $this->_contactSubType; + } + //checking error in custom data - $this->isErrorInCustomData($params, $errorMessage); + $this->isErrorInCustomData($params, $errorMessage, $csType, $this->_relationships); //checking error in core data $this->isErrorInCoreData($params, $errorMessage); @@ -798,7 +809,7 @@ class CRM_Import_Parser_Contact extends CRM_Import_Parser { $relatedCsType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$key]['id'], 'contact_sub_type'); } - if (!empty($relatedCsType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params[$key]['id'], $relatedCsType) && + if (!empty($relatedCsType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params[$key]['id'], $relatedCsType) && $relatedCsType != CRM_Utils_Array::value('contact_sub_type', $formatting))) { $errorMessage = ts("Mismatched or Invalid contact subtype found for this related contact ID: %1", array(1 => $params[$key]['id'])); array_unshift($values, $errorMessage); @@ -1107,20 +1118,14 @@ class CRM_Import_Parser_Contact extends CRM_Import_Parser { * * @access public */ - function isErrorInCustomData($params, &$errorMessage) { + static function isErrorInCustomData($params, &$errorMessage, $csType = NULL, $relationships = NULL) { $session = CRM_Core_Session::singleton(); $dateType = $session->get("dateTypes"); - //CRM-5125 - //add custom fields for contact sub type - $csType = NULL; - if (!empty($this->_contactSubType)) { - $csType = $this->_contactSubType; - } - if (CRM_Utils_Array::value('contact_sub_type', $params)) { $csType = CRM_Utils_Array::value('contact_sub_type', $params); } + if (!CRM_Utils_Array::value('contact_type', $params)) { $params['contact_type'] = 'Individual'; } @@ -1256,11 +1261,14 @@ class CRM_Import_Parser_Contact extends CRM_Import_Parser { elseif (is_array($params[$key]) && isset($params[$key]["contact_type"])) { //CRM-5125 //supporting custom data of related contact subtypes - if (array_key_exists($key, $this->_relationships)) { - $relation = $key; - } - elseif (CRM_Utils_Array::key($key, $this->_relationships)) { - $relation = CRM_Utils_Array::key($key, $this->_relationships); + $relation = NULL; + if ($relationships) { + if (array_key_exists($key, $relationships)) { + $relation = $key; + } + elseif (CRM_Utils_Array::key($key, $relationships)) { + $relation = CRM_Utils_Array::key($key, $relationships); + } } if (!empty($relation)) { list($id, $first, $second) = CRM_Utils_System::explode('_', $relation, 3); @@ -1275,7 +1283,7 @@ class CRM_Import_Parser_Contact extends CRM_Import_Parser { $relationshipType->free(); } - self::isErrorInCustomData($params[$key], $errorMessage); + self::isErrorInCustomData($params[$key], $errorMessage, $csType, $relationships); } } } @@ -1393,7 +1401,7 @@ class CRM_Import_Parser_Contact extends CRM_Import_Parser { if (!empty($value)) { foreach ($value as $stateValue) { if ($stateValue['state_province']) { - if (self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvinceAbbreviation()) || + if (self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvinceAbbreviation()) || self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvince())) { continue; } diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index 0755397916..e0604fc118 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -474,7 +474,7 @@ class CRM_Utils_Date { * @param string $dateParam index of params * @static */ - function convertToDefaultDate(&$params, $dateType, $dateParam) { + static function convertToDefaultDate(&$params, $dateType, $dateParam) { $now = getDate(); $cen = substr($now['year'], 0, 2); $prevCen = $cen - 1; -- 2.25.1