From ddafe4e4109a8d6d412c3c138412ee2ca3d58dbf Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Sat, 27 Oct 2012 10:12:37 -0400
Subject: [PATCH] Merge branch 'dev-compose-newwindow'

---
 program/include/rcube_db_pgsql.php |   44 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/program/include/rcube_db_pgsql.php b/program/include/rcube_db_pgsql.php
index d357d88..0d0caad 100644
--- a/program/include/rcube_db_pgsql.php
+++ b/program/include/rcube_db_pgsql.php
@@ -31,15 +31,16 @@
  */
 class rcube_db_pgsql extends rcube_db
 {
+    public $db_provider = 'postgres';
+
     /**
      * Get last inserted record ID
-     * For Postgres databases, a table name is required
      *
-     * @param  string $table  Table name (to find the incremented sequence)
+     * @param string $table Table name (to find the incremented sequence)
      *
-     * @return mixed   ID or false on failure
+     * @return mixed ID or false on failure
      */
-    public function insert_id($table = '')
+    public function insert_id($table = null)
     {
         if (!$this->db_connected || $this->db_mode == 'r') {
             return false;
@@ -55,14 +56,35 @@
     }
 
     /**
+     * Return correct name for a specific database sequence
+     *
+     * @param string $sequence Secuence name
+     *
+     * @return string Translated sequence name
+     */
+    protected function sequence_name($sequence)
+    {
+        $rcube = rcube::get_instance();
+
+        // return sequence name if configured
+        $config_key = 'db_sequence_'.$sequence;
+
+        if ($name = $rcube->config->get($config_key)) {
+            return $name;
+        }
+
+        return $sequence;
+    }
+
+    /**
      * Return SQL statement to convert a field value into a unix timestamp
      *
      * This method is deprecated and should not be used anymore due to limitations
      * of timestamp functions in Mysql (year 2038 problem)
      *
-     * @param  string $field Field name
+     * @param string $field Field name
      *
-     * @return string  SQL statement to use in query
+     * @return string SQL statement to use in query
      * @deprecated
      */
     public function unixtimestamp($field)
@@ -73,10 +95,10 @@
     /**
      * Return SQL statement for case insensitive LIKE
      *
-     * @param  string $column  Field name
-     * @param  string $value   Search value
+     * @param string $column Field name
+     * @param string $value  Search value
      *
-     * @return string  SQL statement to use in query
+     * @return string SQL statement to use in query
      */
     public function ilike($column, $value)
     {
@@ -86,8 +108,8 @@
     /**
      * Get database runtime variables
      *
-     * @param string $varname  Variable name
-     * @param mixed  $default  Default value if variable is not set
+     * @param string $varname Variable name
+     * @param mixed  $default Default value if variable is not set
      *
      * @return mixed Variable value or default
      */

--
Gitblit v1.9.1