]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttTeamHelper.class.php
Switched from timestamp to created column in a query.
[timetracker.git] / WEB-INF / lib / ttTeamHelper.class.php
index 74ef55452d440da338ac25cf34f81eae68c388a3..27f31bb32d1ee7aa82b21a9d6b77cc3eb758ce44 100644 (file)
@@ -693,12 +693,12 @@ class ttTeamHelper {
     $result = array();
     $mdb2 = getConnection();
 
-    $sql =  "select id, name, lang, timestamp from tt_teams where status = 1 order by id desc";
+    $sql =  "select id, name, created, lang from tt_teams where status = 1 order by id desc";
     $res = $mdb2->query($sql);
     $result = array();
     if (!is_a($res, 'PEAR_Error')) {
       while ($val = $res->fetchRow()) {
-       $val['date'] = substr($val['timestamp'], 0, 10); // Strip the time.
+        $val['date'] = substr($val['created'], 0, 10); // Strip the time.
         $result[] = $val;
       }
       return $result;
@@ -867,6 +867,7 @@ class ttTeamHelper {
   // The update function updates team information.
   static function update($team_id, $fields)
   {
+    global $user;
     $mdb2 = getConnection();
     $name_part = 'name = '.$mdb2->quote($fields['name']);
     $currency_part = '';
@@ -897,10 +898,11 @@ class ttTeamHelper {
     if (isset($fields['config'])) $config_part = ', config = '.$mdb2->quote($fields['config']);
     if (isset($fields['lock_spec'])) $lock_spec_part = ', lock_spec = '.$mdb2->quote($fields['lock_spec']);
     if (isset($fields['workday_minutes'])) $workday_minutes_part = ', workday_minutes = '.$mdb2->quote($fields['workday_minutes']);
+    $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id);
 
     $sql = "update tt_teams set $name_part $currency_part $lang_part $decimal_mark_part
       $date_format_part $time_format_part $week_start_part $tracking_mode_part $task_required_part $record_type_part
-      $bcc_email_part $plugins_part $config_part $lock_spec_part $workday_minutes_part where id = $team_id";
+      $bcc_email_part $plugins_part $config_part $lock_spec_part $workday_minutes_part $modified_part where id = $team_id";
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error')) return false;
 
@@ -912,9 +914,9 @@ class ttTeamHelper {
     $inactive_teams = array();
     $mdb2 = getConnection();
 
-    // Get all team ids for teams created or modified more than 6 months ago.
+    // Get all team ids for teams created or modified more than 8 months ago.
     // $ts = date('Y-m-d', strtotime('-1 year'));
-    $ts = date('Y-m-d', strtotime('-6 month'));
+    $ts = date('Y-m-d', strtotime('-8 month'));
     $sql =  "select id from tt_teams where timestamp < '$ts' order by id";
     $res = $mdb2->query($sql);