Move some templates in the core.
[platal.git] / classes / platal.php
index 858ab98..a8b5459 100644 (file)
@@ -50,7 +50,7 @@ abstract class Platal
         }
 
         $modules    = func_get_args();
-        if (is_array($modules[0])) {
+        if (isset($modules[0]) && is_array($modules[0])) {
             $modules = $modules[0];
         }
         $this->path = trim(Get::_get('n', null), '/');
@@ -273,7 +273,7 @@ abstract class Platal
         $val = call_user_func_array($hook['hook'], $args);
         if ($val == PL_DO_AUTH) {
             // The handler need a better auth with the current args
-            if (!$session->start($hook['auth'])) {
+            if (!$session->start($session->loggedLevel())) {
                 $this->force_login($page);
             }
             $val = call_user_func_array($hook['hook'], $args);
@@ -326,13 +326,21 @@ abstract class Platal
         $page->run();
     }
 
-    public function on_subscribe($forlife, $uid, $promo, $pass)
+    public static function load($modname, $include = null)
     {
-        $args = func_get_args();
-        foreach ($this->__mods as $mod) {
-            if (!is_callable($mod, 'on_subscribe'))
-                continue;
-            call_user_func_array(array($mod, 'on_subscribe'), $args);
+        global $platal;
+        $modname = strtolower($modname);
+        if (isset($platal->__mods[$modname])) {
+            if (is_null($include)) {
+                return;
+            }
+            $platal->__mods[$modname]->load($include);
+        } else {
+            if (is_null($include)) {
+                require_once PLModule::path($modname) . '.php';
+            } else {
+                require_once PLModule::path($modname) . '/' . $include;
+            }
         }
     }