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.
26 * ForumML Archives Browsing page
30 require_once 'env.inc.php';
31 require_once 'pre.php';
32 require_once 'preplugins.php';
33 require_once 'forumml_utils.php';
34 require_once 'mailman/www/mailman_utils.php';
35 require_once 'mailman/include/MailmanList.class.php';
36 //require_once('common/plugin/PluginManager.class.php');
37 require_once(dirname(__FILE__).'/../include/ForumML_FileStorage.class.php');
38 require_once(dirname(__FILE__).'/../include/ForumML_HTMLPurifier.class.php');
39 require_once(dirname(__FILE__).'/../include/ForumML_MessageManager.class.php');
42 $pm = ProjectManager::instance();
43 $Group = $pm->getProject($group_id);
44 $plugin_manager =& PluginManager::instance();
45 $p =& $plugin_manager->getPluginByName('forumml');
46 if ($p && $plugin_manager->isPluginAvailable($p) && $p->isAllowed()) {
48 $current_user=UserManager::instance()->getCurrentUser();
49 $request =& HTTPRequest::instance();
51 $vGrp = new Valid_UInt('group_id');
53 if ($request->valid($vGrp)) {
54 $group_id = $request->get('group_id');
59 $vTopic = new Valid_UInt('topic');
61 if ($request->valid($vTopic)) {
62 $topic = $request->get('topic');
63 $fmlMessageMgr = new ForumML_MessageManager();
64 $topicSubject = $fmlMessageMgr->getHeaderValue($topic, FORUMML_SUBJECT);
70 $vOff = new Valid_UInt('offset');
72 if ($request->valid($vOff)) {
73 $offset = $request->get('offset');
78 // Do we need to pure html cache
79 $vPurge = new Valid_WhiteList('purge_cache', array('true'));
81 if ($request->valid($vPurge)) {
87 // Checks 'list' parameter
88 $vList = new Valid_UInt('list');
90 if (! $request->valid($vList)) {
91 exit_error(_('Error'),_('No list specified'));
93 $list_id = $request->get('list');
94 $list = new MailmanList($group_id,$list_id);
95 if (!isLogged() || ($list->isPublic()!=1 && !$current_user->isMember($group_id))) {
96 exit_error(_('Error'),_('You are not allowed to access this page'));
98 if ($list->getStatus() !=3) {
99 exit_error(_('Error'),_('This list is not active'));
103 // If the list is private, search if the current user is a member of that list. If not, permission denied
104 $list_name = $list->getName();
105 if ($list->isPublic()==0) {
106 exec("{$GLOBALS['mailman_bin_dir']}/list_members ".$list_name , $members);
107 $user = $current_user->getEmail();
108 if (! in_array($user,$members)) {
109 exit_permission_denied();
113 // Build the mail to be sent
114 if ($request->get('send_reply')) {
116 $ret = plugin_forumml_process_mail($p,true);
118 $feedback .=_('Email succefully sent. It can take some time before being displayed');
119 //htmlRedirect('/plugins/forumml/message.php?'. http_build_query(array(
120 // 'group_id' => $group_id,
121 // 'list' => $list_id,
126 else { echo "erreur"; }
129 $params['title'] = $Group->getPublicName().' - ForumML - '.$list_name;
131 $params['title'] .= ' - '.$topicSubject;
133 $params['group'] = $group_id;
134 $params['toptab']='mail';
135 $params['help'] = "CommunicationServices.html#MailingLists";
136 if ($request->valid(new Valid_Pv('pv'))) {
137 $params['pv'] = $request->get('pv');
139 mailman_header($params);
141 if ($request->get('send_reply') && $request->valid($vTopic)) {
142 if (isset($ret) && $ret) {
143 // wait few seconds before redirecting to archives page
144 echo "<script> setTimeout('window.location=\"/plugins/forumml/message.php?group_id=".$group_id."&list=".$list_id."&topic=".$topic."\"',3000) </script>";
148 $list_link = '<a href="/plugins/forumml/message.php?group_id='.$group_id.'&list='.$list_id.'">'.$list_name.'</a>';
149 $title = _('Mailing List').' '.$list_link;
151 $fmlMessageMgr = new ForumML_MessageManager();
152 $value = $fmlMessageMgr->getHeaderValue($topic, FORUMML_SUBJECT);
157 $title .= ' ' . _('Archives');
159 echo '<h2>'.$title.'</h2>';
161 if (! $request->exist('pv') || ($request->exist('pv') && $request->get('pv') == 0)) {
162 echo "<table border='0' width='100%'>
165 echo "<td align='left'>";
167 echo '[<a href="/plugins/forumml/message.php?group_id='.$group_id.'&list='.$list_id.'">'._('Back to the list').'</a>] ';
169 echo " [<a href='/plugins/forumml/index.php?group_id=".$group_id."&list=".$list_id."'>
170 "._('Post a new thread')."
172 if ($list->isPublic()==1) {
173 echo ' [<A HREF="'.util_make_url('/pipermail/'.$list->getName()).'/">'._('Original Archives').'</A>]';
175 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>]';
182 (<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'>
183 <img src='".$p->getThemePath()."/images/ic/msg.png' border='0'> "._('Printer version')."
190 $vSrch = new Valid_String('search');
192 if (! $request->valid($vSrch)) {
193 // Check if there are archives to browse
194 $res = getForumMLDao()->hasArchives($list_id);
195 if ($res->rowCount() > 0) {
196 // Call to show_thread() function to display the archives
197 if (isset($topic) && $topic != 0) {
199 plugin_forumml_show_thread($p, $list_id, $topic, $purgeCache);
201 plugin_forumml_show_all_threads($p,$list_id,$list_name,$offset);
204 echo "<h2>"._('Empty archives')."</h2>";
208 $pattern = "%".$request->get('search')."%";
209 $result = getForumMLDao()->searchArchives($list_id,$pattern);
210 echo "<h3>"._('Search result for ').$request->get('search')." (".$result->rowCount()." "._('Thread(s) found').")</h3>";
211 if ($result->rowCount() > 0) {
212 plugin_forumml_show_search_results($p,$result,$group_id,$list_id);
216 mail_footer($params);
219 header('Location: '.get_server_url());