// 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;
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;
}
$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')) {
$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;
$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'));
$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;
$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;
$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";
$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;
}
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);
// 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;
$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;
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
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;
'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.).
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.80.4198 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.80.4199 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
print "Updated $users_updated users...<br>\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");
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"]) {
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");
<h2>DB Install</h2>
<table width="80%" border="1" cellpadding="10" cellspacing="0">
<tr>
- <td width="80%"><b>Create database structure (v1.17.79)</b>
+ <td width="80%"><b>Create database structure (v1.17.80)</b>
<br>(applies only to new installations, do not execute when updating)</br></td><td><input type="submit" name="crstructure" value="Create"></td>
</tr>
</table>
<td><input type="submit" name="convert11400to11744" value="Update"><br><input type="submit" name="update_role_id" value="Update role_id"></td>
</tr>
<tr valign="top">
- <td>Update database structure (v1.17.44 to v1.17.79)</td>
- <td><input type="submit" name="convert11744to11779" value="Update"></td>
+ <td>Update database structure (v1.17.44 to v1.17.80)</td>
+ <td><input type="submit" name="convert11744to11780" value="Update"></td>
</tr>
</table>
#
-# 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)
#
# 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
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.