From 60226a75d8e4a3ee9504da6eab6d8f329bb32e7b Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Tue, 27 Nov 2012 06:13:33 -0500
Subject: [PATCH] Separate the very application-specific output classes from the Roundcube framework; add autoloader for rmail* classes

---
 program/include/iniset.php |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/program/include/iniset.php b/program/include/iniset.php
index 25ae018..be71fc0 100644
--- a/program/include/iniset.php
+++ b/program/include/iniset.php
@@ -72,8 +72,26 @@
 // include Roundcube Framework
 require_once 'Roundcube/bootstrap.php';
 
-// backward compatybility (to be removed)
-require_once INSTALL_PATH . 'program/include/rcmail.php';
+// register autoloader for rcmail app classes
+spl_autoload_register('rcmail_autoload');
 
 // backward compatybility (to be removed)
 require_once INSTALL_PATH . 'program/include/bc.php';
+
+
+/**
+ * PHP5 autoloader routine for dynamic class loading
+ */
+function rcmail_autoload($classname)
+{
+    if (strpos($classname, 'rcmail') === 0) {
+        $filepath = INSTALL_PATH . "program/include/$classname.php";
+        if (is_readable($filepath)) {
+            include_once $filepath;
+            return true;
+        }
+    }
+
+    return false;
+}
+

--
Gitblit v1.9.1