#490: Can open events to non-members
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 17 Oct 2006 13:07:59 +0000 (13:07 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 17 Oct 2006 13:07:59 +0000 (13:07 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@987 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
include/xnet.inc.php
include/xnet/page.inc.php
modules/xnetevents.php
templates/xnetevents/edit.tpl

index 424f4e5..f32d925 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,9 @@ From 0.9.11 branch:
         - #486: fix force login to see private fiche.                      -Car
         - #509: can access trombi of the current year promotion            -FRU
 
+    * Xnet/Events:
+        - #490: Events can be opened to non-members                        -FRU
+
 ================================================================================
 VERSION 0.9.11                                                 18 Septembre 2006
 
index 0d38975..34ea7dd 100644 (file)
@@ -41,9 +41,9 @@ function new_skinned_page($tpl_name)
 }
 
 // }}}
-// {{{ function new_group_page()
+// {{{ function new_group_open_page()
 
-function new_group_page($tpl_name)
+function new_group_open_page($tpl_name, $refuse_access = false)
 {
     global $page, $globals;
 
@@ -53,28 +53,25 @@ function new_group_page($tpl_name)
     $page->assign('asso', $globals->asso());
     $page->setType($globals->asso('cat'));
 
-    if (!is_member() && !S::has_perms()) {
+    if ($refuse_access) {
         $page->kill("Vous n'avez pas les droits suffisants pour accéder à cette page");
     }
 }
 
 // }}}
-// {{{ function new_groupadmin_page()
+// {{{ function new_group_page()
 
-function new_groupadmin_page($tpl_name)
+function new_group_page($tpl_name)
 {
-    global $page, $globals;
-
-    new_page($tpl_name);
-
-    $page->useMenu();
-    $page->assign('asso', $globals->asso());
-    $page->setType($globals->asso('cat'));
+    new_group_open_page($tpl_name, !is_member() && !S::has_perms());
+}
 
+// }}}
+// {{{ function new_groupadmin_page()
 
-    if (!may_update()) {
-        $page->kill("Vous n'avez pas les droits suffisants pour accéder à cette page");
-    }
+function new_groupadmin_page($tpl_name)
+{
+    new_group_open_page($tpl_name, !may_update());
 }
 
 // }}}
index a3d1e63..bb975f3 100644 (file)
@@ -72,21 +72,22 @@ class XnetPage extends PlatalPage
         $sub['liste des groupes'] = 'plan';
         $sub['documentation']     = 'Xnet';
         $menu["Menu Principal"]   = $sub;
-
-        if (S::logged() && (is_member() || may_update())) {
+        
+        if (S::logged()) {
             $sub = array();
             $dim = $globals->asso('diminutif');
             $sub['présentation'] = "$dim/";
-            if (may_update() || $globals->asso('pub') == 'public') {
+            if (may_update() || (is_member()  && $globals->asso('pub') == 'public')) {
                 $sub['annuaire du groupe'] = "$dim/annuaire";
                 $sub['carte'] = "$dim/geoloc";
             }
-            if ($globals->asso('mail_domain')) {
+            if ((is_member() || may_update()) && $globals->asso('mail_domain')) {
                 $sub['listes de diffusion'] = "$dim/lists";
-                $sub['envoyer un mail']     = "$dim/mail";
             }
             $sub['événement'] = "$dim/events";
-            $sub['télépaiement'] = "$dim/paiement";
+            if (may_update() || is_member()) {
+                $sub['télépaiement'] = "$dim/paiement";
+            }
 
             $menu[$globals->asso('nom')] = $sub;
         }
@@ -95,6 +96,7 @@ class XnetPage extends PlatalPage
             $sub = array();
             $sub['modifier l\'accueil'] = "$dim/edit";
             if ($globals->asso('mail_domain')) {
+                $sub['envoyer un mail']     = "$dim/mail";
                 $sub['créer une liste']     = "$dim/lists/create";
                 $sub['créer un alias']      = "$dim/alias/create";
             }
index 29f9b07..39147d0 100644 (file)
@@ -38,7 +38,7 @@ class XnetEventsModule extends PLModule
     {
         global $globals;
 
-        new_group_page('xnetevents/index.tpl');
+        new_group_open_page('xnetevents/index.tpl');
 
         if (Post::has('del')) {
             if (!may_update()) {
@@ -48,8 +48,8 @@ class XnetEventsModule extends PLModule
             $eid = Post::v('del');
 
             $res = XDB::query("SELECT asso_id, short_name FROM groupex.evenements
-                                        WHERE eid = {?} AND asso_id = {?}",
-                                        $eid, $globals->asso('id'));
+                                WHERE eid = {?} AND asso_id = {?}",
+                              $eid, $globals->asso('id'));
 
             $tmp = $res->fetchOneRow();
             if (!$tmp) {
@@ -97,13 +97,15 @@ class XnetEventsModule extends PLModule
             INNER JOIN  x4dat.auth_user_md5 AS u ON u.user_id = e.organisateur_uid
             INNER JOIN  x4dat.aliases       AS a ON (a.type = 'a_vie' AND a.id = u.user_id)
              LEFT JOIN  groupex.evenements_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?})
-                 WHERE  asso_id = {?}
-              GROUP BY  e.eid
+                 WHERE  asso_id = {?}"
+            . (is_member() || may_update() ? "" : " AND accept_nonmembre != 0 ")
+              . "GROUP BY  e.eid
               ORDER BY  debut", S::v('uid'), $globals->asso('id'));
 
         $evts = array();
 
         while ($e = $evenements->next()) {
+            $e['show_participants'] = ($e['show_participants'] && (is_member() || may_update()));
             $res = XDB::query(
                 "SELECT titre, details, montant, ei.item_id, nb
                    FROM groupex.evenements_items AS ei
@@ -140,7 +142,7 @@ class XnetEventsModule extends PLModule
     {
         require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
 
-        new_group_page('xnetevents/subscribe.tpl');
+        new_group_open_page('xnetevents/subscribe.tpl');
 
         $evt = get_event_detail($eid);
         if (!$evt) {
@@ -150,6 +152,9 @@ class XnetEventsModule extends PLModule
         if (!$evt['inscr_open']) {
             $page->kill('Les inscriptions pour cet événement sont closes');
         }
+        if (!$evt['accept_nonmembre'] && !is_member() && !may_update()) {
+            $page->kill('Cet événement est fermé aux non-membres du groupe');
+        }
 
         $page->assign('event', $evt);
 
@@ -278,7 +283,7 @@ class XnetEventsModule extends PLModule
             );
 
             $trivial = array('intitule', 'descriptif', 'noinvite',
-                             'show_participants');
+                             'show_participants', 'accept_nonmembre');
             foreach ($trivial as $k) {
                 $evt[$k] = Post::v($k);
             }
@@ -296,12 +301,13 @@ class XnetEventsModule extends PLModule
                 SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?},
                     paiement_id = {?}, descriptif = {?}, debut = {?},
                     fin = {?}, show_participants = {?}, short_name = {?},
-                    deadline_inscription = {?}, noinvite = {?}',
+                    deadline_inscription = {?}, noinvite = {?},
+                    accept_nonmembre = {?}',
                     $evt['eid'], $evt['asso_id'], $evt['organisateur_uid'],
                     $evt['intitule'], $evt['paiement_id'], $evt['descriptif'],
                     $evt['debut'], $evt['fin'], $evt['show_participants'],
                     $evt['short_name'], $evt['deadline_inscription'],
-                    $evt['noinvite']);
+                    $evt['noinvite'], $evt['accept_nonmembre']);
 
             // if new event, get its id
             if (!$eid) {
@@ -364,7 +370,7 @@ class XnetEventsModule extends PLModule
             $res = XDB::query(
                     "SELECT    eid, intitule, descriptif, debut, fin,
                                 show_participants, paiement_id, short_name,
-                                deadline_inscription, noinvite
+                                deadline_inscription, noinvite, accept_nonmembre
                        FROM    groupex.evenements
                       WHERE eid = {?}", $eid);
             $evt = $res->fetchOneAssoc();
index aac67db..8c10aed 100644 (file)
@@ -138,6 +138,11 @@ function deadlineChange(box)
         <input type="radio" name="show_participants" value="0" {if !$evt.show_participants}checked="checked"{/if}/> non
 
         <br />
+        Autoriser les non-membres :
+        <input type="radio" name="accept_nonmembre" value="1" {if $evt.accept_nonmembre}checked="checked"{/if} /> oui
+        <input type="radio" name="accept_nonmembre" value="0" {if !$evt.accept_nonmembre}checked="checked"{/if}/> non
+
+        <br />
         Autoriser les invités :
         <input type="radio" name="noinvite" value="0" {if !$evt.noinvite}checked="checked"{/if} /> oui
         <input type="radio" name="noinvite" value="1" {if $evt.noinvite}checked="checked"{/if}/> non