From 6753e281196a94e8a50d9c98d5195093e61fcefb Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 22 Mar 2018 20:27:44 +0000 Subject: [PATCH] Introduced ttGroupHelper class as part of refactoring. --- WEB-INF/lib/ttGroupHelper.class.php | 51 +++++++++++++++++++++++++++++ WEB-INF/lib/ttTeamHelper.class.php | 18 ---------- WEB-INF/templates/footer.tpl | 2 +- admin_teams.php | 5 ++- login.php | 4 +-- mobile/login.php | 4 +-- 6 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 WEB-INF/lib/ttGroupHelper.class.php diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php new file mode 100644 index 00000000..9fcb8443 --- /dev/null +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -0,0 +1,51 @@ +query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + while ($val = $res->fetchRow()) { + $val['date'] = substr($val['created'], 0, 10); // Strip the time. + $result[] = $val; + } + return $result; + } + return false; + } +} diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 27f31bb3..1c9e30fd 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -688,24 +688,6 @@ class ttTeamHelper { return false; } - // The getTeams function returns an array of all active teams on the server. - static function getTeams() { - $result = array(); - $mdb2 = getConnection(); - - $sql = "select id, name, created, lang from tt_teams where status = 1 order by id desc"; - $res = $mdb2->query($sql); - $result = array(); - if (!is_a($res, 'PEAR_Error')) { - while ($val = $res->fetchRow()) { - $val['date'] = substr($val['created'], 0, 10); // Strip the time. - $result[] = $val; - } - return $result; - } - return false; - } - // The markDeleted function marks the team and everything in it as deleted. static function markDeleted($team_id) { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 27a3ad38..1ddc76d9 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.65.4135 | Copyright © Anuko | +  Anuko Time Tracker 1.17.65.4136 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/admin_teams.php b/admin_teams.php index 9c3d2092..55df54fc 100644 --- a/admin_teams.php +++ b/admin_teams.php @@ -27,8 +27,7 @@ // +----------------------------------------------------------------------+ require_once('initialize.php'); -import('form.Form'); -import('ttTeamHelper'); +import('ttGroupHelper'); // Access check. if (!ttAccessAllowed('administer_site')) { @@ -36,7 +35,7 @@ if (!ttAccessAllowed('administer_site')) { exit(); } -$smarty->assign('teams', ttTeamHelper::getTeams()); +$smarty->assign('teams', ttGroupHelper::getTopGroups()); $smarty->assign('title', $i18n->getKey('title.teams')); $smarty->assign('content_page_name', 'admin_teams.tpl'); $smarty->display('index.tpl'); diff --git a/login.php b/login.php index d398794c..538147b0 100644 --- a/login.php +++ b/login.php @@ -28,7 +28,7 @@ require_once('initialize.php'); import('form.Form'); -import('ttTeamHelper'); +import('ttGroupHelper'); import('ttUser'); $cl_login = $request->getParameter('login'); @@ -75,7 +75,7 @@ if ($request->isPost()) { } } // isPost -if(!isTrue(MULTITEAM_MODE) && !ttTeamHelper::getTeams()) +if(!isTrue(MULTITEAM_MODE) && !ttGroupHelper::getTopGroups()) $err->add($i18n->getKey('error.no_teams')); // Determine whether to show login hint. It is currently used only for Windows LDAP authentication. diff --git a/mobile/login.php b/mobile/login.php index 538a0b54..384cf8c7 100644 --- a/mobile/login.php +++ b/mobile/login.php @@ -28,7 +28,7 @@ require_once('../initialize.php'); import('form.Form'); -import('ttTeamHelper'); +import('ttGroupHelper'); import('ttUser'); if ($request->isPost()) { @@ -80,7 +80,7 @@ if ($request->isPost()) { } } // isPost -if(!isTrue(MULTITEAM_MODE) && !ttTeamHelper::getTeams()) +if(!isTrue(MULTITEAM_MODE) && !ttGroupHelper::getTopGroups()) $err->add($i18n->getKey('error.no_teams')); // Determine whether to show login hint. It is currently used only for Windows LDAP authentication. -- 2.20.1