Gives choice for event subscribtion notification: event creator, group animators...
authorStéphane Jacob <sj@m4x.org>
Mon, 3 Jan 2011 18:28:46 +0000 (19:28 +0100)
committerStéphane Jacob <sj@m4x.org>
Mon, 3 Jan 2011 18:28:46 +0000 (19:28 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/xnetevents.php
modules/xnetevents/xnetevents.inc.php
templates/xnetevents/edit.tpl
upgrade/1.1.0/05_xnetevents.sql [new file with mode: 0644]

index 6bc99b1..f0bb1c1 100644 (file)
@@ -268,18 +268,24 @@ class XnetEventsModule extends PLModule
             $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);
+            if ($evt['subscription_notification'] != 'nobody') {
+                $mailer = new PlMailer('xnetevents/subscription-notif.mail.tpl');
+                if ($evt['subscription_notification'] != 'creator') {
+                    $admins = $globals->asso()->iterAdmins();
+                    while ($admin = $admins->next()) {
+                        $mailer->addTo($admin);
+                    }
+                }
+                if ($evt['subscription_notification'] != 'animator') {
+                    $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();
             }
-            $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));
     }
@@ -403,7 +409,7 @@ class XnetEventsModule extends PLModule
                 'short_name'       => $short_name,
             );
 
-            $trivial = array('intitule', 'descriptif', 'noinvite',
+            $trivial = array('intitule', 'descriptif', 'noinvite', 'subscription_notification',
                              'show_participants', 'accept_nonmembre', 'uid');
             foreach ($trivial as $k) {
                 $evt[$k] = Post::v($k);
@@ -424,18 +430,18 @@ class XnetEventsModule extends PLModule
             XDB::execute('INSERT INTO  group_events (eid, asso_id, uid, intitule, paiement_id,
                                                      descriptif, debut, fin, show_participants,
                                                      short_name, deadline_inscription, noinvite,
-                                                     accept_nonmembre)
-                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
+                                                     accept_nonmembre, subscription_notification)
+                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
               ON DUPLICATE KEY UPDATE  asso_id = VALUES(asso_id), uid = VALUES(uid), intitule = VALUES(intitule),
                                        paiement_id = VALUES(paiement_id), descriptif = VALUES(descriptif), debut = VALUES(debut),
                                        fin = VALUES(fin), show_participants = VALUES(show_participants), short_name = VALUES(short_name),
                                        deadline_inscription = VALUES(deadline_inscription), noinvite = VALUES(noinvite),
-                                       accept_nonmembre = VALUES(accept_nonmembre)',
+                                       accept_nonmembre = VALUES(accept_nonmembre), subscription_notification = VALUES(subscription_notification)',
                          $evt['eid'], $evt['asso_id'], $evt['uid'],
                          $evt['intitule'], $evt['paiement_id'], $evt['descriptif'],
                          $evt['debut'], $evt['fin'], $evt['show_participants'],
                          $evt['short_name'], $evt['deadline_inscription'],
-                         $evt['noinvite'], $evt['accept_nonmembre']);
+                         $evt['noinvite'], $evt['accept_nonmembre'], $evt['subscription_notification']);
 
             // if new event, get its id
             if (!$eid) {
@@ -498,7 +504,7 @@ class XnetEventsModule extends PLModule
             $res = XDB::query(
                     "SELECT  eid, intitule, descriptif, debut, fin, uid,
                              show_participants, paiement_id, short_name,
-                             deadline_inscription, noinvite, accept_nonmembre
+                             deadline_inscription, noinvite, accept_nonmembre, subscription_notification
                        FROM  group_events
                       WHERE eid = {?}", $eid);
             $evt = $res->fetchOneAssoc();
index a4ba097..8e069dc 100644 (file)
@@ -34,7 +34,8 @@ function get_event_detail($eid, $item_id = false, $asso_id = null)
                                LEFT(10, e.debut) AS start_day, LEFT(10, e.fin) AS last_day,
                                LEFT(NOW(), 10) AS now,
                                ei.titre, al.vid AS absent_list, pl.vid AS participant_list,
-                               pyl.vid AS payed_list, bl.vid AS booked_unpayed_list
+                               pyl.vid AS payed_list, bl.vid AS booked_unpayed_list,
+                               e.subscription_notification
                          FROM  group_events              AS e
                    INNER JOIN  group_event_items        AS ei ON (e.eid = ei.eid)
                     LEFT JOIN  group_event_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
index 909470b..8751833 100644 (file)
@@ -123,6 +123,19 @@ function deadlineChange(box)
       </td>
     </tr>
     <tr>
+      <td class="titre">
+        Notifier lors d'une inscriptions&nbsp;:
+      </td>
+      <td>
+        <select name="subscription_notification">
+          <option value='creator' {if $evt.subscription_notification eq 'creator'}selected='selected'{/if}>le créateur de l'événement</option>
+          <option value='animator' {if $evt.subscription_notification eq 'animator'}selected='selected'{/if}>les animateurs du groupe</option>
+          <option value='both' {if $evt.subscription_notification eq 'both'}selected='selected'{/if}>le créateur de l'événement et les animateurs du groupe</option>
+          <option value='nobody' {if $evt.subscription_notification eq 'nobody'}selected='selected'{/if}>personne</option>
+        </select>
+      </td>
+    </tr>
+    <tr>
       <td class='titre'>
         Options&nbsp;:
       </td>
diff --git a/upgrade/1.1.0/05_xnetevents.sql b/upgrade/1.1.0/05_xnetevents.sql
new file mode 100644 (file)
index 0000000..d67ad18
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE group_events ADD COLUMN subscription_notification ENUM('nobody', 'creator', 'animator', 'both') NOT NULL DEFAULT 'nobody';
+
+-- vim:set syntax=mysql: