Minor cleanup on status setting.
authoreileen <emcnaughton@wikimedia.org>
Sun, 11 Aug 2019 22:33:09 +0000 (10:33 +1200)
committereileen <emcnaughton@wikimedia.org>
Sun, 11 Aug 2019 22:33:33 +0000 (10:33 +1200)
It appears that this complicated handling is because in the past the setStatus did not have the
ability to ensure a given message was set only once - hence it's being set multiple times

CRM/Contact/Import/Form/MapField.php

index df77083cca2c33b163355ecc21cd9f26594203d2..3fac62a87729207997a575024b2c8a228abccc61 100644 (file)
@@ -395,7 +395,8 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField {
     $js = "<script type='text/javascript'>\n";
     $formName = 'document.forms.' . $this->_name;
     //used to warn for mismatch column count or mismatch mapping
-    $warning = 0;
+    CRM_Core_Session::singleton()->setStatus(NULL);
+
     for ($i = 0; $i < $this->_columnCount; $i++) {
       $sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', [1 => $i]), NULL);
 
@@ -441,16 +442,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField {
     if (isset($mappingName) &&
       ($this->_columnCount != count($mappingName))
     ) {
-      $warning++;
-    }
-
-    if ($warning != 0 && $this->get('savedMapping')) {
-      $session = CRM_Core_Session::singleton();
-      $session->setStatus(ts('The data columns in this import file appear to be different from the saved mapping. Please verify that you have selected the correct saved mapping before continuing.'));
-    }
-    else {
-      $session = CRM_Core_Session::singleton();
-      $session->setStatus(NULL);
+      CRM_Core_Session::singleton()->setStatus(ts('The data columns in this import file appear to be different from the saved mapping. Please verify that you have selected the correct saved mapping before continuing.'));
     }
 
     $this->setDefaults($defaults);