pending commit, finished during MQ/S download ...
[platal.git] / include / xnet.inc.php
index e41b5f8..aea2c12 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -28,30 +28,46 @@ XnetSession::init();
 
 // {{{ function new_skinned_page()
 
-function new_page($tpl_name, $min_auth)
+function new_page($tpl_name, $type = SKINNED)
 {
-    global $page,$globals;
+    global $page, $globals;
     require_once("xnet/page.inc.php");
-    switch($min_auth) {
-        case AUTH_PUBLIC:
-            $page = new XnetPage($tpl_name, $type);
-            break;
-
-        default:
-            $page = new XnetAuth($tpl_name, $type);
-    }
+    $page = new XnetPage($tpl_name, $type);
     $page->assign('xorg_tpl', $tpl_name);
 }
 
+function new_skinned_page($tpl_name)
+{
+    return new_page($tpl_name);
+}
+
 // }}}
+
+function new_identification_page()
+{
+    global $page;
+
+    new_page('');
+    $page->doAuth(true);
+    $page->useMenu();
+}
+
 // {{{ function new_group_page()
 
 function new_group_page($tpl_name)
 {
-    global $page,$globals;
-    require_once("xnet/page.inc.php");
-    $page = new XnetGroupPage($tpl_name);
-    $page->assign('xorg_tpl', $tpl_name);
+    global $page, $globals;
+
+    new_page($tpl_name);
+
+    $page->doAuth(true);
+    if (!is_member() && !S::has_perms()) {
+        $page->kill("You have not sufficient credentials");
+    }
+
+    $page->useMenu();
+    $page->assign('asso', $globals->asso());
+    $page->setType($globals->asso('cat'));
 }
 
 // }}}
@@ -59,10 +75,17 @@ function new_group_page($tpl_name)
 
 function new_groupadmin_page($tpl_name)
 {
-    global $page,$globals;
-    require_once("xnet/page.inc.php");
-    $page = new XnetGroupAdmin($tpl_name);
-    $page->assign('xorg_tpl', $tpl_name);
+    global $page, $globals;
+
+    new_page($tpl_name);
+
+    if (!may_update()) {
+        $page->kill("You have not sufficient credentials");
+    }
+
+    $page->useMenu();
+    $page->assign('asso', $globals->asso());
+    $page->setType($globals->asso('cat'));
 }
 
 // }}}
@@ -70,10 +93,17 @@ function new_groupadmin_page($tpl_name)
 
 function new_admin_page($tpl_name)
 {
-    global $page,$globals;
-    require_once("xnet/page.inc.php");
-    $page = new XnetAdmin($tpl_name);
-    $page->assign('xorg_tpl', $tpl_name);
+    global $page, $globals;
+
+    new_page($tpl_name);
+
+    check_perms();
+
+    $page->useMenu();
+    if ($globals->asso('cat')) {
+        $page->assign('asso', $globals->asso());
+        $page->setType($globals->asso('cat'));
+    }
 }
 
 // }}}
@@ -82,9 +112,17 @@ function new_admin_page($tpl_name)
 function new_nonhtml_page($tpl_name)
 {
     global $page, $globals;
-    require_once("xnet/page.inc.php");
-    $page = new XnetGroupPage($tpl_name, NO_SKIN);
-    $page->assign('xorg_tpl', $tpl_name);
+
+    new_page($tpl_name, NO_SKIN);
+
+    $page->doAuth(true);
+    if (!is_member() && !S::has_perms()) {
+        $page->kill("You have not sufficient credentials");
+    }
+
+    $page->useMenu();
+    $page->assign('asso', $globals->asso());
+    $page->setType($globals->asso('cat'));
 }
 
 // }}}