Add a announce system on X.net
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 7 Nov 2006 15:09:25 +0000 (15:09 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 7 Nov 2006 15:09:25 +0000 (15:09 +0000)
It is connected with X.org announces (NL and front page events).

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1057 839d8a87-29fc-0310-9880-83ba4fa771e5

12 files changed:
ChangeLog
include/rss.inc.php
include/xnet/page.inc.php
modules/xnetgrp.php
templates/xnet/groupe/announce-admin.tpl [new file with mode: 0644]
templates/xnet/groupe/announce-edit.tpl [new file with mode: 0644]
templates/xnet/groupe/announce-rss.tpl [new file with mode: 0644]
templates/xnet/groupe/asso.tpl
templates/xnet/groupe/form.announce.tpl [new file with mode: 0644]
templates/xnet/skin.tpl
templates/xnetlists/index.tpl
upgrade/0.9.12/01_xnet.sql

index f4b7de1..6a99003 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@ New:
 
     * Xnet:
         - Add a vcard of all the members of a group                        -FRU
+        - Add a full announce system                                       -FRU
 
     * Xnet/Events:
         - Events can be archived                                           -FRU
index 5bfcffa..42ffb49 100644 (file)
@@ -37,7 +37,7 @@ function to_rss ($s)
     }
 }
 
