add new members is now OK
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Thu, 28 Apr 2005 11:09:05 +0000 (11:09 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:47 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-601

htdocs.net/groupe/membres-edit.php

index 064d6bc..37c728a 100644 (file)
         return $user;
     }
 
-    if (Env::has('edit'))
+    if (Env::has('new'))
+    {
+        new_groupadmin_page('xnet/groupe/membres-add.tpl');
+        $x = (Env::get('new') == 'x');
+
+        if (Post::has('email')) {
+            if ($x) {
+                require_once 'user.func.inc.php';
+                if ($forlife = get_user_forlife(Post::get('email'))) {
+                    $globals->xdb->execute(
+                                'INSERT INTO  groupex.membres (uid,asso_id,origine)
+                                      SELECT  user_id,{?},"X"
+                                        FROM  auth_user_md5 AS u
+                                  INNER JOIN  aliases       AS a ON (u.user_id = a.id)
+                                       WHERE  a.alias={?}', $globals->asso('id'), $forlife);
+                    header('Location: ?edit='.$forlife);
+                }
+            } else {
+                $email = Post::get('email');
+                if (isvalid_email($email)) {
+                    $res = $globals->xdb->query('SELECT MAX(uid)+1 FROM groupex.membres');
+                    $uid = max(intval($res->fetchOneCell()), 50001);
+                    $globals->xdb->execute('INSERT INTO  groupex.membres (uid,asso_id,origine,email) VALUES({?},{?},"ext",{?})',
+                            $uid, $globals->asso('id'), $email);
+                    header('Location: ?edit='.$email);
+                } else {
+                    $page->trig("« <strong>$email</strong> » n'est pas une adresse mail valide");
+                }
+            }
+        }
+    }
+    elseif (Env::has('edit'))
     {
         new_groupadmin_page('xnet/groupe/membres-edit.tpl');