config proof of concept : skins
authorx2000habouzit <x2000habouzit>
Tue, 23 Nov 2004 11:32:34 +0000 (11:32 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 23 Nov 2004 11:32:34 +0000 (11:32 +0000)
include/xorg.globals.inc.php.in
include/xorg.globals/core.inc.php [new file with mode: 0644]
include/xorg.inc.php
include/xorg/session.inc.php

index cc0d63b..be192e3 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: xorg.globals.inc.php.in,v 1.5 2004-11-23 11:10:41 x2000habouzit Exp $
+    $Id: xorg.globals.inc.php.in,v 1.6 2004-11-23 11:32:34 x2000habouzit Exp $
  ***************************************************************************/
 
 require_once("diogenes.core.globals.inc.php");
@@ -78,7 +78,7 @@ class XorgGlobals extends DiogenesCoreGlobals
                 if ($c == 'global') {
                     global $$key;
                     $$key = $val;
-                } elseif ($c == 'core') {
+                } elseif ($c == 'core' && isset($this->$key)) {
                     $this->$key=$val;
                 } else {
                     $this->$c->$key = $val;
diff --git a/include/xorg.globals/core.inc.php b/include/xorg.globals/core.inc.php
new file mode 100644 (file)
index 0000000..5714ffd
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************
+    $Id: core.inc.php,v 1.1 2004-11-23 11:32:35 x2000habouzit Exp $
+ ***************************************************************************/
+
+// {{{ class XorgGlobals
+
+class CoreConfig
+{
+    // {{{ skin
+
+    var $skin_enable  = 1;
+    var $skin_id      = 1;
+    var $skin_tpl     = 'default.tpl';
+
+    // }}}
+}
+
+// }}}
+
+$this->core = new CoreConfig;
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
index 800a9c9..648bf24 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: xorg.inc.php,v 1.3 2004-11-22 21:40:47 x2000habouzit Exp $
+    $Id: xorg.inc.php,v 1.4 2004-11-23 11:32:34 x2000habouzit Exp $
  ***************************************************************************/
 
 function microtime_float() 
@@ -39,9 +39,6 @@ define("PERMS_EXT", "ext");
 define("PERMS_USER", "user");
 define("PERMS_ADMIN", "admin");
 
-define('SKIN_COMPATIBLE','default.tpl');
-define('SKIN_COMPATIBLE_ID',1);
-
 define('SKINNED', 0);
 define('NO_SKIN', 1);
 
index d1e1e19..e966cc3 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: session.inc.php,v 1.3 2004-11-22 20:11:42 x2000habouzit Exp $
+        $Id: session.inc.php,v 1.4 2004-11-23 11:32:34 x2000habouzit Exp $
  ***************************************************************************/
 
 require_once("diogenes.core.session.inc.php");
@@ -340,21 +340,19 @@ function start_connexion ($uid, $identified)
 function set_skin()
 {
     global $globals;
-    if (logged()) {
+    if (logged() && $globals->core->skin_enable) {
        $result = $globals->db->query("SELECT  skin,skin_tpl
                                         FROM  auth_user_quick AS a
                                   INNER JOIN  skins           AS s ON a.skin=s.id
                                        WHERE  user_id='{$_SESSION['uid']}' AND skin_tpl != ''");
        if (!(list($_SESSION['skin_id'], $_SESSION['skin']) = mysql_fetch_row($result))) {
-           $_SESSION['skin'] = SKIN_COMPATIBLE;
-           $_SESSION['skin_id'] = SKIN_COMPATIBLE_ID;
+           $_SESSION['skin'] = $globals->core->skin_tpl;
+           $_SESSION['skin_id'] = $globals->core->skin_id;
        }
        mysql_free_result($result);
-    }
-
-    if (!logged()) {
-       $_SESSION['skin'] = SKIN_COMPATIBLE;
-       $_SESSION['skin_id'] = SKIN_COMPATIBLE_ID;
+    } else {
+        $_SESSION['skin'] = $globals->core->skin_tpl;
+        $_SESSION['skin_id'] = $globals->core->skin_id;
     }
   
 }