From 45c855269d952873285f7a835e82fc2b3eff3971 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 29 Mar 2018 23:35:58 +0000 Subject: [PATCH] Refactoring. Renamed team_id fields to become group_id. --- WEB-INF/lib/ttAdmin.class.php | 22 +- WEB-INF/lib/ttClientHelper.class.php | 30 +-- WEB-INF/lib/ttCustomFieldHelper.class.php | 6 +- WEB-INF/lib/ttExportHelper.class.php | 24 +- WEB-INF/lib/ttImportHelper.class.php | 30 +-- WEB-INF/lib/ttInvoiceHelper.class.php | 16 +- WEB-INF/lib/ttNotificationHelper.class.php | 14 +- .../lib/ttPredefinedExpenseHelper.class.php | 14 +- WEB-INF/lib/ttProjectHelper.class.php | 28 +-- WEB-INF/lib/ttRegistrator.class.php | 4 +- WEB-INF/lib/ttReportHelper.class.php | 12 +- WEB-INF/lib/ttRoleHelper.class.php | 44 ++-- WEB-INF/lib/ttTaskHelper.class.php | 18 +- WEB-INF/lib/ttTeamHelper.class.php | 206 +++++++++--------- WEB-INF/lib/ttUser.class.php | 14 +- WEB-INF/lib/ttUserHelper.class.php | 24 +- WEB-INF/lib/ttWeekViewHelper.class.php | 2 +- WEB-INF/templates/footer.tpl | 2 +- admin_team_delete.php | 8 +- admin_team_edit.php | 8 +- client_add.php | 4 +- client_edit.php | 4 +- clients.php | 4 +- dbinstall.php | 11 + expense_edit.php | 6 +- expenses.php | 6 +- group_edit.php | 2 +- initialize.php | 4 +- invoice_add.php | 4 +- locking.php | 2 +- mobile/client_add.php | 4 +- mobile/client_edit.php | 4 +- mobile/clients.php | 4 +- mobile/expense_edit.php | 6 +- mobile/expenses.php | 6 +- mobile/project_add.php | 4 +- mobile/project_edit.php | 4 +- mobile/projects.php | 4 +- mobile/task_add.php | 4 +- mobile/task_edit.php | 4 +- mobile/tasks.php | 4 +- mobile/time.php | 8 +- mobile/time_edit.php | 8 +- mobile/timer.php | 8 +- mobile/user_add.php | 6 +- mobile/user_edit.php | 4 +- mobile/users.php | 2 +- mysql.sql | 44 ++-- notification_add.php | 2 +- notification_edit.php | 2 +- notifications.php | 2 +- password_change.php | 4 +- plugins/CustomFields.class.php | 30 +-- plugins/MonthlyQuota.class.php | 18 +- predefined_expense_add.php | 2 +- predefined_expense_edit.php | 2 +- predefined_expenses.php | 2 +- project_add.php | 4 +- project_edit.php | 4 +- projects.php | 4 +- quotas.php | 2 +- report.php | 4 +- reports.php | 4 +- role_add.php | 4 +- task_add.php | 4 +- task_edit.php | 4 +- tasks.php | 4 +- time.php | 8 +- time_edit.php | 8 +- tofile.php | 2 +- topdf.php | 6 +- user_add.php | 6 +- user_edit.php | 4 +- week.php | 8 +- 74 files changed, 428 insertions(+), 417 deletions(-) diff --git a/WEB-INF/lib/ttAdmin.class.php b/WEB-INF/lib/ttAdmin.class.php index ed1b280c..83b93a76 100644 --- a/WEB-INF/lib/ttAdmin.class.php +++ b/WEB-INF/lib/ttAdmin.class.php @@ -47,7 +47,7 @@ class ttAdmin { // getUsers obtains user ids in a group. function getUsers($group_id) { $mdb2 = getConnection(); - $sql = "select id from tt_users where team_id = $group_id"; + $sql = "select id from tt_users where group_id = $group_id"; $res = $mdb2->query($sql); $users = array(); if (!is_a($res, 'PEAR_Error')) { @@ -85,7 +85,7 @@ class ttAdmin { // The markTasksDeleted deletes task binds and marks the tasks as deleted for a group. function markTasksDeleted($group_id) { $mdb2 = getConnection(); - $sql = "select id from tt_tasks where team_id = $group_id"; + $sql = "select id from tt_tasks where group_id = $group_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; @@ -120,7 +120,7 @@ class ttAdmin { // Now that we are done with subgroups, handle this group. $users = $this->getUsers($group_id); - // Iterate through team users and mark them as deleted. + // Iterate through group users and mark them as deleted. foreach ($users as $one_user) { if (!$this->markUserDeleted($one_user['id'])) return false; @@ -132,32 +132,32 @@ class ttAdmin { $mdb2 = getConnection(); // Mark roles deleted. - $sql = "update tt_roles set status = NULL where team_id = $group_id"; + $sql = "update tt_roles set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark projects deleted. - $sql = "update tt_projects set status = NULL where team_id = $group_id"; + $sql = "update tt_projects set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark clients deleted. - $sql = "update tt_clients set status = NULL where team_id = $group_id"; + $sql = "update tt_clients set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark invoices deleted. - $sql = "update tt_invoices set status = NULL where team_id = $group_id"; + $sql = "update tt_invoices set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark custom fields deleted. - $sql = "update tt_custom_fields set status = NULL where team_id = $group_id"; + $sql = "update tt_custom_fields set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark notifications deleted. - $sql = "update tt_cron set status = NULL where team_id = $group_id"; + $sql = "update tt_cron set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -232,7 +232,7 @@ class ttAdmin { } // updateGroup validates user input and updates the group with new information. - function updateGroup($team_id, $fields) { + function updateGroup($group_id, $fields) { if (!$this->validateGroupInfo($fields)) return false; // Can't continue as user input is invalid. global $user; @@ -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_groups set '.$name_part.$modified_part.' where id = '.$team_id; + $sql = 'update tt_groups set '.$name_part.$modified_part.' where id = '.$group_id; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; } diff --git a/WEB-INF/lib/ttClientHelper.class.php b/WEB-INF/lib/ttClientHelper.class.php index 288cd45b..f11edc90 100644 --- a/WEB-INF/lib/ttClientHelper.class.php +++ b/WEB-INF/lib/ttClientHelper.class.php @@ -41,7 +41,7 @@ class ttClientHelper { else $sql .= 'name '; - $sql .= "from tt_clients where team_id = $user->team_id + $sql .= "from tt_clients where group_id = $user->group_id and id = $client_id and (status = 1 or status = 0)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -60,7 +60,7 @@ class ttClientHelper { $mdb2 = getConnection(); $sql = "select id, name from tt_clients - where team_id = $user->team_id and (status = 0 or status = 1) order by upper(name)"; + where group_id = $user->group_id and (status = 0 or status = 1) order by upper(name)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -76,7 +76,7 @@ class ttClientHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_clients where team_id = $user->team_id and name = ". + $sql = "select id from tt_clients where group_id = $user->group_id and name = ". $mdb2->quote($client_name)." and (status = 1 or status = 0)"; $res = $mdb2->query($sql); @@ -95,7 +95,7 @@ class ttClientHelper { $mdb2 = getConnection(); global $user; - $sql = "select name, address from tt_clients where team_id = $user->team_id + $sql = "select name, address from tt_clients where group_id = $user->group_id and id = $client_id and status is NULL"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -138,7 +138,7 @@ class ttClientHelper { // Handle invoices. if ($delete_client_entries) { - $sql = "update tt_invoices set status = NULL where client_id = $id and team_id = $user->team_id"; + $sql = "update tt_invoices set status = NULL where client_id = $id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -151,13 +151,13 @@ class ttClientHelper { return false; // Handle users for client. - $sql = 'update tt_users set status = NULL'.$modified_part." where client_id = $id and team_id = $user->team_id"; + $sql = 'update tt_users set status = NULL'.$modified_part." where client_id = $id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark client deleted. - $sql = "update tt_clients set status = NULL where id = $id and team_id = $user->team_id"; + $sql = "update tt_clients set status = NULL where id = $id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -168,7 +168,7 @@ class ttClientHelper { global $user; $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $name = $fields['name']; $address = $fields['address']; $tax = $fields['tax']; @@ -180,8 +180,8 @@ class ttClientHelper { $tax = str_replace(',', '.', $tax); if ($tax == '') $tax = 0; - $sql = "insert into tt_clients (team_id, name, address, tax, projects, status) - values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($address).", $tax, ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_clients (group_id, name, address, tax, projects, status)". + " values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($address).", $tax, ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) @@ -236,16 +236,16 @@ class ttClientHelper { // Update client properties in tt_clients table. $comma_separated = implode(",", $projects); // This is a comma-separated list of associated project ids. $sql = "update tt_clients set name = ".$mdb2->quote($name).", address = ".$mdb2->quote($address). - ", tax = $tax, projects = ".$mdb2->quote($comma_separated).", status = $status where team_id = ".$user->team_id." and id = ".$id; + ", tax = $tax, projects = ".$mdb2->quote($comma_separated).", status = $status where group_id = ".$user->group_id." and id = ".$id; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } // The setMappedClient function is used during team import to change client_id value for tt_users to a mapped value. - static function setMappedClient($team_id, $imported_id, $mapped_id) + static function setMappedClient($group_id, $imported_id, $mapped_id) { $mdb2 = getConnection(); - $sql = "update tt_users set client_id = $mapped_id where client_id = $imported_id and team_id = $team_id "; + $sql = "update tt_users set client_id = $mapped_id where client_id = $imported_id and group_id = $group_id "; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -272,7 +272,7 @@ class ttClientHelper { // Do a query with inner join to get assigned projects. $sql = "select p.id, p.name from tt_projects p inner join tt_client_project_binds cpb on (cpb.client_id = $client_id and cpb.project_id = p.id) - where p.team_id = $user->team_id and p.status = 1 order by p.name"; + where p.group_id = $user->group_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -318,7 +318,7 @@ class ttClientHelper { $sql = "select p.id, p.name from tt_projects p inner join tt_client_project_binds cpb on (cpb.client_id = $client_id and cpb.project_id = p.id) inner join tt_user_project_binds upb on (upb.user_id = $user_id and upb.project_id = p.id and upb.status = 1) - where p.team_id = $user->team_id and p.status = 1 order by p.name"; + where p.group_id = $user->group_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { diff --git a/WEB-INF/lib/ttCustomFieldHelper.class.php b/WEB-INF/lib/ttCustomFieldHelper.class.php index f1267508..15c7ca05 100644 --- a/WEB-INF/lib/ttCustomFieldHelper.class.php +++ b/WEB-INF/lib/ttCustomFieldHelper.class.php @@ -34,14 +34,14 @@ class ttCustomFieldHelper { { $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $type = (int) $fields['type']; $label = $fields['label']; $required = (int) $fields['required']; $status = $fields['status']; - $sql = "insert into tt_custom_fields (team_id, type, label, required, status) - values ($team_id, $type, ".$mdb2->quote($label).", $required, ".$mdb2->quote($status).")"; + $sql = "insert into tt_custom_fields (group_id, type, label, required, status)". + " values ($group_id, $type, ".$mdb2->quote($label).", $required, ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) diff --git a/WEB-INF/lib/ttExportHelper.class.php b/WEB-INF/lib/ttExportHelper.class.php index 375de2f3..22521c73 100644 --- a/WEB-INF/lib/ttExportHelper.class.php +++ b/WEB-INF/lib/ttExportHelper.class.php @@ -83,17 +83,17 @@ class ttExportHelper { $this->userMap[$user_item['id']] = $key + 1; // Prepare project map. - $projects = ttTeamHelper::getAllProjects($user->team_id, true); + $projects = ttTeamHelper::getAllProjects($user->group_id, true); foreach ($projects as $key=>$project_item) $this->projectMap[$project_item['id']] = $key + 1; // Prepare task map. - $tasks = ttTeamHelper::getAllTasks($user->team_id, true); + $tasks = ttTeamHelper::getAllTasks($user->group_id, true); foreach ($tasks as $key=>$task_item) $this->taskMap[$task_item['id']] = $key + 1; // Prepare client map. - $clients = ttTeamHelper::getAllClients($user->team_id, true); + $clients = ttTeamHelper::getAllClients($user->group_id, true); foreach ($clients as $key=>$client_item) $this->clientMap[$client_item['id']] = $key + 1; @@ -103,12 +103,12 @@ class ttExportHelper { $this->invoiceMap[$invoice_item['id']] = $key + 1; // Prepare custom fields map. - $custom_fields = ttTeamHelper::getAllCustomFields($user->team_id); + $custom_fields = ttTeamHelper::getAllCustomFields($user->group_id); foreach ($custom_fields as $key=>$custom_field) $this->customFieldMap[$custom_field['id']] = $key + 1; // Prepare custom field options map. - $custom_field_options = ttTeamHelper::getAllCustomFieldOptions($user->team_id); + $custom_field_options = ttTeamHelper::getAllCustomFieldOptions($user->group_id); foreach ($custom_field_options as $key=>$option) $this->customFieldOptionMap[$option['id']] = $key + 1; @@ -164,7 +164,7 @@ class ttExportHelper { // Write user to project binds. fwrite($file, "\n"); - $user_binds = ttTeamHelper::getUserToProjectBinds($user->team_id); + $user_binds = ttTeamHelper::getUserToProjectBinds($user->group_id); foreach ($user_binds as $bind) { $user_id = $this->userMap[$bind['user_id']]; $project_id = $this->projectMap[$bind['project_id']]; @@ -222,7 +222,7 @@ class ttExportHelper { unset($custom_field_options); // Write monthly quotas. - $quotas = ttTeamHelper::getMonthlyQuotas($user->team_id); + $quotas = ttTeamHelper::getMonthlyQuotas($user->group_id); fwrite($file, "\n"); foreach ($quotas as $quota) { fwrite($file, " \n"); @@ -246,7 +246,7 @@ class ttExportHelper { unset($records); // Write custom field log. - $custom_field_log = ttTeamHelper::getCustomFieldLog($user->team_id); + $custom_field_log = ttTeamHelper::getCustomFieldLog($user->group_id); fwrite($file, "\n"); foreach ($custom_field_log as $entry) { fwrite($file, " logMap[$entry['log_id']]."\" field_id=\"".$this->customFieldMap[$entry['field_id']]."\" option_id=\"".$this->customFieldOptionMap[$entry['option_id']]."\" status=\"".$entry['status']."\">\n"); @@ -257,7 +257,7 @@ class ttExportHelper { unset($custom_field_log); // Write expense items. - $expense_items = ttTeamHelper::getExpenseItems($user->team_id); + $expense_items = ttTeamHelper::getExpenseItems($user->group_id); fwrite($file, "\n"); foreach ($expense_items as $expense_item) { fwrite($file, " userMap[$expense_item['user_id']]."\" client_id=\"".$this->clientMap[$expense_item['client_id']]."\" project_id=\"".$this->projectMap[$expense_item['project_id']]."\" cost=\"".$expense_item['cost']."\" invoice_id=\"".$this->invoiceMap[$expense_item['invoice_id']]."\" paid=\"".$expense_item['paid']."\" status=\"".$expense_item['status']."\">\n"); @@ -269,7 +269,7 @@ class ttExportHelper { // Write fav reports. fwrite($file, "\n"); - $fav_reports = ttTeamHelper::getFavReports($user->team_id); + $fav_reports = ttTeamHelper::getFavReports($user->group_id); foreach ($fav_reports as $fav_report) { $user_list = ''; if (strlen($fav_report['users']) > 0) { @@ -381,7 +381,7 @@ class ttExportHelper { $mdb2 = getConnection(); $result = array(); - $sql = "select * from tt_roles where team_id = $user->team_id"; + $sql = "select * from tt_roles where group_id = $user->group_id"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -398,7 +398,7 @@ class ttExportHelper { global $user; $mdb2 = getConnection(); - $sql = "select u.*, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $user->team_id order by upper(u.name)"; // Note: deleted users are included. + $sql = "select u.*, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $user->group_id order by upper(u.name)"; // Note: deleted users are included. $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index ca717cae..ea54d0ed 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -47,7 +47,7 @@ class ttImportHelper { var $canImport = true; // False if we cannot import data due to a login collision. var $teamData = array(); // Array of team data such as team name, etc. - var $team_id = null; // New team id we are importing. It is created during the import operation. + var $group_id = null; // New group id we are importing. It is created during the import operation. var $roles = array(); // Array of arrays of role properties. var $users = array(); // Array of arrays of user properties. var $top_role_id = null; // Top manager role id on the new server. @@ -124,7 +124,7 @@ class ttImportHelper { // Now we can create a team. if ($this->canImport) { $this->top_role_id = ttRoleHelper::getRoleByRank(512, 0); - $team_id = ttTeamHelper::insert(array( + $group_id = ttTeamHelper::insert(array( 'name' => $this->teamData['NAME'], 'currency' => $this->teamData['CURRENCY'], 'decimal_mark' => $this->teamData['DECIMAL_MARK'], @@ -141,13 +141,13 @@ class ttImportHelper { 'lock_spec' => $this->teamData['LOCK_SPEC'], 'workday_minutes' => $this->teamData['WORKDAY_MINUTES'], 'config' => $this->teamData['CONFIG'])); - if ($team_id) { - $this->team_id = $team_id; + if ($group_id) { + $this->group_id = $group_id; // Create roles. foreach ($this->roles as $key=>$role_item) { $role_id = ttRoleHelper::insert(array( - 'team_id' => $this->team_id, + 'group_id' => $this->group_id, 'name' => $role_item['NAME'], 'rank' => $role_item['RANK'], 'rights' => $role_item['RIGHTS'], @@ -158,7 +158,7 @@ class ttImportHelper { foreach ($this->users as $key=>$user_item) { $role_id = $user_item['ROLE_ID'] === '0' ? $this->top_role_id : $this->roleMap[$user_item['ROLE_ID']]; // 0 (not null) means top manager role. $user_id = ttUserHelper::insert(array( - 'team_id' => $this->team_id, + 'group_id' => $this->group_id, 'role_id' => $role_id, 'client_id' => $user_item['CLIENT_ID'], // Note: NOT mapped value, replaced in CLIENT handler. 'name' => $user_item['NAME'], @@ -176,7 +176,7 @@ class ttImportHelper { if ($name == 'TASK' && $this->canImport) { $this->taskMap[$this->currentElement['ID']] = ttTaskHelper::insert(array( - 'team_id' => $this->team_id, + 'group_id' => $this->group_id, 'name' => $this->currentElement['NAME'], 'description' => $this->currentElement['DESCRIPTION'], 'status' => $this->currentElement['STATUS'])); @@ -190,7 +190,7 @@ class ttImportHelper { // Add a new project. $this->projectMap[$this->currentElement['ID']] = ttProjectHelper::insert(array( - 'team_id' => $this->team_id, + 'group_id' => $this->group_id, 'name' => $this->currentElement['NAME'], 'description' => $this->currentElement['DESCRIPTION'], 'tasks' => $mapped_tasks, @@ -214,7 +214,7 @@ class ttImportHelper { $this->clientMap[$this->currentElement['ID']] = ttClientHelper::insert(array( - 'team_id' => $this->team_id, + 'group_id' => $this->group_id, 'name' => $this->currentElement['NAME'], 'address' => $this->currentElement['ADDRESS'], 'tax' => $this->currentElement['TAX'], @@ -224,13 +224,13 @@ class ttImportHelper { // Update client_id for tt_users to a mapped value. // We did not do it during user insertion because clientMap was not ready then. if ($this->currentElement['ID'] != $this->clientMap[$this->currentElement['ID']]) - ttClientHelper::setMappedClient($this->team_id, $this->currentElement['ID'], $this->clientMap[$this->currentElement['ID']]); + ttClientHelper::setMappedClient($this->group_id, $this->currentElement['ID'], $this->clientMap[$this->currentElement['ID']]); } if ($name == 'INVOICE' && $this->canImport) { $this->invoiceMap[$this->currentElement['ID']] = ttInvoiceHelper::insert(array( - 'team_id' => $this->team_id, + 'group_id' => $this->group_id, 'name' => $this->currentElement['NAME'], 'date' => $this->currentElement['DATE'], 'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']], @@ -239,7 +239,7 @@ class ttImportHelper { } if ($name == 'MONTHLY_QUOTA' && $this->canImport) { - $this->insertMonthlyQuota($this->team_id, $this->currentElement['YEAR'], $this->currentElement['MONTH'], $this->currentElement['MINUTES']); + $this->insertMonthlyQuota($this->group_id, $this->currentElement['YEAR'], $this->currentElement['MONTH'], $this->currentElement['MINUTES']); } if ($name == 'LOG_ITEM' && $this->canImport) { @@ -263,7 +263,7 @@ class ttImportHelper { if ($name == 'CUSTOM_FIELD' && $this->canImport) { $this->customFieldMap[$this->currentElement['ID']] = ttCustomFieldHelper::insertField(array( - 'team_id' => $this->team_id, + 'group_id' => $this->group_id, 'type' => $this->currentElement['TYPE'], 'label' => $this->currentElement['LABEL'], 'required' => $this->currentElement['REQUIRED'], @@ -433,9 +433,9 @@ class ttImportHelper { } // insertMonthlyQuota - a helper function to insert a monthly quota. - private function insertMonthlyQuota($team_id, $year, $month, $minutes) { + private function insertMonthlyQuota($group_id, $year, $month, $minutes) { $mdb2 = getConnection(); - $sql = "INSERT INTO tt_monthly_quotas (team_id, year, month, minutes) values ($team_id, $year, $month, $minutes)"; + $sql = "INSERT INTO tt_monthly_quotas (group_id, year, month, minutes) values ($group_id, $year, $month, $minutes)"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/lib/ttInvoiceHelper.class.php b/WEB-INF/lib/ttInvoiceHelper.class.php index d58bc116..d35aa348 100644 --- a/WEB-INF/lib/ttInvoiceHelper.class.php +++ b/WEB-INF/lib/ttInvoiceHelper.class.php @@ -37,7 +37,7 @@ class ttInvoiceHelper { { $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $name = $fields['name']; if (!$name) return false; @@ -49,8 +49,8 @@ class ttInvoiceHelper { } // Insert a new invoice record. - $sql = "insert into tt_invoices (team_id, name, date, client_id $status_f) - values($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)"; + $sql = "insert into tt_invoices (group_id, name, date, client_id $status_f)". + " values($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -71,7 +71,7 @@ class ttInvoiceHelper { if ($user->isClient()) $client_part = " and client_id = $user->client_id"; - $sql = "select * from tt_invoices where id = $invoice_id and team_id = $user->team_id $client_part and status = 1"; + $sql = "select * from tt_invoices where id = $invoice_id and group_id = $user->group_id $client_part and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { if ($val = $res->fetchRow()) @@ -86,7 +86,7 @@ class ttInvoiceHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_invoices where team_id = $user->team_id and name = ".$mdb2->quote($invoice_name)." and status = 1"; + $sql = "select id from tt_invoices where group_id = $user->group_id and name = ".$mdb2->quote($invoice_name)." and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -233,7 +233,7 @@ class ttInvoiceHelper { $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; - $sql = "update tt_invoices set status = NULL where id = $invoice_id and team_id = $user->team_id"; + $sql = "update tt_invoices set status = NULL where id = $invoice_id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -328,8 +328,8 @@ class ttInvoiceHelper { if (isset($fields['project_id'])) $project_id = (int) $fields['project_id']; // Create a new invoice record. - $sql = "insert into tt_invoices (team_id, name, date, client_id) - values($user->team_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)"; + $sql = "insert into tt_invoices (group_id, name, date, client_id) + values($user->group_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttNotificationHelper.class.php b/WEB-INF/lib/ttNotificationHelper.class.php index ee7880c4..34c85276 100644 --- a/WEB-INF/lib/ttNotificationHelper.class.php +++ b/WEB-INF/lib/ttNotificationHelper.class.php @@ -41,7 +41,7 @@ class ttNotificationHelper { $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition, c.status, fr.name from tt_cron c left join tt_fav_reports fr on (fr.id = c.report_id) - where c.id = $id and c.team_id = $user->team_id"; + where c.id = $id and c.group_id = $user->group_id"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -57,7 +57,7 @@ class ttNotificationHelper { $mdb2 = getConnection(); - $sql = "delete from tt_cron where id = $id and team_id = $user->team_id"; + $sql = "delete from tt_cron where id = $id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -70,7 +70,7 @@ class ttNotificationHelper { { $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $cron_spec = $fields['cron_spec']; $next = (int) $fields['next']; $report_id = (int) $fields['report_id']; @@ -80,8 +80,8 @@ class ttNotificationHelper { $report_condition = $fields['report_condition']; $status = $fields['status']; - $sql = "insert into tt_cron (team_id, cron_spec, next, report_id, email, cc, subject, report_condition, status) - values ($team_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($cc).", ".$mdb2->quote($subject).", ".$mdb2->quote($report_condition).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_cron (group_id, cron_spec, next, report_id, email, cc, subject, report_condition, status) + values ($group_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($cc).", ".$mdb2->quote($subject).", ".$mdb2->quote($report_condition).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -95,7 +95,7 @@ class ttNotificationHelper { $mdb2 = getConnection(); $notification_id = (int) $fields['id']; - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $cron_spec = $fields['cron_spec']; $next = (int) $fields['next']; $report_id = (int) $fields['report_id']; @@ -106,7 +106,7 @@ class ttNotificationHelper { $status = $fields['status']; $sql = "update tt_cron set cron_spec = ".$mdb2->quote($cron_spec).", next = $next, report_id = $report_id, email = ".$mdb2->quote($email).", cc = ".$mdb2->quote($cc).", subject = ".$mdb2->quote($subject).", report_condition = ".$mdb2->quote($report_condition).", status = ".$mdb2->quote($status). - " where id = $notification_id and team_id = $team_id"; + " where id = $notification_id and group_id = $group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/lib/ttPredefinedExpenseHelper.class.php b/WEB-INF/lib/ttPredefinedExpenseHelper.class.php index 556bc42f..c292870f 100644 --- a/WEB-INF/lib/ttPredefinedExpenseHelper.class.php +++ b/WEB-INF/lib/ttPredefinedExpenseHelper.class.php @@ -39,7 +39,7 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); $sql = "select id, name, cost from tt_predefined_expenses - where id = $id and team_id = $user->team_id"; + where id = $id and group_id = $user->group_id"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -58,7 +58,7 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); - $sql = "delete from tt_predefined_expenses where id = $id and team_id = $user->team_id"; + $sql = "delete from tt_predefined_expenses where id = $id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -73,14 +73,14 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $name = $fields['name']; $cost = $fields['cost']; if ('.' != $user->decimal_mark) $cost = str_replace($user->decimal_mark, '.', $cost); - $sql = "insert into tt_predefined_expenses (team_id, name, cost) - values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")"; + $sql = "insert into tt_predefined_expenses (group_id, name, cost) + values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -96,14 +96,14 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); $predefined_expense_id = (int) $fields['id']; - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $name = $fields['name']; $cost = $fields['cost']; if ('.' != $user->decimal_mark) $cost = str_replace($user->decimal_mark, '.', $cost); $sql = "update tt_predefined_expenses set name = ".$mdb2->quote($name).", cost = ".$mdb2->quote($cost). - " where id = $predefined_expense_id and team_id = $team_id"; + " where id = $predefined_expense_id and group_id = $group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/lib/ttProjectHelper.class.php b/WEB-INF/lib/ttProjectHelper.class.php index d3e0eb1b..ff154af4 100644 --- a/WEB-INF/lib/ttProjectHelper.class.php +++ b/WEB-INF/lib/ttProjectHelper.class.php @@ -35,7 +35,7 @@ class ttProjectHelper { // getAssignedProjects - returns an array of assigned projects. static function getAssignedProjects($user_id) { - global $user; + global $user; $result = array(); $mdb2 = getConnection(); @@ -43,7 +43,7 @@ class ttProjectHelper { // Do a query with inner join to get assigned projects. $sql = "select p.id, p.name, p.tasks, upb.rate from tt_projects p inner join tt_user_project_binds upb on (upb.user_id = $user_id and upb.project_id = p.id and upb.status = 1) - where p.team_id = $user->team_id and p.status = 1 order by p.name"; + where p.group_id = $user->group_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -63,7 +63,7 @@ class ttProjectHelper { $sql = "select p.id, upb.rate from tt_projects p inner join tt_user_project_binds upb on (upb.user_id = $user_id and upb.project_id = p.id) - where team_id = $user->team_id"; + where group_id = $user->group_id"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -82,8 +82,8 @@ class ttProjectHelper { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, tasks from tt_projects - where team_id = $user->team_id and (status = 0 or status = 1) order by name"; + $sql = "select id, name, tasks from tt_projects". + " where group_id = $user->group_id and (status = 0 or status = 1) order by name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -104,7 +104,7 @@ class ttProjectHelper { $sql = "select p.id, p.name, p.tasks from tt_projects p inner join tt_client_project_binds cpb on (cpb.client_id = $user->client_id and cpb.project_id = p.id) - where p.team_id = $user->team_id and (p.status = 0 or p.status = 1) + where p.group_id = $user->group_id and (p.status = 0 or p.status = 1) order by p.name"; $res = $mdb2->query($sql); @@ -124,7 +124,7 @@ class ttProjectHelper { $mdb2 = getConnection(); - $sql = "select id, name, description, status, tasks from tt_projects where id = $id and team_id = $user->team_id and (status = 0 or status = 1)"; + $sql = "select id, name, description, status, tasks from tt_projects where id = $id and group_id = $user->group_id and (status = 0 or status = 1)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -140,7 +140,7 @@ class ttProjectHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_projects where team_id = $user->team_id and name = ". + $sql = "select id from tt_projects where group_id = $user->group_id and name = ". $mdb2->quote($name)." and (status = 1 or status = 0)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -161,7 +161,7 @@ class ttProjectHelper { // we'll fail right here and don't damage any other data. // Mark project as deleted and remove associated tasks. - $sql = "update tt_projects set status = NULL, tasks = NULL where id = $id and team_id = $user->team_id"; + $sql = "update tt_projects set status = NULL, tasks = NULL where id = $id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error') || 0 == $affected) return false; // An error ocurred, or 0 rows updated. @@ -186,7 +186,7 @@ class ttProjectHelper { { $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $name = $fields['name']; $description = $fields['description']; @@ -195,8 +195,8 @@ class ttProjectHelper { $comma_separated = implode(',', $tasks); // This is a comma-separated list of associated task ids. $status = $fields['status']; - $sql = "insert into tt_projects (team_id, name, description, tasks, status) - values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_projects (group_id, name, description, tasks, status) + values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -220,7 +220,7 @@ class ttProjectHelper { } // Bind the project to tasks in tt_project_task_binds table. - $all_tasks = ttTeamHelper::getAllTasks($team_id); + $all_tasks = ttTeamHelper::getAllTasks($group_id); foreach ($all_tasks as $task) { if(in_array($task['id'], $tasks)) { $sql = "insert into tt_project_task_binds (project_id, task_id) values($last_id, ".$task['id'].")"; @@ -312,7 +312,7 @@ class ttProjectHelper { // Update project name, description, tasks and status in tt_projects table. $comma_separated = implode(",", $tasks_to_bind); // This is a comma-separated list of associated task ids. $sql = "update tt_projects set name = ".$mdb2->quote($name).", description = ".$mdb2->quote($description). - ", tasks = ".$mdb2->quote($comma_separated).", status = $status where id = $project_id and team_id = $user->team_id"; + ", tasks = ".$mdb2->quote($comma_separated).", status = $status where id = $project_id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/lib/ttRegistrator.class.php b/WEB-INF/lib/ttRegistrator.class.php index 23df23ea..a82ebd3f 100644 --- a/WEB-INF/lib/ttRegistrator.class.php +++ b/WEB-INF/lib/ttRegistrator.class.php @@ -157,7 +157,7 @@ class ttRegistrator { $created_ip = $mdb2->quote($_SERVER['REMOTE_ADDR']); $values = "values($login, $password, $name, $this->group_id, $this->role_id, $email, $created, $created_ip)"; - $sql = 'insert into tt_users (login, password, name, team_id, role_id, email, created, created_ip) '.$values; + $sql = 'insert into tt_users (login, password, name, group_id, role_id, email, created, created_ip) '.$values; $affected = $mdb2->exec($sql); if (!is_a($affected, 'PEAR_Error')) { $user_id = $mdb2->lastInsertID('tt_users', 'id'); @@ -182,7 +182,7 @@ class ttRegistrator { } // Update top manager. - $sql = "update tt_users set created_by = $user_id where id = $user_id and team_id = $this->group_id"; + $sql = "update tt_users set created_by = $user_id where id = $user_id and group_id = $this->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) { $this->err->add($i18n->get('error.db')); diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index b894b037..67f1da26 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -257,7 +257,7 @@ class ttReportHelper { // Add custom field. $include_cf_1 = $bean->getAttribute('chcf_1') || 'cf_1' == $group_by_option; if ($include_cf_1) { - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $cf_1_type = $custom_fields->fields[0]['type']; if ($cf_1_type == CustomFields::TYPE_TEXT) { array_push($fields, 'cfl.value as cf_1'); @@ -522,7 +522,7 @@ class ttReportHelper { // Add custom field. $include_cf_1 = $report['show_custom_field_1'] || 'cf_1' == $group_by_option; if ($include_cf_1) { - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $cf_1_type = $custom_fields->fields[0]['type']; if ($cf_1_type == CustomFields::TYPE_TEXT) { array_push($fields, 'cfl.value as cf_1'); @@ -756,7 +756,7 @@ class ttReportHelper { break; case 'cf_1': $group_field = 'cfo.value'; - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) $group_join = 'left join tt_custom_field_log cfl on (l.id = cfl.log_id and cfl.status = 1) left join tt_custom_field_options cfo on (cfl.value = cfo.id) '; elseif ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN) @@ -884,7 +884,7 @@ class ttReportHelper { break; case 'cf_1': $group_field = 'cfo.value'; - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) $group_join = 'left join tt_custom_field_log cfl on (l.id = cfl.log_id and cfl.status = 1) left join tt_custom_field_options cfo on (cfl.value = cfo.id) '; elseif ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN) @@ -1168,7 +1168,7 @@ class ttReportHelper { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); // Define some styles to use in email. $style_title = 'text-align: center; font-size: 15pt; font-family: Arial, Helvetica, sans-serif;'; @@ -1464,7 +1464,7 @@ class ttReportHelper { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); // Define some styles to use in email. $style_title = 'text-align: center; font-size: 15pt; font-family: Arial, Helvetica, sans-serif;'; diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index c6cd02ba..25d71419 100644 --- a/WEB-INF/lib/ttRoleHelper.class.php +++ b/WEB-INF/lib/ttRoleHelper.class.php @@ -37,7 +37,7 @@ class ttRoleHelper { $mdb2 = getConnection(); $sql = "select id, name, description, rank, rights, status from tt_roles - where id = $id and team_id = $user->team_id and (status = 0 or status = 1)"; + where id = $id and group_id = $user->group_id and (status = 0 or status = 1)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -56,7 +56,7 @@ class ttRoleHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_roles where team_id = $user->team_id and name = ". + $sql = "select id from tt_roles where group_id = $user->group_id and name = ". $mdb2->quote($role_name)." and (status = 1 or status = 0)"; $res = $mdb2->query($sql); @@ -72,7 +72,7 @@ class ttRoleHelper { static function getTopManagerRoleID() { $mdb2 = getConnection(); - $sql = "select id from tt_roles where team_id = 0 and rank = 512"; + $sql = "select id from tt_roles where group_id = 0 and rank = 512"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -89,7 +89,7 @@ class ttRoleHelper { global $user; $mdb2 = getConnection(); - $sql = "select rights from tt_roles where team_id = $user->team_id and id = $role_id"; + $sql = "select rights from tt_roles where group_id = $user->group_id and id = $role_id"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -102,13 +102,13 @@ class ttRoleHelper { } // getRoleByRank looks up a role by its rank. - static function getRoleByRank($rank, $team_id) { + static function getRoleByRank($rank, $group_id) { global $user; $mdb2 = getConnection(); $rank = (int) $rank; // Cast to int just in case for better security. - $sql = "select id from tt_roles where team_id = $team_id and rank = $rank and (status = 1 or status = 0)"; + $sql = "select id from tt_roles where group_id = $group_id and rank = $rank and (status = 1 or status = 0)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -131,7 +131,7 @@ class ttRoleHelper { if (isset($fields['status'])) $status_part = ', status = '.(int)$fields['status']; if (isset($fields['rights'])) $rights_part = ', rights = '.$mdb2->quote($fields['rights']); $parts = trim($name_part.$rank_part.$descr_part.$status_part.$rights_part, ','); - $sql = "update tt_roles set $parts where id = $id and team_id = $user->team_id"; + $sql = "update tt_roles set $parts where id = $id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -143,7 +143,7 @@ class ttRoleHelper { $mdb2 = getConnection(); // Mark the task as deleted. - $sql = "update tt_roles set status = NULL where id = $role_id and team_id = $user->team_id"; + $sql = "update tt_roles set status = NULL where id = $role_id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -153,15 +153,15 @@ class ttRoleHelper { { $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $name = $fields['name']; $rank = (int) $fields['rank']; $description = $fields['description']; $rights = $fields['rights']; $status = $fields['status']; - $sql = "insert into tt_roles (team_id, name, rank, description, rights, status) - values ($team_id, ".$mdb2->quote($name).", $rank, ".$mdb2->quote($description).", ".$mdb2->quote($rights).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_roles (group_id, name, rank, description, rights, status) + values ($group_id, ".$mdb2->quote($name).", $rank, ".$mdb2->quote($description).", ".$mdb2->quote($rights).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -174,7 +174,7 @@ class ttRoleHelper { } // createPredefinedRoles - creates a set of predefined roles for the team to use. - static function createPredefinedRoles($team_id, $lang) + static function createPredefinedRoles($group_id, $lang) { // We need localized role names and a new I18n object to obtain them. import('I18n'); @@ -193,7 +193,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.user.label')); $description = $mdb2->quote($i18n->get('role.user.description')); $rights = $mdb2->quote($rights_user); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 4, $rights, 1)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 4, $rights, 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -201,7 +201,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.client.label')); $description = $mdb2->quote($i18n->get('role.client.description')); $rights = $mdb2->quote($rights_client); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 16, $rights, 1)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 16, $rights, 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -209,7 +209,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.comanager.label')); $description = $mdb2->quote($i18n->get('role.comanager.description')); $rights = $mdb2->quote($rights_comanager); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 68, $rights, 1)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 68, $rights, 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -217,7 +217,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.manager.label')); $description = $mdb2->quote($i18n->get('role.manager.description')); $rights = $mdb2->quote($rights_manager); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 324, $rights, 1)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 324, $rights, 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -226,7 +226,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.supervisor.label')); $description = $mdb2->quote($i18n->get('role.supervisor.description')); $rights = $mdb2->quote($rights_supervisor); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 12, $rights, 0)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 12, $rights, 0)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -251,7 +251,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.user.label')); $description = $mdb2->quote($i18n->get('role.user.description')); $rights = $mdb2->quote($rights_user); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 4, $rights, 1)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 4, $rights, 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -259,7 +259,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.client.label')); $description = $mdb2->quote($i18n->get('role.client.description')); $rights = $mdb2->quote($rights_client); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 16, $rights, 1)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 16, $rights, 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -267,7 +267,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.comanager.label')); $description = $mdb2->quote($i18n->get('role.comanager.description')); $rights = $mdb2->quote($rights_comanager); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 68, $rights, 1)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 68, $rights, 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -275,7 +275,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.manager.label')); $description = $mdb2->quote($i18n->get('role.manager.description')); $rights = $mdb2->quote($rights_manager); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 324, $rights, 1)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 324, $rights, 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -284,7 +284,7 @@ class ttRoleHelper { $name = $mdb2->quote($i18n->get('role.supervisor.label')); $description = $mdb2->quote($i18n->get('role.supervisor.description')); $rights = $mdb2->quote($rights_supervisor); - $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 12, $rights, 0)"; + $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 12, $rights, 0)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttTaskHelper.class.php b/WEB-INF/lib/ttTaskHelper.class.php index 24831cb2..e09c882d 100644 --- a/WEB-INF/lib/ttTaskHelper.class.php +++ b/WEB-INF/lib/ttTaskHelper.class.php @@ -37,7 +37,7 @@ class ttTaskHelper { $mdb2 = getConnection(); $sql = "select id, name, description, status from tt_tasks - where id = $id and team_id = $user->team_id and (status = 0 or status = 1)"; + where id = $id and group_id = $user->group_id and (status = 0 or status = 1)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -61,7 +61,7 @@ class ttTaskHelper { // Do a query with inner join to get assigned projects. $sql = "select p.id, p.name from tt_projects p inner join tt_project_task_binds ptb on (ptb.project_id = p.id and ptb.task_id = $task_id) - where p.team_id = $user->team_id and p.status = 1 order by p.name"; + where p.group_id = $user->group_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -77,7 +77,7 @@ class ttTaskHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_tasks where team_id = $user->team_id and name = ". + $sql = "select id from tt_tasks where group_id = $user->group_id and name = ". $mdb2->quote($task_name)." and (status = 1 or status = 0)"; $res = $mdb2->query($sql); @@ -103,7 +103,7 @@ class ttTaskHelper { // Delete project binds to this task from the tasks field in tt_projects table. // Get projects where tasks is not NULL. - $sql = "select id, tasks from tt_projects where team_id = $user->team_id and tasks is not NULL"; + $sql = "select id, tasks from tt_projects where group_id = $user->group_id and tasks is not NULL"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; @@ -135,14 +135,14 @@ class ttTaskHelper { { $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $name = $fields['name']; $description = $fields['description']; $projects = $fields['projects']; $status = $fields['status']; - $sql = "insert into tt_tasks (team_id, name, description, status) - values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_tasks (group_id, name, description, status) + values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); $last_id = 0; if (is_a($affected, 'PEAR_Error')) @@ -198,7 +198,7 @@ class ttTaskHelper { $projects = $fields['projects']; $sql = "update tt_tasks set name = ".$mdb2->quote($name).", description = ".$mdb2->quote($description). - ", status = $status where id = $task_id and team_id = $user->team_id"; + ", status = $status where id = $task_id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) die($affected->getMessage()); @@ -220,7 +220,7 @@ class ttTaskHelper { // We need to either delete or insert task id in all affected projects. // Get all not deleted projects for team. - $sql = "select id, tasks from tt_projects where team_id = $user->team_id and status is not NULL"; + $sql = "select id, tasks from tt_projects where group_id = $user->group_id and status is not NULL"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) die($res->getMessage()); diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index d5a7f51d..01b0db36 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -34,10 +34,10 @@ import('ttInvoiceHelper'); class ttTeamHelper { // The getUserCount function returns number of people in team. - static function getUserCount($team_id) { + static function getUserCount($group_id) { $mdb2 = getConnection(); - $sql = "select count(id) as cnt from tt_users where team_id = $team_id and status = 1"; + $sql = "select count(id) as cnt from tt_users where group_id = $group_id and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -75,9 +75,9 @@ class ttTeamHelper { $mdb2 = getConnection(); if (isset($options['getAllFields'])) - $sql = "select u.*, r.name as role_name, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $user->team_id and u.status = 1 order by upper(u.name)"; + $sql = "select u.*, r.name as role_name, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $user->group_id and u.status = 1 order by upper(u.name)"; else - $sql = "select id, name from tt_users where team_id = $user->team_id and status = 1 order by upper(name)"; + $sql = "select id, name from tt_users where group_id = $user->group_id and status = 1 order by upper(name)"; $res = $mdb2->query($sql); $user_list = array(); if (is_a($res, 'PEAR_Error')) @@ -109,7 +109,7 @@ class ttTeamHelper { $mdb2 = getConnection(); // Obtain role id for the user we are swapping ourselves with. - $sql = "select u.id, u.role_id from tt_users u left join tt_roles r on (u.role_id = r.id) where u.id = $user_id and u.team_id = $user->team_id and u.status = 1 and r.rank < $user->rank"; + $sql = "select u.id, u.role_id from tt_users u left join tt_roles r on (u.role_id = r.id) where u.id = $user_id and u.group_id = $user->group_id and u.status = 1 and r.rank < $user->rank"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; @@ -120,13 +120,13 @@ class ttTeamHelper { $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id); // Promote user. - $sql = "update tt_users set role_id = $user->role_id".$modified_part." where id = $user_id and team_id = $user->team_id"; + $sql = "update tt_users set role_id = $user->role_id".$modified_part." where id = $user_id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Demote self. $role_id = $val['role_id']; - $sql = "update tt_users set role_id = $role_id".$modified_part." where id = $user->id and team_id = $user->team_id"; + $sql = "update tt_users set role_id = $role_id".$modified_part." where id = $user->id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -138,7 +138,7 @@ class ttTeamHelper { global $user; $mdb2 = getConnection(); - $sql = "select u.id, u.name, r.rank, r.rights from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $user->team_id and u.status = 1 and r.rank < $user->rank order by upper(u.name)"; + $sql = "select u.id, u.name, r.rank, r.rights from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $user->group_id and u.status = 1 and r.rank < $user->rank order by upper(u.name)"; $res = $mdb2->query($sql); $user_list = array(); if (is_a($res, 'PEAR_Error')) @@ -157,7 +157,7 @@ class ttTeamHelper { static function getUsers() { global $user; $mdb2 = getConnection(); - $sql = "select id, name from tt_users where team_id = $user->team_id and (status = 1 or status = 0) order by upper(name)"; + $sql = "select id, name from tt_users where group_id = $user->group_id and (status = 1 or status = 0) order by upper(name)"; $res = $mdb2->query($sql); $user_list = array(); if (is_a($res, 'PEAR_Error')) @@ -169,13 +169,13 @@ class ttTeamHelper { } // The getInactiveUsers obtains all inactive users in a given team. - static function getInactiveUsers($team_id, $all_fields = false) { + static function getInactiveUsers($group_id, $all_fields = false) { $mdb2 = getConnection(); if ($all_fields) - $sql = "select u.*, r.name as role_name from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $team_id and u.status = 0 order by upper(u.name)"; + $sql = "select u.*, r.name as role_name from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $group_id and u.status = 0 order by upper(u.name)"; else - $sql = "select id, name from tt_users where team_id = $team_id and status = 0 order by upper(name)"; + $sql = "select id, name from tt_users where group_id = $group_id and status = 0 order by upper(name)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -188,12 +188,12 @@ class ttTeamHelper { } // The getAllUsers obtains all users in a given team. - static function getAllUsers($team_id, $all_fields = false) { + static function getAllUsers($group_id, $all_fields = false) { $mdb2 = getConnection(); if ($all_fields) - $sql = "select * from tt_users where team_id = $team_id order by upper(name)"; + $sql = "select * from tt_users where group_id = $group_id order by upper(name)"; else - $sql = "select id, name from tt_users where team_id = $team_id order by upper(name)"; + $sql = "select id, name from tt_users where group_id = $group_id order by upper(name)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -206,13 +206,13 @@ class ttTeamHelper { } // getActiveProjects - returns an array of active projects for team. - static function getActiveProjects($team_id) + static function getActiveProjects($group_id) { $result = array(); $mdb2 = getConnection(); $sql = "select id, name, description, tasks from tt_projects - where team_id = $team_id and status = 1 order by upper(name)"; + where group_id = $group_id and status = 1 order by upper(name)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -224,13 +224,13 @@ class ttTeamHelper { } // getInactiveProjects - returns an array of inactive projects for team. - static function getInactiveProjects($team_id) + static function getInactiveProjects($group_id) { $result = array(); $mdb2 = getConnection(); $sql = "select id, name, description, tasks from tt_projects - where team_id = $team_id and status = 0 order by upper(name)"; + where group_id = $group_id and status = 0 order by upper(name)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -242,13 +242,13 @@ class ttTeamHelper { } // The getAllProjects obtains all projects in a given team. - static function getAllProjects($team_id, $all_fields = false) { + static function getAllProjects($group_id, $all_fields = false) { $mdb2 = getConnection(); if ($all_fields) - $sql = "select * from tt_projects where team_id = $team_id order by status, upper(name)"; + $sql = "select * from tt_projects where group_id = $group_id order by status, upper(name)"; else - $sql = "select id, name from tt_projects where team_id = $team_id order by status, upper(name)"; + $sql = "select id, name from tt_projects where group_id = $group_id order by status, upper(name)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -261,12 +261,12 @@ class ttTeamHelper { } // getActiveTasks - returns an array of active tasks for team. - static function getActiveTasks($team_id) + static function getActiveTasks($group_id) { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, description from tt_tasks where team_id = $team_id and status = 1 order by upper(name)"; + $sql = "select id, name, description from tt_tasks where group_id = $group_id and status = 1 order by upper(name)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -278,13 +278,13 @@ class ttTeamHelper { } // getInactiveTasks - returns an array of inactive tasks for team. - static function getInactiveTasks($team_id) + static function getInactiveTasks($group_id) { $result = array(); $mdb2 = getConnection(); $sql = "select id, name, description from tt_tasks - where team_id = $team_id and status = 0 order by upper(name)"; + where group_id = $group_id and status = 0 order by upper(name)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -296,13 +296,13 @@ class ttTeamHelper { } // The getAllTasks obtains all tasks in a given team. - static function getAllTasks($team_id, $all_fields = false) { + static function getAllTasks($group_id, $all_fields = false) { $mdb2 = getConnection(); if ($all_fields) - $sql = "select * from tt_tasks where team_id = $team_id order by status, upper(name)"; + $sql = "select * from tt_tasks where group_id = $group_id order by status, upper(name)"; else - $sql = "select id, name from tt_tasks where team_id = $team_id order by status, upper(name)"; + $sql = "select id, name from tt_tasks where group_id = $group_id order by status, upper(name)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -322,7 +322,7 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, description, rank, rights from tt_roles where team_id = $user->team_id and rank < $user->rank and status = 1 order by rank"; + $sql = "select id, name, description, rank, rights from tt_roles where group_id = $user->group_id and rank < $user->rank and status = 1 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -337,12 +337,12 @@ class ttTeamHelper { } // getActiveRoles - returns an array of active roles for team. - static function getActiveRoles($team_id) + static function getActiveRoles($group_id) { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, description, rank, rights from tt_roles where team_id = $team_id and status = 1 order by rank"; + $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and status = 1 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -355,13 +355,13 @@ class ttTeamHelper { } // getInactiveRoles - returns an array of inactive roles for team. - static function getInactiveRoles($team_id) + static function getInactiveRoles($group_id) { $result = array(); $mdb2 = getConnection(); $sql = "select id, name, rank, description from tt_roles - where team_id = $team_id and status = 0 order by rank"; + where group_id = $group_id and status = 0 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -380,7 +380,7 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name, description, rank, rights from tt_roles where team_id = $user->team_id and rank < $user->rank and status = 0 order by rank"; + $sql = "select id, name, description, rank, rights from tt_roles where group_id = $user->group_id and rank < $user->rank and status = 0 order by rank"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -395,15 +395,15 @@ class ttTeamHelper { } // The getActiveClients returns an array of active clients for team. - static function getActiveClients($team_id, $all_fields = false) + static function getActiveClients($group_id, $all_fields = false) { $result = array(); $mdb2 = getConnection(); if ($all_fields) - $sql = "select * from tt_clients where team_id = $team_id and status = 1 order by upper(name)"; + $sql = "select * from tt_clients where group_id = $group_id and status = 1 order by upper(name)"; else - $sql = "select id, name from tt_clients where team_id = $team_id and status = 1 order by upper(name)"; + $sql = "select id, name from tt_clients where group_id = $group_id and status = 1 order by upper(name)"; $res = $mdb2->query($sql); $result = array(); @@ -416,15 +416,15 @@ class ttTeamHelper { } // The getInactiveClients returns an array of inactive clients for team. - static function getInactiveClients($team_id, $all_fields = false) + static function getInactiveClients($group_id, $all_fields = false) { $result = array(); $mdb2 = getConnection(); if ($all_fields) - $sql = "select * from tt_clients where team_id = $team_id and status = 0 order by upper(name)"; + $sql = "select * from tt_clients where group_id = $group_id and status = 0 order by upper(name)"; else - $sql = "select id, name from tt_clients where team_id = $team_id and status = 0 order by upper(name)"; + $sql = "select id, name from tt_clients where group_id = $group_id and status = 0 order by upper(name)"; $res = $mdb2->query($sql); $result = array(); @@ -437,13 +437,13 @@ class ttTeamHelper { } // The getAllClients obtains all clients in a given team. - static function getAllClients($team_id, $all_fields = false) { + static function getAllClients($group_id, $all_fields = false) { $mdb2 = getConnection(); if ($all_fields) - $sql = "select * from tt_clients where team_id = $team_id order by status, upper(name)"; + $sql = "select * from tt_clients where group_id = $group_id order by status, upper(name)"; else - $sql = "select id, name from tt_clients where team_id = $team_id order by status, upper(name)"; + $sql = "select id, name from tt_clients where group_id = $group_id order by status, upper(name)"; $res = $mdb2->query($sql); $result = array(); @@ -470,7 +470,7 @@ class ttTeamHelper { $sql = "select i.id, i.name, i.date, i.client_id, i.status, c.name as client_name from tt_invoices i left join tt_clients c on (c.id = i.client_id) - where i.status = 1 and i.team_id = $user->team_id $client_part order by i.name"; + where i.status = 1 and i.group_id = $user->group_id $client_part order by i.name"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -496,7 +496,7 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $sql = "select * from tt_invoices where team_id = $user->team_id"; + $sql = "select * from tt_invoices where group_id = $user->group_id"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -509,7 +509,7 @@ class ttTeamHelper { } // The getRecentInvoices returns an array of recent invoices (max 3) for a client. - static function getRecentInvoices($team_id, $client_id) + static function getRecentInvoices($group_id, $client_id) { global $user; @@ -518,7 +518,7 @@ class ttTeamHelper { $sql = "select i.id, i.name from tt_invoices i left join tt_clients c on (c.id = i.client_id) - where i.team_id = $team_id and i.status = 1 and c.id = $client_id + where i.group_id = $group_id and i.status = 1 and c.id = $client_id order by i.id desc limit 3"; $res = $mdb2->query($sql); $result = array(); @@ -532,11 +532,11 @@ class ttTeamHelper { } // getUserToProjectBinds - obtains all user to project binds for a team. - static function getUserToProjectBinds($team_id) { + static function getUserToProjectBinds($group_id) { $mdb2 = getConnection(); $result = array(); - $sql = "select * from tt_user_project_binds where user_id in (select id from tt_users where team_id = $team_id) order by user_id, status, project_id"; + $sql = "select * from tt_user_project_binds where user_id in (select id from tt_users where group_id = $group_id) order by user_id, status, project_id"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -549,10 +549,10 @@ class ttTeamHelper { } // The getAllCustomFields obtains all custom fields in a given team. - static function getAllCustomFields($team_id) { + static function getAllCustomFields($group_id) { $mdb2 = getConnection(); - $sql = "select * from tt_custom_fields where team_id = $team_id order by status"; + $sql = "select * from tt_custom_fields where group_id = $group_id order by status"; $res = $mdb2->query($sql); $result = array(); @@ -566,10 +566,10 @@ class ttTeamHelper { } // The getAllCustomFieldOptions obtains all custom field options in a given team. - static function getAllCustomFieldOptions($team_id) { + static function getAllCustomFieldOptions($group_id) { $mdb2 = getConnection(); - $sql = "select * from tt_custom_field_options where field_id in (select id from tt_custom_fields where team_id = $team_id) order by id"; + $sql = "select * from tt_custom_field_options where field_id in (select id from tt_custom_fields where group_id = $group_id) order by id"; $res = $mdb2->query($sql); $result = array(); @@ -583,10 +583,10 @@ class ttTeamHelper { } // The getCustomFieldLog obtains all custom field log entries for a given team. - static function getCustomFieldLog($team_id) { + static function getCustomFieldLog($group_id) { $mdb2 = getConnection(); - $sql = "select * from tt_custom_field_log where field_id in (select id from tt_custom_fields where team_id = $team_id) order by id"; + $sql = "select * from tt_custom_field_log where field_id in (select id from tt_custom_fields where group_id = $group_id) order by id"; $res = $mdb2->query($sql); $result = array(); @@ -600,11 +600,11 @@ class ttTeamHelper { } // getFavReports - obtains all favorite reports for all users in team. - static function getFavReports($team_id) { + static function getFavReports($group_id) { $mdb2 = getConnection(); $result = array(); - $sql = "select * from tt_fav_reports where user_id in (select id from tt_users where team_id = $team_id)"; + $sql = "select * from tt_fav_reports where user_id in (select id from tt_users where group_id = $group_id)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -617,11 +617,11 @@ class ttTeamHelper { } // getExpenseItems - obtains all expense items for all users in team. - static function getExpenseItems($team_id) { + static function getExpenseItems($group_id) { $mdb2 = getConnection(); $result = array(); - $sql = "select * from tt_expense_items where user_id in (select id from tt_users where team_id = $team_id)"; + $sql = "select * from tt_expense_items where user_id in (select id from tt_users where group_id = $group_id)"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -634,14 +634,14 @@ class ttTeamHelper { } // getPredefinedExpenses - obtains predefined expenses for team. - static function getPredefinedExpenses($team_id) { + static function getPredefinedExpenses($group_id) { global $user; $replaceDecimalMark = ('.' != $user->decimal_mark); $mdb2 = getConnection(); $result = array(); - $sql = "select id, name, cost from tt_predefined_expenses where team_id = $team_id"; + $sql = "select id, name, cost from tt_predefined_expenses where group_id = $group_id"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -656,13 +656,13 @@ class ttTeamHelper { } // getNotifications - obtains notification descriptions for team. - static function getNotifications($team_id) { + static function getNotifications($group_id) { $mdb2 = getConnection(); $result = array(); $sql = "select c.id, c.cron_spec, c.email, c.report_condition, fr.name from tt_cron c left join tt_fav_reports fr on (fr.id = c.report_id) - where c.team_id = $team_id and c.status = 1 and fr.status = 1"; + where c.group_id = $group_id and c.status = 1 and fr.status = 1"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -675,11 +675,11 @@ class ttTeamHelper { } // getMonthlyQuotas - obtains monthly quotas for team. - static function getMonthlyQuotas($team_id) { + static function getMonthlyQuotas($group_id) { $mdb2 = getConnection(); $result = array(); - $sql = "select year, month, minutes from tt_monthly_quotas where team_id = $team_id"; + $sql = "select year, month, minutes from tt_monthly_quotas where group_id = $group_id"; $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -692,41 +692,41 @@ class ttTeamHelper { } // The markDeleted function marks the team and everything in it as deleted. - static function markDeleted($team_id) { + static function markDeleted($group_id) { // Iterate through team users and mark them as deleted. - $users = ttTeamHelper::getAllUsers($team_id); + $users = ttTeamHelper::getAllUsers($group_id); foreach ($users as $one_user) { if (!ttUserHelper::markDeleted($one_user['id'])) return false; } // Mark tasks deleted. - if (!ttTeamHelper::markTasksDeleted($team_id)) return false; + if (!ttTeamHelper::markTasksDeleted($group_id)) return false; $mdb2 = getConnection(); // Mark roles deleted. - $sql = "update tt_roles set status = NULL where team_id = $team_id"; + $sql = "update tt_roles set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark projects deleted. - $sql = "update tt_projects set status = NULL where team_id = $team_id"; + $sql = "update tt_projects set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark clients deleted. - $sql = "update tt_clients set status = NULL where team_id = $team_id"; + $sql = "update tt_clients set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark custom fields deleted. - $sql = "update tt_custom_fields set status = NULL where team_id = $team_id"; + $sql = "update tt_custom_fields set status = NULL where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark group deleted. - $sql = "update tt_groups set status = NULL where id = $team_id"; + $sql = "update tt_groups set status = NULL where id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -734,15 +734,15 @@ class ttTeamHelper { } // The getTeamDetails function returns team details. - static function getTeamDetails($team_id) { + static function getTeamDetails($group_id) { $result = array(); $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_groups t - inner join tt_users u on (u.team_id = t.id) + inner join tt_users u on (u.group_id = t.id) inner join tt_roles r on (r.id = u.role_id and r.rank = 512) - where t.id = $team_id"; + where t.id = $group_id"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -846,15 +846,15 @@ class ttTeamHelper { $affected = $mdb2->exec($sql); if (!is_a($affected, 'PEAR_Error')) { - $team_id = $mdb2->lastInsertID('tt_groups', 'id'); - return $team_id; + $group_id = $mdb2->lastInsertID('tt_groups', 'id'); + return $group_id; } return false; } // The update function updates team information. - static function update($team_id, $fields) + static function update($group_id, $fields) { global $user; $mdb2 = getConnection(); @@ -891,7 +891,7 @@ class ttTeamHelper { $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"; + $bcc_email_part $plugins_part $config_part $lock_spec_part $workday_minutes_part $modified_part where id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -912,10 +912,10 @@ class ttTeamHelper { $count = 0; if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { - $team_id = $val['id']; - if (ttTeamHelper::isTeamActive($team_id) == false) { + $group_id = $val['id']; + if (ttTeamHelper::isTeamActive($group_id) == false) { $count++; - $inactive_teams[] = $team_id; + $inactive_teams[] = $group_id; // Limit the array size for perfomance by allowing this operation on small chunks only. if ($count >= 100) break; } @@ -926,11 +926,11 @@ class ttTeamHelper { } // The isTeamActive determines if a team is using Time Tracker or abandoned it. - static function isTeamActive($team_id) { + static function isTeamActive($group_id) { $users = array(); $mdb2 = getConnection(); - $sql = "select id from tt_users where team_id = $team_id"; + $sql = "select id from tt_users where group_id = $group_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) die($res->getMessage()); while ($val = $res->fetchRow()) { @@ -971,11 +971,11 @@ class ttTeamHelper { } // The delete function permanently deletes all data for a team. - static function delete($team_id) { + static function delete($group_id) { $mdb2 = getConnection(); // Delete users. - $sql = "select id from tt_users where team_id = $team_id"; + $sql = "select id from tt_users where group_id = $group_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; while ($val = $res->fetchRow()) { @@ -984,38 +984,38 @@ class ttTeamHelper { } // Delete tasks. - if (!ttTeamHelper::deleteTasks($team_id)) return false; + if (!ttTeamHelper::deleteTasks($group_id)) return false; // Delete client to project binds. - $sql = "delete from tt_client_project_binds where client_id in (select id from tt_clients where team_id = $team_id)"; + $sql = "delete from tt_client_project_binds where client_id in (select id from tt_clients where group_id = $group_id)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Delete projects. - $sql = "delete from tt_projects where team_id = $team_id"; + $sql = "delete from tt_projects where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Delete clients. - $sql = "delete from tt_clients where team_id = $team_id"; + $sql = "delete from tt_clients where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Delete invoices. - $sql = "delete from tt_invoices where team_id = $team_id"; + $sql = "delete from tt_invoices where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Delete custom fields. - if (!ttTeamHelper::deleteCustomFields($team_id)) return false; + if (!ttTeamHelper::deleteCustomFields($group_id)) return false; // Delete roles. - $sql = "delete from tt_roles where team_id = $team_id"; + $sql = "delete from tt_roles where group_id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Delete group. - $sql = "delete from tt_groups where id = $team_id"; + $sql = "delete from tt_groups where id = $group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -1023,9 +1023,9 @@ class ttTeamHelper { } // The markTasksDeleted deletes task binds and marks the tasks as deleted for a team. - static function markTasksDeleted($team_id) { + static function markTasksDeleted($group_id) { $mdb2 = getConnection(); - $sql = "select id from tt_tasks where team_id = $team_id"; + $sql = "select id from tt_tasks where group_id = $group_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; @@ -1047,9 +1047,9 @@ class ttTeamHelper { } // The deleteTasks deletes all tasks and task binds for an inactive team. - static function deleteTasks($team_id) { + static function deleteTasks($group_id) { $mdb2 = getConnection(); - $sql = "select id from tt_tasks where team_id = $team_id"; + $sql = "select id from tt_tasks where group_id = $group_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; @@ -1071,9 +1071,9 @@ class ttTeamHelper { } // The deleteCustomFields cleans up tt_custom_field_log, tt_custom_field_options and tt_custom_fields tables for an inactive team. - static function deleteCustomFields($team_id) { + static function deleteCustomFields($group_id) { $mdb2 = getConnection(); - $sql = "select id from tt_custom_fields where team_id = $team_id"; + $sql = "select id from tt_custom_fields where group_id = $group_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; @@ -1118,7 +1118,7 @@ class ttTeamHelper { $plugins = implode(',', $plugin_array); if ($plugins != $user->plugins) { - if (!ttTeamHelper::update($user->team_id, array('name' => $user->team,'plugins' => $plugins))) + if (!ttTeamHelper::update($user->group_id, array('name' => $user->team,'plugins' => $plugins))) return false; $user->plugins = $plugins; } diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 7e167f61..70e55040 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -30,7 +30,7 @@ class ttUser { var $login = null; // User login. var $name = null; // User name. var $id = null; // User id. - var $team_id = null; // Team id. + var $group_id = null; // Group id. var $role_id = null; // Role id. var $role_name = null; // Role name. var $rank = null; // User role rank. @@ -72,11 +72,11 @@ class ttUser { $mdb2 = getConnection(); - $sql = "SELECT u.id, u.login, u.name, u.team_id, u.role_id, r.rank, r.name as role_name, r.rights, u.client_id, u.email, t.name as team_name, + $sql = "SELECT u.id, u.login, u.name, u.group_id, u.role_id, r.rank, r.name as role_name, r.rights, u.client_id, u.email, t.name as team_name, 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_groups 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.group_id = t.id) LEFT JOIN tt_roles r on (r.id = u.role_id) WHERE "; if ($id) $sql .= "u.id = $id"; else @@ -93,7 +93,7 @@ class ttUser { $this->login = $val['login']; $this->name = $val['name']; $this->id = $val['id']; - $this->team_id = $val['team_id']; + $this->group_id = $val['group_id']; $this->role_id = $val['role_id']; $this->role_name = $val['role_name']; $this->rights = explode(',', $val['rights']); @@ -193,7 +193,7 @@ class ttUser { // Do a query with inner join to get assigned projects. $sql = "select p.id, p.name, p.description, p.tasks, upb.rate from tt_projects p inner join tt_user_project_binds upb on (upb.user_id = ".$this->getActiveUser()." and upb.project_id = p.id and upb.status = 1) - where p.team_id = $this->team_id and p.status = 1 order by p.name"; + where p.group_id = $this->group_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -261,7 +261,7 @@ class ttUser { if (isset($options['max_rank']) || $skipClients || isset($options['include_role'])) $left_joins .= ' left join tt_roles r on (u.role_id = r.id)'; - $where_part = " where u.team_id = $this->team_id"; + $where_part = " where u.group_id = $this->group_id"; if (isset($options['status'])) $where_part .= ' and u.status = '.(int)$options['status']; else @@ -312,7 +312,7 @@ class ttUser { $sql = "select u.id, u.name, u.login, u.role_id, u.status, u.rate, u.email from tt_users u". " left join tt_roles r on (u.role_id = r.id)". - " where u.id = $user_id and u.team_id = $this->team_id and u.status is not null". + " where u.id = $user_id and u.group_id = $this->group_id and u.status is not null". " and (r.rank < $this->rank or (r.rank = $this->rank and u.id = $this->id))"; // Users with lesser roles or self. $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index dab51297..40cd7829 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -101,7 +101,7 @@ class ttUserHelper { if($hash) $password = 'md5('.$password.')'; $email = isset($fields['email']) ? $fields['email'] : ''; - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $rate = str_replace(',', '.', isset($fields['rate']) ? $fields['rate'] : 0); if($rate == '') $rate = 0; @@ -112,9 +112,9 @@ class ttUserHelper { $created_ip_v = ', '.$mdb2->quote($_SERVER['REMOTE_ADDR']); $created_by_v = ', '.$mdb2->quote($user->id); - $sql = "insert into tt_users (name, login, password, team_id, role_id, client_id, rate, email, created, created_ip, created_by $status_f) values (". + $sql = "insert into tt_users (name, login, password, group_id, role_id, client_id, rate, email, created, created_ip, created_by $status_f) values (". $mdb2->quote($fields['name']).", ".$mdb2->quote($fields['login']). - ", $password, $team_id, ".$mdb2->quote($fields['role_id']).", ".$mdb2->quote($fields['client_id']).", $rate, ".$mdb2->quote($email).", now() $created_ip_v $created_by_v $status_v)"; + ", $password, $group_id, ".$mdb2->quote($fields['role_id']).", ".$mdb2->quote($fields['client_id']).", $rate, ".$mdb2->quote($email).", now() $created_ip_v $created_by_v $status_v)"; $affected = $mdb2->exec($sql); // Now deal with project assignment. @@ -191,7 +191,7 @@ class ttUserHelper { // otherwise de-activate the bind (set its status to inactive). This will keep the bind // and its rate in database for reporting. - $all_projects = ttTeamHelper::getAllProjects($user->team_id); + $all_projects = ttTeamHelper::getAllProjects($user->group_id); $assigned_projects = isset($fields['projects']) ? $fields['projects'] : array(); foreach($all_projects as $p) { @@ -282,13 +282,13 @@ class ttUserHelper { return false; // Mark user as deleted. - $sql = "update tt_users set status = NULL where id = $user_id and team_id = ".$user->team_id; + $sql = "update tt_users set status = NULL where id = $user_id and group_id = ".$user->group_id; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; } elseif ($user->isManager()) { - $user_count = ttTeamHelper::getUserCount($user->team_id); + $user_count = ttTeamHelper::getUserCount($user->group_id); // Marking deleted a manager with active users is not allowed. if (($user_id == $user->id) && ($user_count > 1)) @@ -296,29 +296,29 @@ class ttUserHelper { if (1 == $user_count) { // Mark tasks deleted. - if (!ttTeamHelper::markTasksDeleted($user->team_id)) + if (!ttTeamHelper::markTasksDeleted($user->group_id)) return false; // Mark projects deleted. - $sql = "update tt_projects set status = NULL where team_id = $user->team_id"; + $sql = "update tt_projects set status = NULL where group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark clients deleted. - $sql = "update tt_clients set status = NULL where team_id = $user->team_id"; + $sql = "update tt_clients set status = NULL where group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark custom fields deleted. - $sql = "update tt_custom_fields set status = NULL where team_id = $user->team_id"; + $sql = "update tt_custom_fields set status = NULL where group_id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Mark team deleted. - $sql = "update tt_groups set status = NULL where id = $user->team_id"; + $sql = "update tt_groups set status = NULL where id = $user->group_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -337,7 +337,7 @@ class ttUserHelper { return false; // Mark user as deleted. - $sql = "update tt_users set status = NULL where id = $user_id and team_id = ".$user->team_id; + $sql = "update tt_users set status = NULL where id = $user_id and group_id = ".$user->group_id; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttWeekViewHelper.class.php b/WEB-INF/lib/ttWeekViewHelper.class.php index f4ee719f..27a1bbcf 100644 --- a/WEB-INF/lib/ttWeekViewHelper.class.php +++ b/WEB-INF/lib/ttWeekViewHelper.class.php @@ -45,7 +45,7 @@ class ttWeekViewHelper { $custom_field_1 = null; if ($user->isPluginEnabled('cf')) { - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $cf_1_type = $custom_fields->fields[0]['type']; if ($cf_1_type == CustomFields::TYPE_TEXT) { $custom_field_1 = ', cfl.value as cf_1_value'; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 1a5dbf67..10419c01 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.80.4199 | Copyright © Anuko | +  Anuko Time Tracker 1.17.81.4200 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/admin_team_delete.php b/admin_team_delete.php index a9ce1ee1..61a17041 100644 --- a/admin_team_delete.php +++ b/admin_team_delete.php @@ -36,12 +36,12 @@ if (!ttAccessAllowed('administer_site')) { exit(); } -$team_id = (int)$request->getParameter('id'); -$team_details = ttTeamHelper::getTeamDetails($team_id); +$group_id = (int)$request->getParameter('id'); +$team_details = ttTeamHelper::getTeamDetails($group_id); $team_name = $team_details['team_name']; $form = new Form('teamForm'); -$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$team_id)); +$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id)); $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->get('label.delete'))); $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel'))); @@ -49,7 +49,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_delete')) { import('ttAdmin'); $admin = new ttAdmin(); - $result = $admin->markGroupDeleted($team_id); + $result = $admin->markGroupDeleted($group_id); if ($result) { header('Location: admin_teams.php'); exit(); diff --git a/admin_team_edit.php b/admin_team_edit.php index a737050a..05bfec8b 100644 --- a/admin_team_edit.php +++ b/admin_team_edit.php @@ -37,8 +37,8 @@ if (!ttAccessAllowed('administer_site')) { exit(); } -$team_id = $request->getParameter('id'); -$team_details = ttTeamHelper::getTeamDetails($team_id); +$group_id = $request->getParameter('id'); +$team_details = ttTeamHelper::getTeamDetails($group_id); if ($request->isPost()) { $cl_team_name = trim($request->getParameter('team_name')); @@ -68,7 +68,7 @@ if (!$auth->isPasswordExternal()) { $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password2','value'=>$cl_password2)); } $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email)); -$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$team_id)); +$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id)); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel'))); @@ -88,7 +88,7 @@ if ($request->isPost()) { import('ttAdmin'); $admin = new ttAdmin($err); - $result = $admin->updateGroup($team_id, $fields); + $result = $admin->updateGroup($group_id, $fields); if ($result) { header('Location: admin_teams.php'); exit(); diff --git a/client_add.php b/client_add.php index 5ae5997f..3afcbc07 100644 --- a/client_add.php +++ b/client_add.php @@ -41,7 +41,7 @@ if (!$user->isPluginEnabled('cl')) { exit(); } -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -71,7 +71,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttClientHelper::getClientByName($cl_name)) { if (ttClientHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'address' => $cl_address, 'tax' => $cl_tax, diff --git a/client_edit.php b/client_edit.php index b74fb315..74062d06 100644 --- a/client_edit.php +++ b/client_edit.php @@ -43,7 +43,7 @@ if (!$user->isPluginEnabled('cl')) { $cl_id = (int) $request->getParameter('id'); -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -103,7 +103,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttClientHelper::getClientByName($cl_name)) { if (ttClientHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'address' => $cl_address, 'tax' => $cl_tax, diff --git a/clients.php b/clients.php index 6ac6f5a1..177bd61e 100644 --- a/clients.php +++ b/clients.php @@ -40,8 +40,8 @@ if (!$user->isPluginEnabled('cl')) { exit(); } -$smarty->assign('active_clients', ttTeamHelper::getActiveClients($user->team_id, true)); -$smarty->assign('inactive_clients', ttTeamHelper::getInactiveClients($user->team_id, true)); +$smarty->assign('active_clients', ttTeamHelper::getActiveClients($user->group_id, true)); +$smarty->assign('inactive_clients', ttTeamHelper::getInactiveClients($user->group_id, true)); $smarty->assign('title', $i18n->get('title.clients')); $smarty->assign('content_page_name', 'clients.tpl'); $smarty->display('index.tpl'); diff --git a/dbinstall.php b/dbinstall.php index 190ff7ee..97a5085d 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -872,6 +872,17 @@ if ($_POST) { 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'"); + setChange("ALTER TABLE `tt_roles` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_users` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_projects` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_tasks` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_invoices` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_cron` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_clients` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_custom_fields` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_predefined_expenses` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("ALTER TABLE `tt_monthly_quotas` CHANGE `team_id` `group_id` int(11) NOT NULL"); + setChange("UPDATE `tt_site_config` SET param_value = '1.17.81', modified = now() where param_name = 'version_db' and param_value = '1.17.80'"); } if ($_POST["cleanup"]) { diff --git a/expense_edit.php b/expense_edit.php index 99503b06..3e8b18e9 100644 --- a/expense_edit.php +++ b/expense_edit.php @@ -76,7 +76,7 @@ $form = new Form('expenseItemForm'); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -101,7 +101,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -127,7 +127,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } } // If predefined expenses are configured, add controls to select an expense and quantity. -$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id); +$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id); if ($predefined_expenses) { $form->addInput(array('type'=>'combobox', 'onchange'=>'recalculateCost();', diff --git a/expenses.php b/expenses.php index 7291414a..fee81205 100644 --- a/expenses.php +++ b/expenses.php @@ -92,7 +92,7 @@ if ($user->can('track_expenses')) { // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -118,7 +118,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -144,7 +144,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } } // If predefined expenses are configured, add controls to select an expense and quantity. -$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id); +$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id); if ($predefined_expenses) { $form->addInput(array('type'=>'combobox', 'onchange'=>'recalculateCost();', diff --git a/group_edit.php b/group_edit.php index 0ce93582..1d71cc17 100644 --- a/group_edit.php +++ b/group_edit.php @@ -268,7 +268,7 @@ if ($request->isPost()) { $config .= ',uncompleted_indicators'; $config = trim($config, ','); - $update_result = ttTeamHelper::update($user->team_id, array( + $update_result = ttTeamHelper::update($user->group_id, array( 'name' => $cl_team, 'currency' => $cl_currency, 'lang' => $cl_lang, diff --git a/initialize.php b/initialize.php index 5d721b80..261ec747 100644 --- a/initialize.php +++ b/initialize.php @@ -170,8 +170,8 @@ $msg = new ActionErrors(); // Notification messages (not errrors) for user. import('ttUser'); $user = new ttUser(null, $auth->getUserId()); if ($user->custom_logo) { - $smarty->assign('custom_logo', 'images/'.$user->team_id.'.png'); - $smarty->assign('mobile_custom_logo', '../images/'.$user->team_id.'.png'); + $smarty->assign('custom_logo', 'images/'.$user->group_id.'.png'); + $smarty->assign('mobile_custom_logo', '../images/'.$user->group_id.'.png'); } $smarty->assign('user', $user); diff --git a/invoice_add.php b/invoice_add.php index ad9c3cfb..61568e2a 100644 --- a/invoice_add.php +++ b/invoice_add.php @@ -56,12 +56,12 @@ $form->addInput(array('type'=>'datefield','name'=>'date','size'=>'20','value'=>$ // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $clients = ttTeamHelper::getActiveClients($user->team_id); + $clients = ttTeamHelper::getActiveClients($user->group_id); $form->addInput(array('type'=>'combobox','name'=>'client','style'=>'width: 250px;','data'=>$clients,'datakeys'=>array('id','name'),'value'=>$cl_client,'empty'=>array(''=>$i18n->get('dropdown.select')))); } // Dropdown for projects. if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $projects = ttTeamHelper::getActiveProjects($user->team_id); + $projects = ttTeamHelper::getActiveProjects($user->group_id); $form->addInput(array('type'=>'combobox','name'=>'project','style'=>'width: 250px;','data'=>$projects,'datakeys'=>array('id','name'),'value'=>$cl_project,'empty'=>array(''=>$i18n->get('dropdown.all')))); } $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'number','style'=>'width: 250px;','value'=>$cl_number)); diff --git a/locking.php b/locking.php index 2b49b837..99e79a21 100644 --- a/locking.php +++ b/locking.php @@ -51,7 +51,7 @@ if ($request->isPost()) { if (!ttValidCronSpec($cl_lock_spec)) $err->add($i18n->get('error.field'), $i18n->get('label.schedule')); if ($err->no()) { - if (ttTeamHelper::update($user->team_id, array( + if (ttTeamHelper::update($user->group_id, array( 'name' => $user->team, 'lock_spec' => $cl_lock_spec))) { header('Location: profile_edit.php'); diff --git a/mobile/client_add.php b/mobile/client_add.php index fc57853d..f83c720a 100644 --- a/mobile/client_add.php +++ b/mobile/client_add.php @@ -41,7 +41,7 @@ if (!$user->isPluginEnabled('cl')) { exit(); } -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -71,7 +71,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttClientHelper::getClientByName($cl_name)) { if (ttClientHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'address' => $cl_address, 'tax' => $cl_tax, diff --git a/mobile/client_edit.php b/mobile/client_edit.php index eb859229..093e9668 100644 --- a/mobile/client_edit.php +++ b/mobile/client_edit.php @@ -43,7 +43,7 @@ if (!$user->isPluginEnabled('cl')) { $cl_id = (int) $request->getParameter('id'); -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -104,7 +104,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttClientHelper::getClientByName($cl_name)) { if (ttClientHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'address' => $cl_address, 'tax' => $cl_tax, diff --git a/mobile/clients.php b/mobile/clients.php index 43e6848a..4f03510c 100644 --- a/mobile/clients.php +++ b/mobile/clients.php @@ -40,8 +40,8 @@ if (!$user->isPluginEnabled('cl')) { exit(); } -$smarty->assign('active_clients', ttTeamHelper::getActiveClients($user->team_id, true)); -$smarty->assign('inactive_clients', ttTeamHelper::getInactiveClients($user->team_id, true)); +$smarty->assign('active_clients', ttTeamHelper::getActiveClients($user->group_id, true)); +$smarty->assign('inactive_clients', ttTeamHelper::getInactiveClients($user->group_id, true)); $smarty->assign('title', $i18n->get('title.clients')); $smarty->assign('content_page_name', 'mobile/clients.tpl'); $smarty->display('mobile/index.tpl'); diff --git a/mobile/expense_edit.php b/mobile/expense_edit.php index 1611378d..f560f557 100644 --- a/mobile/expense_edit.php +++ b/mobile/expense_edit.php @@ -73,7 +73,7 @@ $form = new Form('expenseItemForm'); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -98,7 +98,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -124,7 +124,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } } // If predefined expenses are configured, add controls to select an expense and quantity. -$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id); +$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id); if ($predefined_expenses) { $form->addInput(array('type'=>'combobox', 'onchange'=>'recalculateCost();', diff --git a/mobile/expenses.php b/mobile/expenses.php index 1cd39c04..815a4fc3 100644 --- a/mobile/expenses.php +++ b/mobile/expenses.php @@ -96,7 +96,7 @@ if ($user->can('track_expenses')) { // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -122,7 +122,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -148,7 +148,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } } // If predefined expenses are configured, add controls to select an expense and quantity. -$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id); +$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id); if ($predefined_expenses) { $form->addInput(array('type'=>'combobox', 'onchange'=>'recalculateCost();', diff --git a/mobile/project_add.php b/mobile/project_add.php index bb0f1d09..b0d5394d 100644 --- a/mobile/project_add.php +++ b/mobile/project_add.php @@ -46,7 +46,7 @@ $users = ttTeamHelper::getActiveUsers(); foreach ($users as $user_item) $all_users[$user_item['id']] = $user_item['name']; -$tasks = ttTeamHelper::getActiveTasks($user->team_id); +$tasks = ttTeamHelper::getActiveTasks($user->group_id); foreach ($tasks as $task_item) $all_tasks[$task_item['id']] = $task_item['name']; @@ -78,7 +78,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'description' => $cl_description, 'users' => $cl_users, diff --git a/mobile/project_edit.php b/mobile/project_edit.php index 6adb475e..94f3e514 100644 --- a/mobile/project_edit.php +++ b/mobile/project_edit.php @@ -52,7 +52,7 @@ $users = ttTeamHelper::getActiveUsers(); foreach ($users as $user_item) $all_users[$user_item['id']] = $user_item['name']; -$tasks = ttTeamHelper::getActiveTasks($user->team_id); +$tasks = ttTeamHelper::getActiveTasks($user->group_id); foreach ($tasks as $task_item) $all_tasks[$task_item['id']] = $task_item['name']; @@ -119,7 +119,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'description' => $cl_description, 'users' => $cl_users, diff --git a/mobile/projects.php b/mobile/projects.php index a9f8ab02..e3dc2f87 100644 --- a/mobile/projects.php +++ b/mobile/projects.php @@ -42,8 +42,8 @@ if (MODE_PROJECTS != $user->tracking_mode && MODE_PROJECTS_AND_TASKS != $user->t // End of access checks. if($user->can('manage_projects')) { - $active_projects = ttTeamHelper::getActiveProjects($user->team_id); - $inactive_projects = ttTeamHelper::getInactiveProjects($user->team_id); + $active_projects = ttTeamHelper::getActiveProjects($user->group_id); + $inactive_projects = ttTeamHelper::getInactiveProjects($user->group_id); } else $active_projects = $user->getAssignedProjects(); diff --git a/mobile/task_add.php b/mobile/task_add.php index fd1fb464..4b257edc 100644 --- a/mobile/task_add.php +++ b/mobile/task_add.php @@ -43,7 +43,7 @@ if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) { } // End of access checks. -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -68,7 +68,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'description' => $cl_description, 'status' => ACTIVE, diff --git a/mobile/task_edit.php b/mobile/task_edit.php index f1748c7e..f1e25689 100644 --- a/mobile/task_edit.php +++ b/mobile/task_edit.php @@ -48,7 +48,7 @@ if (!$task) { } // End of access checks. -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -103,7 +103,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'description' => $cl_description, 'status' => $cl_status, diff --git a/mobile/tasks.php b/mobile/tasks.php index e49498c4..9ad18a17 100644 --- a/mobile/tasks.php +++ b/mobile/tasks.php @@ -41,8 +41,8 @@ if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) { } // End of access checks. -$smarty->assign('active_tasks', ttTeamHelper::getActiveTasks($user->team_id)); -$smarty->assign('inactive_tasks', ttTeamHelper::getInactiveTasks($user->team_id)); +$smarty->assign('active_tasks', ttTeamHelper::getActiveTasks($user->group_id)); +$smarty->assign('inactive_tasks', ttTeamHelper::getInactiveTasks($user->group_id)); $smarty->assign('title', $i18n->get('title.tasks')); $smarty->assign('content_page_name', 'mobile/tasks.tpl'); $smarty->display('mobile/index.tpl'); diff --git a/mobile/time.php b/mobile/time.php index 8c6721d4..2649ff27 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -57,7 +57,7 @@ $next_date = date('Y-m-d', strtotime('+1 day', strtotime($cl_date))); // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('../plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -90,7 +90,7 @@ $form = new Form('timeRecordForm'); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -116,7 +116,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -144,7 +144,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->team_id); + $task_list = ttTeamHelper::getActiveTasks($user->group_id); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/mobile/time_edit.php b/mobile/time_edit.php index a1a56e37..40f58e8d 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -51,7 +51,7 @@ if (!$time_rec || $time_rec['invoice_id']) { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('../plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -107,7 +107,7 @@ $form = new Form('timeRecordForm'); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -133,7 +133,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -161,7 +161,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->team_id); + $task_list = ttTeamHelper::getActiveTasks($user->group_id); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/mobile/timer.php b/mobile/timer.php index 059767ed..e547c256 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -53,7 +53,7 @@ $_SESSION['date'] = $cl_date; // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('../plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -88,7 +88,7 @@ $form = new Form('timeRecordForm'); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -116,7 +116,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -144,7 +144,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->team_id); + $task_list = ttTeamHelper::getActiveTasks($user->group_id); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/mobile/user_add.php b/mobile/user_add.php index 53b9842f..93411452 100644 --- a/mobile/user_add.php +++ b/mobile/user_add.php @@ -45,7 +45,7 @@ if (!ttAccessAllowed('manage_users')) { @include('plugins/limit/user_add.php'); if ($user->isPluginEnabled('cl')) - $clients = ttTeamHelper::getActiveClients($user->team_id); + $clients = ttTeamHelper::getActiveClients($user->group_id); $assigned_projects = array(); if ($request->isPost()) { @@ -89,7 +89,7 @@ if ($user->isPluginEnabled('cl')) $form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate)); -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); // Define classes for the projects table. class NameCellRenderer extends DefaultCellRenderer { @@ -147,7 +147,7 @@ if ($request->isPost()) { 'login' => $cl_login, 'password' => $cl_password1, 'rate' => $cl_rate, - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'role_id' => $cl_role_id, 'client_id' => $cl_client_id, 'projects' => $assigned_projects, diff --git a/mobile/user_edit.php b/mobile/user_edit.php index f82d9314..46646bca 100644 --- a/mobile/user_edit.php +++ b/mobile/user_edit.php @@ -48,9 +48,9 @@ if (!$user_details) { // End of access checks. if ($user->isPluginEnabled('cl')) - $clients = ttTeamHelper::getActiveClients($user->team_id); + $clients = ttTeamHelper::getActiveClients($user->group_id); -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); $assigned_projects = array(); if ($request->isPost()) { diff --git a/mobile/users.php b/mobile/users.php index 18ad2e5f..4723543d 100644 --- a/mobile/users.php +++ b/mobile/users.php @@ -42,7 +42,7 @@ if (!(ttAccessAllowed('view_users') || ttAccessAllowed('manage_users'))) { $active_users = ttTeamHelper::getActiveUsers(array('getAllFields'=>true)); if($user->canManageTeam()) { $can_delete_manager = (1 == count($active_users)); - $inactive_users = ttTeamHelper::getInactiveUsers($user->team_id, true); + $inactive_users = ttTeamHelper::getInactiveUsers($user->group_id, true); } // Check if the team is set to show indicators for uncompleted time entries. diff --git a/mysql.sql b/mysql.sql index 4a48a662..78ee25ab 100644 --- a/mysql.sql +++ b/mysql.sql @@ -50,7 +50,7 @@ CREATE TABLE `tt_groups` ( # CREATE TABLE `tt_roles` ( `id` int(11) NOT NULL auto_increment, # Role id. Identifies roles for all groups on the server. - `team_id` int(11) NOT NULL, # Team id the role is defined for. + `group_id` int(11) NOT NULL, # Group id the role is defined for. `name` varchar(80) default NULL, # Role name - custom role name. In case we are editing a # predefined role (USER, etc.), we can rename the role here. `description` varchar(255) default NULL, # Role description. @@ -69,11 +69,11 @@ CREATE TABLE `tt_roles` ( ); # Create an index that guarantees unique active and inactive role ranks in each group. -create unique index role_idx on tt_roles(team_id, rank, status); +create unique index role_idx on tt_roles(group_id, rank, status); # Insert site-wide roles - site administrator and top manager. -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, 'track_own_time,track_own_expenses,view_own_reports,view_own_charts,view_own_invoices,view_own_projects,manage_own_settings,view_users,track_time,track_expenses,view_reports,view_charts,override_punch_mode,override_own_punch_mode,override_date_lock,override_own_date_lock,swap_roles,approve_timesheets,manage_own_account,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'); +INSERT INTO `tt_roles` (`group_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site'); +INSERT INTO `tt_roles` (`group_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'track_own_time,track_own_expenses,view_own_reports,view_own_charts,view_own_invoices,view_own_projects,manage_own_settings,view_users,track_time,track_expenses,view_reports,view_charts,override_punch_mode,override_own_punch_mode,override_date_lock,override_own_date_lock,swap_roles,approve_timesheets,manage_own_account,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'); # @@ -84,7 +84,7 @@ CREATE TABLE `tt_users` ( `login` varchar(50) COLLATE utf8_bin NOT NULL, # user login `password` varchar(50) default NULL, # password hash `name` varchar(100) default NULL, # user name - `team_id` int(11) NOT NULL, # team id + `group_id` int(11) NOT NULL, # group id `role_id` int(11) default NULL, # role id `client_id` int(11) default NULL, # client id for "client" user role `rate` float(6,2) NOT NULL default '0.00', # default hourly rate @@ -106,7 +106,7 @@ create unique index login_idx on tt_users(login, status); # Create admin account with password 'secret'. Admin is a superuser, who can create teams. DELETE from `tt_users` WHERE login = 'admin'; -INSERT INTO `tt_users` (`login`, `password`, `name`, `team_id`, `role_id`) VALUES ('admin', md5('secret'), 'Admin', '0', (select id from tt_roles where rank = 1024)); +INSERT INTO `tt_users` (`login`, `password`, `name`, `group_id`, `role_id`) VALUES ('admin', md5('secret'), 'Admin', '0', (select id from tt_roles where rank = 1024)); # @@ -114,7 +114,7 @@ INSERT INTO `tt_users` (`login`, `password`, `name`, `team_id`, `role_id`) VALUE # CREATE TABLE `tt_projects` ( `id` int(11) NOT NULL auto_increment, # project id - `team_id` int(11) NOT NULL, # team id + `group_id` int(11) NOT NULL, # group id `name` varchar(80) COLLATE utf8_bin NOT NULL, # project name `description` varchar(255) default NULL, # project description `tasks` text default NULL, # comma-separated list of task ids associated with this project @@ -122,8 +122,8 @@ CREATE TABLE `tt_projects` ( PRIMARY KEY (`id`) ); -# Create an index that guarantees unique active and inactive projects per team. -create unique index project_idx on tt_projects(team_id, name, status); +# Create an index that guarantees unique active and inactive projects per group. +create unique index project_idx on tt_projects(group_id, name, status); # @@ -131,15 +131,15 @@ create unique index project_idx on tt_projects(team_id, name, status); # CREATE TABLE `tt_tasks` ( `id` int(11) NOT NULL auto_increment, # task id - `team_id` int(11) NOT NULL, # team id + `group_id` int(11) NOT NULL, # group id `name` varchar(80) COLLATE utf8_bin NOT NULL, # task name `description` varchar(255) default NULL, # task description `status` tinyint(4) default 1, # task status PRIMARY KEY (`id`) ); -# Create an index that guarantees unique active and inactive tasks per team. -create unique index task_idx on tt_tasks(team_id, name, status); +# Create an index that guarantees unique active and inactive tasks per group. +create unique index task_idx on tt_tasks(group_id, name, status); # @@ -212,7 +212,7 @@ create index task_idx on tt_log(task_id); # CREATE TABLE `tt_invoices` ( `id` int(11) NOT NULL auto_increment, # invoice id - `team_id` int(11) NOT NULL, # team id + `group_id` int(11) NOT NULL, # group id `name` varchar(80) COLLATE utf8_bin NOT NULL, # invoice name `date` date NOT NULL, # invoice date `client_id` int(11) NOT NULL, # client id @@ -221,7 +221,7 @@ CREATE TABLE `tt_invoices` ( ); # Create an index that guarantees unique invoice names per team. -create unique index name_idx on tt_invoices(team_id, name, status); +create unique index name_idx on tt_invoices(group_id, name, status); # @@ -277,7 +277,7 @@ CREATE TABLE `tt_fav_reports` ( # CREATE TABLE `tt_cron` ( `id` int(11) NOT NULL auto_increment, # entry id - `team_id` int(11) NOT NULL, # team id + `group_id` int(11) NOT NULL, # group id `cron_spec` varchar(255) NOT NULL, # cron specification, "0 1 * * *" for "daily at 01:00" `last` int(11) default NULL, # UNIX timestamp of when job was last run `next` int(11) default NULL, # UNIX timestamp of when to run next job @@ -296,7 +296,7 @@ CREATE TABLE `tt_cron` ( # CREATE TABLE `tt_clients` ( `id` int(11) NOT NULL AUTO_INCREMENT, # client id - `team_id` int(11) NOT NULL, # team id + `group_id` int(11) NOT NULL, # group id `name` varchar(80) COLLATE utf8_bin NOT NULL, # client name `address` varchar(255) default NULL, # client address `tax` float(6,2) default '0.00', # applicable tax for this client @@ -306,7 +306,7 @@ CREATE TABLE `tt_clients` ( ); # Create an index that guarantees unique active and inactive clients per team. -create unique index client_name_idx on tt_clients(team_id, name, status); +create unique index client_name_idx on tt_clients(group_id, name, status); # @@ -343,7 +343,7 @@ create unique index param_idx on tt_config(user_id, param_name); # CREATE TABLE `tt_custom_fields` ( `id` int(11) NOT NULL auto_increment, # custom field id - `team_id` int(11) NOT NULL, # team id + `group_id` int(11) NOT NULL, # group id `type` tinyint(4) NOT NULL default 0, # custom field type (text or dropdown) `label` varchar(32) NOT NULL default '', # custom field label `required` tinyint(4) default 0, # whether this custom field is mandatory for time records @@ -416,7 +416,7 @@ create index invoice_idx on tt_expense_items(invoice_id); # CREATE TABLE `tt_predefined_expenses` ( `id` int(11) NOT NULL auto_increment, # predefined expense id - `team_id` int(11) NOT NULL, # team id + `group_id` int(11) NOT NULL, # group id `name` varchar(255) NOT NULL, # predefined expense name, such as mileage `cost` decimal(10,2) default '0.00', # cost for one unit PRIMARY KEY (`id`) @@ -428,11 +428,11 @@ CREATE TABLE `tt_predefined_expenses` ( # This table keeps monthly work hour quotas for groups. # CREATE TABLE `tt_monthly_quotas` ( - `team_id` int(11) NOT NULL, # group id + `group_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`) + PRIMARY KEY (`group_id`,`year`,`month`) ); @@ -449,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.80', now()); # TODO: change when structure changes. +INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.81', now()); # TODO: change when structure changes. diff --git a/notification_add.php b/notification_add.php index 7dd680ff..e30970af 100644 --- a/notification_add.php +++ b/notification_add.php @@ -86,7 +86,7 @@ if ($request->isPost()) { $next = tdCron::getNextOccurrence($cl_cron_spec, mktime()); if (ttNotificationHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'cron_spec' => $cl_cron_spec, 'next' => $next, 'report_id' => $cl_fav_report, diff --git a/notification_edit.php b/notification_edit.php index 1c36865f..69535815 100644 --- a/notification_edit.php +++ b/notification_edit.php @@ -94,7 +94,7 @@ if ($request->isPost()) { if (ttNotificationHelper::update(array( 'id' => $notification_id, - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'cron_spec' => $cl_cron_spec, 'next' => $next, 'report_id' => $cl_fav_report, diff --git a/notifications.php b/notifications.php index 6dcf33fd..23400beb 100644 --- a/notifications.php +++ b/notifications.php @@ -50,7 +50,7 @@ if ($request->isPost()) { } } else { $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); - $notifications = ttTeamHelper::getNotifications($user->team_id); + $notifications = ttTeamHelper::getNotifications($user->group_id); } $smarty->assign('forms', array($form->getName()=>$form->toArray())); diff --git a/password_change.php b/password_change.php index 832118f6..f8c47112 100644 --- a/password_change.php +++ b/password_change.php @@ -49,8 +49,8 @@ if ($user_id) { $smarty->assign('i18n', $i18n->keys); } if ($user->custom_logo) { - $smarty->assign('custom_logo', 'images/'.$user->team_id.'.png'); - $smarty->assign('mobile_custom_logo', '../images/'.$user->team_id.'.png'); + $smarty->assign('custom_logo', 'images/'.$user->group_id.'.png'); + $smarty->assign('mobile_custom_logo', '../images/'.$user->group_id.'.png'); } $smarty->assign('user', $user); } diff --git a/plugins/CustomFields.class.php b/plugins/CustomFields.class.php index f9592f1c..afb59dae 100644 --- a/plugins/CustomFields.class.php +++ b/plugins/CustomFields.class.php @@ -37,11 +37,11 @@ class CustomFields { var $options = array(); // Array of options for a dropdown custom field. // Constructor. - function __construct($team_id) { + function __construct($group_id) { $mdb2 = getConnection(); // Get fields. - $sql = "select id, type, label, required from tt_custom_fields where team_id = $team_id and status = 1 and type > 0"; + $sql = "select id, type, label, required from tt_custom_fields where group_id = $group_id and status = 1 and type > 0"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -149,12 +149,12 @@ class CustomFields { $field_id = CustomFields::getFieldIdForOption($id); // First make sure that the field is ours. - $sql = "select team_id from tt_custom_fields where id = $field_id"; + $sql = "select group_id from tt_custom_fields where id = $field_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; $val = $res->fetchRow(); - if ($user->team_id != $val['team_id']) + if ($user->group_id != $val['group_id']) return false; // Delete log entries with this option. @@ -176,12 +176,12 @@ class CustomFields { $options = array(); // First make sure that the field is ours. - $sql = "select team_id from tt_custom_fields where id = $field_id"; + $sql = "select group_id from tt_custom_fields where id = $field_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; $val = $res->fetchRow(); - if ($user->team_id != $val['team_id']) + if ($user->group_id != $val['group_id']) return false; // Get options. @@ -204,12 +204,12 @@ class CustomFields { $field_id = CustomFields::getFieldIdForOption($id); // First make sure that the field is ours. - $sql = "select team_id from tt_custom_fields where id = $field_id"; + $sql = "select group_id from tt_custom_fields where id = $field_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; $val = $res->fetchRow(); - if ($user->team_id != $val['team_id']) + if ($user->group_id != $val['group_id']) return false; // Get option name. @@ -229,7 +229,7 @@ class CustomFields { $mdb2 = getConnection(); $fields = array(); - $sql = "select id, type, label from tt_custom_fields where team_id = $user->team_id and status = 1 and type > 0"; + $sql = "select id, type, label from tt_custom_fields where group_id = $user->group_id and status = 1 and type > 0"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -245,7 +245,7 @@ class CustomFields { global $user; $mdb2 = getConnection(); - $sql = "select label, type, required from tt_custom_fields where id = $id and team_id = $user->team_id"; + $sql = "select label, type, required from tt_custom_fields where id = $id and group_id = $user->group_id"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -274,7 +274,7 @@ class CustomFields { static function insertField($field_name, $field_type, $required) { global $user; $mdb2 = getConnection(); - $sql = "insert into tt_custom_fields (team_id, type, label, required, status) values($user->team_id, $field_type, ".$mdb2->quote($field_name).", $required, 1)"; + $sql = "insert into tt_custom_fields (group_id, type, label, required, status) values($user->group_id, $field_type, ".$mdb2->quote($field_name).", $required, 1)"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -283,7 +283,7 @@ class CustomFields { static function updateField($id, $name, $type, $required) { global $user; $mdb2 = getConnection(); - $sql = "update tt_custom_fields set label = ".$mdb2->quote($name).", type = $type, required = $required where id = $id and team_id = $user->team_id"; + $sql = "update tt_custom_fields set label = ".$mdb2->quote($name).", type = $type, required = $required where id = $id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -299,12 +299,12 @@ class CustomFields { $mdb2 = getConnection(); // First make sure that the field is ours so that we can safely delete it. - $sql = "select team_id from tt_custom_fields where id = $field_id"; + $sql = "select group_id from tt_custom_fields where id = $field_id"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) return false; $val = $res->fetchRow(); - if ($user->team_id != $val['team_id']) + if ($user->group_id != $val['group_id']) return false; // Mark log entries as deleted. @@ -320,7 +320,7 @@ class CustomFields { return false; // Delete the field. - $sql = "delete from tt_custom_fields where id = $field_id and team_id = $user->team_id"; + $sql = "delete from tt_custom_fields where id = $field_id and group_id = $user->group_id"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/plugins/MonthlyQuota.class.php b/plugins/MonthlyQuota.class.php index a4be6ee3..de1f7cd2 100644 --- a/plugins/MonthlyQuota.class.php +++ b/plugins/MonthlyQuota.class.php @@ -32,21 +32,21 @@ import('ttTimeHelper'); class MonthlyQuota { var $db; // Database connection. - var $team_id; // Team id. + var $group_id; // Group id. function __construct() { $this->db = getConnection(); global $user; - $this->team_id = $user->team_id; + $this->group_id = $user->group_id; } // update - deletes a quota, then inserts a new one. public function update($year, $month, $minutes) { - $team_id = $this->team_id; - $deleteSql = "DELETE FROM tt_monthly_quotas WHERE year = $year AND month = $month AND team_id = $team_id"; + $group_id = $this->group_id; + $deleteSql = "DELETE FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $group_id"; $this->db->exec($deleteSql); if ($minutes){ - $insertSql = "INSERT INTO tt_monthly_quotas (team_id, year, month, minutes) values ($team_id, $year, $month, $minutes)"; + $insertSql = "INSERT INTO tt_monthly_quotas (group_id, year, month, minutes) values ($group_id, $year, $month, $minutes)"; $affected = $this->db->exec($insertSql); return (!is_a($affected, 'PEAR_Error')); } @@ -64,8 +64,8 @@ class MonthlyQuota { // getSingle - obtains a quota for a single month. private function getSingle($year, $month) { - $team_id = $this->team_id; - $sql = "SELECT minutes FROM tt_monthly_quotas WHERE year = $year AND month = $month AND team_id = $team_id"; + $group_id = $this->group_id; + $sql = "SELECT minutes FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $group_id"; $reader = $this->db->query($sql); if (is_a($reader, 'PEAR_Error')) { return false; @@ -83,8 +83,8 @@ class MonthlyQuota { // getMany - returns an array of quotas for a given year for team. private function getMany($year){ - $team_id = $this->team_id; - $sql = "SELECT month, minutes FROM tt_monthly_quotas WHERE year = $year AND team_id = $team_id"; + $group_id = $this->group_id; + $sql = "SELECT month, minutes FROM tt_monthly_quotas WHERE year = $year AND group_id = $group_id"; $result = array(); $res = $this->db->query($sql); if (is_a($res, 'PEAR_Error')) { diff --git a/predefined_expense_add.php b/predefined_expense_add.php index 2f1621ca..e653192b 100644 --- a/predefined_expense_add.php +++ b/predefined_expense_add.php @@ -56,7 +56,7 @@ if ($request->isPost()) { if (!ttValidFloat($cl_cost)) $err->add($i18n->get('error.field'), $i18n->get('label.cost')); if ($err->no()) { if (ttPredefinedExpenseHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'cost' => $cl_cost))) { header('Location: predefined_expenses.php'); diff --git a/predefined_expense_edit.php b/predefined_expense_edit.php index 7791b244..9b3727bf 100644 --- a/predefined_expense_edit.php +++ b/predefined_expense_edit.php @@ -64,7 +64,7 @@ if ($request->isPost()) { if ($err->no()) { if (ttPredefinedExpenseHelper::update(array( 'id' => $predefined_expense_id, - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'cost' => $cl_cost))) { header('Location: predefined_expenses.php'); diff --git a/predefined_expenses.php b/predefined_expenses.php index 7aed7ad6..88ac44d7 100644 --- a/predefined_expenses.php +++ b/predefined_expenses.php @@ -50,7 +50,7 @@ if ($request->isPost()) { } } else { $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add'))); - $predefinedExpenses = ttTeamHelper::getPredefinedExpenses($user->team_id); + $predefinedExpenses = ttTeamHelper::getPredefinedExpenses($user->group_id); } $smarty->assign('forms', array($form->getName()=>$form->toArray())); diff --git a/project_add.php b/project_add.php index 55b83b42..98087025 100644 --- a/project_add.php +++ b/project_add.php @@ -45,7 +45,7 @@ $users = ttTeamHelper::getActiveUsers(); foreach ($users as $user_item) $all_users[$user_item['id']] = $user_item['name']; -$tasks = ttTeamHelper::getActiveTasks($user->team_id); +$tasks = ttTeamHelper::getActiveTasks($user->group_id); foreach ($tasks as $task_item) $all_tasks[$task_item['id']] = $task_item['name']; @@ -77,7 +77,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'description' => $cl_description, 'users' => $cl_users, diff --git a/project_edit.php b/project_edit.php index 543c532e..14e8e771 100644 --- a/project_edit.php +++ b/project_edit.php @@ -52,7 +52,7 @@ $users = ttTeamHelper::getActiveUsers(); foreach ($users as $user_item) $all_users[$user_item['id']] = $user_item['name']; -$tasks = ttTeamHelper::getActiveTasks($user->team_id); +$tasks = ttTeamHelper::getActiveTasks($user->group_id); foreach ($tasks as $task_item) $all_tasks[$task_item['id']] = $task_item['name']; @@ -118,7 +118,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'description' => $cl_description, 'users' => $cl_users, diff --git a/projects.php b/projects.php index bf6aed1c..d206fe8c 100644 --- a/projects.php +++ b/projects.php @@ -42,8 +42,8 @@ if (MODE_PROJECTS != $user->tracking_mode && MODE_PROJECTS_AND_TASKS != $user->t // End of access checks. if($user->can('manage_projects')) { - $active_projects = ttTeamHelper::getActiveProjects($user->team_id); - $inactive_projects = ttTeamHelper::getInactiveProjects($user->team_id); + $active_projects = ttTeamHelper::getActiveProjects($user->group_id); + $inactive_projects = ttTeamHelper::getInactiveProjects($user->group_id); } else $active_projects = $user->getAssignedProjects(); diff --git a/quotas.php b/quotas.php index c921fba4..8e6f59c4 100644 --- a/quotas.php +++ b/quotas.php @@ -90,7 +90,7 @@ if ($request->isPost()){ // Handle workday hours. $workday_minutes = ttTimeHelper::postedDurationToMinutes($request->getParameter('workdayHours')); if ($workday_minutes != $user->workday_minutes) { - if (!ttTeamHelper::update($user->team_id, array('name'=>$user->team,'workday_minutes'=>$workday_minutes))) + if (!ttTeamHelper::update($user->group_id, array('name'=>$user->team,'workday_minutes'=>$workday_minutes))) $err->add($i18n->get('error.db')); } diff --git a/report.php b/report.php index c59f6b5e..d712968d 100644 --- a/report.php +++ b/report.php @@ -54,7 +54,7 @@ if ($user->isPluginEnabled('iv')) { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -92,7 +92,7 @@ if ($bean->getAttribute('chpaid')) { // Controls for "Assign to invoice" block. if ($client_id && $bean->getAttribute('chinvoice') && ('no_grouping' == $bean->getAttribute('group_by')) && !$user->isClient()) { // Client is selected and we are displaying the invoice column. - $recent_invoices = ttTeamHelper::getRecentInvoices($user->team_id, $client_id); + $recent_invoices = ttTeamHelper::getRecentInvoices($user->group_id, $client_id); if ($recent_invoices) { $assign_invoice_select_options = array('1'=>$i18n->get('dropdown.all'),'2'=>$i18n->get('dropdown.select')); $form->addInput(array('type'=>'combobox', diff --git a/reports.php b/reports.php index 3aba9cdf..99683c1a 100644 --- a/reports.php +++ b/reports.php @@ -45,7 +45,7 @@ if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports'))) { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -104,7 +104,7 @@ $form->addInput(array('type'=>'combobox', 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.all')))); if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->team_id); + $task_list = ttTeamHelper::getActiveTasks($user->group_id); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/role_add.php b/role_add.php index d26cb6ad..086da632 100644 --- a/role_add.php +++ b/role_add.php @@ -59,11 +59,11 @@ if ($request->isPost()) { if ($cl_rank >= $user->rank || $cl_rank < 0) $err->add($i18n->get('error.field'), $i18n->get('form.roles.rank')); if ($err->no()) { - $existing_role = ttRoleHelper::getRoleByRank($cl_rank, $user->team_id); + $existing_role = ttRoleHelper::getRoleByRank($cl_rank, $user->group_id); if (!$existing_role) { // Insert a role with default user rights. if (ttRoleHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'rank' => $cl_rank, 'description' => $cl_description, diff --git a/task_add.php b/task_add.php index eaaba5e8..e25fa390 100644 --- a/task_add.php +++ b/task_add.php @@ -43,7 +43,7 @@ if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) { } // End of access checks. -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -68,7 +68,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'description' => $cl_description, 'status' => ACTIVE, diff --git a/task_edit.php b/task_edit.php index 324f1dbb..feff4e52 100644 --- a/task_edit.php +++ b/task_edit.php @@ -48,7 +48,7 @@ if (!$task) { } // End of access checks. -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); @@ -101,7 +101,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'name' => $cl_name, 'description' => $cl_description, 'status' => $cl_status, diff --git a/tasks.php b/tasks.php index 2d310d01..e967e095 100644 --- a/tasks.php +++ b/tasks.php @@ -41,8 +41,8 @@ if (MODE_PROJECTS_AND_TASKS != $user->tracking_mode) { } // End of access checks. -$smarty->assign('active_tasks', ttTeamHelper::getActiveTasks($user->team_id)); -$smarty->assign('inactive_tasks', ttTeamHelper::getInactiveTasks($user->team_id)); +$smarty->assign('active_tasks', ttTeamHelper::getActiveTasks($user->group_id)); +$smarty->assign('inactive_tasks', ttTeamHelper::getInactiveTasks($user->group_id)); $smarty->assign('title', $i18n->get('title.tasks')); $smarty->assign('content_page_name', 'tasks.tpl'); $smarty->display('index.tpl'); diff --git a/time.php b/time.php index d75854c8..24cc7c8a 100644 --- a/time.php +++ b/time.php @@ -61,7 +61,7 @@ $_SESSION['date'] = $cl_date; // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -125,7 +125,7 @@ if ($user->can('track_time')) { // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -151,7 +151,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -179,7 +179,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->team_id); + $task_list = ttTeamHelper::getActiveTasks($user->group_id); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/time_edit.php b/time_edit.php index 507f28ab..81259436 100644 --- a/time_edit.php +++ b/time_edit.php @@ -51,7 +51,7 @@ if (!$time_rec || $time_rec['invoice_id']) { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -110,7 +110,7 @@ $form = new Form('timeRecordForm'); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -136,7 +136,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -164,7 +164,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->team_id); + $task_list = ttTeamHelper::getActiveTasks($user->group_id); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', diff --git a/tofile.php b/tofile.php index e7b9ed96..62632fa9 100644 --- a/tofile.php +++ b/tofile.php @@ -41,7 +41,7 @@ if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports'))) { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); } // Report settings are stored in session bean before we get here. diff --git a/topdf.php b/topdf.php index 475522ef..9149e1c6 100644 --- a/topdf.php +++ b/topdf.php @@ -52,7 +52,7 @@ require_once('WEB-INF/lib/tcpdf/tcpdf.php'); // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); } // Report settings are stored in session bean before we get here. @@ -391,8 +391,8 @@ class ttPDF extends TCPDF { $pdf = new ttPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // If custom logo file exists - set it. -if (file_exists('images/'.$user->team_id.'.png')) - $pdf->SetImageFile('images/'.$user->team_id.'.png'); +if (file_exists('images/'.$user->group_id.'.png')) + $pdf->SetImageFile('images/'.$user->group_id.'.png'); // Set page word for the footer. $pdf->SetPageWord($i18n->get('label.page')); diff --git a/user_add.php b/user_add.php index b235cbd1..1ed0cb72 100644 --- a/user_add.php +++ b/user_add.php @@ -46,7 +46,7 @@ if (!ttAccessAllowed('manage_users')) { @include('plugins/limit/user_add.php'); if ($user->isPluginEnabled('cl')) - $clients = ttTeamHelper::getActiveClients($user->team_id); + $clients = ttTeamHelper::getActiveClients($user->group_id); $assigned_projects = array(); if ($request->isPost()) { @@ -90,7 +90,7 @@ if ($user->isPluginEnabled('cl')) $form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate)); -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); // Define classes for the projects table. class NameCellRenderer extends DefaultCellRenderer { @@ -150,7 +150,7 @@ if ($request->isPost()) { 'login' => $cl_login, 'password' => $cl_password1, 'rate' => $cl_rate, - 'team_id' => $user->team_id, + 'group_id' => $user->group_id, 'role_id' => $cl_role_id, 'client_id' => $cl_client_id, 'projects' => $assigned_projects, diff --git a/user_edit.php b/user_edit.php index 95ed29e7..f370f451 100644 --- a/user_edit.php +++ b/user_edit.php @@ -49,9 +49,9 @@ if (!$user_details) { // End of access checks. if ($user->isPluginEnabled('cl')) - $clients = ttTeamHelper::getActiveClients($user->team_id); + $clients = ttTeamHelper::getActiveClients($user->group_id); -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttTeamHelper::getActiveProjects($user->group_id); $assigned_projects = array(); if ($request->isPost()) { diff --git a/week.php b/week.php index 1d72ce40..c71a2ccd 100644 --- a/week.php +++ b/week.php @@ -83,7 +83,7 @@ $endDate->setTimestamp(mktime(0,0,0,$t_arr[4]+1,$t_arr[3]-$t_arr[6]+6+$startWeek // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) { require_once('plugins/CustomFields.class.php'); - $custom_fields = new CustomFields($user->team_id); + $custom_fields = new CustomFields($user->group_id); $smarty->assign('custom_fields', $custom_fields); } @@ -244,7 +244,7 @@ $form->addInputElement($table); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -270,7 +270,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -298,7 +298,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { - $task_list = ttTeamHelper::getActiveTasks($user->team_id); + $task_list = ttTeamHelper::getActiveTasks($user->group_id); $form->addInput(array('type'=>'combobox', 'name'=>'task', 'style'=>'width: 250px;', -- 2.20.1