Can read the forum of the group directly from Xnet
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Thu, 1 Mar 2007 21:44:23 +0000 (21:44 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Thu, 1 Mar 2007 21:44:23 +0000 (21:44 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1535 839d8a87-29fc-0310-9880-83ba4fa771e5

13 files changed:
ChangeLog
htdocs/css/keynote.css
include/banana/forum.inc.php
include/banana/hooks.inc.php
include/banana/moderate.inc.php
include/xnet/page.inc.php
modules/banana.php
modules/lists.php
modules/xnetgrp.php
templates/banana/index.tpl
templates/lists/moderate_mail.tpl
templates/xnetgrp/asso.tpl
templates/xnetgrp/forum.tpl [new file with mode: 0644]

index 8a8b6fd..6e9f58e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,9 @@ New:
     * Search:
         - Search Engine IE7 compatible                                     -FRU
 
     * Search:
         - Search Engine IE7 compatible                                     -FRU
 
+    * Xnetgrp:
+        - Direct access to the group forum (if exists)                     -FRU
+
 Bug/Wish:
 
     * Banana:
 Bug/Wish:
 
     * Banana:
index 7d7a02b..1114d81 100644 (file)
@@ -42,6 +42,7 @@ td    { vertical-align: top; }
 li    { padding-left: 3px; padding-right: 3px; 
         text-align: justify; }
 hr    { text-align: center; }
 li    { padding-left: 3px; padding-right: 3px; 
         text-align: justify; }
 hr    { text-align: center; }
+dt    { font-weight: bold; }
 
 fieldset {
     border-top: 1px solid #fff;
 
 fieldset {
     border-top: 1px solid #fff;
@@ -536,7 +537,7 @@ div.adresse {
 
 
 #body-bottom {
 
 
 #body-bottom {
-    border-top: 1px solid #fff;
+    border-top: 1px solid #aaa;
     text-align: center;
     padding: 4px;
     font-size: 75%;
     text-align: center;
     padding: 4px;
     font-size: 75%;
index 3061c7a..1abeafb 100644 (file)
@@ -96,15 +96,20 @@ class ForumsBanana extends Banana
                          $time, S::i('uid'));
         }
 
                          $time, S::i('uid'));
         }
 
-        // Register custom Banana links and tabs
-        if (!Banana::$profile['autoup']) {
-            Banana::$page->registerAction('<a href=\'javascript:dynpostkv("'
-                                . $platal->path . '", "updateall", ' . time() . ')\'>'
-                                . 'Marquer tous les messages comme lus'
-                                . '</a>', array('forums', 'thread', 'message'));
-        }   
-        Banana::$page->registerPage('profile', 'Préférences', null);
-        
+        if (!empty($GLOBALS['IS_XNET_SITE'])) {
+            Banana::$page->killPage('forums');
+            Banana::$page->killPage('subscribe');
+            Banana::$spool_boxlist = false;
+        } else {            
+            // Register custom Banana links and tabs
+            if (!Banana::$profile['autoup']) {
+                Banana::$page->registerAction('<a href=\'javascript:dynpostkv("'
+                                    . $platal->path . '", "updateall", ' . time() . ')\'>'
+                                    . 'Marquer tous les messages comme lus'
+                                    . '</a>', array('forums', 'thread', 'message'));
+            }   
+            Banana::$page->registerPage('profile', 'Préférences', null);
+        }
 
         // Run Banana
         return parent::run();
 
         // Run Banana
         return parent::run();
index 493e560..fe000d5 100644 (file)
@@ -125,12 +125,15 @@ function hook_makeImg($img, $alt, $height, $width)
     return '<img src="' . $url . '"' . $height . $width . ' alt="' . $alt . '" />';
 }
 
     return '<img src="' . $url . '"' . $height . $width . ' alt="' . $alt . '" />';
 }
 
