From: Nik Okuntseff Date: Tue, 6 Nov 2018 19:42:21 +0000 (+0000) Subject: More refactoring for subgroup support. X-Git-Tag: timetracker_1.19-1~696 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3a835e437ea379fb2ddd6b532f4a61bc5d5bbf33;p=timetracker.git More refactoring for subgroup support. --- diff --git a/WEB-INF/lib/ttProjectHelper.class.php b/WEB-INF/lib/ttProjectHelper.class.php index 174a31ce..9203b560 100644 --- a/WEB-INF/lib/ttProjectHelper.class.php +++ b/WEB-INF/lib/ttProjectHelper.class.php @@ -41,9 +41,9 @@ class ttProjectHelper { $mdb2 = getConnection(); // 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->group_id and p.status = 1 order by p.name"; + $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"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -61,9 +61,9 @@ class ttProjectHelper { $result = array(); $mdb2 = getConnection(); - $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->group_id"; + $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(); $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->group_id and (status = 0 or status = 1) order by name"; + " where group_id = ".$user->getActiveGroup()." 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->group_id and (p.status = 0 or p.status = 1)". + " where p.group_id = ".$user->getActiveGroup()." and (p.status = 0 or p.status = 1)". " order by p.name"; $res = $mdb2->query($sql); @@ -124,7 +124,8 @@ class ttProjectHelper { $mdb2 = getConnection(); - $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)"; + $sql = "select id, name, description, status, tasks from tt_projects where id = $id and group_id = ". + $user->getActiveGroup()." and (status = 0 or status = 1)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -140,12 +141,13 @@ class ttProjectHelper { $mdb2 = getConnection(); global $user; - $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')) { + $sql = "select id from tt_projects where group_id = ". + $user->getActiveGroup()." and name = ".$mdb2->quote($name). + " and (status = 1 or status = 0)"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); - if ($val && $val['id']) + if ($val && $val['id']) return $val; } return false; @@ -161,7 +163,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 group_id = $user->group_id"; + $sql = "update tt_projects set status = NULL, tasks = NULL where id = $id and group_id = ".$user->getActiveGroup(); $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error') || 0 == $affected) return false; // An error ocurred, or 0 rows updated. @@ -312,7 +314,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->group_id"; + ", tasks = ".$mdb2->quote($comma_separated).", status = $status where id = $project_id and group_id = ".$user->getActiveGroup(); $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 760672f7..d0d15732 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.08.4377 | Copyright © Anuko | +  Anuko Time Tracker 1.18.08.4378 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}