ttOrgImportHelper class impoved to output conflicting login names.
[timetracker.git] / WEB-INF / lib / ttGroupHelper.class.php
index 22362b5..44dc3e1 100644 (file)
@@ -36,7 +36,7 @@ class ttGroupHelper {
     $mdb2 = getConnection();
 
     $sql =  "select id, name, created, lang from tt_groups".
-            " where status = 1 and org_id is NULL or org_id = id order by id desc";
+            " where status = 1 and (org_id is NULL or org_id = id) order by id desc";
     $res = $mdb2->query($sql);
     $result = array();
     if (!is_a($res, 'PEAR_Error')) {
@@ -62,4 +62,20 @@ class ttGroupHelper {
     }
     return false;
   }
+
+  // The getParentGroup determines a parent group for a given group.
+  static function getParentGroup($group_id) {
+    global $user;
+
+    $mdb2 = getConnection();
+
+    $sql = "select parent_id from tt_groups where id = $group_id and org_id = $user->org_id and status = 1";
+    $res = $mdb2->query($sql);
+
+    if (!is_a($res, 'PEAR_Error')) {
+      $val = $res->fetchRow();
+      return $val['parent_id'];
+    }
+    return false;
+  }
 }