From: Nik Okuntseff Date: Thu, 29 Mar 2018 19:32:52 +0000 (+0000) Subject: Refactoring. Renamed tt_teams table to tt_groups. X-Git-Tag: timetracker_1.19-1~908 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=82113b6a111dc3f716c71fb8fb55b11845cbd697;p=timetracker.git Refactoring. Renamed tt_teams table to tt_groups. --- diff --git a/WEB-INF/lib/ttAdmin.class.php b/WEB-INF/lib/ttAdmin.class.php index fbcabd47..ed1b280c 100644 --- a/WEB-INF/lib/ttAdmin.class.php +++ b/WEB-INF/lib/ttAdmin.class.php @@ -174,7 +174,7 @@ class ttAdmin { // Mark group deleted. global $user; $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id); - $sql = "update tt_teams set status = NULL $modified_part where id = $group_id"; + $sql = "update tt_groups set status = NULL $modified_part where id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -242,7 +242,7 @@ class ttAdmin { if ($fields['old_group_name'] != $fields['new_group_name']) { $name_part = 'name = '.$mdb2->quote($fields['new_group_name']); $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id); - $sql = 'update tt_teams set '.$name_part.$modified_part.' where id = '.$team_id; + $sql = 'update tt_groups set '.$name_part.$modified_part.' where id = '.$team_id; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; } diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 9fcb8443..6ffa6b21 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -35,8 +35,8 @@ class ttGroupHelper { $result = array(); $mdb2 = getConnection(); - // TODO: when we have subgroups, improve the query to return only top groups. - $sql = "select id, name, created, lang from tt_teams where status = 1 order by id desc"; + $sql = "select id, name, created, lang from tt_groups". + " where status = 1 and org_id is NULL order by id desc"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/lib/ttRegistrator.class.php b/WEB-INF/lib/ttRegistrator.class.php index 3c424f48..23df23ea 100644 --- a/WEB-INF/lib/ttRegistrator.class.php +++ b/WEB-INF/lib/ttRegistrator.class.php @@ -135,11 +135,11 @@ class ttRegistrator { $created = 'now()'; $created_ip = $mdb2->quote($_SERVER['REMOTE_ADDR']); - $sql = "insert into tt_teams (name, currency, lang, created, created_ip) values($name, $currency, $lang, $created, $created_ip)"; + $sql = "insert into tt_groups (name, currency, lang, created, created_ip) values($name, $currency, $lang, $created, $created_ip)"; $affected = $mdb2->exec($sql); if (!is_a($affected, 'PEAR_Error')) { - $group_id = $mdb2->lastInsertID('tt_teams', 'id'); + $group_id = $mdb2->lastInsertID('tt_groups', 'id'); return $group_id; } return false; @@ -174,7 +174,7 @@ class ttRegistrator { $mdb2 = getConnection(); // Update group. - $sql = "update tt_teams set created_by = $user_id where id = $this->group_id"; + $sql = "update tt_groups set created_by = $user_id where id = $this->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) { $this->err->add($i18n->get('error.db')); @@ -199,7 +199,7 @@ class ttRegistrator { $mdb2 = getConnection(); $ip_part = ' created_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']); - $sql = 'select created from tt_teams where '.$ip_part.' and created > now() - interval 1 minute'; + $sql = 'select created from tt_groups where '.$ip_part.' and created > now() - interval 1 minute'; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 2aff793b..d5a7f51d 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -725,8 +725,8 @@ class ttTeamHelper { $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; - // Mark team deleted. - $sql = "update tt_teams set status = NULL where id = $team_id"; + // Mark group deleted. + $sql = "update tt_groups set status = NULL where id = $team_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -739,7 +739,7 @@ class ttTeamHelper { $mdb2 = getConnection(); $sql = "select t.name as team_name, u.id as manager_id, u.name as manager_name, u.login as manager_login, u.email as manager_email - from tt_teams t + from tt_groups t inner join tt_users u on (u.team_id = t.id) inner join tt_roles r on (r.id = u.role_id and r.rank = 512) where t.id = $team_id"; @@ -842,11 +842,11 @@ class ttTeamHelper { $columns .= ', created, created_ip, created_by'; $values .= ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id); - $sql = "insert into tt_teams ($columns) values($values)"; + $sql = "insert into tt_groups ($columns) values($values)"; $affected = $mdb2->exec($sql); if (!is_a($affected, 'PEAR_Error')) { - $team_id = $mdb2->lastInsertID('tt_teams', 'id'); + $team_id = $mdb2->lastInsertID('tt_groups', 'id'); return $team_id; } @@ -889,7 +889,7 @@ class ttTeamHelper { if (isset($fields['workday_minutes'])) $workday_minutes_part = ', workday_minutes = '.$mdb2->quote($fields['workday_minutes']); $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id); - $sql = "update tt_teams set $name_part $currency_part $lang_part $decimal_mark_part + $sql = "update tt_groups set $name_part $currency_part $lang_part $decimal_mark_part $date_format_part $time_format_part $week_start_part $tracking_mode_part $task_required_part $record_type_part $bcc_email_part $plugins_part $config_part $lock_spec_part $workday_minutes_part $modified_part where id = $team_id"; $affected = $mdb2->exec($sql); @@ -906,7 +906,7 @@ class ttTeamHelper { // Get all team ids for teams created or modified more than 8 months ago. // $ts = date('Y-m-d', strtotime('-1 year')); $ts = $mdb2->quote(date('Y-m-d', strtotime('-8 month'))); - $sql = "select id from tt_teams where created < $ts and (modified is null or modified < $ts) order by id"; + $sql = "select id from tt_groups where created < $ts and (modified is null or modified < $ts) order by id"; $res = $mdb2->query($sql); $count = 0; @@ -1014,8 +1014,8 @@ class ttTeamHelper { $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; - // Delete team. - $sql = "delete from tt_teams where id = $team_id"; + // Delete group. + $sql = "delete from tt_groups where id = $team_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index f9edc8cc..7e167f61 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -76,7 +76,7 @@ class ttUser { t.currency, t.lang, t.decimal_mark, t.date_format, t.time_format, t.week_start, t.tracking_mode, t.project_required, t.task_required, t.record_type, t.bcc_email, t.plugins, t.config, t.lock_spec, t.workday_minutes, t.custom_logo - FROM tt_users u LEFT JOIN tt_teams t ON (u.team_id = t.id) LEFT JOIN tt_roles r on (r.id = u.role_id) WHERE "; + FROM tt_users u LEFT JOIN tt_groups t ON (u.team_id = t.id) LEFT JOIN tt_roles r on (r.id = u.role_id) WHERE "; if ($id) $sql .= "u.id = $id"; else diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index 31c7bde4..dab51297 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -318,7 +318,7 @@ class ttUserHelper { return false; // Mark team deleted. - $sql = "update tt_teams set status = NULL where id = $user->team_id"; + $sql = "update tt_groups set status = NULL where id = $user->team_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 4e06cc0e..9631a87b 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -89,7 +89,7 @@ $i18n_key_words = array( 'error.task_exists' => 'Er bestaat al een taak met deze naam.', 'error.client_exists' => 'Een klant met deze naam bestaat al.', 'error.invoice_exists' => 'Dit nummer is al eens toegekend aan een factuur.', -// TODO: translate the following. It seems like rank is misplaced ith rights. +// TODO: translate the following. It seems like rank is misplaced with rights. // 'error.role_exists' => 'Role with this rank already exists.', // 'error.role_exists' => 'Een rol met deze rechten bestaat al.', // TODO: rank is not rights. Rank is a number. // Rights (rechten) is a set of permissions ("view_users", etc.). diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index e70cdbea..1a5dbf67 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - - + +
 Anuko Time Tracker 1.17.80.4198 | Copyright © Anuko | +  Anuko Time Tracker 1.17.80.4199 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index 8f1e867f..190ff7ee 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -805,7 +805,7 @@ if ($_POST) { print "Updated $users_updated users...
\n"; } - if ($_POST["convert11744to11779"]) { + if ($_POST["convert11744to11780"]) { setChange("update `tt_roles` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.44') set rights = replace(rights, 'override_punch_mode,override_date_lock', 'override_punch_mode,override_own_punch_mode,override_date_lock')"); setChange("UPDATE `tt_site_config` SET param_value = '1.17.48' where param_name = 'version_db' and param_value = '1.17.44'"); setChange("update `tt_users` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.48') set role_id = (select id from tt_roles where team_id = 0 and rank = 512) where role = 324"); @@ -869,6 +869,9 @@ if ($_POST) { setChange("UPDATE `tt_site_config` SET param_value = '1.17.78', modified = now() where param_name = 'version_db' and param_value = '1.17.77'"); setChange("update `tt_roles` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.78') set rights = replace(rights, 'manage_own_settings,view_projects,view_users', 'view_own_projects,manage_own_settings,view_users')"); setChange("UPDATE `tt_site_config` SET param_value = '1.17.79', modified = now() where param_name = 'version_db' and param_value = '1.17.78'"); + setChange("RENAME TABLE `tt_teams` TO `tt_groups`"); + setChange("ALTER TABLE `tt_monthly_quotas` DROP FOREIGN KEY FK_TT_TEAM_CONSTRAING"); + setChange("UPDATE `tt_site_config` SET param_value = '1.17.80', modified = now() where param_name = 'version_db' and param_value = '1.17.79'"); } if ($_POST["cleanup"]) { @@ -897,7 +900,7 @@ if ($_POST) { setChange("OPTIMIZE TABLE tt_project_task_binds"); setChange("OPTIMIZE TABLE tt_projects"); setChange("OPTIMIZE TABLE tt_tasks"); - setChange("OPTIMIZE TABLE tt_teams"); + setChange("OPTIMIZE TABLE tt_groups"); setChange("OPTIMIZE TABLE tt_tmp_refs"); setChange("OPTIMIZE TABLE tt_user_project_binds"); setChange("OPTIMIZE TABLE tt_users"); @@ -914,7 +917,7 @@ if ($_POST) {

DB Install

-
Create database structure (v1.17.79) + Create database structure (v1.17.80)
(applies only to new installations, do not execute when updating)
@@ -954,8 +957,8 @@ if ($_POST) {

Update database structure (v1.17.44 to v1.17.79)Update database structure (v1.17.44 to v1.17.80)
diff --git a/mysql.sql b/mysql.sql index 9d2f1e7b..4a48a662 100644 --- a/mysql.sql +++ b/mysql.sql @@ -9,10 +9,10 @@ # -# Structure for table tt_teams. A team is a group of users for whom we are tracking work time. +# Structure for table tt_groups. A team is a group of users for whom we are tracking work time. # This table stores settings common to all group members such as language, week start day, etc. # -CREATE TABLE `tt_teams` ( +CREATE TABLE `tt_groups` ( `id` int(11) NOT NULL auto_increment, # group id `parent_id` int(11) default NULL, # parent group id `org_id` int(11) default NULL, # organization id (id of top group) @@ -425,19 +425,16 @@ CREATE TABLE `tt_predefined_expenses` ( # # Structure for table tt_monthly_quotas. -# This table keeps monthly work hour quotas for teams. +# This table keeps monthly work hour quotas for groups. # CREATE TABLE `tt_monthly_quotas` ( - `team_id` int(11) NOT NULL, # team id + `team_id` int(11) NOT NULL, # group id `year` smallint(5) UNSIGNED NOT NULL, # quota year `month` tinyint(3) UNSIGNED NOT NULL, # quota month `minutes` int(11) default NULL, # quota in minutes in specified month and year PRIMARY KEY (`team_id`,`year`,`month`) ); -ALTER TABLE `tt_monthly_quotas` - ADD CONSTRAINT `FK_TT_TEAM_CONSTRAING` FOREIGN KEY (`team_id`) REFERENCES `tt_teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - # # Structure for table tt_site_config. This table stores configuration data @@ -452,4 +449,4 @@ CREATE TABLE `tt_site_config` ( PRIMARY KEY (`param_name`) ); -INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.79', now()); # TODO: change when structure changes. +INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.80', now()); # TODO: change when structure changes.