Fixes
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 22 Jun 2008 08:08:36 +0000 (10:08 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 22 Jun 2008 08:08:36 +0000 (10:08 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/platal.php
classes/plglobals.php
classes/plsession.php
classes/s.php
include/globals.inc.php.in
include/platal.inc.php
include/xorg.misc.inc.php
modules/platal.php

index aed33a8..1d5c466 100644 (file)
@@ -337,6 +337,18 @@ class Platal
         }
         return self::$_page;
     }
+
+    static public function &session()
+    {
+        global $session;
+        return $session;
+    }
+
+    static public function &globals()
+    {
+        global $globals;
+        return $globals;
+    }
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index d78d1e3..f614458 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  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
+ */
+define('DEBUG_BT', 1);
+define('DEBUG_VALID', 2);
+define('DEBUG_SMARTY', 4);
 
 /** PlGlobals provides functions to read a set of configuration files and gives
  * access to this configurations.
@@ -41,6 +49,21 @@ class PlGlobals
 {
     public $coreVersion = '0.9.17';
 
+    /** Debug level.
+     * This is a combination of the DEBUG_ flags. As soon as at least
+     * one flag is set, the debug mode is activated, this means:
+     *   - debug panel on the top of the pages
+     *   - don't hide php notices
+     *   - recompile templates when they have been changed
+     */
+    public $debug   = 0;
+
+    /** Access mode.
+     */
+    public $mode    = 'rw';    // 'rw' => read/write,
+                               // 'r'  => read/only
+                               // ''   => site down
+
     /** 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
index add2bd3..73426fd 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+/** Authentication level.
+ * Only AUTH_PUBLIC is mandatory. The others are defined as useful values,
+ * but can be overwritten by others auth levels definitions.
+ */
+define('AUTH_PUBLIC', 0);
+define('AUTH_COOKIE', 1);
+define('AUTH_MDP',    2);
+
 
 /** The PlSession is a wrapper around the user session management.
  */
index 700fdf6..626dfef 100644 (file)
@@ -72,7 +72,7 @@ class S
         }
     }
 
-    public static function logger($uid)
+    public static function logger($uid = null)
     {
         if (!S::has('log')) {
             if (S::has('suid')) {
@@ -87,8 +87,7 @@ class S
 
     public static function has_perms()
     {
-        global $session;
-        return $session->checkPerms(PERMS_ADMIN);
+        return Platal::session()->checkPerms(PERMS_ADMIN);
     }
 
     public static function logged()
@@ -98,8 +97,7 @@ class S
 
     public static function identified()
     {
-        global $session;
-        return S::v('auth', AUTH_PUBLIC) >= $session->sureLevel();
+        return S::v('auth', AUTH_PUBLIC) >= Platal::session()->sureLevel();
     }
 
     // Anti-XSRF protections.
index 23b6374..1e15c81 100644 (file)
 
 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';
@@ -41,11 +35,11 @@ class PlatalGlobals extends PlGlobals
     public $skin;
     public $register_skin;
 
-    public function __construct($sess)
+    public function __construct()
     {
         parent::__construct(array('platal.ini', 'platal.conf'));
-        $globals->bootstrap(array('NbIns'), 'update_NbIns');i
-        $globals->bootstrap(array('NbValid'), 'update_NbValid');
+        $this->bootstrap(array('NbIns'), 'update_NbIns');
+        $this->bootstrap(array('NbValid'), 'update_NbValid');
     }
 
     public function asso($key=null)
index bb33ca8..e30429d 100644 (file)
 
 $TIME_BEGIN = microtime(true);
 
-define('AUTH_PUBLIC', 0);
-define('AUTH_COOKIE', 1);
-define('AUTH_MDP',    2);
-
 define('PERMS_EXT',   'ext');
 define('PERMS_USER',  'user');
 define('PERMS_ADMIN', 'admin');
@@ -123,8 +119,8 @@ function pl_print_errors()
 }
 
 set_error_handler('pl_error_handler', E_ALL | E_STRICT);
-//register_shutdown_function('pl_print_errors');
-register_shutdown_function('pl_dump_env');
+register_shutdown_function('pl_print_errors');
+//register_shutdown_function('pl_dump_env');
 
 /** Check if the string is utf8
  */
index eefbfb2..dd3c70f 100644 (file)
@@ -354,7 +354,7 @@ function update_NbIns()
                          FROM  auth_user_md5
                         WHERE  perms IN ('admin','user') AND deces=0");
     $cnt = $res->fetchOneCell();
-    $globals->change_dynamic_config(array('NbIns' => $cnt));
+    $globals->changeDynamicConfig(array('NbIns' => $cnt));
 }
 
 function update_NbValid()
@@ -362,7 +362,7 @@ function update_NbValid()
     global $globals;
     $res = XDB::query("SELECT  COUNT(*)
                          FROM  requests");
-    $globals->change_dynamic_config(array('NbValid' => $res->fetchOneCell()));
+    $globals->changeDynamicConfig(array('NbValid' => $res->fetchOneCell()));
 }
 
 function update_NbNotifs()
index 2dd4e08..1e01daa 100644 (file)
@@ -394,7 +394,7 @@ Adresse de secours : " . Post::v('email') : ""));
                              SET skin={?} WHERE user_id={?}',
                          Env::i('newskin'), S::v('uid'));
             S::kill('skin');
-            set_skin();
+            Platal::session()->setSkin();
         }
 
         $res = XDB::query('SELECT id FROM skins WHERE skin_tpl={?}', S::v('skin'));
@@ -410,13 +410,12 @@ Adresse de secours : " . Post::v('email') : ""));
 
     function handler_exit(&$page, $level = null)
     {
-        global $session;
         if (S::has('suid')) {
             $a4l  = S::v('forlife');
             $suid = S::v('suid');
             $log  = S::v('log');
             $log->log("suid_stop", S::v('forlife') . " by " . $suid['forlife']);
-            $session->stopSUID();
+            Platal::session()->stopSUID();
             pl_redirect('admin/user/' . $a4l);
         }
 
@@ -438,7 +437,7 @@ Adresse de secours : " . Post::v('email') : ""));
             $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
             $_SESSION['log']->log('deconnexion',$ref);
         }
-        $session->destroy();
+        Platal::session()->destroy();
 
         if (Get::has('redirect')) {
             http_redirect(rawurldecode(Get::v('redirect')));