New member class for immaterial entities on Xnet
[platal.git] / include / xnet / page.inc.php
index 261da94..ce6d324 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('platal/page.inc.php');
-require_once('xnet/smarty.plugins.inc.php');
-
-// {{{ class XnetPage
-
 class XnetPage extends PlatalPage
 {
+    var $nomenu = false;
+
     // {{{ function XnetPage()
 
     function XnetPage($tpl, $type=SKINNED)
     {
         $this->PlatalPage($tpl, $type);
+
+        $this->register_function('list_all_my_groups', 'list_all_my_groups');
+        $this->register_modifier('cat_pp', 'cat_pp');
+        $this->assign('it_is_xnet', true);
+
+        if (!S::logged() && Get::has('auth')) {
+            XnetSession::doAuthX();
+        }
     }
 
     // }}}
@@ -38,6 +43,9 @@ class XnetPage extends PlatalPage
 
     function run()
     {
+        if (!$this->nomenu) {
+            $this->useMenu();
+        }
         $this->_run('xnet/skin.tpl');
     }
 
@@ -59,174 +67,92 @@ class XnetPage extends PlatalPage
         $menu = array();
 
         $sub = array();
-        $sub['accueil']           = 'index.php';
-        $sub['liste des groupes'] = 'plan.php';
-        if (logged()) {
-            if (has_perms()) {
-                $sub['admin X.net'] = 'admin.php';
-            }
-            $sub['déconnexion']   = 'deconnexion.php';
-        }
-        $menu["Menu Principal"]   = $sub;
-
-        if (logged() && (is_member() || may_update())) {
+        $sub['liste des groupes'] = 'plan';
+        $sub['documentation']     = 'Xnet';
+        $sub['signaler un bug']   = array('href' => 'send_bug', 'class' => 'popup_840x600'); 
+        $menu["no_title"]   = $sub;
+        
+        if (S::logged() && $globals->asso()) {
             $sub = array();
             $dim = $globals->asso('diminutif');
-            $sub['présentation'] = "$dim/asso.php";
-            if (may_update() || $globals->asso('pub') == 'public') {
-                $sub['annuaire du groupe'] = "$dim/annuaire.php";
-                if ($globals->xnet->geoloc)
-                    $sub['carte'] = "$dim/geoloc.php";
+            $sub['présentation'] = "login/$dim/";
+            if (may_update() || (is_member()  && $globals->asso('pub') == 'public')
+                || $globals->asso('cat') == 'Promotions') {
+                $sub['annuaire du groupe'] = "$dim/annuaire";
+                $sub['trombinoscope'] = "$dim/trombi";
+                $sub['carte'] = "$dim/geoloc";
             }
-            if ($globals->asso('mail_domain')) {
-                $sub['listes de diffusion'] = "$dim/listes.php";
+            if ((is_member() || may_update()) && $globals->asso('mail_domain')) {
+                $sub['listes de diffusion'] = "$dim/lists";
             }
-            $sub['événement'] = "$dim/evenements.php";
-            if (false) {
-                $sub['carnet'] = "$dim/carnet.php";
+            $sub['événement'] = "$dim/events";
+            if (may_update() || is_member()) {
+                $sub['télépaiement'] = "$dim/payment";
             }
-            $sub['télépaiement'] = "$dim/telepaiement.php";
 
             $menu[$globals->asso('nom')] = $sub;
         }
 
-        if (logged() && may_update()) {
+        if (S::logged() && may_update()) {
             $sub = array();
-            $sub['modifier l\'accueil'] = "$dim/edit.php";
-            if ($globals->wiki->wikidir && $globals->xnet->wiki)
-                $sub['wiki'] = "$dim/Accueil";
+            $sub['modifier l\'accueil'] = "$dim/edit";
+            $sub['gérer les annonces'] = "$dim/admin/announces";
             if ($globals->asso('mail_domain')) {
-                $sub['envoyer un mail']     = "$dim/mail.php";
-                $sub['créer une liste']     = "$dim/listes-create.php";
-                $sub['créer un alias']      = "$dim/alias-create.php";
+                $sub['envoyer un mail']     = "$dim/mail";
+                $sub['créer une liste']     = "$dim/lists/create";
+                $sub['créer un alias']      = "$dim/alias/create";
+            }
+            if (S::has_perms()) {
+                $sub['gérer les groupes'] = 'admin';
             }
-            $menu['Administrer Groupe'] = $sub;
+            $menu['Administrer'] = $sub;
+        } elseif (S::has_perms()) {
+            $sub = array();
+            $sub['gérer les groupes'] = 'admin';
+            $menu['Administrer'] = $sub;
         }
 
         $this->assign('menu', $menu);
     }
 
     // }}}
-    // {{{ function doAuth()
-
-    function doAuth()
-    {
-        $this->register_function('list_all_my_groups', 'list_all_my_groups');
-        $this->register_modifier('cat_pp', 'cat_pp');
-        $this->assign('it_is_xnet', true);
-        if (!logged() && Get::has('auth')) {
-            $_SESSION['session']->doAuthX($this);
-        }
-    }
-
-    // }}}
 }
 
-// }}}
-// {{{ class XnetAuth
+// {{{  function list_all_my_groups
 
-/** Une classe pour les pages nécessitant l'authentification.
- * (equivalent de controlauthentification.inc.php)
- */
-class XnetAuth extends XnetPage
+function list_all_my_groups($params)
 {
-    // {{{ function XnetAuth()
-
-    function XnetAuth($tpl, $type=SKINNED)
-    {
-        $this->XnetPage($tpl, $type);
-    }
-
-    // }}}
-    // {{{ function doAuth()
-
-    function doAuth()
-    {
-        parent::doAuth();
-        $_SESSION['session']->doAuth($this);
+    if (!S::logged()) {
+        return;
     }
-    
-    // }}}
-}
-
-// }}}
-// {{{ class XnetAdmin
-
-/** Une classe pour les pages réservées aux admins (authentifiés!).
- */
-class XnetAdmin extends XnetAuth
-{
-    // {{{ function XnetAdmin()
-    
-    function XnetAdmin($tpl, $type=SKINNED)
-    {
-        global $globals;
-        
-        $this->XnetAuth($tpl, $type);
-        check_perms();
-
-        $this->useMenu();
-        if ($globals->asso('cat')) {
-            $this->assign('asso', $globals->asso());
-            $this->setType($globals->asso('cat'));
-        }
+    $res = XDB::iterRow(
+            "SELECT  a.nom, a.diminutif
+               FROM  groupex.asso    AS a
+         INNER JOIN  groupex.membres AS m ON m.asso_id = a.id
+              WHERE  m.uid={?}", S::v('uid'));
+    $html = '<div>Mes groupes (<a href="exit">déconnexion</a>) :</div>';
+    while (list($nom, $mini) = $res->next()) {
+        $html .= "<span class='gp'>&bull; <a href='login/$mini'>$nom</a></span>";
     }
-    
-    // }}}
+    return $html;
 }
 
 // }}}
-// {{{ class XnetGroupPage
+// {{{ cat_pp
 
-/** Une classe pour les pages réservées aux admins (authentifiés!).
- */
-class XnetGroupPage extends XnetAuth
+function cat_pp($cat)
 {
-    // {{{ function XnetAdmin()
-    
-    function XnetGroupPage($tpl, $type=SKINNED)
-    {
-        global $globals;
-
-        $this->XnetAuth($tpl, $type);
-        if (!is_member() && !has_perms()) {
-            $this->kill("You have not sufficient credentials");
-        }
-
-        $this->useMenu();
-        $this->assign('asso', $globals->asso());
-        $this->setType($globals->asso('cat'));
-    }
-    
-    // }}}
+    $trans = array(
+        'groupesx' => 'Groupes X' ,
+        'binets'   => 'Binets' ,
+        'institutions' => 'Institutions' ,
+        'promotions' => 'Promotions'
+    );
+
+    return $trans[strtolower($cat)];
 }
 
 // }}}
-// {{{ class XnetGroupAdmin
-
-/** Une classe pour les pages réservées aux admins (authentifiés!).
- */
-class XnetGroupAdmin extends XnetAuth
-{
-    // {{{ function XnetAdmin()
-    
-    function XnetGroupAdmin($tpl, $type=SKINNED)
-    {
-        global $globals;
-        
-        $this->XnetAuth($tpl, $type);
-        if (!may_update()) {
-            $this->kill("You have not sufficient credentials");
-        }
-
-        $this->useMenu();
-        $this->assign('asso', $globals->asso());
-        $this->setType($globals->asso('cat'));
-    }
-    
-    // }}}
-}
 
-// }}}
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>