+if (!function_exists('hook_makeLink')) {
 function hook_makeLink($params)
 {
     global $globals, $platal;
 function hook_makeLink($params)
 {
     global $globals, $platal;
-    if (Banana::$protocole->name() == 'NNTP') {
+    $xnet = !empty($GLOBALS['IS_XNET_SITE']);
+    $feed = (@$params['action'] == 'rss' || @$params['action'] == 'rss2' || @$params['action'] == 'atom');
+    if (Banana::$protocole->name() == 'NNTP' && !$xnet) {
         $base = $globals->baseurl . '/banana';
         $base = $globals->baseurl . '/banana';
-        if (@$params['action'] == 'rss' || @$params['action'] == 'rss2' || @$params['action'] == 'atom') {
+        if ($feed) {
             return $base . hook_platalRSS(@$params['group']);
         }
         if (isset($params['page'])) {
             return $base . hook_platalRSS(@$params['group']);
         }
         if (isset($params['page'])) {
@@ -144,9 +147,14 @@ function hook_makeLink($params)
             return $base;
         }
         $base .= '/' . $params['group'];
             return $base;
         }
         $base .= '/' . $params['group'];
+    } else if (Banana::$protocole->name() == 'NNTP' && $xnet) {
+        if ($feed) {
+            return 'http://www.polytechnique.org/banana' . hook_platalRSS(@$params['group']);
+        }   
+        $base = $globals->baseurl . '/' . $platal->ns . 'forum';        
     } else if (Banana::$protocole->name() == 'MLArchives') {
         $base = $globals->baseurl . '/' . $platal->ns . 'lists/archives';
     } else if (Banana::$protocole->name() == 'MLArchives') {
         $base = $globals->baseurl . '/' . $platal->ns . 'lists/archives';
-        if (@$params['action'] == 'rss' || @$params['action'] == 'rss2' || @$params['action'] == 'atom') {
+        if ($feed) {
             return $base . hook_platalRSS(MLBanana::$listname);
         }
         $base .= '/' . MLBanana::$listname;
             return $base . hook_platalRSS(MLBanana::$listname);
         }
         $base .= '/' . MLBanana::$listname;
@@ -157,6 +165,60 @@ function hook_makeLink($params)
     }
     return $base;
 }
     }
     return $base;
 }
+}
+
+function get_banana_params(array &$get, $group = null, $action = null, $artid = null)
+{
+    if (!is_null($group)) {
+        $get['group'] = $group;
+    }
+    if (!is_null($action)) {
+        if ($action == 'new') {
+            $get['action'] = 'new'; 
+        } elseif (!is_null($artid)) {
+            $get['artid'] = $artid; 
+            if ($action == 'reply') {
+                $get['action'] = 'new';
+            } elseif ($action == 'cancel') {
+                $get['action'] = $action;
+            } elseif ($action == 'from') {
+                $get['first'] = $artid;
+                unset($get['artid']);
+            } elseif ($action == 'read') {
+                $get['part']  = @$_GET['part'];
+            } elseif ($action == 'source') {
+                $get['part'] = 'source';
+            } elseif ($action == 'xface') {
+                $get['part']  = 'xface';
+            } elseif ($action) {
+                $get['part'] = str_replace('.', '/', $action);
+            }
+            if (Get::v('action') == 'showext') { 
+                $get['action'] = 'showext'; 
+            }   
+        }
+    }
+}
+
+function run_banana(&$page, $class, array $args)
+{
+    $banana = new $class($args);
+    $page->assign('banana', $banana->run());
+    $page->addCssInline($banana->css());
+    $page->addCssLink('banana.css');
+    $rss = $banana->feed();
+    if ($rss) {
+        if (Banana::$group) {
+            $page->setRssLink('Banana :: ' . Banana::$group, $rss);
+        } else {
+            $page->setRssLink('Banana :: Abonnements', $rss);
+        }
+    }
+    $bt = $banana->backtrace();
+    if ($bt) {
+        new PlBacktrace(Banana::$protocole->name(), $banana->backtrace(), 'response', 'time');
+    }    
+}
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index e4c03af..2c743ac 100644 (file)
@@ -56,10 +56,10 @@ class ModerationBanana extends Banana
     static public $domain;
     static public $client;
 
     static public $domain;
     static public $client;
 
-    function __construct($params = null, &$client)
+    function __construct($params = null)
     {
         global $globals;
     {
         global $globals;
-        ModerationBanana::$client = $client;
+        ModerationBanana::$client = $params['client'];
         ModerationBanana::$listname = $params['listname'];
         ModerationBanana::$domain = isset($params['domain']) ? $params['domain'] : $globals->mail->domain;
         $params['group'] = ModerationBanana::$listname . '@' . ModerationBanana::$domain;
         ModerationBanana::$listname = $params['listname'];
         ModerationBanana::$domain = isset($params['domain']) ? $params['domain'] : $globals->mail->domain;
         $params['group'] = ModerationBanana::$listname . '@' . ModerationBanana::$domain;
index 8e19fa2..2874af8 100644 (file)
@@ -82,8 +82,13 @@ class XnetPage extends PlatalPage
                 $sub['trombinoscope'] = "$dim/trombi";
                 $sub['carte'] = "$dim/geoloc";
             }
                 $sub['trombinoscope'] = "$dim/trombi";
                 $sub['carte'] = "$dim/geoloc";
             }
