]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttUser.class.php
Removed group selector from projects.php to keep things simple.
[timetracker.git] / WEB-INF / lib / ttUser.class.php
index 05081c5ab80921acaa4680dd2cf97ce3911dfd84..e6f271df8b4f40178e77ffc95f1c18d27233d469 100644 (file)
@@ -250,9 +250,9 @@ class ttUser {
     $result = array();
     $mdb2 = getConnection();
 
+    $user_id = $this->getUser();
     $group_id = $this->getGroup();
     $org_id = $this->org_id;
-    $user_id = $this->getUser();
 
     // Do a query with inner join to get assigned projects.
     $sql = "select p.id, p.name, p.description, p.tasks, upb.rate from tt_projects p".
@@ -594,15 +594,10 @@ class ttUser {
 
   // updateGroup updates group information with new data.
   function updateGroup($fields) {
-    if (!($this->can('manage_basic_settings') ||
-      $this->can('manage_advanced_settings') ||
-      $this->can('manage_features'))) return false;
-    // TODO: update the above for subgroup updates.
+    $mdb2 = getConnection();
 
     $group_id = $fields['group_id'];
     if ($group_id && !$this->isGroupValid($group_id)) return false;
-
-    $mdb2 = getConnection();
     if (!$group_id) $group_id = $this->getGroup();
 
     if (isset($fields['name'])) $name_part = ', name = '.$mdb2->quote($fields['name']);
@@ -810,7 +805,7 @@ class ttUser {
     return;
   }
 
-   // setOnBehalfUser sets on behalf user both the object and the session.
+  // setOnBehalfUser sets on behalf user both the object and the session.
   function setOnBehalfUser($user_id) {
 
     // Unset things first.
@@ -833,4 +828,17 @@ class ttUser {
     $this->behalf_name = $onBehalfUserName;
     return;
   }
+
+  // The exists() function determines if an active user exists in context of a page.
+  // If we are working as self, true.
+  // If we are working in a subgroup with active users, true.
+  // If we are working in a subgroup without active users, false.
+  function exists() {
+    if (!$this->behalfGroup)
+      return true; // Working as self.
+    else if ($this->behalfGroup->active_users)
+      return true; // Subgroup has users.
+
+    return false;
+  }
 }