From b20bc88bdf10d0599435f36bc8acd01b7a35c23c Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Wed, 4 Apr 2018 13:26:42 +0000 Subject: [PATCH] A little bit of refactoring in export-import. --- WEB-INF/lib/ttExportHelper.class.php | 4 +-- WEB-INF/lib/ttImportHelper.class.php | 48 ++++++++++++++-------------- WEB-INF/templates/footer.tpl | 2 +- export.php | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/WEB-INF/lib/ttExportHelper.class.php b/WEB-INF/lib/ttExportHelper.class.php index 22521c73..c26937eb 100644 --- a/WEB-INF/lib/ttExportHelper.class.php +++ b/WEB-INF/lib/ttExportHelper.class.php @@ -62,7 +62,7 @@ class ttExportHelper { fwrite($file, "\n"); // Write team info. - fwrite($file, "currency."\" decimal_mark=\"".$user->decimal_mark."\" lang=\"".$user->lang. + fwrite($file, "currency."\" decimal_mark=\"".$user->decimal_mark."\" lang=\"".$user->lang. "\" date_format=\"".$user->date_format."\" time_format=\"".$user->time_format."\" week_start=\"".$user->week_start. "\" tracking_mode=\"".$user->tracking_mode."\" project_required=\"".$user->project_required."\" task_required=\"".$user->task_required. "\" record_type=\"".$user->record_type."\" bcc_email=\"".$user->bcc_email. @@ -70,7 +70,7 @@ class ttExportHelper { "\" config=\"".$user->config. "\">\n"); fwrite($file, " team."]]>\n"); - fwrite($file, "\n"); + fwrite($file, "\n"); // Prepare role map. $roles = $this->getRoles(); diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index ea54d0ed..b7c024d7 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -38,7 +38,7 @@ import('ttFavReportHelper'); import('ttExpenseHelper'); import('ttRoleHelper'); -// ttImportHelper - this class is used to import team data from a file. +// ttImportHelper - this class is used to import group data from a file. class ttImportHelper { var $errors = null; // Errors go here. Set in constructor by reference. @@ -46,7 +46,7 @@ class ttImportHelper { var $currentTag = ''; // XML tag of the current element. var $canImport = true; // False if we cannot import data due to a login collision. - var $teamData = array(); // Array of team data such as team name, etc. + var $groupData = array(); // Array of group data such as group name, etc. var $group_id = null; // New group id we are importing. It is created during the import operation. var $roles = array(); // Array of arrays of role properties. var $users = array(); // Array of arrays of user properties. @@ -73,7 +73,7 @@ class ttImportHelper { // startElement - callback handler for opening tag of an XML element. // In this function we assign passed in attributes to currentElement. function startElement($parser, $name, $attrs) { - if ($name == 'TEAM' + if ($name == 'GROUP' || $name == 'USER' || $name == 'TASK' || $name == 'PROJECT' @@ -98,10 +98,10 @@ class ttImportHelper { // When we are here, currentElement is an array of the element attributes (as set in startElement). // Here we do the actual import of data into the database. function endElement($parser, $name) { - if ($name == 'TEAM') { - $this->teamData = $this->currentElement; - // Now teamData is an array of team properties. We'll use it later to create a team. - // Cannot create the team here. Need to determine whether logins collide with existing logins. + if ($name == 'GROUP') { + $this->groupData = $this->currentElement; + // Now groupData is an array of group properties. We'll use it later to create a group. + // Cannot create the group here. Need to determine whether logins collide with existing logins. $this->currentElement = array(); } if ($name == 'ROLE') { @@ -121,26 +121,26 @@ class ttImportHelper { } } - // Now we can create a team. + // Now we can create a group. if ($this->canImport) { $this->top_role_id = ttRoleHelper::getRoleByRank(512, 0); $group_id = ttTeamHelper::insert(array( - 'name' => $this->teamData['NAME'], - 'currency' => $this->teamData['CURRENCY'], - 'decimal_mark' => $this->teamData['DECIMAL_MARK'], - 'lang' => $this->teamData['LANG'], - 'date_format' => $this->teamData['DATE_FORMAT'], - 'time_format' => $this->teamData['TIME_FORMAT'], - 'week_start' => $this->teamData['WEEK_START'], - 'tracking_mode' => $this->teamData['TRACKING_MODE'], - 'project_required' => $this->teamData['PROJECT_REQUIRED'], - 'task_required' => $this->teamData['TASK_REQUIRED'], - 'record_type' => $this->teamData['RECORD_TYPE'], - 'bcc_email' => $this->teamData['BCC_EMAIL'], - 'plugins' => $this->teamData['PLUGINS'], - 'lock_spec' => $this->teamData['LOCK_SPEC'], - 'workday_minutes' => $this->teamData['WORKDAY_MINUTES'], - 'config' => $this->teamData['CONFIG'])); + 'name' => $this->groupData['NAME'], + 'currency' => $this->groupData['CURRENCY'], + 'decimal_mark' => $this->groupData['DECIMAL_MARK'], + 'lang' => $this->groupData['LANG'], + 'date_format' => $this->groupData['DATE_FORMAT'], + 'time_format' => $this->groupData['TIME_FORMAT'], + 'week_start' => $this->groupData['WEEK_START'], + 'tracking_mode' => $this->groupData['TRACKING_MODE'], + 'project_required' => $this->groupData['PROJECT_REQUIRED'], + 'task_required' => $this->groupData['TASK_REQUIRED'], + 'record_type' => $this->groupData['RECORD_TYPE'], + 'bcc_email' => $this->groupData['BCC_EMAIL'], + 'plugins' => $this->groupData['PLUGINS'], + 'lock_spec' => $this->groupData['LOCK_SPEC'], + 'workday_minutes' => $this->groupData['WORKDAY_MINUTES'], + 'config' => $this->groupData['CONFIG'])); if ($group_id) { $this->group_id = $group_id; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index b377a9ed..ce32bb19 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.86.4224 | Copyright © Anuko | +  Anuko Time Tracker 1.17.86.4225 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/export.php b/export.php index 4f1a571a..5f7bd02d 100644 --- a/export.php +++ b/export.php @@ -47,7 +47,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->get( if ($request->isPost()) { - $filename = 'team_data.xml'; + $filename = 'group_data.xml'; $mime_type = 'text/xml'; $compress = false; if ('bzip' == $cl_compression) { -- 2.20.1