From eef9eb1146cf9903e58743291ca27c68340aea2c Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 21 Aug 2013 03:44:27 -0400
Subject: [PATCH] Synchronized localization files from Transifex

---
 program/lib/Roundcube/rcube.php |   59 +++++++++++++++++++++++++----------------------------------
 1 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index ebfa4f8..fbf9540 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -99,20 +99,20 @@
     protected $texts;
     protected $caches = array();
     protected $shutdown_functions = array();
-    protected $expunge_cache = false;
 
 
     /**
      * This implements the 'singleton' design pattern
      *
      * @param integer Options to initialize with this instance. See rcube::INIT_WITH_* constants
+     * @param string Environment name to run (e.g. live, dev, test)
      *
      * @return rcube The one and only instance
      */
-    static function get_instance($mode = 0)
+    static function get_instance($mode = 0, $env = '')
     {
         if (!self::$instance) {
-            self::$instance = new rcube();
+            self::$instance = new rcube($env);
             self::$instance->init($mode);
         }
 
@@ -123,10 +123,10 @@
     /**
      * Private constructor
      */
-    protected function __construct()
+    protected function __construct($env = '')
     {
         // load configuration
-        $this->config  = new rcube_config;
+        $this->config  = new rcube_config($env);
         $this->plugins = new rcube_dummy_plugin_api;
 
         register_shutdown_function(array($this, 'shutdown'));
@@ -378,6 +378,7 @@
             'auth_pw'     => $this->config->get("{$driver}_auth_pw"),
             'debug'       => (bool) $this->config->get("{$driver}_debug"),
             'force_caps'  => (bool) $this->config->get("{$driver}_force_caps"),
+            'disabled_caps' => $this->config->get("{$driver}_disabled_caps"),
             'timeout'     => (int) $this->config->get("{$driver}_timeout"),
             'skip_deleted' => (bool) $this->config->get('skip_deleted'),
             'driver'      => $driver,
@@ -462,9 +463,13 @@
         // use database for storing session data
         $this->session = new rcube_session($this->get_dbh(), $this->config);
 
-        $this->session->register_gc_handler(array($this, 'gc_handler'));
+        $this->session->register_gc_handler(array($this, 'gc'));
         $this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME']));
         $this->session->set_ip_check($this->config->get('ip_check'));
+
+        if ($this->config->get('session_auth_name')) {
+            $this->session->set_cookiename($this->config->get('session_auth_name'));
+        }
 
         // start PHP session (if not in CLI mode)
         if ($_SERVER['REMOTE_ADDR']) {
@@ -478,15 +483,9 @@
      */
     public function gc()
     {
-        foreach ($this->caches as $cache) {
-            if (is_object($cache)) {
-                $cache->expunge();
-            }
-        }
-
-        if (is_object($this->storage)) {
-            $this->storage->expunge_cache();
-        }
+        rcube_cache::gc();
+        rcube_cache_shared::gc();
+        $this->get_storage()->cache_gc();
 
         $this->gc_temp();
     }
@@ -503,29 +502,17 @@
 
         if ($tmp && ($dir = opendir($tmp))) {
             while (($fname = readdir($dir)) !== false) {
-                if ($fname{0} == '.') {
+                if ($fname[0] == '.') {
                     continue;
                 }
 
-                if (filemtime($tmp.'/'.$fname) < $expire) {
+                if (@filemtime($tmp.'/'.$fname) < $expire) {
                     @unlink($tmp.'/'.$fname);
                 }
             }
 
             closedir($dir);
         }
-    }
-
-
-    /**
-     * Garbage collector for cache entries.
-     * Set flag to expunge caches on shutdown
-     */
-    public function gc_handler()
-    {
-        // because this gc function is called before storage is initialized,
-        // we just set a flag to expunge storage cache on shutdown.
-        $this->expunge_cache = true;
     }
 
 
@@ -928,12 +915,16 @@
             call_user_func($function);
         }
 
-        if (is_object($this->smtp)) {
-            $this->smtp->disconnect();
+        // write session data as soon as possible and before
+        // closing database connection, don't do this before
+        // registered shutdown functions, they may need the session
+        // Note: this will run registered gc handlers (ie. cache gc)
+        if ($_SERVER['REMOTE_ADDR'] && is_object($this->session)) {
+            $this->session->write_close();
         }
 
-        if ($this->expunge_cache) {
-            $this->gc();
+        if (is_object($this->smtp)) {
+            $this->smtp->disconnect();
         }
 
         foreach ($this->caches as $cache) {
@@ -1502,7 +1493,7 @@
                     $subject    = str_replace("\r\n", $delim, $subject);
                 }
 
-                if (ini_get('safe_mode'))
+                if (filter_var(ini_get('safe_mode'), FILTER_VALIDATE_BOOLEAN))
                     $sent = mail($to, $subject, $msg_body, $header_str);
                 else
                     $sent = mail($to, $subject, $msg_body, $header_str, "-f$from");

--
Gitblit v1.9.1