Group base URL does not anymore need the trailing slash.
[platal.git] / include / xnet / page.inc.php
index 4c30410..d716ee3 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,72 +67,91 @@ class XnetPage extends PlatalPage
         $menu = array();
 
         $sub = array();
-        $sub['accueil']           = '';
         $sub['liste des groupes'] = 'plan';
-        if (logged()) {
-            if (has_perms()) {
-                $sub['admin X.net'] = 'admin';
-            }
-            $sub['déconnexion']   = 'exit';
-        }
-        $menu["Menu Principal"]   = $sub;
-
-        if (logged() && (is_member() || may_update())) {
+        $sub['documentation']     = 'Xnet';
+        $sub['Signaler un bug']   = array('link' => 'send_bug', 'onclick' => 'send_bug();return false'); 
+        $menu["no_title"]   = $sub;
+        
+        if (S::logged() && $globals->asso()) {
             $sub = array();
             $dim = $globals->asso('diminutif');
-            $sub['présentation'] = "$dim/";
-            if (may_update() || $globals->asso('pub') == 'public') {
+            $sub['présentation'] = "login/$dim/";
+            if (may_update() || (is_member()  && $globals->asso('pub') == 'public')) {
                 $sub['annuaire du groupe'] = "$dim/annuaire";
-                if ($globals->xnet->geoloc)
-                    $sub['carte'] = "$dim/geoloc.php";
+                $sub['trombinoscope'] = "$dim/trombi";
+                $sub['carte'] = "$dim/geoloc";
             }
-            if ($globals->asso('mail_domain')) {
+            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/paiement";
             }
-            $sub['télépaiement'] = "$dim/paiement";
 
             $menu[$globals->asso('nom')] = $sub;
         }
 
-        if (logged() && may_update()) {
+        if (S::logged() && may_update()) {
             $sub = array();
             $sub['modifier l\'accueil'] = "$dim/edit";
-            if ($globals->wiki->wikidir && $globals->xnet->wiki)
-                $sub['wiki'] = "$dim/Accueil";
+            $sub['gérer les annonces'] = "$dim/admin/announces";
             if ($globals->asso('mail_domain')) {
                 $sub['envoyer un mail']     = "$dim/mail";
                 $sub['créer une liste']     = "$dim/lists/create";
                 $sub['créer un alias']      = "$dim/alias/create";
             }
-            $menu['Administrer Groupe'] = $sub;
+            if (S::has_perms()) {
+                $sub['gérer les groupes'] = 'admin';
+            }
+            $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($force = false)
-    {
-        $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() && $force) {
-            $_SESSION['session']->doLogin($this);
-        }
-        if (!logged() && Get::has('auth')) {
-            $_SESSION['session']->doAuthX($this);
-        }
+// {{{  function list_all_my_groups
+
+function list_all_my_groups($params)
+{
+    if (!S::logged()) {
+        return;
+    }
+    $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='$mini/'>$nom</a></span>";
     }
+    return $html;
+}
 
-    // }}}
+// }}}
+// {{{ cat_pp
+
+function cat_pp($cat)
+{
+    $trans = array(
+        'groupesx' => 'Groupes X' ,
+        'binets'   => 'Binets' ,
+        'institutions' => 'Institutions' ,
+        'promotions' => 'Promotions'
+    );
+
+    return $trans[strtolower($cat)];
 }
 
 // }}}
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>