[opw-web] Add config variable



commit 54e3af16a94a7a3e6f69eb3cf089d444fe277e57
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sun Mar 9 17:50:55 2014 -0400

    Add config variable

 classes/class_cache.php  |   10 ++++++++--
 classes/class_config.php |    4 ++++
 config.sample.php        |    3 +++
 3 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/classes/class_cache.php b/classes/class_cache.php
index fe4a3c5..6349131 100644
--- a/classes/class_cache.php
+++ b/classes/class_cache.php
@@ -5,8 +5,6 @@
 * @copyright (c) 2012 KDE. All rights reserved.
 */
 
-include_once('PEAR.php');
-
 class cache
 {
     // Global vars
@@ -16,7 +14,15 @@ class cache
     // Constructor
     function __construct()
     {
+        global $config;
+
+        if (!$config->enable_cache) {
+            $this->is_available = false;
+            return;
+        }
+
         @include('Cache/Lite.php');
+        include_once('PEAR.php');
 
         if (class_exists('Cache_Lite'))
         {
diff --git a/classes/class_config.php b/classes/class_config.php
index 47a3bb6..a39e607 100644
--- a/classes/class_config.php
+++ b/classes/class_config.php
@@ -15,6 +15,8 @@ class config
     var $db_password;
     var $db_prefix;
 
+    var $enable_cache;
+
     var $site_name;
     var $site_url;
     var $site_copyright;
@@ -86,6 +88,8 @@ class config
             $this->db_password      = isset($db_password) ? $db_password : '';
             $this->db_prefix        = isset($db_prefix) ? $db_prefix : '';
 
+            $this->enable_cache     = isset($enable_cache) ? $enable_cache : '';
+
             $this->site_name        = isset($site_name) ? $site_name : 'Pandora';
             $this->site_url         = isset($site_url ) ? $site_url  : 'https://' . $_SERVER["HTTP_HOST"];
             $this->site_copyright   = isset($site_copyright) ? $site_copyright : '&copy; 2012 KDE';
diff --git a/config.sample.php b/config.sample.php
index 72e7a44..9ab3046 100644
--- a/config.sample.php
+++ b/config.sample.php
@@ -28,6 +28,9 @@ $db_password = "";
 // Table prefix
 $db_prefix = "";
 
+// Whether caching is turned on if Cache-Lite is installed; turn off for development
+$enable_cache = true;
+
 // Site name
 $site_name = "Outreach Program for Women";
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]