Split Globals into PlGlobals and PlatalGlobals:
[platal.git] / include / globals.inc.php.in
index fa8646a..2ddbcc1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 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                *
  ***************************************************************************/
 
-class PlatalGlobals
+class PlatalGlobals extends PlGlobals
 {
     public $session;
 
     /** The x.org version */
     public $version = '@VERSION@';
     public $debug   = 0;
+    public $mode    = 'rw';    // 'rw' => read/write,
+                               // 'r'  => read/only
+                               // ''   => site down
 
     /** db params */
     public $dbdb               = 'x4dat';
@@ -34,58 +37,14 @@ class PlatalGlobals
     public $dbpwd              = 'x4dat';
     public $dbcharset          = 'utf8';
 
-    /** paths */
-    public $baseurl;
-    public $spoolroot;
-
-    public $locale;
-    public $timezone;
+    /** default skin */
+    public $skin;
+    public $register_skin;
 
     public function __construct($sess)
     {
-        $this->session   = $sess;
-
-        $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
-        $this->baseurl   = trim($base.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
-        $this->spoolroot = dirname(dirname(__FILE__));
-
-        $this->read_config();
-        $this->setlocale();
-    }
-
-    private function read_ini_file($filename)
-    {
-        $array = parse_ini_file($filename, true);
-        if (!is_array($array)) {
-            return;
-        }
-        foreach ($array as $cat => $conf) {
-            $c = strtolower($cat);
-            foreach ($conf as $k => $v) {
-                if ($c == 'core' && property_exists($this, $k)) {
-                    $this->$k=$v;
-                } else {
-                    if (!isset($this->$c)) {
-                        $this->$c = new stdClass;
-                    }
-                    $this->$c->$k = $v;
-                }
-            }
-        }
-    }
-
-    private function read_config()
-    {
-        $this->read_ini_file($this->spoolroot.'/configs/platal.ini');
-        $this->read_ini_file($this->spoolroot.'/configs/platal.conf');
-    }
-
-    private function setlocale()
-    {
-        setlocale(LC_MESSAGES, $this->locale);
-        setlocale(LC_TIME,     $this->locale);
-        setlocale(LC_CTYPE,    $this->locale);
-        date_default_timezone_set($this->timezone);
+        $this->session = $sess; /* XXX Remove references to session from $globals */
+        parent::__construct(array('platal.ini', 'platal.conf'));
     }
 
     public function asso($key=null)
@@ -99,7 +58,9 @@ class PlatalGlobals
             }
 
             if ($gp) {
-                $res = XDB::query('SELECT  a.*, d.nom AS domnom
+                $res = XDB::query('SELECT  a.*, d.nom AS domnom,
+                                           FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
+                                           FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub
                                      FROM  groupex.asso AS a
                                 LEFT JOIN  groupex.dom  AS d ON d.id = a.dom
                                     WHERE  diminutif = {?}', $gp);