]> wagnertech.de Git - timetracker.git/commitdiff
ttOrgImportHelper class impoved to output conflicting login names.
authorNik Okuntseff <support@anuko.com>
Fri, 9 Nov 2018 14:25:57 +0000 (14:25 +0000)
committerNik Okuntseff <support@anuko.com>
Fri, 9 Nov 2018 14:25:57 +0000 (14:25 +0000)
31 files changed:
WEB-INF/lib/ttOrgImportHelper.class.php
WEB-INF/resources/ca.lang.php
WEB-INF/resources/cs.lang.php
WEB-INF/resources/da.lang.php
WEB-INF/resources/de.lang.php
WEB-INF/resources/en.lang.php
WEB-INF/resources/es.lang.php
WEB-INF/resources/et.lang.php
WEB-INF/resources/fa.lang.php
WEB-INF/resources/fi.lang.php
WEB-INF/resources/fr.lang.php
WEB-INF/resources/gr.lang.php
WEB-INF/resources/he.lang.php
WEB-INF/resources/hu.lang.php
WEB-INF/resources/it.lang.php
WEB-INF/resources/ja.lang.php
WEB-INF/resources/ko.lang.php
WEB-INF/resources/nl.lang.php
WEB-INF/resources/no.lang.php
WEB-INF/resources/pl.lang.php
WEB-INF/resources/pt-br.lang.php
WEB-INF/resources/pt.lang.php
WEB-INF/resources/ro.lang.php
WEB-INF/resources/ru.lang.php
WEB-INF/resources/sk.lang.php
WEB-INF/resources/sl.lang.php
WEB-INF/resources/sr.lang.php
WEB-INF/resources/sv.lang.php
WEB-INF/resources/tr.lang.php
WEB-INF/resources/zh-cn.lang.php
WEB-INF/resources/zh-tw.lang.php

index c70d25805007d7f72f7ee2cf3a2108966fc2057c..b22c4fe3d5387f610639bb98d42d79c80583c45b 100644 (file)
 // +----------------------------------------------------------------------+
 
 import('ttUserHelper');
