From: Nik Okuntseff Date: Sat, 1 Dec 2018 22:58:13 +0000 (+0000) Subject: Some more refactoring for subgroups. X-Git-Tag: timetracker_1.19-1~502 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=75ff7ff29a038803d3b6e2c31b793049bbb2fbd4;p=timetracker.git Some more refactoring for subgroups. --- diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index e04c221d..9f9f4a2f 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -320,4 +320,46 @@ class ttGroupHelper { } return $result; } + + // getActiveProjects - returns an array of active projects for a group. + static function getActiveProjects() + { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $sql = "select id, name, description, tasks from tt_projects". + " where group_id = $group_id and org_id = $org_id and status = 1 order by upper(name)"; + $res = $mdb2->query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val; + } + } + return $result; + } + + // getInactiveProjects - returns an array of inactive projects for a group. + static function getInactiveProjects() + { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $sql = "select id, name, description, tasks from tt_projects". + " where group_id = $group_id and org_id = $org_id and status = 0 order by upper(name)"; + $res = $mdb2->query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $result[] = $val; + } + } + return $result; + } } diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index f82fc263..67d97b85 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -194,24 +194,6 @@ class ttTeamHelper { return $result; } - // getInactiveProjects - returns an array of inactive projects for a group. - static function getInactiveProjects($group_id) - { - $result = array(); - $mdb2 = getConnection(); - - $sql = "select id, name, description, tasks from tt_projects - where group_id = $group_id and status = 0 order by upper(name)"; - $res = $mdb2->query($sql); - $result = array(); - if (!is_a($res, 'PEAR_Error')) { - while ($val = $res->fetchRow()) { - $result[] = $val; - } - } - return $result; - } - // The getAllProjects obtains all projects in a group. static function getAllProjects($group_id, $all_fields = false) { $mdb2 = getConnection(); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 83288cf4..00eaa060 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.29.4563 | Copyright © Anuko | +  Anuko Time Tracker 1.18.29.4564 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/mobile/projects.php b/mobile/projects.php index e3dc2f87..d244ae1b 100644 --- a/mobile/projects.php +++ b/mobile/projects.php @@ -29,6 +29,7 @@ require_once('../initialize.php'); import('form.Form'); import('ttTeamHelper'); +import('ttGroupHelper'); // Access checks. if (!(ttAccessAllowed('view_own_projects') || ttAccessAllowed('manage_projects'))) { @@ -42,8 +43,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->group_id); - $inactive_projects = ttTeamHelper::getInactiveProjects($user->group_id); + $active_projects = ttGroupHelper::getActiveProjects(); + $inactive_projects = ttGroupHelper::getInactiveProjects(); } else $active_projects = $user->getAssignedProjects(); diff --git a/projects.php b/projects.php index b8faa14d..8b4537e7 100644 --- a/projects.php +++ b/projects.php @@ -29,6 +29,7 @@ require_once('initialize.php'); import('form.Form'); import('ttTeamHelper'); +import('ttGroupHelper'); // Access checks. if (!(ttAccessAllowed('view_own_projects') || ttAccessAllowed('manage_projects'))) { @@ -73,8 +74,8 @@ if ($user->can('manage_subgroups')) { } if($user->can('manage_projects')) { - $active_projects = ttTeamHelper::getActiveProjects($group_id); - $inactive_projects = ttTeamHelper::getInactiveProjects($group_id); + $active_projects = ttGroupHelper::getActiveProjects(); + $inactive_projects = ttGroupHelper::getInactiveProjects(); } else $active_projects = $user->getAssignedProjects();