Fix session bootstrap
[platal.git] / modules / xnetgrp.php
index 3c2f74b..e0da41d 100644 (file)
@@ -76,8 +76,10 @@ class XnetGrpModule extends PLModule
             '%grp'                => $this->make_hook('index',     AUTH_PUBLIC),
             '%grp/asso.php'       => $this->make_hook('index',     AUTH_PUBLIC),
             '%grp/logo'           => $this->make_hook('logo',      AUTH_PUBLIC),
+            '%grp/site'           => $this->make_hook('site',      AUTH_PUBLIC),
             '%grp/edit'           => $this->make_hook('edit',      AUTH_MDP),
             '%grp/mail'           => $this->make_hook('mail',      AUTH_MDP),
+            '%grp/forum'          => $this->make_hook('forum',     AUTH_MDP),
             '%grp/annuaire'       => $this->make_hook('annuaire',  AUTH_MDP),
             '%grp/annuaire/vcard' => $this->make_hook('vcard',     AUTH_MDP),
             '%grp/trombi'         => $this->make_hook('trombi',    AUTH_MDP),
@@ -94,7 +96,7 @@ class XnetGrpModule extends PLModule
             '%grp/member/new'
                  => $this->make_hook('admin_member_new', AUTH_MDP),
             '%grp/member/new/ajax'
-                 => $this->make_hook('admin_member_new_ajax', AUTH_MDP, '', NO_AUTH),         
+                 => $this->make_hook('admin_member_new_ajax', AUTH_MDP, 'user', NO_AUTH),         
             '%grp/member/del'
                  => $this->make_hook('admin_member_del', AUTH_MDP),
 
@@ -204,6 +206,18 @@ class XnetGrpModule extends PLModule
         exit;
     }
 
+    function handler_site(&$page)
+    {
+        global $globals;
+        $site = $globals->asso('site');
+        if (!$site) {
+            $page->trig('Le groupe n\'a pas de site web');
+            return $this->handler_index($page);
+        }
+        header("Location: $site");
+        exit;
+    }
+
     function handler_edit(&$page)
     {
         global $globals;
@@ -294,6 +308,19 @@ class XnetGrpModule extends PLModule
         }
     }
 
+    function handler_forum(&$page, $group = null, $artid = null)
+    {
+        global $globals;
+        new_group_page('xnetgrp/forum.tpl');
+        if (!$globals->asso('forum')) {
+            return PL_NOT_FOUND;
+        }
+        require_once 'banana/forum.inc.php';
+        $get = array();
+        get_banana_params($get, $globals->asso('forum'), $group, $artid);
+        run_banana($page, 'ForumsBanana', $get);
+    }
+
     function handler_annuaire(&$page)
     {
         global $globals;
@@ -314,8 +341,8 @@ class XnetGrpModule extends PLModule
                                     IF(m.origine="X", IF(u.nom_usage<>"", u.nom_usage, u.nom),m.nom),
                                      1, 1)) as letter, COUNT(*)
                            FROM  groupex.membres AS m
-                      LEFT JOIN  auth_user_md5   AS u ON ( u.user_id = m.uid )
-                          WHERE  asso_id = {?}
+                      LEFT JOIN  auth_user_md5   AS u ON ( u.user_id = m.uid)
+                          WHERE  asso_id = {?} and u.perms != \'pending\'
                        GROUP BY  letter
                        ORDER BY  letter', $globals->asso('id'));
         } else {
@@ -602,7 +629,7 @@ class XnetGrpModule extends PLModule
     {
         global $globals;
 
-        require_once 'xnet/mail.inc.php';
+        require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php';
 
         new_groupadmin_page('xnetgrp/annuaire-admin.tpl');
         $mmlist = new MMList(S::v('uid'), S::v('password'),
@@ -656,11 +683,14 @@ class XnetGrpModule extends PLModule
             return;
         }
 
-        list(,$fqdn) = explode('@', $email);
-        $fqdn = strtolower($fqdn);
-        $x = ($fqdn == 'polytechnique.org' || $fqdn == 'melix.org' ||
-              $fqdn == 'm4x.org' || $fqdn == 'melix.net');
-
+        if (strpos($email, '@') === false) {
+            $x = true;
+        } else {
+            list(,$fqdn) = explode('@', $email, 2);
+            $fqdn = strtolower($fqdn);
+            $x = ($fqdn == 'polytechnique.org' || $fqdn == 'melix.org' ||
+                  $fqdn == 'm4x.org' || $fqdn == 'melix.net');
+        }
         if ($x) {
             require_once 'user.func.inc.php';
             if ($forlife = get_user_forlife($email)) {
@@ -675,6 +705,7 @@ class XnetGrpModule extends PLModule
                 $page->trig($email." n'est pas un alias polytechnique.org valide");
             }
         } else {
+            require_once 'xorg.misc.inc.php';
             if (isvalid_email($email)) {
                 if (Env::v('x') && Env::has('userid') && Env::i('userid')) {
                     $uid = Env::i('userid');