Forbids empty names and diminutives for groups.
[platal.git] / modules / xnetgrp.php
index 570f97b..aacc262 100644 (file)
@@ -164,10 +164,20 @@ class XnetGrpModule extends PLModule
                 $site = "";
             }
             if (S::has_perms()) {
+                $dom = XDB::iterator('SELECT  *
+                                        FROM  group_dom
+                                    ORDER BY  nom');
+                $page->assign('dom', $dom);
+                $page->assign('super', true);
+
                 if (Post::v('mail_domain') && (strstr(Post::v('mail_domain'), '.') === false)) {
                     $page->trigError('Le domaine doit être un FQDN (aucune modification effectuée) !!!');
                     return;
                 }
+                if (Post::t('nom') == '' || Post::t('diminutif') == '') {
+                    $page->trigError('Ni le nom ni le diminutif du groupe ne peuvent être vide.');
+                    return;
+                }
                 XDB::execute(
                     "UPDATE  groups
                         SET  nom={?}, diminutif={?}, cat={?}, dom={?},
@@ -218,12 +228,6 @@ class XnetGrpModule extends PLModule
 
             pl_redirect('../'.Post::v('diminutif', $globals->asso('diminutif')).'/edit');
         }
-
-        if (S::admin()) {
-            $dom = XDB::iterator('SELECT * FROM group_dom ORDER BY nom');
-            $page->assign('dom', $dom);
-            $page->assign('super', true);
-        }
     }
 
     function handler_mail(&$page)
@@ -282,21 +286,20 @@ class XnetGrpModule extends PLModule
     {
         global $globals;
 
-        if ($action == 'search') {
-            http_redirect("https://www.polytechnique.org/search/adv?rechercher=Chercher&groupex={$globals->asso('id')}"
-                        . "&cityid=" . Env::v('cityid') . "&mapid=" . Env::v('mapid'));
-        } else if ($action == 'geoloc' || $action == 'trombi') {
-            $view = new UserSet();
+        if ($action == 'trombi') {
+            __autoload('userset');
+            if ($action == 'trombi') {
+                $view = new ProfileSet(new UFC_Group($globals->asso('id')));
+            } else {
+                $view = new UserSet(new UFC_Group($globals->asso('id')));
+            }
             $view->addMod('trombi', 'Trombinoscope');
-            // TODO: Reactivate when the new map is completed.
-            // $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'annuaire/search'));
             $view->apply('annuaire', $page, $action, $subaction);
-            if ($action == 'geoloc' && $subaction) {
-                return;
-            }
+            $page->changeTpl('xnetgrp/annuaire.tpl');
+            return;
         }
-        $page->changeTpl('xnetgrp/annuaire.tpl');
 
+        $page->changeTpl('xnetgrp/annuaire.tpl');
         $sort = Env::s('order', 'directory_name');
         $ofs  = Env::i('offset');
         if ($ofs < 0) {
@@ -704,8 +707,9 @@ class XnetGrpModule extends PLModule
 
         if ($globals->asso('notif_unsub')) {
             $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl');
-            foreach ($globals->asso()->getMembersFilter()->getUsers() as $user) {
-                $mailer->addTo($user);
+            $admins = $globals->asso()->iterAdmins();
+            while ($admin = $admins->next()) {
+                $mailer->addTo($admin);
             }
             $mailer->assign('group', $globals->asso('nom'));
             $mailer->assign('user', $user);
@@ -801,16 +805,15 @@ class XnetGrpModule extends PLModule
                             WHERE  a.alias = {?}",
                           $login);
         if ($res->numRows() == 0) {
-            // TODO: replace this call to a removed function.
-            $x = get_not_registered_user($login);
-            if (!$x) {
-                $page->trigError("Le login $login ne correspond à aucun X.");
+            $accounts = User::getPendingAccounts($login);
+            if (!$accounts) {
+                $page->trigError("L'identifiant $login ne correspond à aucun X.");
                 return false;
-            } else if (count($x) > 1) {
-                $page->trigError("Le login $login correspond a plusieurs camarades.");
+            } else if (count($accounts) > 1) {
+                $page->trigError("L'identifiant $login correspond à plusieurs camarades.");
                 return false;
             }
-            $uid = $x[0]['uid'];
+            $uid = $accounts[0]['uid'];
             $sub = false;
         } else {
             list($uid, $login) = $res->fetchOneRow();