X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=WEB-INF%2Flib%2FttOrgImportHelper.class.php;h=f8dbc523b20b1283cbcac058c16b39eed5f6c93d;hb=d79a4bb229f2ce666fdb8d663e51e55e39a91827;hp=991424e610bfe597dd2b6be080d44aba170c4925;hpb=310dc5d75dc9ee3edac18b362a71cee758376d53;p=timetracker.git diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index 991424e6..f8dbc523 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -28,6 +28,8 @@ import('ttUserHelper'); import('ttRoleHelper'); +import('ttTaskHelper'); +import('ttProjectHelper'); // ttOrgImportHelper - this class is a future replacement for ttImportHelper. // Currently, it is work in progress. @@ -46,7 +48,9 @@ class ttOrgImportHelper { // var $currentGroupUsers = array(); // Array of arrays of user properties. // Entity maps for current group. They map XML ids with database ids. - var $currentGroupRoleMap = array(); // Maps role ids from XML to their database ids. + var $currentGroupRoleMap = array(); + var $currentGroupTaskMap = array(); + var $currentGroupProjectMap = array(); //var $userMap = array(); // User ids. //var $projectMap = array(); // Project ids. //var $taskMap = array(); // Task ids. @@ -120,6 +124,55 @@ class ttOrgImportHelper { $this->currentGroupRoleMap[$attrs['ID']] = $role_id; } else $this->errors->add($i18n->get('error.db')); } + + if ($name == 'TASKS') { + // If we get here, we have to recycle $currentGroupTaskMap. + unset($this->currentGroupTaskMap); + $this->currentGroupTaskMap = array(); + // Task map is reconstructed after processing elements in XML. See below. + } + + if ($name == 'TASK') { + // We get here when processing tags for the current group. + $task_id = ttTaskHelper::insert(array( + 'group_id' => $this->current_group_id, + 'org_id' => $this->org_id, + 'name' => $attrs['NAME'], + 'description' => $attrs['DESCRIPTION'], + 'status' => $attrs['STATUS'])); + if ($task_id) { + // Add a mapping. + $this->currentGroupTaskMap[$attrs['ID']] = $task_id; + } else $this->errors->add($i18n->get('error.db')); + } + + if ($name == 'PROJECTS') { + // If we get here, we have to recycle $currentGroupProjectMap. + unset($this->currentGroupProjectMap); + $this->currentGroupProjectMap = array(); + // Project map is reconstructed after processing elements in XML. See below. + } + + if ($name == 'PROJECT') { + // We get here when processing tags for the current group. + + // Prepare a list of task ids. + $tasks = explode(',', $attrs['TASKS']); + foreach ($tasks as $id) + $mapped_tasks[] = $this->currentGroupTaskMap[$id]; + + $project_id = ttProjectHelper::insert(array( + 'group_id' => $this->current_group_id, + 'org_id' => $this->org_id, + 'name' => $attrs['NAME'], + 'description' => $attrs['DESCRIPTION'], + 'tasks' => $mapped_tasks, + 'status' => $attrs['STATUS'])); + if ($project_id) { + // Add a mapping. + $this->currentGroupProjectMap[$attrs['ID']] = $project_id; + } else $this->errors->add($i18n->get('error.db')); + } } }