Post xnet announces on the forum of the group
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 20 Apr 2007 14:44:47 +0000 (14:44 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 20 Apr 2007 14:44:47 +0000 (14:44 +0000)
 classes/miniwiki.php                |   11 ++++++-----
 modules/xnetgrp.php                 |   31 +++++++++++++++++++++----------
 templates/xnetgrp/asso.tpl          |    2 +-
 templates/xnetgrp/form.announce.tpl |    9 ++++++++-
 upgrade/0.9.14/03_evenements.sql    |    4 ++++
 5 files changed, 40 insertions(+), 17 deletions(-)

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

classes/miniwiki.php
modules/xnetgrp.php
templates/xnetgrp/asso.tpl
templates/xnetgrp/form.announce.tpl
upgrade/0.9.14/03_evenements.sql

index 02f1ca4..f8ceecd 100644 (file)
@@ -32,6 +32,11 @@ class MiniWiki
         // retours à la ligne avec \\
         MiniWiki::Markup("/\\\\(?".">(\\\\*))\n/e", "str_repeat('<br />\n',strlen('$1'))", "str_repeat('\n',strlen('$1'))", "ligne1\\\\\nligne2");
         
+        // * unordered list 
+        MiniWiki::Markup("/(^|\n)\*(([^\n]*(\n|$))(\*[^\n]*(\n|$))*)/se", "'<ul><li>'.str_replace(\"\\n*\",'</li><li>','$2').'</li></ul>'", "$0", "* element1\n* element2\n* element3"); 
+        // # unordered list 
+        MiniWiki::Markup("/(^|\n)#(([^\n]*(\n|$))(#[^\n]*(\n|$))*)/se", "'<ol><li>'.str_replace(\"\\n#\",'</li><li>','$2').'</li></ol>'", "$0", "# element1\n# element2\n# element3"); 
+        
         // bold, italic and others
         // ''' bold '''
         MiniWiki::Markup("/'''(.*?)'''/",'<strong>$1</strong>','*$1*', "'''gras'''");
@@ -61,11 +66,6 @@ class MiniWiki
         MiniWiki::$title_index = MiniWiki::Markup('/(\n|^)(!+)([^\n]*)/se', "'$1<h'.strlen('$2').'>$3</h'.strlen('$2').'>'",
                                                   "'$1$3'", "!titre1\n\n!!titre2\n\n!!!titre3");
         
-        // * unordered list
-        MiniWiki::Markup("/(^|\n)\*(([^\n]*(\n|$))(\*[^\n]*(\n|$))*)/se", "'<ul><li>'.str_replace(\"\\n*\",'</li><li>','$2').'</li></ul>'", "$0", "* element1\n* element2\n* element3");
-        // # unordered list
-        MiniWiki::Markup("/(^|\n)#(([^\n]*(\n|$))(#[^\n]*(\n|$))*)/se", "'<ol><li>'.str_replace(\"\\n#\",'</li><li>','$2').'</li></ol>'", "$0", "# element1\n# element2\n# element3");
-        
         // links
         MiniWiki::Markup('/((?:https?|ftp):\/\/(?:[\.\,\;\!\:]*[\w@~%$£µ&i#\-+=_\/\?])*)/ui', '<a href="\\0">\\0</a>', '[\\0]');
         MiniWiki::Markup('/(\s|^|\\[\\[)www\.((?:[\.\,\;\!\:]*[\w@~%$£µ&i#\-+=_\/\?])*)/iu', '\\1<a href="http://www.\\2">www.\\2</a>', '[http://www.\\2]');
@@ -144,6 +144,7 @@ class MiniWiki
             $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index];
             MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'";
         }
+        $text = trim($wiki);
         $text = preg_replace(MiniWiki::$patternsWiki, MiniWiki::$replacementText, trim($wiki));
         if (!$title) {
             MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12;
index 88547d8..057bcc7 100644 (file)
@@ -1015,17 +1015,28 @@ class XnetGrpModule extends PLModule
             $promo_min = ($art['public'] ? 0 : $art['promo_min']);
             $promo_max = ($art['public'] ? 0 : $art['promo_max']);
             if (is_null($aid)) {
+                $fulltext = $art['texte']; 
+                if (!empty($art['contact_html'])) { 
+                    $fulltext .= "\n\n'''Contacts :'''\\\\\n" . $art['contact_html']; 
+                }
+                $post = null;
+                if ($globals->asso('forum')) {
+                    require_once 'banana/forum.inc.php';
+                    $banana = new ForumsBanana(S::v('forlife'));
+                    $post = $banana->post($globals->asso('forum'), null,
+                                          $art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80));
+                }
                 XDB::query("INSERT INTO groupex.announces
                                  (user_id, asso_id, create_date, titre, texte, contacts,
-                                   peremption, promo_min, promo_max, flags)
-                            VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?})",
+                                   peremption, promo_min, promo_max, flags, post_id)
+                            VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})",
                            S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'],
-                           $art['peremption'], $promo_min, $promo_max, $art['public'] ? 'public' : '');
+                           $art['peremption'], $promo_min, $promo_max, $art['public'] ? 'public' : '', $post);
                 $aid = XDB::insertId();
                 if ($art['xorg']) {
                     require_once('validations.inc.php');
                     $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'],
-                                    MiniWiki::WikiToHTML($art['texte'] . (!empty($art['contact_html']) ? "\n\nContacts :\n" . $art['contact_html'] : "")),
+                                    MiniWiki::WikiToHTML($fulltext),
                                     $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");
@@ -1087,14 +1098,14 @@ class XnetGrpModule extends PLModule
         $page->changeTpl('xnetgrp/announce-admin.tpl');
 
         if (Env::has('del')) {
-            XDB::execute("DELETE FROM groupex.announces
-                                WHERE id = {?} AND asso_id = {?}",
+            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",
+        $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);
     }
index d29ea84..b616d7b 100644 (file)
@@ -151,7 +151,7 @@ respectifs et sont publiées à leur initiative. L'association Polytechnique.org
 ne pourrait en aucun cas être tenue responsable de la nature des propos relatés
 sur cet espace d'expression et d'information. Elle se réserve le droit de
 refuser ou de retirer toute information de nature diffamante ou pouvant être
-interprétée comme polémique par un membre de la communauté polytechnicienne.
+interprétée comme polémique par un lecteur.
 </small>
 </p>
 {/if}
index 03d612c..ca3b565 100644 (file)
     </td>
   </tr>
   {/if}
-  <tr class="pair right">
+  <tr class="pair">
     <td>
+      <div style="float: right">
       <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>
+      </div>
+      <small>
+      {if $art.post_id}
+      <a href="{$platal->ns}forum/read/{$art.post_id}">{icon name=comments title="Discussions"}Discuter</a>
+      {/if}
+      </small>
     </td>
   </tr>
 </table>
index 5c8555d..fafc2a8 100644 (file)
@@ -9,4 +9,8 @@ create table evenements_photo (
     primary key eid (eid)
 ) charset=utf8;
 
+use groupex;
+alter table announces add post_id smallint(4) unsigned default NULL;
+use x4dat;
+
 # vim:set syntax=mysql: