3 * Copyright (c) STMicroelectronics, 2005. All Rights Reserved.
4 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
6 * Originally written by Jean-Philippe Giola, 2005
8 * This file is a part of codendi.
10 * codendi is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * codendi is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * ForumML New Thread submission form
31 require_once 'env.inc.php';
32 require_once 'pre.php';
33 require_once 'preplugins.php';
34 require_once 'forumml_utils.php';
35 require_once 'mailman/www/mailman_utils.php';
36 require_once 'mailman/include/MailmanList.class.php';
37 //require_once('common/plugin/PluginManager.class.php');
38 require_once(dirname(__FILE__).'/../include/ForumML_FileStorage.class.php');
39 require_once(dirname(__FILE__).'/../include/ForumML_HTMLPurifier.class.php');
41 $plugin_manager =& PluginManager::instance();
42 $p =& $plugin_manager->getPluginByName('forumml');
43 if ($p && $plugin_manager->isPluginAvailable($p) && $p->isAllowed()) {
45 $request =& HTTPRequest::instance();
47 if ($request->valid(new Valid_UInt('group_id'))) {
48 $group_id = $request->get('group_id');
53 // Checks 'list' parameter
54 if (! $request->valid(new Valid_UInt('list'))) {
55 exit_error(_('Error'),_('No list specified'));
57 $list_id = $request->get('list');
58 $list = new MailmanList($group_id,$list_id);
59 if (!isLogged() || ($list->isPublic()!=1 && !$current_user->isMember($group_id))) {
60 exit_error(_('error'),_('You are not allowed to access this page'));
62 if ($list->getStatus() !=3) {
63 exit_error(_('Error'),_('The mailing list does not exist or is inactive'));
67 // If message is posted, send a mail
68 if ($request->isPost() && $request->get('post')) {
69 // Checks if mail subject is empty
70 $vSub = new Valid_String('subject');
72 if (! $request->valid($vSub)) {
73 $feedback .=_('Submit failed you must specify the mail subject.');
76 $return = plugin_forumml_process_mail($p);
78 $feedback .=_('There can be some delay before to see the message in the archives.')._(' Redirecting to archive page, please wait ...');
79 //htmlRedirect('/plugins/forumml/message.php?'. http_build_query(array(
80 // 'group_id' => $group_id,
81 // 'list' => $list_id,
88 $params['title'] = 'ForumML';
89 $params['group'] = $group_id;
90 $params['toptab'] = 'mail';
91 $params['help'] = "CommunicationServices.html#MailingLists";
92 mailman_header($params);
94 if ($request->isPost() && $request->get('post') && $request->valid($vSub)) {
95 if (isset($return) && $return) {
96 // wait few seconds before redirecting to archives page
97 echo "<script> setTimeout('window.location=\"/plugins/forumml/message.php?group_id=".$group_id."&list=".$list_id."\"',3000) </script>";
101 $list_link = '<a href="/plugins/forumml/message.php?group_id='.$group_id.'&list='.$list_id.'">'.$list->getName().'</a>';
102 echo '<h2>'._('Mailing List ').$list_link.' - '._('New Thread').'</h2>
103 <a href="/plugins/forumml/message.php?group_id='.$group_id.'&list='.$list_id.'">['._('Browse Archives').']</a><br><br>
104 <h3>'._('Submit a new thread').'</h3>';
107 echo '<script type="text/javascript" src="scripts/cc_attach_js.php"></script>';
108 echo "<form name='form' method='post' enctype='multipart/form-data'>
111 <td valign='top' align='left'><b> "._('Subject').": </b></td>
112 <td align='left'><input type=text name='subject' size='80'></td>
117 <p><a href="javascript:;" onclick="addHeader(\'\',\'\',1);">['.('Add cc').']</a>
118 - <a href="javascript:;" onclick="addHeader(\'\',\'\',2);">['._('Attach :').']</a></p>
119 <input type="hidden" value="0" id="header_val" />
120 <div id="mail_header"></div></td></tr></table>';
122 <td valign='top' align='left'><b>"._('Message :')." </b></td>
123 <td align='left'><textarea rows='20' cols='100' name='message'></textarea></td>
127 <td><input type='submit' name='post' value='"._('Submit')."'>
128 <input type='reset' value='"._('Erase')."'></td>
132 mail_footer($params);
135 header('Location: '.get_server_url());