Can archive the events (useful to clean %grp/events without deleting the events)
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 22 Oct 2006 16:36:32 +0000 (16:36 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 22 Oct 2006 16:36:32 +0000 (16:36 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1006 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
modules/xnetevents.php
templates/xnetevents/index.tpl
upgrade/0.9.12/01_xnet.sql

index 9186518..a1c5ba4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,9 @@ New:
     * Xnet:
         - Add a vcard of all the members of a group                        -FRU
 
+    * Xnet/Events:
+        - Events can be archived                                           -FRU
+
 Bug/Wish:
 
     * Admin:
index 22b4586..5e3d31b 100644 (file)
@@ -34,19 +34,35 @@ class XnetEventsModule extends PLModule
         );
     }
 
-    function handler_events(&$page)
+    function handler_events(&$page, $archive = null)
     {
         global $globals;
 
-        new_group_open_page('xnetevents/index.tpl');
+        if ($archive == 'archive') {
+            $archive = true;
+            new_groupadmin_page('xnetevents/index.tpl');
+        } else {
+            $archive = false;
+            new_group_open_page('xnetevents/index.tpl');
+        }
 
+        $action = null;
         if (Post::has('del')) {
+            $action = 'del';
+            $eid = Post::v('del');
+        } elseif (Post::has('archive')) {
+            $action = 'archive';
+            $eid = Post::v('archive');
+        } elseif (Post::has('unarchive')) {
+            $action = 'unarchive';
+            $eid = Post::v('unarchive');
+        }
+
+        if (!is_null($action)) {
             if (!may_update()) {
                 return PL_NOT_ALLOWED;
             }
 
-            $eid = Post::v('del');
-
             $res = XDB::query("SELECT asso_id, short_name FROM groupex.evenements
                                 WHERE eid = {?} AND asso_id = {?}",
                               $eid, $globals->asso('id'));
@@ -55,7 +71,9 @@ class XnetEventsModule extends PLModule
             if (!$tmp) {
                 return PL_NOT_ALLOWED;
             }
+        }
 
+        if ($action == 'del') {
             // deletes the event mailing aliases
             if ($tmp[1]) {
                 XDB::execute(
@@ -85,6 +103,21 @@ class XnetEventsModule extends PLModule
                                    PayReq::same_event($eid, $globals->asso('id')));
         }
 
+        if ($action == 'archive') {
+            XDB::execute("UPDATE groupex.evenements
+                             SET archive = 1
+                           WHERE eid = {?} AND asso_id = {?}",
+                         $eid, $globals->asso('id'));
+        }
+
+        if ($action == 'unarchive') {
+            XDB::execute("UPDATE groupex.evenements
+                             SET archive = 0
+                           WHERE eid = {?} AND asso_id = {?}",
+                         $eid, $globals->asso('id'));
+        }
+
+        $page->assign('archive', $archive);
         $page->assign('admin', may_update());
 
         $evenements = XDB::iterator(
@@ -97,7 +130,8 @@ 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 = {?}"
+                 WHERE  asso_id = {?}
+                   AND  archive = " . ($archive ? "1 " : "0 ")
             . (is_member() || may_update() ? "" : " AND accept_nonmembre != 0 ")
               . "GROUP BY  e.eid
                  ORDER BY  inscr_open DESC, debut DESC", S::v('uid'), $globals->asso('id'));
index 2f282d1..54187c9 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
+{if !$admin}
 <h1>{$asso.nom} : Evénements</h1>
+{else}
+<h1>
+  {$asso.nom} : 
+  {if $archive}[<a href="{$platal->ns}events">Evénements</a>] {else}Evénements {/if}
+  {if $archive}Archives {else}[<a href="{$platal->ns}events/archive">Archives</a>] {/if}
+</h1>
 
-{if $admin}
 <p class="center">
   [<a href="{$platal->ns}events/edit">Annoncer un nouvel événement</a>]
 </p>
       [<a href="{$platal->ns}events/edit/{$e.eid}">
         modifier
         {icon name=date_edit title="Edition de l'événement"}</a>]
-      &nbsp;&nbsp;&nbsp;&nbsp;
+      &nbsp;
+      [<a href="javascript:dynpostkv('{$platal->pl_self()}', {if !$archive}'archive'{else}'unarchive'{/if}, {$e.eid})">
+        {if !$archive}
+          archiver
+          {icon name=package_add title="Archivage"}</a>]
+        {else}
+          désarchiver
+          {icon name=package_delete title="Désarchivage"}</a>]
+        {/if}
+      &nbsp;
       [<a href="javascript:dynpostkv('{$platal->ns}events', 'del', {$e.eid})"
         onclick="return confirm('Supprimer l\'événement effacera la liste des inscrits et des paiements.\n Es-tu sûr de vouloir supprimer l\'événement ?')">
         supprimer
index 81b87e0..62cf075 100644 (file)
@@ -1,3 +1,4 @@
 use groupex;
-alter table evenements add accept_nonmembre tinyint(1) default 0;
+alter table evenements add column accept_nonmembre tinyint(1) not null default 0;
+alter table evenements add column archive tinyint(1) not null default 0;
 use x4dat;