]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttOrgImportHelper.class.php
Improved handlng of import.
[timetracker.git] / WEB-INF / lib / ttOrgImportHelper.class.php
index ff3376d329fac9c39dc78a08fb00996e44e7fb2b..e95b836de90ba5adbcba542a9e3ef4a07992241c 100644 (file)
@@ -499,6 +499,11 @@ class ttOrgImportHelper {
   function importXml() {
     global $i18n;
 
+    if (!$_FILES['xmlfile']['name']) {
+      $this->errors->add($i18n->get('error.upload'));
+      return; // There is nothing to do if we don't have a file.
+    }
+
     // Do we have a compressed file?
     $compressed = false;
     $file_ext = substr($_FILES['xmlfile']['name'], strrpos($_FILES['xmlfile']['name'], '.') + 1);
@@ -551,11 +556,11 @@ class ttOrgImportHelper {
     $this->firstPass = false; // We are done with 1st pass.
     xml_parser_free($parser);
     if ($file) fclose($file);
-    if (!$this->canImport) {
+    if ($this->errors->yes()) {
+      // Remove the file and exit if we have errors.
       unlink($filename);
       return;
     }
-    if ($this->errors->yes()) return; // Exit if we have errors.
 
     // Now we can do a second pass, where real work is done.
     $parser = xml_parser_create();