-            if ((is_member() || may_update()) && $globals->asso('mail_domain')) {
-                $sub['listes de diffusion'] = "$dim/lists";
+            if (is_member() || may_update()) {
+                if ($globals->asso('forum')) {
+                    $sub['forum'] = "$dim/forum";
+                }
+                if ($globals->asso('mail_domain')) {
+                    $sub['listes de diffusion'] = "$dim/lists";
+                }
             }
             $sub['événement'] = "$dim/events";
             if (may_update() || is_member()) {
             }
             $sub['événement'] = "$dim/events";
             if (may_update() || is_member()) {
index 85f8db7..6a82468 100644 (file)
@@ -59,37 +59,16 @@ class BananaModule extends PLModule
 
     function handler_banana(&$page, $group = null, $action = null, $artid = null)
     {
 
     function handler_banana(&$page, $group = null, $action = null, $artid = null)
     {
+        $page->changeTpl('banana/index.tpl');
+        $page->assign('xorg_title','Polytechnique.org - Forums & PA');
+
         $get = Array();
         $get = Array();
-        if (!is_null($group)) {
-            $get['group'] = $group;
-        }
         if (Post::has('updateall')) {
             $get['updateall'] = Post::v('updateall');
         }
         if (Post::has('updateall')) {
             $get['updateall'] = Post::v('updateall');
         }
-        if (!is_null($action)) {
-            if ($action == 'new') {
-                $get['action'] = 'new';
-            } elseif (!is_null($artid)) {
-                $get['artid'] = $artid; 
-                if ($action == 'reply') {
-                    $get['action'] = 'new';
-                } elseif ($action == 'cancel') {
-                    $get['action'] = $action;
-                } elseif ($action == 'from') {
-                    $get['first'] = $artid;
-                    unset($get['artid']);
-                } elseif ($action == 'read') {
-                    $get['part']  = @$_GET['part'];
-                } elseif ($action == 'source') {
-                    $get['part'] = 'source';
-                } elseif ($action == 'xface') {
-                    $get['part']  = 'xface';
-                } elseif ($action) {
-                    $get['part'] = str_replace('.', '/', $action);
-                }  
-            }
-        }   
-        return BananaModule::run_banana($page, $get);
+        require_once 'banana/forum.inc.php';
+        get_banana_params($get, $group, $action, $artid);
+        run_banana($page, 'ForumsBanana', $get);
     }
 
     function handler_profile(&$page, $action = null)
     }
 
     function handler_profile(&$page, $action = null)
@@ -133,7 +112,11 @@ class BananaModule extends PLModule
 
     function handler_subscription(&$page)
     {
 
     function handler_subscription(&$page)
     {
-        return $this->run_banana($page, Array('action' => 'subscribe'));
+        $page->changeTpl('banana/index.tpl');
+        $page->assign('xorg_title','Polytechnique.org - Forums & PA');
+
+        require_once 'banana/forum.inc.php';
+        run_banana($page, 'ForumsBanana', Array('action' => 'subscribe'));
     }
 
     function handler_rss(&$page, $group, $alias, $hash, $file = null)
     }
 
     function handler_rss(&$page, $group, $alias, $hash, $file = null)
@@ -157,7 +140,7 @@ class BananaModule extends PLModule
 
         require_once 'banana/forum.inc.php';
         $banana = new ForumsBanana(array('group' => $group, 'action' => 'rss2'));
 
         require_once 'banana/forum.inc.php';
         $banana = new ForumsBanana(array('group' => $group, 'action' => 'rss2'));
-        echo $banana->run();
+        $banana->run();
         exit;
     }
 
         exit;
     }
 
@@ -167,22 +150,7 @@ class BananaModule extends PLModule
         $page->assign('xorg_title','Polytechnique.org - Forums & PA');
 
         require_once 'banana/forum.inc.php';
         $page->assign('xorg_title','Polytechnique.org - Forums & PA');
 
         require_once 'banana/forum.inc.php';
-
-        $banana = new ForumsBanana($params);
-        $res = $banana->run();
-        $page->assign_by_ref('banana', $banana);
-        $page->assign('banana_res', $res);
-        $page->addCssInline($banana->css());
-        $page->addCssLink('banana.css');
-        $rss = $banana->feed();
-        if ($rss) {
-            if (@$params['group']) {
-                $page->setRssLink('Banana :: ' . $params['group'], $rss);
-            } else {
-                $page->setRssLink('Banana :: Abonnements', $rss);
-            }
-        }
-        new PlBacktrace('NNTP', $banana->backtrace(), 'response', 'time');
+        run_banana($page, 'ForumsBanana', $params);
     }
 }
 
     }
 }
 
index da280b3..cfd66e1 100644 (file)
@@ -362,42 +362,9 @@ class ListsModule extends PLModule
             if (Post::has('updateall')) {
                 $get['updateall'] = Post::v('updateall');
             }
             if (Post::has('updateall')) {
                 $get['updateall'] = Post::v('updateall');
             }
-            if (!is_null($action)) {
-                if ($action == 'new') {
-                    $get['action'] = 'new';
-                } elseif (!is_null($artid)) {
-                    $get['artid'] = $artid;
-                    if ($action == 'reply') {
-                        $get['action'] = 'new';
-                    } elseif ($action == 'cancel') {
-                        $get['action'] = $action;
-                    } elseif ($action == 'from') {
-                        $get['first'] = $artid;
-                        unset($get['artid']);
-                    } elseif ($action == 'read') {
-                        $get['part']  = @$_GET['part'];
-                    } elseif ($action == 'source') {
-                        $get['part'] = 'source';
-                    } elseif ($action == 'xface') {
-                        $get['part']  = 'xface';
-                    } elseif ($action) {
-                        $get['part'] = str_replace('.', '/', $action);
-                    }
-                    if (Get::v('action') == 'showext') {
-                        $get['action'] = 'showext';
-                    }   
-                }
-            }
-            require_once('banana/ml.inc.php');
-            $banana = new MLBanana($get);
-            $page->assign('banana', $banana->run());
-            $page->addCssInline($banana->css());
-            $page->addCssLink('banana.css');
-            $rss = $banana->feed();
-            if ($rss) {
-                $page->setRssLink('Banana :: ' . $list, $rss);
-            }
-            new PlBacktrace('MBox', $banana->backtrace(), 'response', 'time');
+            require_once 'banana/ml.inc.php';
+            get_banana_params($get, null, $action, $artid);
+            run_banana($page, 'MLBanana', $get);
         } else {
             $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter");
         }
         } else {
             $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter");
         }
@@ -426,7 +393,7 @@ class ListsModule extends PLModule
             }
             require_once('banana/ml.inc.php');
             $banana = new MLBanana(Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
             }
             require_once('banana/ml.inc.php');
             $banana = new MLBanana(Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
-            echo $banana->run();
+            $banana->run();
         }
         exit;
     }
         }
         exit;
     }
@@ -503,12 +470,12 @@ class ListsModule extends PLModule
             }
         } elseif (Env::has('mid')) {
             if (Get::has('mid') && !Env::has('mok') && !Env::has('mdel')) {
             }
         } elseif (Env::has('mid')) {
             if (Get::has('mid') && !Env::has('mok') && !Env::has('mdel')) {
+                $page->changeTpl('lists/moderate_mail.tpl');
                 require_once('banana/moderate.inc.php');
                 $params = array('listname' => $liste, 'domain' => $domain,
                                 'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action'));
                 require_once('banana/moderate.inc.php');
                 $params = array('listname' => $liste, 'domain' => $domain,
                                 'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action'));
-                $banana = new ModerationBanana($params, $this->client);
-                $res    = $banana->run();
-                $page->addCssInline($banana->css());
+                $params['client'] = $this->client;
+                run_banana($page, 'ModerationBanana', $params);
 
                 $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
                 $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg);
 
                 $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
                 $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg);
@@ -516,10 +483,6 @@ class ListsModule extends PLModule
                 $msg = str_replace("%(reason)s",    "<< TON EXPLICATION >>",  $msg);
                 $msg = str_replace("%(listname)s",  $liste, $msg);
                 $page->assign('msg', $msg);
                 $msg = str_replace("%(reason)s",    "<< TON EXPLICATION >>",  $msg);
                 $msg = str_replace("%(listname)s",  $liste, $msg);
                 $page->assign('msg', $msg);
