]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttUser.class.php
Some more progress on group editor.
[timetracker.git] / WEB-INF / lib / ttUser.class.php
index 6bac7cb468232b622ac728c9709e694ac346bb83..16b536c22bc670bf06e49508021970c98ab5e7a7 100644 (file)
@@ -27,6 +27,7 @@
 // +----------------------------------------------------------------------+
 
 import('ttConfigHelper');
+import('ttGroupHelper');
 
 class ttUser {
   var $login = null;            // User login.
@@ -410,6 +411,22 @@ class ttUser {
     return $groups;
   }
 
+  // getSubgroups obtains a list of immediate subgroups.
+  function getSubgroups($group_id = null) {
+    $mdb2 = getConnection();
+
+    if (!$group_id) $group_id = $this->getActiveGroup();
+
+    $sql = "select id, name, description from tt_groups where org_id = $this->org_id and parent_id = $group_id";
+    $res = $mdb2->query($sql);
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $groups[] = $val;
+      }
+    }
+    return $groups;
+  }
+
   // getUser function is used to manage users in group and returns user details.
   // At the moment, the function is used for user edits and deletes.
   function getUser($user_id) {
@@ -585,6 +602,14 @@ class ttUser {
     return true;
   }
 
+  // isGroupValid determines if a group is valid for user.
+  function isGroupValid($group_id) {
+    if ($group_id == $this->group_id)
+      return true;
+    else
+      return $this->isSubgroupValid($group_id);
+  }
+
   // isSubgroupValid determines if a subgroup is valid for user.
   // A subgroup is valid if:
   //   - user can manage_subgroups;