Introduced ttGroupHelper class as part of refactoring.
authorNik Okuntseff <support@anuko.com>
Thu, 22 Mar 2018 20:27:44 +0000 (20:27 +0000)
committerNik Okuntseff <support@anuko.com>
Thu, 22 Mar 2018 20:27:44 +0000 (20:27 +0000)
WEB-INF/lib/ttGroupHelper.class.php [new file with mode: 0644]
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/templates/footer.tpl
admin_teams.php
login.php
mobile/login.php

diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php
new file mode 100644 (file)
index 0000000..9fcb844
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+// Class ttGroupHelper - contains helper functions that operate with groups.
+// This is a planned replacement for ttTeamHelper as we move forward with subgroups.
+class ttGroupHelper {
+
+  // The getTopGroups function returns an array of all active top groups on the server.
+  static function getTopGroups() {
+    $result = array();
+    $mdb2 = getConnection();
+
+    // TODO: when we have subgroups, improve the query to return only top groups.
+    $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;
+  }
+}
index 27f31bb..1c9e30f 100644 (file)
@@ -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) {
 
index 27a3ad3..1ddc76d 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.17.65.4135 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.65.4136 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index 9c3d209..55df54f 100644 (file)
@@ -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');
index d398794..538147b 100644 (file)
--- 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.
index 538a0b5..384cf8c 100644 (file)
@@ -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.