Complete [1086]
[platal.git] / modules / xnetgrp.php
index 66eef6d..ee3aaa7 100644 (file)
@@ -55,7 +55,7 @@ function get_infos($email)
                          CONCAT(b.alias, '@m4x.org') AS email,
                          CONCAT(b.alias, '@polytechnique.org') AS email2,
                          m.perms='admin' AS perms, m.origine,
-                         FIND_IN_SET(flags, 'femme') AS sexe
+                         FIND_IN_SET(u.flags, 'femme') AS sexe
                    FROM  auth_user_md5   AS u
              INNER JOIN  aliases         AS a ON ( u.user_id = a.id AND a.type != 'homonyme' )
              INNER JOIN  aliases         AS b ON ( u.user_id = b.id AND b.type = 'a_vie' )
@@ -296,8 +296,6 @@ class XnetGrpModule extends PLModule
     {
         global $globals;
 
-        define('NB_PER_PAGE', 25);
-
         if ($globals->asso('pub') == 'public') {
             new_group_page('xnet/groupe/annuaire.tpl');
         } else {
@@ -346,6 +344,7 @@ class XnetGrpModule extends PLModule
         }
         $page->assign('group', $group);
         $page->assign('request_group', Env::v($group));
+        $page->assign('only_admin', Env::has('admin'));
         $page->assign('alphabet', $alphabet);
         $page->assign('nb_tot',   $nb_tot);
 
@@ -374,6 +373,8 @@ class XnetGrpModule extends PLModule
         } elseif (Env::has('promo')) {
             $ini = 'AND IF(m.origine="X", u.promo, "extérieur") = "'
                  .addslashes(Env::v('promo')).'"';
+        } elseif (Env::has('admin')) {
+            $ini = 'AND m.perms = "admin"';
         }
 
         $ann = XDB::iterator(
@@ -394,7 +395,6 @@ class XnetGrpModule extends PLModule
                            AND (m.origine = 'ext' OR u.perms != 'pending' OR m.email IS NOT NULL)
                  ORDER BY  $tri
                     LIMIT  {?},{?}", $globals->asso('id'), $ofs*NB_PER_PAGE, NB_PER_PAGE);
-
         $page->assign('ann', $ann);
     }
 
@@ -730,6 +730,7 @@ class XnetGrpModule extends PLModule
 
     function handler_admin_member_new_ajax(&$page)
     {
+        header('Content-Type: text/html; charset="iso-8859-15"');
         $page->changeTpl('xnet/groupe/membres-new-search.tpl', NO_SKIN);
         list($nom, $prenom) = str_replace(array('-', ' ', "'"), '%', array(Env::v('nom'), Env::v('prenom')));
         $where = "perms = 'pending'";
@@ -739,8 +740,10 @@ class XnetGrpModule extends PLModule
         if (!empty($prenom)) {
             $where .= " AND prenom LIKE '%$prenom%'";
         }
-        if (is_numeric(Env::v('promo'))) {
+        if (preg_match('/^[0-9]{4}$/', Env::v('promo'))) {
             $where .= " AND promo = " . Env::i('promo');
+        } elseif (Env::has('promo')) {
+            return;
         }
         $res = XDB::iterator("SELECT user_id, nom, prenom, promo
                                 FROM auth_user_md5