Add sort_name to pluser.
[platal.git] / classes / plglobals.php
index 5185836..3482155 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 /** Debug levels:
- * DEBUG_BT     = show the backtraces (SQL/XMLRPC/...)
- * DEBUG_VALID  = run html validation
- * DEBUG_SMARTY = don't hide smarty errors/warnings/notices
+ * DEBUG_BT      = show the backtraces (SQL/XMLRPC/...)
+ * DEBUG_VALID   = run html validation
+ * DEBUG_SMARTY  = don't hide smarty errors/warnings/notices
+ * DEBUG_NOCACHE = disable cache
+ * DEBUG_SCRIPTCACHE = cache expires after the execution of the script
  */
-define('DEBUG_BT', 1);
-define('DEBUG_VALID', 2);
-define('DEBUG_SMARTY', 4);
+define('DEBUG_BT',          1);
+define('DEBUG_VALID',       2);
+define('DEBUG_SMARTY',      4);
+define('DEBUG_NOCACHE',     8);
+define('DEBUG_SCRIPTCACHE', 16);
+
+/* First allowed value for user-defined DEBUG_* flags.
+ * Set to 256 to keep rooms for future core flags (5 flags available).
+ */
+define('DEBUG_USERBASE', 256);
 
 /** PlGlobals provides functions to read a set of configuration files and gives
  * access to this configurations.
@@ -64,6 +73,20 @@ class PlGlobals
                                // 'r'  => read/only
                                // ''   => site down
 
+    /** Catch-all mode for emails.
+     * If set to a valid email address, all emails from plat/al are sent to
+     * that email address, instead of their normal destination (From:, To:,
+     * and CC: headers are not actually modified).
+     * Note: only valid if restricted_platal is set to true.
+     */
+    public $email_catchall = false;
+
+    /** Tell smarty to check the timestamps of the templates to decide
+     * whether recompile the template or not. If this option is false and
+     * debug mode is not activate, templates won't be recompile if they changed.
+     */
+    public $smarty_autocompile = false;
+
     /** BaseURL of the site.
      * This is read from the HTTP headers if available but you MUST give a
      * default value for this field in you configuration file (because, this
@@ -80,31 +103,43 @@ class PlGlobals
     public $baseurl_http;
 
     /** paths */
+    public $coreroot;
     public $spoolroot;
 
     /** Localization configuration.
      */
-    public $locale;
-    public $timezone;
+    public $locale = 'fr_FR.UTF-8';
+    public $timezone = 'Europe/Paris';
 
     /** Cookie configuration.
      */
     public $cookie_ns = 'ORG';
     public $cookie_path = '/';
 
-    /** You must give a list of file to load.
+    /** Cache duration for static and dynamic cacheable content generated by
+     * plat/al. Defaults to a week for static content, and an hour for dynamic
+     * content.
+     */
+    public $static_cache_duration = 604800;
+    public $dynamic_cache_duration = 3600;
+
+    /** You should give a list of file to load if you don't want the default configuration.
      * The filenames given are relatives to the config path of your plat/al installation.
      */
-    public function __construct(array $files)
+    public function __construct(array $files = null)
     {
-        $this->spoolroot = dirname(dirname(dirname(__FILE__)));
+        $this->coreroot = dirname(dirname(__FILE__));
+        $this->spoolroot = dirname($this->coreroot);
 
-        $this->readConfig($files);
+        if (!is_null($files)) {
+            $this->readConfig($files);
+        }
         if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
             $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
             $this->baseurl      = @trim($base    .$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
             $this->baseurl_http = @trim('http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
         }
+        assert_options(ASSERT_ACTIVE, $this->debug != 0);
 
         $this->setLocale();
     }
@@ -171,10 +206,10 @@ class PlGlobals
     /** Change dynamic config file
      * @param conf array of keys and values to add or replace
      * @param category name of category to change
-     * 
+     *
      * Opens the dynamic conf file and set values from conf in specified
      * category. Updates config vars too.
-     */ 
+     */
     public function changeDynamicConfig($conf, $category = 'Core')
     {
         $dynamicfile = $this->spoolroot.'/spool/conf/platal.dynamic.conf';
@@ -217,7 +252,7 @@ class PlGlobals
                     if (isset($conflower[strtolower($k)])) {
                         $array[$same][$k] = $v;
                     }
-                } 
+                }
             }
         }
         // writes the file over
@@ -251,5 +286,5 @@ class PlGlobals
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>