Disable xnet accounts when they have no group left.
authorStéphane Jacob <sj@m4x.org>
Sat, 19 Mar 2011 17:53:09 +0000 (18:53 +0100)
committerStéphane Jacob <sj@m4x.org>
Sun, 20 Mar 2011 23:06:46 +0000 (00:06 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/xnetgrp.php
templates/xnetgrp/membres-del.tpl

index 6a610a4..9126b90 100644 (file)
@@ -888,11 +888,10 @@ class XnetGrpModule extends PLModule
         } else {
             $page->trigWarning('Tu as été désinscrit du groupe, mais des erreurs se sont produites lors des désinscriptions des alias et des listes de diffusion.');
         }
-        if ($user->type == 'xnet' && $hasSingleGroup && Post::has('accountDeletion')) {
-            XDB::execute('DELETE FROM  acounts
-                                WHERE  uid = {?}',
-                         $user->id());
-            $page->trigSuccess('Ton compte a bien été supprimé.');
+
+        // If user is of type xnet account and this was her last group, disable the account.
+        if ($user->type == 'xnet' && $hasSingleGroup) {
+            $user->clear(true);
         }
         $page->assign('is_member', is_member(true));
     }
@@ -928,24 +927,9 @@ class XnetGrpModule extends PLModule
             $page->trigWarning("{$user->fullName()} a été désinscrit du groupe, mais des erreurs subsistent&nbsp;!");
         }
 
-        // Either deletes or notifies site administrators if it was the last group
-        // of a xnet account.
+        // If user is of type xnet account and this was her last group, disable the account.
         if ($user->type == 'xnet' && $hasSingleGroup) {
-            if ($user->state == 'pending') {
-                // If the user has never logged in the site, we delete her account.
-                XDB::execute('DELETE FROM  acounts
-                                    WHERE  uid = {?}',
-                             $user->id());
-            } else {
-                // It the user has already logged in the site, we notify site
-                // administrators that there is a new xnet account without any
-                // group.
-                $mailer = new PlMailer('xnetgrp/unsubscription.mail.tpl');
-                $mailer->assign('user', $user);
-                $mailer->assign('groupId', $globals->asso('id'));
-                $mailer->assign('groupName', $globals->asso('nom'));
-                $mailer->send();
-            }
+            $user->clear(true);
         }
     }
 
index b2c0df2..004a356 100644 (file)
     {if $self}
     Êtes-vous sûr de vouloir vous désinscrire du groupe {$asso->nom} et de toutes
     les listes de diffusion associées&nbsp;?
-    {if $user->type eq 'xnet' && $user->groupCount() eq 1}
-    <br />C'est le seul groupe auquel tu es actuellement inscrit sur polytechnique.net.
-    Si, malgré cela, tu souhaites garder ton accès à Polytechnique.net, décoche la case
-    ci-dessous.<br />
-    <label><input type="checkbox" name="accountDeletion" checked="checked" />Supprimer mon compte.</label>
-    {/if}
     {else}
     Êtes-vous sûr de vouloir supprimer {$user->fullName()} du groupe,
     lui retirer tous les droits associés à son statut de membre