From 955fd23bfdcee44acebe95fcfbae416c8e21649b Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 1 Mar 2018 16:17:21 +0000 Subject: [PATCH] A bit more work in progress on roles. --- WEB-INF/lib/ttImportHelper.class.php | 11 ++++++++++- WEB-INF/templates/footer.tpl | 2 +- dbinstall.php | 1 - mysql.sql | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index b6c7b8b3..002dac22 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -53,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. @@ -314,12 +315,20 @@ class ttImportHelper { } if ($name == 'ROLE' && $this->canImport) { - ttRoleHelper::insert(array( + $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 = ''; } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 743d8180..b874646a 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.35.4036 | Copyright © Anuko | +  Anuko Time Tracker 1.17.35.4037 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index 43463457..6bb9234f 100755 --- a/dbinstall.php +++ b/dbinstall.php @@ -748,7 +748,6 @@ if ($_POST) { setChange("ALTER TABLE `tt_users` ADD `role_id` int(11) default NULL AFTER `role`"); setChange("CREATE TABLE `tt_site_config` (`param_name` varchar(32) NOT NULL, `param_value` text default NULL, `created` datetime default NULL, `updated` datetime default NULL, PRIMARY KEY (`param_name`))"); setChange("INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.34', now())"); - setChange("DELETE from `tt_roles` WHERE team_id = 0"); setChange("INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site')"); setChange("INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'data_entry,view_own_data,manage_own_settings,view_users,on_behalf_data_entry,view_data,override_punch_mode,swap_roles,approve_timesheets,manage_users,manage_projects,manage_tasks,manage_custom_fields,manage_clients,manage_invoices,manage_features,manage_basic_settings,manage_advanced_settings,manage_roles,export_data,manage_subgroups')"); setChange("UPDATE `tt_site_config` SET `param_value` = '1.17.35' where param_name = 'version_db'"); diff --git a/mysql.sql b/mysql.sql index c625e8c1..9d690111 100644 --- a/mysql.sql +++ b/mysql.sql @@ -410,9 +410,9 @@ CREATE TABLE `tt_roles` ( create unique index role_idx on tt_roles(team_id, rank, status); # Insert site-wide roles - site administrator and top manager. -DELETE from `tt_roles` WHERE team_id = 0; INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site'); INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'data_entry,view_own_data,manage_own_settings,view_users,on_behalf_data_entry,view_data,override_punch_mode,swap_roles,approve_timesheets,manage_users,manage_projects,manage_tasks,manage_custom_fields,manage_clients,manage_invoices,manage_features,manage_basic_settings,manage_advanced_settings,manage_roles,export_data,manage_subgroups'); +# TODO: move this code above, create roles before creating admin account and assign admin account its role. # # Structure for table tt_site_config. This table stores configuration data -- 2.20.1