3 * Copyright (c) STMicroelectronics, 2005. All Rights Reserved.
5 * Originally written by Jean-Philippe Giola, 2005
7 * This file is a part of Fusionforge.
9 * Fusionforge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * Fusionforge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * ForumML Archives Browsing page
29 require_once 'env.inc.php';
30 require_once 'pre.php';
31 require_once 'preplugins.php';
32 require_once 'forumml_utils.php';
33 require_once 'mailman/www/mailman_utils.php';
34 require_once 'mailman/include/MailmanList.class.php';
35 //require_once('common/plugin/PluginManager.class.php');
36 require_once(dirname(__FILE__).'/../include/ForumML_FileStorage.class.php');
37 require_once(dirname(__FILE__).'/../include/ForumML_HTMLPurifier.class.php');
38 require_once(dirname(__FILE__).'/../include/ForumML_MessageManager.class.php');
41 $pm = ProjectManager::instance();
42 $Group = $pm->getProject($group_id);
43 $plugin_manager =& PluginManager::instance();
44 $p =& $plugin_manager->getPluginByName('forumml');
45 if ($p && $plugin_manager->isPluginAvailable($p) && $p->isAllowed()) {
47 $current_user=UserManager::instance()->getCurrentUser();
48 $request =& HTTPRequest::instance();
50 $vGrp = new Valid_UInt('group_id');
52 if ($request->valid($vGrp)) {
53 $group_id = $request->get('group_id');
58 $vTopic = new Valid_UInt('topic');
60 if ($request->valid($vTopic)) {
61 $topic = $request->get('topic');
62 $fmlMessageMgr = new ForumML_MessageManager();
63 $topicSubject = $fmlMessageMgr->getHeaderValue($topic, FORUMML_SUBJECT);
69 $vOff = new Valid_UInt('offset');
71 if ($request->valid($vOff)) {
72 $offset = $request->get('offset');
77 // Do we need to pure html cache
78 $vPurge = new Valid_WhiteList('purge_cache', array('true'));
80 if ($request->valid($vPurge)) {
86 // Checks 'list' parameter
87 $vList = new Valid_UInt('list');
89 if (! $request->valid($vList)) {
90 exit_error(_('Error'),_('No list specified'));
92 $list_id = $request->get('list');
93 $list = new MailmanList($group_id,$list_id);
94 if (!isLogged() || ($list->isPublic()!=1 && !$current_user->isMember($group_id))) {
95 exit_error(_('Error'),_('You are not allowed to access this page'));
97 if ($list->getStatus() !=3) {
98 exit_error(_('Error'),_('This list is not active'));
102 // If the list is private, search if the current user is a member of that list. If not, permission denied
103 $list_name = $list->getName();
104 if ($list->isPublic()==0) {
105 exec("{$GLOBALS['mailman_bin_dir']}/list_members ".$list_name , $members);
106 $user = $current_user->getEmail();
107 if (! in_array($user,$members)) {
108 exit_permission_denied();
112 // Build the mail to be sent
113 if ($request->get('send_reply')) {
115 $ret = plugin_forumml_process_mail($p,true);
117 $feedback .=_('Email succefully sent. It can take some time before being displayed');
118 //htmlRedirect('/plugins/forumml/message.php?'. http_build_query(array(
119 // 'group_id' => $group_id,
120 // 'list' => $list_id,
125 else { echo "erreur"; }
128 $params['title'] = $Group->getPublicName().' - ForumML - '.$list_name;
130 $params['title'] .= ' - '.$topicSubject;
132 $params['group'] = $group_id;
133 $params['toptab']='mail';
134 $params['help'] = "CommunicationServices.html#MailingLists";
135 if ($request->valid(new Valid_Pv('pv'))) {
136 $params['pv'] = $request->get('pv');
138 mailman_header($params);
140 if ($request->get('send_reply') && $request->valid($vTopic)) {
141 if (isset($ret) && $ret) {
142 // wait few seconds before redirecting to archives page
143 echo "<script> setTimeout('window.location=\"/plugins/forumml/message.php?group_id=".$group_id."&list=".$list_id."&topic=".$topic."\"',3000) </script>";
147 $list_link = '<a href="/plugins/forumml/message.php?group_id='.$group_id.'&list='.$list_id.'">'.$list_name.'</a>';
148 $title = _('Mailing List').' '.$list_link;
150 $fmlMessageMgr = new ForumML_MessageManager();
151 $value = $fmlMessageMgr->getHeaderValue($topic, FORUMML_SUBJECT);
156 $title .= ' ' . _('Archives');
158 echo '<h2>'.$title.'</h2>';
160 if (! $request->exist('pv') || ($request->exist('pv') && $request->get('pv') == 0)) {
161 echo "<table border='0' width='100%'>
164 echo "<td align='left'>";
166 echo '[<a href="/plugins/forumml/message.php?group_id='.$group_id.'&list='.$list_id.'">'._('Back to the list').'</a>] ';
168 echo " [<a href='/plugins/forumml/index.php?group_id=".$group_id."&list=".$list_id."'>
169 "._('Post a new thread')."
171 if ($list->isPublic()==1) {
172 echo ' [<A HREF="'.util_make_url('/pipermail/'.$list->getName()).'/">'._('Original Archives').'</A>]';
174 echo ' ['._('Original list archives').': <A HREF="http://'.forge_get_config('lists_host').'/pipermail/'.$list->getName().'/">'._('Public archives').'</A>/<A HREF="http://'.forge_get_config('lists_host').'/mailman/private/'.$list->getName().'/">'._('Private Archives').'</A>]';
181 (<a href='/plugins/forumml/message.php?group_id=".$group_id."&list=".$list_id."&topic=".$topic."&offset=".$offset."&search=".($request->exist('search') ? $request->get('search') : "")."&pv=1'>
182 <img src='".$p->getThemePath()."/images/ic/msg.png' border='0'> "._('Printer version')."
189 $vSrch = new Valid_String('search');
191 if (! $request->valid($vSrch)) {
192 // Check if there are archives to browse
193 $res = getForumMLDao()->hasArchives($list_id);
194 if ($res->rowCount() > 0) {
195 // Call to show_thread() function to display the archives
196 if (isset($topic) && $topic != 0) {
198 plugin_forumml_show_thread($p, $list_id, $topic, $purgeCache);
200 plugin_forumml_show_all_threads($p,$list_id,$list_name,$offset);
203 echo "<h2>"._('Empty archives')."</h2>";
207 $pattern = "%".$request->get('search')."%";
208 $result = getForumMLDao()->searchArchives($list_id,$pattern);
209 echo "<h3>"._('Search result for ').$request->get('search')." (".$result->rowCount()." "._('Thread(s) found').")</h3>";
210 if ($result->rowCount() > 0) {
211 plugin_forumml_show_search_results($p,$result,$group_id,$list_id);
215 mail_footer($params);
218 header('Location: '.get_server_url());