]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttAdmin.class.php
Update for tt_users created field.
[timetracker.git] / WEB-INF / lib / ttAdmin.class.php
index e054547d1eb4a0ce96f8eccb9c52695aafdc6a94..87fe00bcadd014278b594a4f732c2d9856aea8c7 100644 (file)
@@ -183,8 +183,8 @@ class ttAdmin {
     return true;
   }
 
-  // validateTeamInfo validates team information entered by user.
-  function validateTeamInfo($fields) {
+  // validateGroupInfo validates group information entered by user.
+  function validateGroupInfo($fields) {
     global $i18n;
     global $auth;
 
@@ -233,16 +233,18 @@ class ttAdmin {
     return $result;
   }
 
-  // updateTeam validates user input and updates the team with new information.
-  function updateTeam($team_id, $fields) {
-    if (!$this->validateTeamInfo($fields)) return false; // Can't continue as user input is invalid.
+  // updateGroup validates user input and updates the group with new information.
+  function updateGroup($team_id, $fields) {
+    if (!$this->validateGroupInfo($fields)) return false; // Can't continue as user input is invalid.
 
+    global $user;
     $mdb2 = getConnection();
 
     // Update group name if it changed.
     if ($fields['old_group_name'] != $fields['new_group_name']) {
-      $name = $mdb2->quote($fields['new_group_name']);
-      $sql = "update tt_teams set name = $name where id = $team_id";
+      $name_part = 'name = '.$mdb2->quote($fields['new_group_name']);
+      $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id);
+      $sql = 'update tt_teams set '.$name_part.$modified_part.' where id = '.$team_id;
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error')) return false;
     }
@@ -254,11 +256,16 @@ class ttAdmin {
       $password_part = ', password = md5('.$mdb2->quote($fields['password1']).')';
     $name_part = ', name = '.$mdb2->quote($fields['user_name']);
     $email_part = ', email = '.$mdb2->quote($fields['email']);
-
-    $sql = 'update tt_users set '.$login_part.$password_part.$name_part.$email_part.'where id = '.$user_id;
+    $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id);
+    $sql = 'update tt_users set '.$login_part.$password_part.$name_part.$email_part.$modified_part.'where id = '.$user_id;
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error')) return false;
 
     return true;
   }
+
+  // updateSelf validates user input and updates admin account with new information.
+  function updateSelf($fields) {
+    return false; // Not yet implemeneted.
+  }
 }