X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=WEB-INF%2Flib%2FttImportHelper.class.php;h=9ce34ff7eabb6201caeca5c140a1a82efeccc014;hb=7916f561fed6b50348f144fc411ca82ee9bd5ebb;hp=9b1aad2ac771a637e6114cc58dab603f20e4531e;hpb=e3ed046e205a14772a8157def21fea9a14acdde8;p=timetracker.git diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index 9b1aad2a..9ce34ff7 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -36,6 +36,7 @@ import('ttClientHelper'); import('ttCustomFieldHelper'); import('ttFavReportHelper'); import('ttExpenseHelper'); +import('ttRoleHelper'); // ttImportHelper - this class is used to import team data from a file. class ttImportHelper { @@ -52,6 +53,7 @@ class ttImportHelper { // The following arrays are maps between entity ids in the file versus the database. // In the file they are sequential (1,2,3...) while in the database the entities have different ids. var $userMap = array(); // User ids. + var $roleMap = array(); // Role ids. var $projectMap = array(); // Project ids. var $taskMap = array(); // Task ids. var $clientMap = array(); // Client ids. @@ -83,7 +85,8 @@ class ttImportHelper { || $name == 'INVOICE_HEADER' || $name == 'USER_PROJECT_BIND' || $name == 'EXPENSE_ITEM' - || $name == 'FAV_REPORT') { + || $name == 'FAV_REPORT' + || $name == 'ROLE') { $this->currentElement = $attrs; } $this->currentTag = $name; @@ -136,7 +139,7 @@ class ttImportHelper { foreach ($this->users as $key=>$user_item) { $user_id = ttUserHelper::insert(array( 'team_id' => $this->team_id, - 'role' => $user_item['ROLE'], + 'role_id' => $user_item['ROLE_ID'], // Note: NOT mapped value. Not implemented currently, need to fix. 'client_id' => $user_item['CLIENT_ID'], // Note: NOT mapped value, replaced in CLIENT handler. 'name' => $user_item['NAME'], 'login' => $user_item['LOGIN'], @@ -310,6 +313,23 @@ class ttImportHelper { 'group_by' => $this->currentElement['GROUP_BY'], 'chtotalsonly' => (int) $this->currentElement['SHOW_TOTALS_ONLY'])); } + + if ($name == 'ROLE' && $this->canImport) { + $this->roleMap[$this->currentElement['ID']] = ttRoleHelper::insert(array( + 'team_id' => $this->team_id, + 'name' => $this->currentElement['NAME'], + 'rank' => $this->currentElement['RANK'], + 'rights' => $this->currentElement['RIGHTS'], + 'status' => $this->currentElement['STATUS'])); + + // Update role_id for tt_users to a mapped value. + // We did not do it during user insertion because roleMap was not ready then. + // TODO: write setMappedRole function. + /* + if ($this->currentElement['ID'] != $this->roleMap[$this->currentElement['ID']]) + ttRoleHelper::setMappedRole($this->team_id, $this->currentElement['ID'], $this->roleMap[$this->currentElement['ID']]); + */ + } $this->currentTag = ''; }