Commits

zurmo committed 339782f Merge

Merged in hugohabels/zurmo (pull request #63)

Comments (0)

Files changed (2)

app/protected/modules/import/controllers/DefaultController.php

             $import           = Import::getById((int)$id);
             $importWizardForm = ImportWizardUtil::makeFormByImport($import);
             $importWizardForm->setAttributes($_POST['ImportWizardForm']);
-            if (!$importWizardForm->validate(array('rowColumnDelimiter')))
+            if (!$importWizardForm->validateRowColumnDelimeterIsNotEmpty())
             {
                 $fileUploadData = array('error' => Yii::t('Default', 'Error: Invalid delimiter'));
             }
-            elseif (!$importWizardForm->validate(array('rowColumnDelimiter')))
+            elseif (!$importWizardForm->validateRowColumnEnclosureIsNotEmpty())
             {
                 $fileUploadData = array('error' => Yii::t('Default', 'Error: Invalid qualifier'));
             }

app/protected/modules/import/forms/ImportWizardForm.php

                                                array('{message}' => $e->getMessage())));
             }
         }
+        /**
+         * Validation used when a file is uploaded on the import section. 
+         * It validates that a column delimeter value was introduced on the form.
+         * @return bool If the value is not empty, returns true, otherwise returns false.
+         */
+        public function validateRowColumnDelimeterIsNotEmpty() {
+            if (empty($this->rowColumnDelimiter))
+            {
+                return false;
+            }
+            return true;
+        }
+        /**
+         * Validation used when a file is uploaded on the import section. 
+         * It validates that a column enclosure value was introduced on the form.
+         * @return bool If the value is not empty, returns true, otherwise returns false.
+         */
+        public function validateRowColumnEnclosureIsNotEmpty() {
+            if (empty($this->rowColumnEnclosure))
+            {
+                return false;
+            }
+            return true;
+        }
     }
 ?>