-import('ttProjectHelper');
-import('ttTaskHelper');
-import('ttInvoiceHelper');
-import('ttTimeHelper');
-import('ttClientHelper');
-import('ttCustomFieldHelper');
-import('ttFavReportHelper');
-import('ttExpenseHelper');
-import('ttRoleHelper');
 
 // ttOrgImportHelper - this class is a future replacement for ttImportHelper.
 // Currently, it is work in progress.
 // When done, it should handle import of complex groups consisting of other groups.
 class ttOrgImportHelper {
   var $errors         = null;    // Errors go here. Set in constructor by reference.
-
-  var $currentElement = array(); // Current element of the XML file we are parsing.
-  var $currentTag     = '';      // XML tag of the current element.
+  var $cannotImport   = null;    // A comma-separated string of entity names that we cannot import.
+                                 // TODO: rename the above to something better.
 
   var $canImport      = true;    // False if we cannot import data due to a login collision.
   var $firstPass      = true;    // True during first pass through the file.
-
   var $org_id         = null;    // Organization id (same as top group_id).
   var $current_parent_group_id = null; // Current parent group id as we parse the file.
                                        // Set when we create a new group.
@@ -71,38 +60,32 @@ class ttOrgImportHelper {
 
   // startElement - callback handler for opening tag of an XML element in the file.
   function startElement($parser, $name, $attrs) {
-/*
-    if ($name == 'GROUP'
-      || $name == 'USER') {
-      $this->currentElement = $attrs;
-    }
-    $this->currentTag = $name;
-*/
+
     // First pass. We only check user logins for potential collisions with existing.
     if ($this->firstPass) {
       if ($name == 'USER' && $this->canImport) {
-        if ('' != $attrs['STATUS'] && ttUserHelper::getUserByLogin($attrs['LOGIN'])) {
-          // We have a login collision, cannot import any data.
-          $this->canImport = false;
+        $login = $attrs['LOGIN'];
+        if ('' != $attrs['STATUS'] && ttUserHelper::getUserByLogin($login)) {
+          // We have a login collision. Append colliding login to a list of things we cannot import.
+          $this->cannotImport .= ($this->cannotImport ? ", $login" : $login);
         }
       }
-      //$this->currentTag = '';
     }
 
     // Second pass processing. We import data here, one tag at a time.
     if (!$this->firstPass && $this->canImport) {
       $mdb2 = getConnection();
 
-      // We are in second pass through the XML file and can import data.
+      // We are in second pass and can import data.
       if ($name == 'GROUP') {
         // Create a new group.
         $group_id = $this->createGroup(array(
           'parent_id' => $this->current_parent_group_id,
           'org_id' => $this->org_id,
-          'name' => $this->currentElement['NAME'],
-          'currency' => $this->currentElement['CURRENCY'],
-          'lang' => $this->currentElement['LANG']));
-        // We only have 3 properties in export at the moment, while work is ongoing...
+          'name' => $attrs['NAME'],
+          'currency' => $attrs['CURRENCY'],
+          'lang' => $attrs['LANG']));
+        // We only have 3 properties at the moment, while work is ongoing...
 
         // Special handling for top group.
         if (!$this->org_id) {
@@ -128,8 +111,7 @@ class ttOrgImportHelper {
       if ($name == 'ROLE') {
         // We get here when processing a <role> tag for the current group.
         // Add new role to $this->currentGroupRoles and a mapping to $this->currentGroupRoleMap.
-        $this->currentGroupRoles[$this->currentElement['ID']] = $this->currentElement;
-      $this->currentElement = array();
+        $this->currentGroupRoles[$attrs['ID']] = $attrs;
       }
     }
   }
@@ -185,11 +167,13 @@ class ttOrgImportHelper {
           xml_error_string(xml_get_error_code($parser)),
           xml_get_current_line_number($parser)));
       }
-      if (!$this->canImport) {
-        $this->errors->add($i18n->get('error.user_exists'));
-        break;
-      }
     }
+    if ($this->cannotImport) {
+      $this->canImport = false;
+      $this->errors->add($i18n->get('error.user_exists'));
+      $this->errors->add(sprintf($i18n->get('error.cannot_import'), $this->cannotImport));
+    }
+
     $this->firstPass = false; // We are done with 1st pass.
     xml_parser_free($parser);
     if ($file) fclose($file);
index 64a3b86a64a743a03ea4d3044ca8f777327807f0..2a74077ead8881fb9a645ace83448aed4435e8c9 100644 (file)
@@ -116,6 +116,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Iniciar sessió',
index 1cc0734d1dac76b8765f0d2c47b5c399c2a89036..4d593749497b7392ff6ce4905607130ef79d0d00 100644 (file)
@@ -118,6 +118,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Přihlásit',
index 280c9945cdbbb08dc5413c62369cd9975d7c53b3..914bba6d99524f1f39b413e5e655631c54d5c7a4 100644 (file)
@@ -108,6 +108,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Gå til uafsluttet registrering.',
 'error.overlap' => 'Tidsinterval overlapper eksisterende poster.',
 'error.future_date' => 'Datoen er ud i fremtiden.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Log ind',
index 48d5dcfaa6d701da871f79f2ce5eb2f7bff0db4b..9e118e4ac302e1026afc79302ff06bbd006a164a 100644 (file)
@@ -101,6 +101,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Zum unvollständigen Eintrag gehen.',
 'error.overlap' => 'Der Zeitinterval überschneidet sich mit vorhandenen Einträgen.',
 'error.future_date' => 'Datum ist in der Zukunft.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Anmelden',
index a28c87cfa5ebd0589293ca913b65377b7c758e4c..16f61f22a1e1f914af3974cd4a2642a6da981801 100644 (file)
@@ -100,6 +100,7 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 'error.overlap' => 'Time interval overlaps with existing records.',
 'error.future_date' => 'Date is in future.',
+'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Login',
index 28dbb500b51dda90e04954202535b39555b31a27..2ee7de8c30333cc84c753f1ddcb81a87f6ab712f 100644 (file)
@@ -114,6 +114,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Iniciar sesion',
index 8540216325436fac3feb649ce3911892f5218372..86cde2a337f3fc702e24768e5acfbb7c86e5b1c3 100644 (file)
@@ -118,6 +118,8 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Login',
index d220c13d8c84a57b5c7030cf5536ed7232c08699..55625a8832bda0b1278120448ca283f54253887c 100644 (file)
@@ -116,6 +116,7 @@ $i18n_key_words = array(
 'error.overlap' => 'بازه زمانی با سوابق موجود هم پوشانی دارد.',
 // TODO: translate the following.
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'ورود',
index 1e4b86a63920fb3fc79b09f1c5a01b616b888a85..36b4d0bd3195138005f0978f44926215b09bf281 100644 (file)
@@ -110,6 +110,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Siirry kesken olevaan syötteeseen.',
 'error.overlap' => 'Aikavälillä on päällekkäisiä syötteitä.',
 'error.future_date' => 'Aika on tulevaisuudessa.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Kirjaudu',
index 1e64e96d2a211b0a0be1a85a84a0508a825b3a91..6290479f21210178a6d2baa48e993459438d0416 100644 (file)
@@ -108,6 +108,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Aller à l\\\'entrée non terminée.',
 'error.overlap' => 'Les heures des projets ne peuvent se chevaucher.',
 'error.future_date' => 'Date ultérieure.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Connexion',
index 180401534fc066d2e775e146e9973f4cca54c005..f2de6f5199583ee6d91f504595efd3869342a4c7 100644 (file)
@@ -102,6 +102,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Μεταβείτε στην μη ολοκληρωμένη καταχώρηση.',
 'error.overlap' => 'Το χρονικό διάστημα επικαλύπτει υπάρχουσες καταχωρήσεις.',
 'error.future_date' => 'Η ημερομηνία είναι στο μέλλον.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Σύνδεση',
index a44d82e50d7d37c8b621f18c6f1523b95dcc4bba..66cbea766ab6fae93a5318af906d021444c9b9e1 100644 (file)
@@ -126,6 +126,7 @@ $i18n_key_words = array(
 'error.overlap' => 'טווח הזמן מתנגש עם רישומים קיימים.',
 // TODO: translate the following.
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'היכנס',
index 9e59b544ce87d31164cb5a66cfe0fa037aee7616..b740fe3564f70a57ccb46cccc300c33c1c7bf7f8 100644 (file)
@@ -115,6 +115,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Bejelentkezés',
index ea2b2514034544eda0fe3ff4dd7c65a8f57c16c0..5d0600aa13ab8b9a62d6b7940994134dcf09481b 100644 (file)
@@ -106,6 +106,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Vai alle voce incompleta.',
 'error.overlap' => 'Intervallo temporale sovrapposto a voci esistenti.',
 'error.future_date' => 'La data è nel futuro.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Login',
index 23afc5d99bed36d67be62d309b936f633209c393..6149e7c4bc1311274e6d07262fff8d26d05363de 100644 (file)
@@ -120,6 +120,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'ログイン',
index 6e0f59bdd91b4570c4ab53903e1230d924554537..fa41f2ca0fc71dbfeb0258f737f42c8b7b81a8d8 100644 (file)
@@ -119,6 +119,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => '로그인',
index b1f76af77674b6a8479c43d763debb369e2badcb..8c4a5244c5c5f9ed36b2410d62606c56e1cbde06 100644 (file)
@@ -99,6 +99,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Ga naar onvolledige invoer.',
 'error.overlap' => 'De huidige registratie overlapt een reeds bestaande registratie.',
 'error.future_date' => 'Datum ligt in de toekomst.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Aanmelden',
index 07026ae572b8249287cba21e188a196a5e6cfc3c..044a6f33872cf55aa269133f3875958139546ad5 100644 (file)
@@ -120,6 +120,7 @@ $i18n_key_words = array(
 // TODO: translate the following.
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Innlogging',
index f88888fc32c966e460b54cb8f8d9388662f78b57..c94ae1c95bff06ab2dc16cd714714423052eab24 100644 (file)
@@ -112,6 +112,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Przejdź do niedokończonego wpisu.',
 'error.overlap' => 'Okres czasowy nakłada się z istniejącymi wpisami.',
 'error.future_date' => 'Data jest w przyszłości.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons
 'button.login' => 'Login',
index 79370ec62db754e2857209db254b4da9bdfe7496..f40b5f0175b5b0ca7c05b34cb609459dc77d0ff9 100644 (file)
@@ -109,6 +109,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Ir até a entrada incompleta.',
 'error.overlap' => 'O intervalo se sobrepõe com entradas já existentes.',
 'error.future_date' => 'Data é no futuro.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Login',
index c9b24b347e971e3683b953838df6bac1c007f822..4f7d748b9bedf65dc0afde759179717f4aef187f 100644 (file)
@@ -112,6 +112,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Login',
index 223415522b97d2e11ac2934cc01ec2bbfb29f751..82d5d3e6aa58ceb2cc561ca89e669b69ed2923c1 100644 (file)
@@ -120,6 +120,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Autentifica',
index 4a5dbd629aafe05a1779b25d56ed63d61a0dbe37..3974d16734228cbec48a47d0af14e1bad89f403a 100644 (file)
@@ -99,6 +99,7 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Посмотреть неоконченную запись.',
 'error.overlap' => 'Интервал времени перекрывается с существующими записями.',
 'error.future_date' => 'Дата в будущем.',
+'error.cannot_import' => 'Невозможно импортировать: %s.',
 
 // Labels for buttons.
 'button.login' => 'Войти',
index 13992fe8bf4935caf885bf52f8e4e55774db786d..cfca9b0a81b9f620cc7a882ebfc8271fd42a4c34 100644 (file)
@@ -115,6 +115,7 @@ $i18n_key_words = array(
 // TODO: translate the following.
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Prihlásiť',
index df5ddf52a2475190b1ad6304dc4ba491a14f92a5..e07b2089879b97d9e63643af5fdc5f774df8541b 100644 (file)
@@ -109,6 +109,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Prijava',
index a35014c0116e3f5399dd92d7abd306f2fc6e8cfd..6bc886a0adba3db1b521b9559d8d745d13a70994 100644 (file)
@@ -109,6 +109,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Prikaži postojeći unos.',
 'error.overlap' => 'Navedeni vremenski interval se podudara sa već unetim vremenom.',
 'error.future_date' => 'Naveli ste budući datum.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Prijava',
index fb4289a814c22fe86e52a0cd0694a5b26d9cb3fa..a646aab5eff55bf3413674d9dfba059e1c1a44f0 100644 (file)
@@ -106,6 +106,8 @@ $i18n_key_words = array(
 'error.goto_uncompleted' => 'Visa registrering.',
 'error.overlap' => 'Tidsintervallet överlappar med en redan existerande tidsregistrering.',
 'error.future_date' => 'Det går inte att registrera tider framåt i tiden.',
+// TODO: translate the following.
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Logga in',
index 4b167e8826d0d31dec3d0f5500c6641b89a4457f..eb4887542705cb9df5bc4b493c62f64e885b184a 100644 (file)
@@ -123,6 +123,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => 'Giriş',
index 2d55378f97402a0c7e09c8bea0b9cd552877a851..e37138ba37364cc13454a2a64c4005e402bd53b6 100644 (file)
@@ -112,6 +112,7 @@ $i18n_key_words = array(
 // TODO: translate the following.
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => '登录',
index 74d379fc376e9714d99f7b447985059ddfaa8beb..f46f456271d7ed7f1458e163b3412b21bbba0895 100644 (file)
@@ -117,6 +117,7 @@ $i18n_key_words = array(
 // 'error.goto_uncompleted' => 'Go to uncompleted entry.',
 // 'error.overlap' => 'Time interval overlaps with existing records.',
 // 'error.future_date' => 'Date is in future.',
+// 'error.cannot_import' => 'Cannot import: %s.',
 
 // Labels for buttons.
 'button.login' => '登錄',