Notifies group admins and event creator when someone subscribes to it.
authorStéphane Jacob <sj@m4x.org>
Mon, 3 Jan 2011 18:05:19 +0000 (19:05 +0100)
committerStéphane Jacob <sj@m4x.org>
Mon, 3 Jan 2011 18:05:19 +0000 (19:05 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
configs/mails.conf
modules/xnetevents.php
templates/xnetevents/subscription-notif.mail.tpl [new file with mode: 0644]

index 059b0d9..6afd15b 100644 (file)
@@ -71,3 +71,6 @@ replyto=registration+watch@staff.m4x.org
 from="Polytechnique.org" <validation_modification@polytechnique.org>
 cc="Polytechnique.org" <validation_modification@polytechnique.org>
 
+[xnet_notification]
+from="Polytechnique.org" <contact@polytechnique.org>
+
index bae5758..6bc99b1 100644 (file)
@@ -267,6 +267,19 @@ class XnetEventsModule extends PLModule
         if ($updated !== false) {
             $page->trigSuccess('Ton inscription à l\'événement a été mise à jour avec succès.');
             subscribe_lists_event(S::i('uid'), $evt, ($total > 0 ? 1 : 0), 0);
+
+            $mailer = new PlMailer('xnetevents/subscription-notif.mail.tpl');
+            $admins = $globals->asso()->iterAdmins();
+            while ($admin = $admins->next()) {
+                $mailer->addTo($admin);
+            }
+            $mailer->addTo($evt['organizer']);
+            $mailer->assign('group', $globals->asso('nom'));
+            $mailer->assign('event', $evt['intitule']);
+            $mailer->assign('subs', $subs);
+            $mailer->assign('moments', $evt['moments']);
+            $mailer->assign('name', S::user()->fullName('promo'));
+            $mailer->send();
         }
         $page->assign('event', get_event_detail($eid));
     }
diff --git a/templates/xnetevents/subscription-notif.mail.tpl b/templates/xnetevents/subscription-notif.mail.tpl
new file mode 100644 (file)
index 0000000..4b09166
--- /dev/null
@@ -0,0 +1,38 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  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_notification"}
+{if $mail_part eq 'head'}
+{from full=#from#}
+{subject text="[`$group`] $event"}
+{elseif $mail_part eq 'wiki'}
+Chers organisateurs,
+
+{$name} a mis a jour son inscription à cet événement. En voici le détail :
+{foreach from=$subs item=count key=i}
+{assign var=j value=$i-1}
+* {$moments.$j.titre} : {$count} personne{if $count > 1}s{/if}
+{/foreach}
+
+{include file="include/signature.mail.tpl"}
+{/if}
+{* vim:set et sw=2 sts=2 sws=2: *}