From: Nik Okuntseff Date: Mon, 26 Nov 2018 10:03:45 +0000 (+0000) Subject: Some refactoring for subgroups. X-Git-Tag: timetracker_1.19-1~545 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=7797eda9fb04c217a813db88e00bb9ee541eabbb;p=timetracker.git Some refactoring for subgroups. --- diff --git a/WEB-INF/lib/ttClientHelper.class.php b/WEB-INF/lib/ttClientHelper.class.php index eeb77f77..e557676f 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 group_id = ".$user->getActiveGroup(). + $sql .= "from tt_clients where group_id = ".$user->getGroup(). " and id = $client_id and (status = 1 or status = 0)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -59,7 +59,7 @@ class ttClientHelper { $result = array(); $mdb2 = getConnection(); - $sql = "select id, name from tt_clients where group_id = ".$user->getActiveGroup()." and (status = 0 or status = 1) order by upper(name)"; + $sql = "select id, name from tt_clients where group_id = ".$user->getGroup()." and (status = 0 or status = 1) order by upper(name)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -75,7 +75,7 @@ class ttClientHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_clients where group_id = ".$user->getActiveGroup(). + $sql = "select id from tt_clients where group_id = ".$user->getGroup(). " and name = ".$mdb2->quote($client_name)." and (status = 1 or status = 0)"; $res = $mdb2->query($sql); @@ -94,7 +94,7 @@ class ttClientHelper { $mdb2 = getConnection(); global $user; - $sql = "select name, address from tt_clients where group_id = ".$user->getActiveGroup(). + $sql = "select name, address from tt_clients where group_id = ".$user->getGroup(). " and id = $client_id and status is NULL"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -137,7 +137,7 @@ class ttClientHelper { // Handle invoices. if ($delete_client_entries) { - $sql = "update tt_invoices set status = NULL where client_id = $id and group_id = ".$user->getActiveGroup(); + $sql = "update tt_invoices set status = NULL where client_id = $id and group_id = ".$user->getGroup(); $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -150,13 +150,13 @@ class ttClientHelper { return false; // Handle users for client. - $sql = 'update tt_users set status = NULL'.$modified_part." where client_id = $id and group_id = ".$user->getActiveGroup(); + $sql = 'update tt_users set status = NULL'.$modified_part." where client_id = $id and group_id = ".$user->getGroup(); $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 group_id = ".$user->getActiveGroup(); + $sql = "update tt_clients set status = NULL where id = $id and group_id = ".$user->getGroup(); $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -237,7 +237,7 @@ class ttClientHelper { $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 group_id = ".$user->getActiveGroup()." and id = ".$id; + " where group_id = ".$user->getGroup()." and id = ".$id; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -273,7 +273,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.group_id = ".$user->getActiveGroup()." and p.status = 1 order by p.name"; + " where p.group_id = ".$user->getGroup()." 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/ttExpenseHelper.class.php b/WEB-INF/lib/ttExpenseHelper.class.php index 7c0d83ff..e42a0ab5 100644 --- a/WEB-INF/lib/ttExpenseHelper.class.php +++ b/WEB-INF/lib/ttExpenseHelper.class.php @@ -35,7 +35,7 @@ class ttExpenseHelper { $mdb2 = getConnection(); $user_id = $user->getActiveUser(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $date = $fields['date']; diff --git a/WEB-INF/lib/ttFavReportHelper.class.php b/WEB-INF/lib/ttFavReportHelper.class.php index ab9fa0e0..f1943f71 100644 --- a/WEB-INF/lib/ttFavReportHelper.class.php +++ b/WEB-INF/lib/ttFavReportHelper.class.php @@ -80,7 +80,7 @@ class ttFavReportHelper { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $sql = "insert into tt_fav_reports". diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index 01429aa6..d332060a 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -67,7 +67,7 @@ class ttGroupHelper { global $user; $mdb2 = getConnection(); - $parent_id = $user->getActiveGroup(); + $parent_id = $user->getGroup(); $org_id = $user->org_id; $sql = "select id from tt_groups where parent_id = $parent_id and org_id = $org_id". @@ -86,7 +86,7 @@ class ttGroupHelper { global $user; $mdb2 = getConnection(); - $parent_id = $user->getActiveGroup(); + $parent_id = $user->getGroup(); $org_id = $user->org_id; $name = $fields['name']; $description = $fields['description']; @@ -259,7 +259,7 @@ class ttGroupHelper { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $sql = "select * from tt_roles". " where group_id = $group_id and org_id = $org_id and status is not null"; diff --git a/WEB-INF/lib/ttInvoiceHelper.class.php b/WEB-INF/lib/ttInvoiceHelper.class.php index 3a8dbe27..13e5dea0 100644 --- a/WEB-INF/lib/ttInvoiceHelper.class.php +++ b/WEB-INF/lib/ttInvoiceHelper.class.php @@ -73,7 +73,7 @@ class ttInvoiceHelper { if ($user->isClient()) $client_part = " and client_id = $user->client_id"; $sql = "select * from tt_invoices where id = $invoice_id and group_id = ". - $user->getActiveGroup()."$client_part and status = 1"; + $user->getGroup()."$client_part and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { if ($val = $res->fetchRow()) @@ -89,7 +89,7 @@ class ttInvoiceHelper { global $user; $sql = "select id from tt_invoices where group_id = ". - $user->getActiveGroup()." and name = ".$mdb2->quote($invoice_name)." and status = 1"; + $user->getGroup()." and name = ".$mdb2->quote($invoice_name)." and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -236,7 +236,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 group_id = ".$user->getActiveGroup(); + $sql = "update tt_invoices set status = NULL where id = $invoice_id and group_id = ".$user->getGroup(); $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -332,7 +332,7 @@ class ttInvoiceHelper { // Create a new invoice record. $sql = "insert into tt_invoices (group_id, org_id, name, date, client_id) values(". - $user->getActiveGroup().", $user->org_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)"; + $user->getGroup().", $user->org_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 a4fa5e6d..c9f0a1e9 100644 --- a/WEB-INF/lib/ttNotificationHelper.class.php +++ b/WEB-INF/lib/ttNotificationHelper.class.php @@ -38,7 +38,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.group_id = ".$user->getActiveGroup(); + where c.id = $id and c.group_id = ".$user->getGroup(); $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -54,7 +54,7 @@ class ttNotificationHelper { $mdb2 = getConnection(); - $sql = "delete from tt_cron where id = $id and group_id = ".$user->getActiveGroup(); + $sql = "delete from tt_cron where id = $id and group_id = ".$user->getGroup(); $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -68,7 +68,7 @@ class ttNotificationHelper { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $cron_spec = $fields['cron_spec']; $next = (int) $fields['next']; diff --git a/WEB-INF/lib/ttPredefinedExpenseHelper.class.php b/WEB-INF/lib/ttPredefinedExpenseHelper.class.php index 27a3a833..16dff284 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 group_id = ".$user->getActiveGroup(); + where id = $id and group_id = ".$user->getGroup(); $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 group_id = ".$user->getActiveGroup(); + $sql = "delete from tt_predefined_expenses where id = $id and group_id = ".$user->getGroup(); $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -73,7 +73,7 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $name = $fields['name']; $cost = $fields['cost']; @@ -96,7 +96,7 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $predefined_expense_id = (int) $fields['id']; $name = $fields['name']; diff --git a/WEB-INF/lib/ttProjectHelper.class.php b/WEB-INF/lib/ttProjectHelper.class.php index 5e59a928..2a439dd9 100644 --- a/WEB-INF/lib/ttProjectHelper.class.php +++ b/WEB-INF/lib/ttProjectHelper.class.php @@ -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.group_id = ".$user->getActiveGroup()." and p.status = 1 order by p.name"; + " where p.group_id = ".$user->getGroup()." 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 group_id = ".$user->getActiveGroup(); + " where group_id = ".$user->getGroup(); $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -83,7 +83,7 @@ class ttProjectHelper { $mdb2 = getConnection(); $sql = "select id, name, tasks from tt_projects". - " where group_id = ".$user->getActiveGroup()." and (status = 0 or status = 1) order by name"; + " where group_id = ".$user->getGroup()." 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.group_id = ".$user->getActiveGroup()." and (p.status = 0 or p.status = 1)". + " where p.group_id = ".$user->getGroup()." and (p.status = 0 or p.status = 1)". " order by p.name"; $res = $mdb2->query($sql); @@ -125,7 +125,7 @@ class ttProjectHelper { $mdb2 = getConnection(); $sql = "select id, name, description, status, tasks from tt_projects where id = $id and group_id = ". - $user->getActiveGroup()." and (status = 0 or status = 1)"; + $user->getGroup()." and (status = 0 or status = 1)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -142,7 +142,7 @@ class ttProjectHelper { global $user; $sql = "select id from tt_projects where group_id = ". - $user->getActiveGroup()." and name = ".$mdb2->quote($name). + $user->getGroup()." and name = ".$mdb2->quote($name). " and (status = 1 or status = 0)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -159,7 +159,7 @@ class ttProjectHelper { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; // Start with project itself. Reason: if the passed in project_id is bogus, @@ -245,7 +245,7 @@ class ttProjectHelper { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $project_id = $fields['id']; // Project we are updating. $name = $fields['name']; // Project name. @@ -323,7 +323,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 group_id = ".$user->getActiveGroup(); + ", tasks = ".$mdb2->quote($comma_separated).", status = $status where id = $project_id and group_id = ".$user->getGroup(); $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 76c1765e..16277bd1 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -62,7 +62,7 @@ class ttReportHelper { $user_list_part = " and l.user_id in ($userlist)"; else $user_list_part = " and l.user_id = ".$user->id; - $user_list_part .= " and l.group_id = ".$user->getActiveGroup(); + $user_list_part .= " and l.group_id = ".$user->getGroup(); // Prepare sql query part for where. if ($options['period']) @@ -100,7 +100,7 @@ class ttReportHelper { $user_list_part = " and ei.user_id in ($userlist)"; else $user_list_part = " and ei.user_id = ".$user->id; - $user_list_part .= " and ei.group_id = ".$user->getActiveGroup(); + $user_list_part .= " and ei.group_id = ".$user->getGroup(); // Prepare sql query part for where. if ($options['period']) @@ -157,7 +157,7 @@ class ttReportHelper { // Add custom field. $include_cf_1 = $options['show_custom_field_1'] || $grouping_by_cf_1; if ($include_cf_1) { - $custom_fields = new CustomFields($user->getActiveGroup()); + $custom_fields = new CustomFields($user->getGroup()); $cf_1_type = $custom_fields->fields[0]['type']; if ($cf_1_type == CustomFields::TYPE_TEXT) { array_push($fields, 'cfl.value as cf_1'); @@ -616,7 +616,7 @@ class ttReportHelper { // Use custom fields plugin if it is enabled. if ($user->isPluginEnabled('cf')) - $custom_fields = new CustomFields($user->getActiveGroup()); + $custom_fields = new CustomFields($user->getGroup()); // Define some styles to use in email. $style_title = 'text-align: center; font-size: 15pt; font-family: Arial, Helvetica, sans-serif;'; @@ -1460,7 +1460,7 @@ class ttReportHelper { $join .= ' left join tt_tasks t on (l.task_id = t.id)'; } if (ttReportHelper::groupingBy('cf_1', $options)) { - $custom_fields = new CustomFields($user->getActiveGroup()); + $custom_fields = new CustomFields($user->getGroup()); if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) $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) diff --git a/WEB-INF/lib/ttRoleHelper.class.php b/WEB-INF/lib/ttRoleHelper.class.php index ee151462..35374469 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 group_id = ".$user->getActiveGroup()." and (status = 0 or status = 1)"; + where id = $id and group_id = ".$user->getGroup()." 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 group_id = ".$user->getActiveGroup(). + $sql = "select id from tt_roles where group_id = ".$user->getGroup(). " and name = ".$mdb2->quote($role_name)." and (status = 1 or status = 0)"; $res = $mdb2->query($sql); @@ -89,7 +89,7 @@ class ttRoleHelper { global $user; $mdb2 = getConnection(); - $sql = "select rights from tt_roles where group_id = ".$user->getActiveGroup()." and id = $role_id"; + $sql = "select rights from tt_roles where group_id = ".$user->getGroup()." and id = $role_id"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -124,7 +124,7 @@ class ttRoleHelper { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $id = (int)$fields['id']; @@ -144,7 +144,7 @@ class ttRoleHelper { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; // Mark the task as deleted. diff --git a/WEB-INF/lib/ttSysConfig.class.php b/WEB-INF/lib/ttSysConfig.class.php index fd990521..4cc5f8c2 100644 --- a/WEB-INF/lib/ttSysConfig.class.php +++ b/WEB-INF/lib/ttSysConfig.class.php @@ -44,7 +44,7 @@ class ttSysConfig { function __construct($user_id) { global $user; $this->user_id = $user_id; // TODO: review "on behalf" situation and refactor if necessary. - $this->group_id = $user->getActiveGroup(); + $this->group_id = $user->getGroup(); $this->org_id = $user->org_id; $this->mdb2 = getConnection(); } diff --git a/WEB-INF/lib/ttTaskHelper.class.php b/WEB-INF/lib/ttTaskHelper.class.php index 2c0fbe1e..c7f25d1a 100644 --- a/WEB-INF/lib/ttTaskHelper.class.php +++ b/WEB-INF/lib/ttTaskHelper.class.php @@ -192,7 +192,7 @@ class ttTaskHelper { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $task_id = (int)$fields['task_id']; $name = $fields['name']; diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 1b2616b3..241c92c0 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -60,7 +60,7 @@ class ttTeamHelper { global $i18n; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; if (isset($options['getAllFields'])) @@ -293,7 +293,7 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and org_id = $org_id and rank < $user->rank and status = 1 order by rank"; @@ -354,7 +354,7 @@ class ttTeamHelper { $result = array(); $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and org_id = $org_id and rank < $user->rank and status = 0 order by rank"; diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 8e907c8a..04273aa7 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -166,6 +166,11 @@ class ttUser { } } + // The getGroup returns group id on behalf of which the current user is operating. + function getGroup() { + return ($this->behalfGroup ? $this->behalfGroup->id : $this->group_id); + } + // getDecimalMark returns decimal mark for active group. function getDecimalMark() { return ($this->behalfGroup ? $this->behalfGroup->decimal_mark : $this->decimal_mark); @@ -181,11 +186,6 @@ class ttUser { return ($this->behalf_id ? $this->behalf_id : $this->id); } - // The getActiveGroup returns group id on behalf of which the current user is operating. - function getActiveGroup() { - return ($this->behalf_group_id ? $this->behalf_group_id : $this->group_id); - } - // can - determines whether user has a right to do something. function can($do_something) { return in_array($do_something, $this->rights); @@ -323,7 +323,7 @@ class ttUser { function getUsers($options) { $mdb2 = getConnection(); - $group_id = $this->getActiveGroup(); + $group_id = $this->getGroup(); $org_id = $this->org_id; $skipClients = !isset($options['include_clients']); @@ -408,7 +408,7 @@ class ttUser { // Start with subgroups. $groups = array(); - $group_id = $this->getActiveGroup(); + $group_id = $this->getGroup(); $sql = "select id, name from tt_groups where org_id = $this->org_id and parent_id = $group_id and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { @@ -451,7 +451,7 @@ class ttUser { function getSubgroups($group_id = null) { $mdb2 = getConnection(); - if (!$group_id) $group_id = $this->getActiveGroup(); + if (!$group_id) $group_id = $this->getGroup(); $sql = "select id, name, description from tt_groups where org_id = $this->org_id". " and parent_id = $group_id and status is not null order by upper(name)"; @@ -470,7 +470,7 @@ class ttUser { if (!$this->can('manage_users')) return false; $mdb2 = getConnection(); - $group_id = $this->getActiveGroup(); + $group_id = $this->getGroup(); $org_id = $this->org_id; $sql = "select u.id, u.name, u.login, u.role_id, u.client_id, u.status, u.rate, u.email from tt_users u". @@ -552,7 +552,7 @@ class ttUser { if ($group_id && !$this->isGroupValid($group_id)) return false; $mdb2 = getConnection(); - if (!$group_id) $group_id = $this->getActiveGroup(); + if (!$group_id) $group_id = $this->getGroup(); if (isset($fields['name'])) $name_part = ', name = '.$mdb2->quote($fields['name']); if (isset($fields['description'])) $description_part = ', description = '.$mdb2->quote($fields['description']); @@ -597,7 +597,7 @@ class ttUser { if (!$user_details) return false; $mdb2 = getConnection(); - $group_id = $this->getActiveGroup(); + $group_id = $this->getGroup(); $org_id = $this->org_id; // Mark user to project binds as deleted. diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index 222cfdaa..d1e11268 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -232,7 +232,7 @@ class ttUserHelper { ttUserHelper::insertBind(array( 'user_id' => $user_id, 'project_id' => $project_id, - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'rate' => $rate, 'status' => ACTIVE)); @@ -320,7 +320,7 @@ class ttUserHelper { $mdb2 = getConnection(); // This may be used during import. Use the following until we have import refactored. - $group_id = $fields['group_id'] ? (int) $fields['group_id'] : $user->getActiveGroup(); + $group_id = $fields['group_id'] ? (int) $fields['group_id'] : $user->getGroup(); $org_id = $fields['org_id'] ? (int) $fields['org_id'] : $user->org_id; $user_id = (int) $fields['user_id']; diff --git a/WEB-INF/lib/ttWeekViewHelper.class.php b/WEB-INF/lib/ttWeekViewHelper.class.php index 53065d38..f0bc13bd 100644 --- a/WEB-INF/lib/ttWeekViewHelper.class.php +++ b/WEB-INF/lib/ttWeekViewHelper.class.php @@ -493,7 +493,7 @@ class ttWeekViewHelper { // Prepare an array of fields for regular insert function. $fields4insert = array(); $fields4insert['user_id'] = $user->getActiveUser(); - $fields4insert['group_id'] = $user->getActiveGroup(); + $fields4insert['group_id'] = $user->getGroup(); $fields4insert['org_id'] = $user->org_id; $fields4insert['date'] = $entry_date; $fields4insert['duration'] = $fields['duration']; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index d037aa87..8c299c99 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.28.4520 | Copyright © Anuko | +  Anuko Time Tracker 1.18.28.4521 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/client_add.php b/client_add.php index db94e620..b3d27ac7 100644 --- a/client_add.php +++ b/client_add.php @@ -71,7 +71,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttClientHelper::getClientByName($cl_name)) { if (ttClientHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'address' => $cl_address, diff --git a/client_edit.php b/client_edit.php index a5c1b8b7..34c0a070 100644 --- a/client_edit.php +++ b/client_edit.php @@ -103,7 +103,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttClientHelper::getClientByName($cl_name)) { if (ttClientHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'address' => $cl_address, diff --git a/group_edit.php b/group_edit.php index ed2002d7..08c1db59 100644 --- a/group_edit.php +++ b/group_edit.php @@ -50,7 +50,7 @@ if ($group_id) { $user->setOnBehalfGroup($group_id); } -if (!$group_id) $group_id = $user->getActiveGroup(); +if (!$group_id) $group_id = $user->getGroup(); $groups = $user->getGroupsForDropdown(); $group = ttGroupHelper::getGroupAttrs($group_id); $config = new ttConfigHelper($group['config']); diff --git a/groups.php b/groups.php index 6c35bfb3..f335153c 100644 --- a/groups.php +++ b/groups.php @@ -45,7 +45,7 @@ if ($request->isPost()) { $group_id = $request->getParameter('group'); $user->setOnBehalfGroup($group_id); } else { - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); } $form = new Form('subgroupsForm'); diff --git a/mobile/client_add.php b/mobile/client_add.php index 02de56d1..222012d4 100644 --- a/mobile/client_add.php +++ b/mobile/client_add.php @@ -71,7 +71,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttClientHelper::getClientByName($cl_name)) { if (ttClientHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'address' => $cl_address, diff --git a/mobile/client_edit.php b/mobile/client_edit.php index c1004b1b..917b656a 100644 --- a/mobile/client_edit.php +++ b/mobile/client_edit.php @@ -104,7 +104,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttClientHelper::getClientByName($cl_name)) { if (ttClientHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'address' => $cl_address, diff --git a/mobile/project_add.php b/mobile/project_add.php index 3b1d0fb0..a7a540d0 100644 --- a/mobile/project_add.php +++ b/mobile/project_add.php @@ -78,7 +78,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, diff --git a/mobile/project_edit.php b/mobile/project_edit.php index 2d67b88d..88794615 100644 --- a/mobile/project_edit.php +++ b/mobile/project_edit.php @@ -119,7 +119,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttProjectHelper::getProjectByName($cl_name)) { if (ttProjectHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, diff --git a/mobile/task_add.php b/mobile/task_add.php index d1eab74b..00300347 100644 --- a/mobile/task_add.php +++ b/mobile/task_add.php @@ -68,7 +68,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, diff --git a/mobile/task_edit.php b/mobile/task_edit.php index 784028ee..47dc5d71 100644 --- a/mobile/task_edit.php +++ b/mobile/task_edit.php @@ -103,7 +103,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, diff --git a/mobile/time.php b/mobile/time.php index a25cf90c..25f832bc 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -252,7 +252,7 @@ if ($request->isPost()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, 'user_id' => $user->getActiveUser(), - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'client' => $cl_client, 'project' => $cl_project, diff --git a/mobile/timer.php b/mobile/timer.php index 2f5dbad4..8422338b 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -225,7 +225,7 @@ if ($request->isPost()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, 'user_id' => $user->getActiveUser(), - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'client' => $cl_client, 'project' => $cl_project, diff --git a/plugins/CustomFields.class.php b/plugins/CustomFields.class.php index 1517bf08..74fef831 100644 --- a/plugins/CustomFields.class.php +++ b/plugins/CustomFields.class.php @@ -66,7 +66,7 @@ class CustomFields { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $sql = "insert into tt_custom_field_log (group_id, org_id, log_id, field_id, option_id, value)". @@ -118,7 +118,7 @@ class CustomFields { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; // Check if the option exists. @@ -283,7 +283,7 @@ class CustomFields { static function insertField($field_name, $field_type, $required) { global $user; $mdb2 = getConnection(); - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); $org_id = $user->org_id; $sql = "insert into tt_custom_fields (group_id, org_id, type, label, required, status)". " values($group_id, $org_id, $field_type, ".$mdb2->quote($field_name).", $required, 1)"; diff --git a/plugins/MonthlyQuota.class.php b/plugins/MonthlyQuota.class.php index 6a047bad..36f2d8cb 100644 --- a/plugins/MonthlyQuota.class.php +++ b/plugins/MonthlyQuota.class.php @@ -38,7 +38,7 @@ class MonthlyQuota { function __construct() { $this->db = getConnection(); global $user; - $this->group_id = $user->getActiveGroup(); + $this->group_id = $user->getGroup(); $this->org_id = $user->org_id; } diff --git a/project_add.php b/project_add.php index d32c8802..6b41c15c 100644 --- a/project_add.php +++ b/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->getActiveGroup()); +$tasks = ttTeamHelper::getActiveTasks($user->getGroup()); 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( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, diff --git a/project_edit.php b/project_edit.php index 20376325..29c0d51b 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->getActiveGroup()); +$tasks = ttTeamHelper::getActiveTasks($user->getGroup()); 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( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, diff --git a/projects.php b/projects.php index d149d841..b8faa14d 100644 --- a/projects.php +++ b/projects.php @@ -54,7 +54,7 @@ if ($request->isPost()) { exit(); } } else { - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); } $form = new Form('projectsForm'); diff --git a/task_add.php b/task_add.php index a93c80e2..28a554bb 100644 --- a/task_add.php +++ b/task_add.php @@ -68,7 +68,7 @@ if ($request->isPost()) { if ($err->no()) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, diff --git a/task_edit.php b/task_edit.php index 630a22cd..2b91f058 100644 --- a/task_edit.php +++ b/task_edit.php @@ -101,7 +101,7 @@ if ($request->isPost()) { if ($request->getParameter('btn_copy')) { if (!ttTaskHelper::getTaskByName($cl_name)) { if (ttTaskHelper::insert(array( - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'name' => $cl_name, 'description' => $cl_description, diff --git a/time.php b/time.php index c7d2979c..ae17aa0a 100644 --- a/time.php +++ b/time.php @@ -312,7 +312,7 @@ if ($request->isPost()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, 'user_id' => $user->getActiveUser(), - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'client' => $cl_client, 'project' => $cl_project, diff --git a/time_edit.php b/time_edit.php index 21c3effa..d0689ba7 100644 --- a/time_edit.php +++ b/time_edit.php @@ -365,7 +365,7 @@ if ($request->isPost()) { $id = ttTimeHelper::insert(array( 'date'=>$new_date->toString(DB_DATEFORMAT), 'user_id'=>$user->getActiveUser(), - 'group_id'=>$user->getActiveGroup(), + 'group_id'=>$user->getGroup(), 'org_id' => $user->org_id, 'client'=>$cl_client, 'project'=>$cl_project, diff --git a/user_add.php b/user_add.php index 662813ea..bc78adbf 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->getActiveGroup()); + $clients = ttTeamHelper::getActiveClients($user->getGroup()); $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->getActiveGroup()); +$projects = ttTeamHelper::getActiveProjects($user->getGroup()); // 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, - 'group_id' => $user->getActiveGroup(), + 'group_id' => $user->getGroup(), 'org_id' => $user->org_id, 'role_id' => $cl_role_id, 'client_id' => $cl_client_id, diff --git a/user_edit.php b/user_edit.php index 580ad73c..26dfa01a 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->getActiveGroup()); + $clients = ttTeamHelper::getActiveClients($user->getGroup()); -$projects = ttTeamHelper::getActiveProjects($user->getActiveGroup()); +$projects = ttTeamHelper::getActiveProjects($user->getGroup()); $assigned_projects = array(); if ($request->isPost()) { diff --git a/users.php b/users.php index 4afd5521..fe0e92da 100644 --- a/users.php +++ b/users.php @@ -48,7 +48,7 @@ if ($request->isPost()) { $group_id = $request->getParameter('group'); $user->setOnBehalfGroup($group_id); } else { - $group_id = $user->getActiveGroup(); + $group_id = $user->getGroup(); } $form = new Form('usersForm');