3 * Copyright (c) STMicroelectronics, 2005. All Rights Reserved.
5 * Originally written by Jean-Philippe Giola, 2005
7 * This file is a part of codendi.
9 * codendi 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 * codendi 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
20 * along with codendi; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * ForumML New Thread submission form
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');
40 $plugin_manager =& PluginManager::instance();
41 $p =& $plugin_manager->getPluginByName('forumml');
42 if ($p && $plugin_manager->isPluginAvailable($p) && $p->isAllowed()) {
44 $request =& HTTPRequest::instance();
46 if ($request->valid(new Valid_UInt('group_id'))) {
47 $group_id = $request->get('group_id');
52 // Checks 'list' parameter
53 if (! $request->valid(new Valid_UInt('list'))) {
54 exit_error(_('Error'),_('No list specified'));
56 $list_id = $request->get('list');
57 $list = new MailmanList($group_id,$list_id);
58 if (!isLogged() || ($list->isPublic()!=1 && !$current_user->isMember($group_id))) {
59 exit_error(_('error'),_('You are not allowed to access this page'));
61 if ($list->getStatus() !=3) {
62 exit_error(_('Error'),_('The mailing list does not exist or is inactive'));
66 // If message is posted, send a mail
67 if ($request->isPost() && $request->get('post')) {
68 // Checks if mail subject is empty
69 $vSub = new Valid_String('subject');
71 if (! $request->valid($vSub)) {
72 $feedback .=_('Submit failed you must specify the mail subject.');
75 $return = plugin_forumml_process_mail($p);
77 $feedback .=_('There can be some delay before to see the message in the archives.')._(' Redirecting to archive page, please wait ...');
78 //htmlRedirect('/plugins/forumml/message.php?'. http_build_query(array(
79 // 'group_id' => $group_id,
80 // 'list' => $list_id,
87 $params['title'] = 'ForumML';
88 $params['group'] = $group_id;
89 $params['toptab'] = 'mail';
90 $params['help'] = "CommunicationServices.html#MailingLists";
91 mailman_header($params);
93 if ($request->isPost() && $request->get('post') && $request->valid($vSub)) {
94 if (isset($return) && $return) {
95 // wait few seconds before redirecting to archives page
96 echo "<script> setTimeout('window.location=\"/plugins/forumml/message.php?group_id=".$group_id."&list=".$list_id."\"',3000) </script>";
100 $list_link = '<a href="/plugins/forumml/message.php?group_id='.$group_id.'&list='.$list_id.'">'.$list->getName().'</a>';
101 echo '<H2><b>'._('Mailing List ').$list_link._(' - New Thread').'</b></H2>
102 <a href="/plugins/forumml/message.php?group_id='.$group_id.'&list='.$list_id.'">['._('Browse Archives').']</a><br><br>
103 <H3><b>'._('Submit a new thread').'</b></H3>';
106 echo '<script type="text/javascript" src="scripts/cc_attach_js.php"></script>';
107 echo "<form name='form' method='post' enctype='multipart/form-data'>
110 <td valign='top' align='left'><b> "._('Subject').": </b></td>
111 <td align='left'><input type=text name='subject' size='80'></td>
116 <p><a href="javascript:;" onclick="addHeader(\'\',\'\',1);">['.('Add cc').']</a>
117 - <a href="javascript:;" onclick="addHeader(\'\',\'\',2);">['._('Attach :').']</a></p>
118 <input type="hidden" value="0" id="header_val" />
119 <div id="mail_header"></div></td></tr></table>';
121 <td valign='top' align='left'><b>"._('Message :')." </b></td>
122 <td align='left'><textarea rows='20' cols='100' name='message'></textarea></td>
126 <td><input type='submit' name='post' value='"._('Submit')."'>
127 <input type='reset' value='"._('Erase')."'></td>
131 mail_footer($params);
134 header('Location: '.get_server_url());