From 7139e33e6c7dcd206e166416e7b5742bc3849cb9 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 08 Sep 2006 11:16:47 -0400
Subject: [PATCH] Updated MDB2 with MSSQL support + some cosmetics

---
 program/include/main.inc       |    2 +-
 program/include/rcube_mdb2.inc |   22 ++++++++++++++++++++++
 program/js/app.js              |    2 +-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index c084588..02f5b57 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -185,7 +185,7 @@
   // renew auth cookie every 5 minutes (only for GET requests)
   if (!$valid || ($_SERVER['REQUEST_METHOD']!='POST' && $now-$_SESSION['auth_time'] > 300))
     {
-	  $_SESSION['last_auth'] = $_SESSION['auth_time'];
+    $_SESSION['last_auth'] = $_SESSION['auth_time'];
     $_SESSION['auth_time'] = $now;
     setcookie('sessauth', rcmail_auth_hash(session_id(), $now));
     }
diff --git a/program/include/rcube_mdb2.inc b/program/include/rcube_mdb2.inc
index eec975c..d372302 100755
--- a/program/include/rcube_mdb2.inc
+++ b/program/include/rcube_mdb2.inc
@@ -411,6 +411,25 @@
 
 
   /**
+   * Return SQL function for current time and date
+   *
+   * @return string SQL function to use in query
+   * @access public
+   */
+  function now()
+    {
+    switch($this->db_provider)
+      {
+      case 'mssql':
+        return "getdate()";
+
+      default:
+        return "now()";
+      }
+    }
+
+
+  /**
    * Return SQL statement to convert a field value into a unix timestamp
    *
    * @param  string  Field name
@@ -425,6 +444,9 @@
         return "EXTRACT (EPOCH FROM $field)";
         break;
 
+      case 'mssql':
+        return "datediff(s, '1970-01-01 00:00:00', $field)";
+
       default:
         return "UNIX_TIMESTAMP($field)";
       }
diff --git a/program/js/app.js b/program/js/app.js
index 8d2f1ed..d52efae 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -49,7 +49,7 @@
                              'application/x-shockwave-flash');
 
   // default environment vars
-  this.env.keep_alive = 50;        // seconds
+  this.env.keep_alive = 60;        // seconds
   this.env.request_timeout = 180;  // seconds
   this.env.draft_autosave = 0;     // seconds
 

--
Gitblit v1.9.1