]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttUser.class.php
Adjusted group_edit.php to work with subgroups.
[timetracker.git] / WEB-INF / lib / ttUser.class.php
index 16b536c22bc670bf06e49508021970c98ab5e7a7..79f7ae77b229996fc28a4eae23c8dde6387d81dd 100644 (file)
@@ -380,14 +380,14 @@ class ttUser {
     if ($selected_group_id != $this->group_id) {
       // We are in one of subgroups, and a parent exists.
       // Get parent group info.
-      $sql = "select parent_id from tt_groups where org_id = $this->org_id and id = $selected_group_id";
+      $sql = "select parent_id from tt_groups where org_id = $this->org_id and id = $selected_group_id and status = 1";
       $res = $mdb2->query($sql);
       if (!is_a($res, 'PEAR_Error')) {
         $val = $res->fetchRow();
         $parent_id = $val['parent_id'];
         if ($parent_id) {
           // Get parent group name.
-          $sql = "select name from tt_groups where org_id = $this->org_id and id = $parent_id";
+          $sql = "select name from tt_groups where org_id = $this->org_id and id = $parent_id and status = 1";
           $res = $mdb2->query($sql);
           if (!is_a($res, 'PEAR_Error')) {
             $val = $res->fetchRow();
@@ -401,11 +401,12 @@ class ttUser {
     $groups[] = array('id'=>$selected_group_id,'name'=>$selected_group_name);
 
     // Add subgroups.
-    $sql = "select id, name from tt_groups where org_id = $this->org_id and parent_id = $selected_group_id";
+    $sql = "select id, name from tt_groups where org_id = $this->org_id and parent_id = $selected_group_id and status = 1";
+    //die($sql);
     $res = $mdb2->query($sql);
     if (!is_a($res, 'PEAR_Error')) {
       while ($val = $res->fetchRow()) {
-        $groups[] = array('id'=>$val['id'],'name'=>$val['name']);
+        $groups[] = $val;
       }
     }
     return $groups;
@@ -417,7 +418,8 @@ class ttUser {
 
     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";
+    $sql = "select id, name, description from tt_groups where org_id = $this->org_id".
+      " and parent_id = $group_id and status is not null";
     $res = $mdb2->query($sql);
     if (!is_a($res, 'PEAR_Error')) {
       while ($val = $res->fetchRow()) {
@@ -507,8 +509,13 @@ class ttUser {
     if (!($this->can('manage_basic_settings') ||
       $this->can('manage_advanced_settings') ||
       $this->can('manage_features'))) return false;
+    // TODO: update the above for subgroup updates.
+
+    $group_id = $fields['group_id'];
+    if ($group_id && !$this->isGroupValid($group_id)) return false;
 
     $mdb2 = getConnection();
+    if (!$group_id) $group_id = $this->getActiveGroup();
 
     if (isset($fields['name'])) $name_part = ', name = '.$mdb2->quote($fields['name']);
     if (isset($fields['currency'])) $currency_part = ', currency = '.$mdb2->quote($fields['currency']);
@@ -535,7 +542,7 @@ class ttUser {
       $time_format_part.$week_start_part.$tracking_mode_part.$task_required_part.$project_required_part.$record_type_part.
       $bcc_email_part.$allow_ip_part.$plugins_part.$config_part.$lock_spec_part.$workday_minutes_part.$modified_part, ',');
 
-    $sql = "update tt_groups set $parts where id = $this->group_id";
+    $sql = "update tt_groups set $parts where id = $group_id and org_id = $this->org_id";
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error')) return false;