-function init_rss($template, $alias, $hash)
+function init_rss($template, $alias, $hash, $require_uid = true)
 {
     global $page;
     $page->changeTpl($template, NO_SKIN);
@@ -52,7 +52,11 @@ function init_rss($template, $alias, $hash)
     $uid = $res->fetchOneCell();
 
     if (empty($uid)) {
-        exit;
+        if ($require_uid) {
+            exit;
+        } else {
+            $uid = null;
+        }
     }
 
     header('Content-Type: application/rss+xml; charset=utf8');
index e41a0e0..56a382f 100644 (file)
@@ -100,6 +100,7 @@ class XnetPage extends PlatalPage
         if (S::logged() && may_update()) {
             $sub = array();
             $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";
                 $sub['créer une liste']     = "$dim/lists/create";
index de80da7..4c624b7 100644 (file)
@@ -84,23 +84,86 @@ class XnetGrpModule extends PLModule
                  => $this->make_hook('admin_member_new', AUTH_MDP),
             '%grp/member/del'
                  => $this->make_hook('admin_member_del', AUTH_MDP),
+
+            '%grp/rss'             => $this->make_hook('rss', AUTH_PUBLIC),         
+            '%grp/announce/new'    => $this->make_hook('edit_announce', AUTH_MDP),
+            '%grp/announce/edit'   => $this->make_hook('edit_announce', AUTH_MDP),
+            '%grp/admin/announces' => $this->make_hook('admin_announce', AUTH_MDP),
         );
     }
 
     function handler_index(&$page, $arg = null)
     {
-        global $globals;
+        global $globals, $platal;
 
         if (!is_null($arg)) {
             return PL_NOT_FOUND;
         }
 
         $page->changeTpl('xnet/groupe/asso.tpl');
-        $page->useMenu();
         $page->setType($globals->asso('cat'));
+        $page->assign('is_admin', may_update());
         $page->assign('is_member', is_member());
         $page->assign('logged', S::logged());
 
+        if (S::logged()) {
+            if (Env::has('read')) {
+                XDB::query('DELETE r.*
+                              FROM groupex.announces_read AS r
+                        INNER JOIN groupex.announces AS a ON a.id = r.announce_id
+                             WHERE peremption < CURRENT_DATE()');       
+                XDB::query('INSERT INTO groupex.announces_read
+                                 VALUES ({?}, {?})',
+                            Env::i('read'), S::i('uid'));
+                pl_redirect("");
+            }
+            if (Env::has('unread')) {
+                XDB::query('DELETE FROM groupex.announces_read
+                                  WHERE announce_id={?} AND user_id={?}',
+                            Env::i('unread'), S::i('uid'));
+                pl_redirect("#art" . Env::i('unread'));
+            }
+            $arts = XDB::iterator("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife
+                                     FROM groupex.announces AS a
+                               INNER JOIN auth_user_md5 AS u USING(user_id)
+                               INNER JOIN aliases AS l ON (u.user_id = l.id AND l.type = 'a_vie')
+                                LEFT JOIN groupex.announces_read AS r ON (r.user_id = {?} AND r.announce_id = a.id)
+                                    WHERE asso_id = {?} AND peremption >= CURRENT_DATE()
+                                          AND (promo_min = 0 OR promo_min <= {?})
+                                          AND (promo_max = 0 OR promo_max >= {?})
+                                          AND r.announce_id IS NULL
+                                 ORDER BY a.peremption",
+                                   S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo'));
+            $index = XDB::iterator("SELECT a.id, a.titre, r.user_id IS NULL AS nonlu
+                                      FROM groupex.announces AS a
+                                 LEFT JOIN groupex.announces_read AS r ON (a.id = r.announce_id AND r.user_id = {?})
+                                     WHERE asso_id = {?} AND peremption >= CURRENT_DATE()
+                                           AND (promo_min = 0 OR promo_min <= {?})
+                                           AND (promo_max = 0 OR promo_max >= {?})
+                                  ORDER BY a.peremption",
+                                   S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo'));
+            $page->assign('article_index', $index);
+        } else {
+            $arts = XDB::iterator("SELECT a.*, u.nom, u.prenom, u.promo
+                                     FROM groupex.announces AS a
+                               INNER JOIN auth_user_md5 AS u USING(user_id)
+                                    WHERE asso_id = {?} AND peremption >= CURRENT_DATE()
+                                          AND FIND_IN_SET(u.flags, 'public')",
+                                  $globals->asso('id'));
+        }
+
+        if (!S::has('core_rss_hash')) {
+            $page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News publiques",
+                              "rss/rss.xml");
+        } else {
+            $page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News",
+                              'rss/'.S::v('forlife') .'/'.S::v('core_rss_hash').'/rss.xml');
+        }
+
+        require_once('url_catcher.inc.php');
+        $page->register_modifier('url_catcher', 'url_catcher');
+        $page->assign('articles', $arts);
+
         $page->assign('asso', $globals->asso());
     }
 
@@ -109,8 +172,8 @@ class XnetGrpModule extends PLModule
         global $globals;
 
         $res = XDB::query("SELECT logo, logo_mime
-                                       FROM groupex.asso WHERE id = {?}",
-                                    $globals->asso('id'));
+                             FROM groupex.asso WHERE id = {?}",
+                          $globals->asso('id'));
         list($logo, $logo_mime) = $res->fetchOneRow();
 
         if (!empty($logo)) {
@@ -346,7 +409,6 @@ class XnetGrpModule extends PLModule
 
         $page->changeTpl('xnet/groupe/inscrire.tpl');
 
-        $page->useMenu();
         $page->setType($globals->asso('cat'));
         $page->assign('asso', $globals->asso());
         $page->assign('admin', may_update());
@@ -777,6 +839,166 @@ class XnetGrpModule extends PLModule
                 $user['email'], '%@'.$globals->asso('mail_domain'));
         $page->assign('alias', $res->fetchAllAssoc());
     }
+
+    function handler_rss(&$page, $user = null, $hash = null)
+    {
+        global $globals;
+        require_once('rss.inc.php');
+        require_once('url_catcher.inc.php');
+        $uid = init_rss('xnet/groupe/announce-rss.tpl', $user, $hash, false);
+        $page->register_modifier('url_catcher', 'url_catcher');
+
+        if ($uid) {
+            $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.contacts, a.create_date,
+                                         IF(u2.nom_usage != '', u2.nom_usage, u2.nom) AS nom, u2.prenom, u2.promo
+                                   FROM auth_user_md5 AS u
+                             INNER JOIN groupex.announces AS a ON ( (a.promo_min = 0 OR a.promo_min <= u.promo)
+                                                                  AND (a.promo_max = 0 OR a.promo_max <= u.promo))
+                             INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = a.user_id)
+                                  WHERE u.user_id = {?} AND peremption >= NOW()", $uid);
+        } else {
+            $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.create_date,
+                                         IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo
+                                    FROM groupex.announces AS a
+                             INNER JOIN auth_user_md5 AS u USING(user_id)
+                                   WHERE FIND_IN_SET(a.flags, 'public') AND peremption >= NOW()");
+        }
+        $page->assign('asso', $globals->asso());
+        $page->assign('rss', $rss);
+    }
+
+    function handler_edit_announce(&$page, $aid = null)
+    {
+        global $globals, $platal;
+        new_groupadmin_page('xnet/groupe/announce-edit.tpl');
+        $page->assign('new', is_null($aid));
+        $art = array();
+
+        if (Post::v('valid') == 'Visualiser' || Post::v('valid') == 'Enregistrer') {
+            if (!is_null($aid)) {
+                $art['id'] = $aid;
+            }
+            $art['titre']      = Post::v('titre');
+            $art['texte']      = Post::v('texte');
+            $art['contacts']   = Post::v('contacts');
+            $art['promo_min']  = Post::i('promo_min');
+            $art['promo_max']  = Post::i('promo_max');
+            $art['nom']        = S::v('nom');
+            $art['prenom']     = S::v('prenom');
+            $art['promo']      = S::v('promo');
+            $art['forlife']    = S::v('forlife');
+            $art['peremption'] = Post::v('peremption');
+            $art['public']     = Post::has('public');
+            $art['xorg']       = Post::has('xorg');
+            $art['nl']         = Post::has('nl');
+            $art['event']      = Post::v('event');
+
+            $art['contact_html'] = $art['contacts'];
+            if (@$art['event']) {
+                 $art['contact_html'] .= "\n{$globals->baseurl}/{$platal->ns}events/sub/{$art['event']}";
+            }
+        }
+
+        if (Post::v('valid') == 'Enregistrer') {
+            if (is_null($aid)) {
+                XDB::query("INSERT INTO groupex.announces
+                                 (user_id, asso_id, create_date, titre, texte, contacts,
+                                   peremption, promo_min, promo_max, flags)
+                            VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?})",
+                           S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'],
+                           $art['peremption'], $art['promo_min'], $art['promo_max'], $art['public'] ? 'public' : '');
+                $aid = mysql_insert_id();
+                if ($art['xorg']) {
+                    require_once('validations.inc.php');
+                    require_once('url_catcher.inc.php');
+                    $article = new EvtReq($art['titre'],
+                                    url_catcher($art['texte'] . (!empty($art['contacts']) ? "\n\nContacts :\n" . $art['contacts'] : "")),
+                                    $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::v('uid'));
+                    $article->submit();
+                    $page->trig("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation");
+                }
+                if ($art['nl']) {
+                    require_once('validations.inc.php');
+                    $article = new NLReq(S::v('uid'), $art['titre'], $art['texte'], $art['contact_html']);
+                    $article->submit();
+                    $page->trig("La parution dans la Lettre Mensuelle est en attente de validation");
+                }
+            } else {
+                XDB::query("UPDATE groupex.announces
+                               SET titre={?}, texte={?}, contacts={?}, peremption={?},
+                                   promo_min={?}, promo_max={?}, flags={?}
+                             WHERE id={?} AND asso_id={?}",
+                           $art['titre'], $art['texte'], $art['contacts'], $art['peremption'],
+                           $art['promo_min'], $art['promo_max'],  $art['public'] ? 'public' : '',
+                           $art['id'], $globals->asso('id'));
+            }
+            pl_redirect("");
+        } 
+
+        if (empty($art) && !is_null($aid)) {
+            $res = XDB::query("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife,
+                                      FIND_IN_SET(a.flags, 'public') AS public
+                                 FROM groupex.announces AS a
+                           INNER JOIN auth_user_md5 AS u USING(user_id)
+                           INNER JOIN aliases AS l ON (l.id = u.user_id AND l.type = 'a_vie')
+                                WHERE asso_id = {?} AND a.id = {?}",
+                              $globals->asso('id'), $aid);
+            if ($res->numRows()) {
+                $art = $res->fetchOneAssoc();
+                $art['contact_html'] = $art['contacts'];
+            } else {
+                $page->kill("Aucun article correspond à l'identifiant indiqué");
+            }
+        }
+
+        $select = '';
+        for ($i = 1 ; $i < 30 ; $i++) {
+            $time    = time() + 3600 * 24 * $i;
+            $p_stamp = date('Ymd', $time);
+            $year    = date('Y',   $time);
+            $month   = date('m',   $time);
+            $day     = date('d',   $time);
+
+            $select .= "<option value=\"$p_stamp\"";
+            if ($p_stamp == strtr(@$art['peremption'], array("-" => ""))) {
+                $select .= " selected='selected'";
+            }
+            $select .= "> $day / $month / $year</option>\n";
+        }
+        $page->assign('select', $select);
+
+        if (is_null($aid)) {
+            $events = XDB::iterator("SELECT *
+                                      FROM groupex.evenements
+                                     WHERE asso_id = {?} AND archive = 0",
+                                   $globals->asso('id'));
+            if ($events->total()) {
+                $page->assign('events', $events);
+            }
+        } 
+
+        require_once('url_catcher.inc.php');
+        $art['contact_html'] = url_catcher($art['contact_html']);
+        $page->assign('art', $art);
+    }
+
+    function handler_admin_announce(&$page)
+    {
+        global $globals;
+        new_groupadmin_page('xnet/groupe/announce-admin.tpl');
+
+        if (Env::has('del')) {
+            XDB::execute("DELETE FROM groupex.announces
+                                WHERE id = {?} AND asso_id = {?}",
+                         Env::i('del'), $globals->asso('id'));
+        }
+        $res = XDB::iterator("SELECT a.id, a.titre, a.peremption, a.peremption < CURRENT_DATE() AS perime
+                                FROM groupex.announces AS a
+                                WHERE a.asso_id = {?}
+                             ORDER BY a.peremption DESC",
+                             $globals->asso('id'));
+        $page->assign('articles', $res);
+    }
 }
 
 ?>
diff --git a/templates/xnet/groupe/announce-admin.tpl b/templates/xnet/groupe/announce-admin.tpl
new file mode 100644 (file)
index 0000000..45ae5f8
--- /dev/null
@@ -0,0 +1,50 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h1>{$asso.nom} : Administration des announces</h1>
+
+<table class="bicol">
+  <tr>
+    <th>Titre</th>
+    <th>Péremption</th>
+    <th></th>
+  </tr>
+  {iterate item=art from=$articles}
+  <tr class="{if $art.perime}im{/if}pair">
+    <td><a href="{$platal->ns}announce/edit/{$art.id}">{$art.titre}</a></td>
+    <td>{$art.peremption|date_format}</td>
+    <td class="right"><a href="{$platal->ns}admin/announces?del={$art.id}">
+        Supprimer l'annonce {icon name=cross}
+      </a>
+    </td>
+  </tr>
+  {/iterate}
+  <tr>
+    <td colspan="3" class="center">
+      <a href="{$platal->ns}announce/new">
+        {icon name=add title="Nouvelle annonce"} Ecrire une nouvelle annonce
+      </a>
+    </td>
+  </tr>
+</table>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/xnet/groupe/announce-edit.tpl b/templates/xnet/groupe/announce-edit.tpl
new file mode 100644 (file)
index 0000000..927b3d6
--- /dev/null
@@ -0,0 +1,188 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h1>{$asso.nom} : Edition d'une annonce</h1>
+
+{if $art.texte}
+<div>
+{include file="xnet/groupe/form.announce.tpl" admin=true}
+<br />
+</div>
+{/if}
+
+<form method="post" action="{$platal->ns}announce/{if $new}new{else}edit/{$art.id}{/if}">
+<div>
+  <table class="bicol">
+    <tr>
+      <th colspan="2">Editer une annonce</th>
+    </tr>
+    <tr class="pair">
+      <td class="titre">Titre :</td>
+      <td><input type="text" name="titre" value="{$art.titre}" size="50" maxlength="200" /></td>
+    </tr>
+    <tr>
+      <td class="titre">Contenu de l'annonce :</td>
+      <td>
+        <small>
+          Le contenu est destiné à recevoir la descriptioin de ce qui est annoncé.
+          Il faut éviter d'y mettre des adresses mails ou web (surtout si l'annonce est publique),
+          qui devront être placées dans la section "contacts".
+        </small>
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2">
+        <textarea name="texte" rows="10" cols="60" onfocus="update_texte_count(this.form)">{$art.texte}</textarea>
+        <br />
+        <script type="text/javascript">
+          var form_propose_texte = false;
+          {literal}
+          function update_texte_count(f) {
+            if (!form_propose_texte && f) form_propose_texte = f;
+            form_propose_texte.texte_count.value=form_propose_texte.texte.value.length;
+            setTimeout("update_texte_count(0)", 100);
+          }
+          {/literal}
+        </script>
+        <small>
+          Essaie de faire un <strong>texte court</strong>, une annonce ne doit pas excéder 600 caractères soit une dizaine de ligne.
+          Tu en es déjà à <input type='text' name='texte_count' size="4"/> caractères.
+          Si tu veux proposer cette annonce pour la Lettre Mensuelle, il faut te limiter à 8 lignes.
+        </small>
+      </td>
+    </tr>
+    <tr style="border-top: 1px solid gray">
+      <td class="titre">Contacts :</td>
+      <td>
+        <small>
+          La section "contacts" sert à noter les informations telles que les adresses mails de contact, les sites web.
+          Elle n'est accessible qu'aux personnes authentifiées. Si l'annonce est attachée à une événement, un lien vers
+          la page d'inscription est automatiquement ajouté.
+        </small>
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2">
+        <textarea cols="60" rows="6" name='contacts'>{$art.contacts}</textarea>
+      </td>
+    </tr>
+  </table>
+  <br />
+
+  <table class="tinybicol">
+    <tr>
+      <th colspan="2">Promotions cibles</th>
+    </tr>
+    <tr>
+      <td class="titre">Promotion minimale :</td>
+      <td>
+        <input type="text" size="4" maxlength="4" name="promo_min" value="{$art.promo_min|default:0}" />
+        incluse*  (ex : 1980)
+      </td>
+    </tr>
+    <tr>
+      <td class="titre">Promotion minimale :</td>
+      <td>
+        <input type="text" size="4" maxlength="4" name="promo_max" value="{$art.promo_max|default:0}" />
+        incluse*  (ex : 2000)
+      </td>
+    </tr>
+    <tr class="pair">
+      <td colspan="2">
+        <small>* 0 signifie qu'il n'y a pas de limite</small>
+      </td>
+    </tr>
+    <tr>
+      <th colspan="2">Options</th>
+    </tr>
+    <tr>
+      <td class="titre">Date de péremption :</td>
+      <td>
+        <select name="peremption">
+          {$select|smarty:nodefaults}
+        </select>
+      </td>
+    </tr>
+    {if $events}
+    <tr>
+      <td class="titre">Attacher à un événement :</td>
+      <td>
+        <select name="event">
+          <option value="" {if !$art.event}selected="selected"{/if}>-- Aucun --</option>
+          {iterate item=evt from=$events}
+          <option value="{$evt.short_name|default:$evt.eid}" 
+            {if $art.event eq $evt.short_name|default:$evt.eid}selected="selected"{/if}>
+            {$evt.intitule}
+          </option>
+          {/iterate}
+        </select>
+      </td>
+    </tr>
+    {/if}
+    <tr> 
+      <td class="titre">Visibilité :</td>
+      <td>
+        <input type="checkbox" name="public" {if $art.public}checked="checked"{/if} />
+        Rendre cette annonce publique
+      </td>
+    </tr>
+    {if $new}
+    <tr>
+      <th colspan="2">Demandes de publication</th>
+    </tr>
+    <tr>
+      <td colspan="2">
+        <input type="checkbox" name="xorg" {if $art.xorg}checked="checked"{/if} />
+        sur la page d'accueil de Polytechnique.org
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2">
+        <input type="checkbox" name="nl" {if $art.nl}checked="checked"{/if} />
+        dans la Lettre Mensuelle de Polytechnique.org
+      </td>
+    </tr>
+    <tr class="pair">
+      <td colspan="2">
+        <small>Les demandes de publication sont soumises à validation par l'équipe
+        de Polytechnique.org</small>
+      </td>
+    </tr>
+    {/if}
+  </table>
+
+  <div class="center">
+    {if $art.id}
+    <input type="hidden" name="id" value="{$art.id}" />
+    {/if}
+    <input type="submit" name="valid" value="Visualiser" /><br />
+    {if $art.texte}
+    <input type="submit" name="valid" value="Enregistrer" /> 
+    {if !$new}
+    <input type="submit" name="valid" value="Annuler" />
+    {/if}
+    {/if}
+  </div>
+</div>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/xnet/groupe/announce-rss.tpl b/templates/xnet/groupe/announce-rss.tpl
new file mode 100644 (file)
index 0000000..c4353d5
--- /dev/null
@@ -0,0 +1,46 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<?xml version="1.0"?>
+<rss version="2.0">
+  <channel>
+    <title>Polytechnique.net :: {$asso.nom} :: News</title>
+    <language>fr</language>
+    <link>{#globals.baseurl#}/{$asso.diminutif}/</link>
+    <description>L'actualite polytechnicienne...</description>
+    <image>
+      <title>{#globals.core.sitename#}</title>
+      <url>{#globals.baseurl#}/images/logo.png</url>
+      <link>{#globals.baseurl#}/{$asso.diminutif}/</link>
+    </image>
+    {iterate item=line from=$rss}
+    <item>
+      <title>{$line.titre|strip_tags}</title>
+      <link>{#globals.baseurl#}/{$asso.diminutif}/#art{$line.id}</link>
+      <description><![CDATA[{$line.texte|nl2br}{if $line.contacts}<br/><br/><strong>Contacts :</strong><br/>{$line.contacts|url_catcher|nl2br}{/if}]]></description>
+      <author>{$line.prenom} {$line.nom} (X{$line.promo})</author>
+      <pubDate>{$line.creation_date|rss_date}</pubDate>
+    </item>
+    {/iterate}
+  </channel>
+</rss>
+{* vim:set et sw=2 sts=2 sws=2: *}
index f144b0d..7ba1550 100644 (file)
 
 <br />
 
-<div>
+<div style="text-align: justify">
   {$asso.descr|smarty:nodefaults}
 </div>
 
+<br />
+
+{if $articles->total()}
+<div>
+{iterate item=art from=$articles}
+{include file="xnet/groupe/form.announce.tpl"}
+<br />
+{/iterate}
+</div>
+{/if}
+
+{if $article_index && $article_index->total()}
+<table class="tinybicol">
+  <tr>
+    <th>
+      {if $smarty.session.core_rss_hash}
+      <a href='{$platal->ns}rss/{$smarty.session.forlife}/{$smarty.session.core_rss_hash}/rss.xml' style="display:block;float:right">
+        {icon name=feed title='fil rss'}
+      </a>
+      {else}
+      <a href='https://www.polytechnique.org/prefs/rss?referer=events'  style="display:block;float:right">
+        {icon name=feed_add title='Activer mon fil rss'}
+      </a>
+      {/if}
+      Sommaire des annonces du groupe
+    </th>
+  </tr>
+  {iterate item=art from=$article_index}
+  <tr>
+    <td>&bull; 
+    {if $art.nonlu}
+      <a href="{$platal->ns}#art{$art.id}">
+    {else}
+      <a href="{$platal->ns}?unread={$art.id}"><strong>
+    {/if}
+    {tidy}{$art.titre}{/tidy}
+    {if !$art.nonlu}</strong>{/if}</a>
+    </td>
+  </tr>
+  {/iterate}
+</table>
+{/if}
+
+{if $is_admin}
+<div class="center">
+  [<a href="{$platal->ns}announce/new">Ajouter une annonce</a>]
+</div>
+{/if}
+
 {* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/xnet/groupe/form.announce.tpl b/templates/xnet/groupe/form.announce.tpl
new file mode 100644 (file)
index 0000000..d1bb90a
--- /dev/null
@@ -0,0 +1,70 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<table class="tinybicol" id="art{$art.id}">
+  <tr>
+    <th>
+      {if $logged && !$admin}
+      <div style="float: right">
+        {if $is_admin}
+          <a href="{$platal->ns}announce/edit/{$art.id}">{icon name=page_edit title="Editer cet article"}</a>
+        {/if}
+        <a href="{$platal->ns}?read={$art.id}">{icon name=cross title="Cacher cet article"}</a>
+      </div>
+      {/if}
+      {tidy}
+      {if $admin}Aperçu de : {/if}{$art.titre}
+      {/tidy}
+    </th>
+  </tr>
+  <tr>
+    <td style="padding-bottom: 1em">
+      {tidy}
+      {$art.texte|nl2br}
+      {/tidy}
+    </td>
+  </tr>
+  {if ($logged || $admin) && $art.contacts}
+  <tr class="pair">
+    <td class="titre">Contacts :</td>
+  </tr>
+  <tr class="pair">
+    <td style="padding-left: 20px">
+      {tidy}
+      {$art.contacts|url_catcher|nl2br|smarty:nodefaults}
+      {/tidy}
+    </td>
+  </tr>
+  {/if}
+  <tr class="pair right">
+    <td>
+      <small>
+        Annonce proposée par
+        <a class="popup2" href="https://www.polytechnique.org/profile/{$art.forlife}">
+          {$art.prenom} {$art.nom} (X{$art.promo})
+        </a>
+      </small>
+    </td>
+  </tr>
+</table>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
index 61d4401..a5aa901 100644 (file)
     <script type="text/javascript" src="javascript/{$js}"></script>
     {/foreach}
     <script type="text/javascript" src="javascript/overlib.js"></script>
-    
+
+    {if $xorg_rss}
+    <link rel="alternate" type="application/rss+xml" title="{$xorg_rss.title}" href="{$xorg_rss.href}" />
+    {/if}
+
     {if $xorg_extra_header}
     {$xorg_extra_header|smarty:nodefaults}
     {/if}
index e8bc6bc..eaf7cbc 100644 (file)
@@ -88,7 +88,7 @@ croix verte te permet de t'inscrire, apr
     </td>
   </tr>
   {foreachelse}
-  <tr><td colspan='6'>Pas de listes pour ce groupe</td></tr>
+  <tr><td colspan='7'>Pas de listes pour ce groupe</td></tr>
   {/foreach}
 </table>
 
index 62cf075..28fd09d 100644 (file)
@@ -1,4 +1,27 @@
 use groupex;
 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;
+
+create table announces (
+    id smallint(4) unsigned not null auto_increment,
+    user_id smallint(4) unsigned not null default 0,
+    asso_id smallint(4) unsigned not null default 0,
+    create_date timestamp(14) default null,
+    titre varchar(255) not null,
+    texte mediumtext not null,
+    contacts mediumtext not null,
+    peremption date not null default '0000-00-00',
+    promo_min smallint(4) unsigned not null default 0,
+    promo_max smallint(4) unsigned not null default 0,
+    flags set('public') not null default '',
+
+    primary key (id)
+);
+
+create table announces_read (
+    announce_id smallint(4) unsigned not null default 0,
+    user_id smallint(4) unsigned not null default 0,
+    primary key (announce_id, user_id)
+);
+
 use x4dat;