]> 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 7a37109ebc7cc5db08aecf1245c01dc0147b9377..16b536c22bc670bf06e49508021970c98ab5e7a7 100644 (file)
@@ -27,6 +27,7 @@
 // +----------------------------------------------------------------------+
 
 import('ttConfigHelper');
+import('ttGroupHelper');
 
 class ttUser {
   var $login = null;            // User login.
@@ -411,10 +412,12 @@ class ttUser {
   }
 
   // getSubgroups obtains a list of immediate subgroups.
-  function getSubgroups() {
+  function getSubgroups($group_id = null) {
     $mdb2 = getConnection();
 
-    $sql = "select id, name, description from tt_groups where org_id = $this->org_id and parent_id = ".$this->getActiveGroup();;
+    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()) {
@@ -599,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;