Add Platal::assert() function
[platal.git] / modules / core.php
index 63d7d9e..adbcf38 100644 (file)
@@ -31,6 +31,7 @@ class CoreModule extends PLModule
             'purge_cache'   => $this->make_hook('purge_cache',   AUTH_COOKIE, 'admin'),
             'kill_sessions' => $this->make_hook('kill_sessions', AUTH_COOKIE, 'admin'),
             'sql_errors'    => $this->make_hook('sqlerror',      AUTH_COOKIE, 'admin'),
+            'assert_errors' => $this->make_hook('asserterror',      AUTH_COOKIE, 'admin'),
 
             'wiki_help'     => $this->make_hook('wiki_help',     AUTH_PUBLIC),
             'wiki_preview'  => $this->make_hook('wiki_preview',  AUTH_COOKIE, 'user', NO_AUTH),
@@ -188,6 +189,19 @@ class CoreModule extends PLModule
             $page->trigSuccess("Erreurs MySQL effacées.");
         }
     }
+
+    function handler_asserterror(&$page) {
+        global $globals;
+        $page->coreTpl('assert_errors.tpl');
+        $file = @file_get_contents($globals->spoolroot . '/spool/tmp/assert_errors');
+        if ($file !== false) {
+            $page->assign('errors', utf8_encode($file));
+        }
+        if (Post::has('clear')) {
+            @unlink($globals->spoolroot . '/spool/tmp/assert_errors');
+            $page->trigSuccess("Erreurs d'assertion effacées.");
+        }
+    }
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: