fix notices and strict warnings from PHP 5.4 in running webtests
authorDonald A. Lobo <lobo@civicrm.org>
Thu, 21 Mar 2013 01:34:47 +0000 (18:34 -0700)
committerDonald A. Lobo <lobo@civicrm.org>
Thu, 21 Mar 2013 01:49:27 +0000 (18:49 -0700)
CRM/Dedupe/BAO/RuleGroup.php
CRM/Import/Form/MapField.php
CRM/Import/Page/AJAX.php
CRM/Import/Parser/Contact.php
CRM/Utils/Date.php

index 01b981adf0795345c0310b5946ba2478537c8ea9..01298f45eb2648274ae0199a67eb3cbbf3e1407b 100644 (file)
@@ -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'];
index 2bae0df6e889e43ed79058e6dc1036de3f84e16c..15df99eadedce0cff9b31643d7a3232020b33b78 100644 (file)
@@ -94,7 +94,7 @@ class CRM_Import_Form_MapField extends CRM_Core_Form {
    * @var array
    * @access protected
    */
-  protected static $_formattedFieldNames;
+  protected $_formattedFieldNames;
 
   /**
    * on duplicate
index 46401062a73930ed3db7e306b0a4aede941496a1..38d16c1f145c58681a02de7d8783c0d3617d9852 100644 (file)
@@ -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;
index 86df1c22e39933f0f798e3922c3aeec1dbe0a84b..b703f95e212286fcb7ba55bcce08abe8ae1d3748 100644 (file)
@@ -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;
                   }
index 0755397916869aa376a519f8ad06dd8566b76dbe..e0604fc118e76874f4bd9c277aef7b6427e2f3c0 100644 (file)
@@ -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;