-                
-                $page->addCssLink('banana.css');
-                $this->changeTpl('lists/moderate_mail.tpl');
-                $page->assign_by_ref('mail', $res);
                 return;
             }
 
                 return;
             }
 
index 2383b30..f340068 100644 (file)
@@ -78,6 +78,7 @@ class XnetGrpModule extends PLModule
             '%grp/logo'           => $this->make_hook('logo',      AUTH_PUBLIC),
             '%grp/edit'           => $this->make_hook('edit',      AUTH_MDP),
             '%grp/mail'           => $this->make_hook('mail',      AUTH_MDP),
             '%grp/logo'           => $this->make_hook('logo',      AUTH_PUBLIC),
             '%grp/edit'           => $this->make_hook('edit',      AUTH_MDP),
             '%grp/mail'           => $this->make_hook('mail',      AUTH_MDP),
+            '%grp/forum'          => $this->make_hook('forum',     AUTH_MDP),
             '%grp/annuaire'       => $this->make_hook('annuaire',  AUTH_MDP),
             '%grp/annuaire/vcard' => $this->make_hook('vcard',     AUTH_MDP),
             '%grp/trombi'         => $this->make_hook('trombi',    AUTH_MDP),
             '%grp/annuaire'       => $this->make_hook('annuaire',  AUTH_MDP),
             '%grp/annuaire/vcard' => $this->make_hook('vcard',     AUTH_MDP),
             '%grp/trombi'         => $this->make_hook('trombi',    AUTH_MDP),
@@ -294,6 +295,19 @@ class XnetGrpModule extends PLModule
         }
     }
 
         }
     }
 
+    function handler_forum(&$page, $group = null, $artid = null)
+    {
+        global $globals;
+        new_group_page('xnetgrp/forum.tpl');
+        if (!$globals->asso('forum')) {
+            return PL_NOT_FOUND;
+        }
+        require_once 'banana/forum.inc.php';
+        $get = array();
+        get_banana_params($get, $globals->asso('forum'), $group, $artid);
+        run_banana($page, 'ForumsBanana', $get);
+    }
+
     function handler_annuaire(&$page)
     {
         global $globals;
     function handler_annuaire(&$page)
     {
         global $globals;
index 7581b47..153cf7a 100644 (file)
@@ -21,6 +21,6 @@
 {**************************************************************************}
 
 <br />
 {**************************************************************************}
 
 <br />
-{$banana_res|smarty:nodefaults}
+{$banana|smarty:nodefaults}
  
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
  
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index fbe7b64..216fd94 100644 (file)
@@ -26,7 +26,7 @@
   Contenu du mail en attente
 </h1>
 
   Contenu du mail en attente
 </h1>
 
-{$mail|smarty:nodefaults}
+{$banana|smarty:nodefaults}
 
 <form method='post' action='{$platal->pl_self(1)}'>
   <table class='tinybicol' cellpadding='0' cellspacing='0'>
 
 <form method='post' action='{$platal->pl_self(1)}'>
   <table class='tinybicol' cellpadding='0' cellspacing='0'>
index be5194f..7750a7a 100644 (file)
@@ -53,7 +53,7 @@
       Forum:
     </td>
     <td>
       Forum:
     </td>
     <td>
-      <a href="https://www.polytechnique.org/banana/{$asso.forum}">par le web</a>
+      <a href="{$platal->ns}forum">par le web</a>
       ou <a href="news://ssl.polytechnique.org/{$asso.forum}">par nntp</a>
     </td>
   </tr>
       ou <a href="news://ssl.polytechnique.org/{$asso.forum}">par nntp</a>
     </td>
   </tr>
diff --git a/templates/xnetgrp/forum.tpl b/templates/xnetgrp/forum.tpl
new file mode 100644 (file)
index 0000000..3108c63
--- /dev/null
@@ -0,0 +1,33 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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} : Forum</h1>
+
+{$banana|smarty:nodefaults}
+
+<p>
+  Cette page utiliser les <a href="https://www.polytechnique.org/banana/profile">préférences</a> de Polytechnique.org.<br />
+  Tu peux également retrouver tous les forums en te rendant à la rubrique
+  <a href="https://www.polytechnique.org/banana">Forums &amp; PA</a>
+</p>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}