From: Stéphane Jacob Date: Sat, 7 Aug 2010 16:17:04 +0000 (+0200) Subject: Either deletes or notifies site administrators if it was the last group of a xnet... X-Git-Tag: xorg/1.1.0~26^2~36 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=91d2135cb4ad4a0237ce00b3c387e64e62c55681;p=platal.git Either deletes or notifies site administrators if it was the last group of a xnet account. Signed-off-by: Stéphane Jacob --- diff --git a/configs/mails.conf b/configs/mails.conf index 059b0d9..459d521 100644 --- a/configs/mails.conf +++ b/configs/mails.conf @@ -62,6 +62,10 @@ cc=validation+googleapps@polytechnique.org [xnet_unsubscription] from="Gestion des groupes X sur Polytechnique.net" +[xnet_unsubscription_account] +from=br@staff.polytechnique.org +to=br@staff.polytechnique.org + [registration] from="Webmaster Polytechnique.org" to=registration+watch@staff.m4x.org diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 2ec9e2c..dbb2d07 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -834,11 +834,34 @@ class XnetGrpModule extends PLModule S::assert_xsrf_token(); } + $hasSingleGroup = $user->hasSingleGroup(); + if ($this->unsubscribe($user)) { $page->trigSuccess("{$user->fullName()} a été désinscrit du groupe !"); } else { $page->trigWarning("{$user->fullName()} a été désinscrit du groupe, mais des erreurs subsistent !"); } + + // Either deletes or notifies site administrators if it was the last group + // of a xnet 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. + global $globals; + $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(); + } + } } private function changeLogin(PlPage &$page, PlUser &$user, MMList &$mmlist, $login) diff --git a/templates/xnetgrp/unsubscription.mail.tpl b/templates/xnetgrp/unsubscription.mail.tpl new file mode 100644 index 0000000..2e8e722 --- /dev/null +++ b/templates/xnetgrp/unsubscription.mail.tpl @@ -0,0 +1,33 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2010 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +{config_load file="mails.conf" section="xnet_unsubscription_account"} +{if $mail_part eq 'head'} +{from full=#from#} +{to full=#to#} +{subject text="Nouveau compte xnet sans groupe."} +{elseif $mail_part eq 'wiki'} +Bonjour, + +{$user->fullName()} (hruid : {$user->hruid}) vient d'être désinscrit du groupe {$groupName} (id : {$groupName}). Son compte a été conservé bien qu'il ne soit plus inscrit à aucun groupe. + +{* vim:set et sw=2 sts=2 sws=2: *}