Some more refactoring for subgroups.
authorNik Okuntseff <support@anuko.com>
Sat, 1 Dec 2018 22:58:13 +0000 (22:58 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 1 Dec 2018 22:58:13 +0000 (22:58 +0000)
WEB-INF/lib/ttGroupHelper.class.php
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/templates/footer.tpl
mobile/projects.php
projects.php

index e04c221..9f9f4a2 100644 (file)
@@ -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;
+  }
 }
index f82fc26..67d97b8 100644 (file)
@@ -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();
index 83288cf..00eaa06 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.18.29.4563 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.29.4564 | 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 e3dc2f8..d244ae1 100644 (file)
@@ -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();
 
index b8faa14..8b4537e 100644 (file)
@@ -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();