xnetgrp: Allow disabling batch emails for a group.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Tue, 23 Apr 2013 23:06:30 +0000 (01:06 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Tue, 23 Apr 2013 23:06:37 +0000 (01:06 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
ChangeLog
classes/xnetpage.php
modules/xnetgrp.php
templates/xnetgrp/edit.tpl
upgrade/1.1.8/02_add_group_disable_global_mails.sql [new file with mode: 0644]

index a85d118..618b49d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ VERSION 1.1.8                                                         XX XX XXXX
 
     * XnetGrp:
         - Add footer linking to the group for group-related emails         -XEL
+        - Allow disabling the "send mails" on a per-group basis            -XEL
 
 ================================================================================
 VERSION 1.1.7                                                         18 02 2013
index 24a889c..c124057 100644 (file)
@@ -124,7 +124,9 @@ class XnetPage extends PlPage
             $sub['modifier l\'accueil'] = "$dim/edit";
             $sub['gérer les annonces'] = "$dim/admin/announces";
             if ($globals->asso('mail_domain')) {
-                $sub['envoyer un mail']     = "$dim/mail";
+                if (!$globals->asso('disable_mails')) {
+                    $sub['envoyer un mail']     = "$dim/mail";
+                }
                 $sub['créer une liste']     = "$dim/lists/create";
                 $sub['créer un alias']      = "$dim/alias/create";
             }
index af9c68d..2774de5 100644 (file)
@@ -245,6 +245,7 @@ class XnetGrpModule extends PLModule
                     $page->assign('pub', Post::v('pub'));
                     $page->assign('notif_unsub', Post::i('notif_unsub'));
                     $page->assign('descr', Post::t('descr'));
+                    $page->assign('disable_mails', Post::b('disable_mails'));
                     $page->assign('error', $error);
                     return;
                 }
@@ -261,7 +262,7 @@ class XnetGrpModule extends PLModule
                              descr={?}, site={?}, mail={?}, resp={?},
                              forum={?}, mail_domain={?}, ax={?}, axDate = {?}, pub={?},
                              sub_url={?}, inscriptible={?}, unsub_url={?},
-                             flags = {?}, welcome_msg = {?}
+                             flags = {?}, welcome_msg = {?}, disable_mails = {?}
                       WHERE  id={?}",
                       Post::v('nom'), Post::v('diminutif'),
                       Post::v('cat'), (Post::i('dom') == 0) ? null : Post::i('dom'),
@@ -271,6 +272,7 @@ class XnetGrpModule extends PLModule
                       Post::has('ax'), $axDate, Post::v('pub'),
                       Post::v('sub_url'), Post::v('inscriptible'),
                       Post::v('unsub_url'), $flags, Post::t('welcome_msg'),
+                      Post::b('disable_mails'),
                       $globals->asso('id'));
                 if (Post::v('mail_domain')) {
                     XDB::execute('INSERT IGNORE INTO  email_virtual_domains (name)
@@ -347,11 +349,15 @@ class XnetGrpModule extends PLModule
         $page->assign('pub', $globals->asso('pub'));
         $page->assign('notif_unsub', $globals->asso('notif_unsub'));
         $page->assign('notify_all', $globals->asso('notify_all'));
+        $page->assign('disable_mails', $globals->asso('disable_mails'));
     }
 
     function handler_mail($page)
     {
         global $globals;
+        if ($globals->asso('disable_mails')) {
+            return PL_FORBIDDEN;
+        }
 
         $page->changeTpl('xnetgrp/mail.tpl');
         $mmlist = new MMList(S::user(), $globals->asso('mail_domain'));
index b037346..fdf0eef 100644 (file)
         <small>(ex: 01/01/1970)</small>
       </td>
     </tr>
+    <tr>
+      <td class="titre center" colspan="2">
+        <label><input type="checkbox" value="1" name="disable_mails" {if $disable_mails}checked="checked"{/if} />
+        désactiver l'envoi de mails</label>
+      </td>
+    </tr>
   </table>
   <p></p>
   {/if}
diff --git a/upgrade/1.1.8/02_add_group_disable_global_mails.sql b/upgrade/1.1.8/02_add_group_disable_global_mails.sql
new file mode 100644 (file)
index 0000000..f56be94
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE groups ADD COLUMN disable_mails int(1) NOT NULL DEFAULT 0;
+
+-- vim:set syntax=mysql: