Forbids empty names and diminutives for groups.
authorStéphane Jacob <sj@m4x.org>
Tue, 1 Jun 2010 11:09:36 +0000 (13:09 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 1 Jun 2010 11:46:23 +0000 (13:46 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/xnetgrp.php
upgrade/account/06_groups.sql [new file with mode: 0644]

index 5ce2c22..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)&nbsp;!!!');
                     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)
diff --git a/upgrade/account/06_groups.sql b/upgrade/account/06_groups.sql
new file mode 100644 (file)
index 0000000..6c1d558
--- /dev/null
@@ -0,0 +1,3 @@
+DELETE FROM groups WHERE nom = '' OR diminutif = '';
+
+# vim:set syntax=mysql: