5 * Copyright 1999-2001, Tim Perdue - Sourceforge
6 * Copyright 2002, Tim Perdue - GForge, LLC
7 * Copyright 2010 (c) Franck Villaume - Capgemini
8 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once('../env.inc.php');
28 require_once $gfcommon.'include/pre.php';
29 require_once $gfcommon.'forum/ForumHTML.class.php';
30 require_once $gfcommon.'forum/AttachManager.class.php';
31 require_once $gfcommon.'forum/Forum.class.php';
32 require_once $gfcommon.'forum/ForumFactory.class.php';
33 require_once $gfcommon.'forum/ForumMessageFactory.class.php';
34 require_once $gfcommon.'forum/ForumMessage.class.php';
36 $msg_id = getIntFromRequest('msg_id');
37 $total_rows = getIntFromRequest('total_rows');
38 $ret_val = getIntFromRequest('ret_val');
39 $reply = getIntFromRequest('reply', 1);
44 Figure out which group this message is in, for the sake of the admin links
46 $result=db_query_params ('SELECT forum_group_list.group_id,forum_group_list.group_forum_id
47 FROM forum_group_list,forum
48 WHERE forum_group_list.group_forum_id=forum.group_forum_id
52 if (!$result || db_numrows($result) < 1) {
56 exit_error(_('This message does not (any longer) exist'),'forums');
59 $group_id=db_result($result,0,'group_id');
60 $forum_id=db_result($result,0,'group_forum_id');
63 // Set up local objects
65 $g = group_get_object($group_id);
66 if (!$g || !is_object($g) || $g->isError()) {
70 $f=new Forum($g,$forum_id);
71 if (!$f || !is_object($f)) {
72 exit_error(_('Error getting new Forum'),'forums');
73 } elseif ($f->isError()) {
74 if ($f->isPermissionDeniedError()) {
75 exit_permission_denied();
77 exit_error($f->getErrorMessage(),'forums');
80 $fm=new ForumMessage($f,$msg_id);
81 if (!$fm || !is_object($fm)) {
82 exit_error(_('Error getting new ForumMessage'),'forums');
83 } elseif ($fm->isError()) {
84 exit_error($fm->getErrorMessage(),'forums');
87 $fmf = new ForumMessageFactory($f);
88 if (!$fmf || !is_object($fmf)) {
89 exit_error(_('Error getting new ForumMessageFactory'),'forums');
90 } elseif ($fmf->isError()) {
91 exit_error($fmf->getErrorMessage(),'forums');
94 $fmf->setUp(0,'threaded',200,'');
95 $style=$fmf->getStyle();
96 $max_rows=$fmf->max_rows;
99 $fh = new ForumHTML($f);
100 if (!$fh || !is_object($fh)) {
101 exit_error(_('Error getting new ForumHTML'),'forums');
102 } elseif ($fh->isError()) {
103 exit_error($fh->getErrorMessage(),'forums');
107 session_require_perm ('forum', $f->getID(), 'post') ;
110 forum_header(array('title'=>$fm->getSubject(),'forum_id'=>$forum_id));
112 // $title_arr=array();
113 // $title_arr[]=_('Message').': '.$msg_id;
115 // echo $GLOBALS['HTML']->listTableTop ($title_arr);
117 $url = util_make_url('/forum/message.php?msg_id='. $msg_id .'&group_id='.$group_id);
119 echo '<br /><table border="0" width="100%" cellspacing="0">';
120 echo '<tr class="tablecontent"><td valign="top">'."\n";
121 echo '<strong>'.$fm->getSubject() .'</strong>';
123 echo ' <a href="'.$url.'&reply=1">[ '._("reply").' ]</a>';
126 echo _("By:").' '. util_make_link_u($fm->getPosterName(), $fm->getPosterID(), $fm->getPosterRealName());
127 echo ' on '. date(_('Y-m-d H:i'), $fm->getPostDate()) .'</td><td align="right">';
128 echo '<a href="'.$url.'">[forum:'.$msg_id.']</a><br/>';
129 $fa = new ForumAdmin($f->Group->getID());
130 if (forge_check_perm ('forum_admin', $f->Group->getID())) {
131 echo $fa->PrintAdminMessageOptions($msg_id,$group_id,0,$forum_id); // 0 in thread id because that tells us to go back to message.php instead of forum.php
133 $am = new AttachManager();
134 echo $am->PrintHelperFunctions();
135 echo $am->PrintAttachLink($fm,$group_id,$forum_id) . '</td></tr><tr><td colspan="2"><br/><br />';
138 if (strpos($fm->getBody(), '>') === false) {
139 echo util_make_links(nl2br($fm->getBody())); //backwards compatibility for non html messages
141 echo util_make_links($fm->getBody());
143 echo '</td></tr></table>';
145 // echo $GLOBALS['HTML']->listTableBottom();
152 echo '<h2>'._('Thread View').'</h2>';
154 $msg_arr = $fmf->nestArray($fmf->getThreaded($fm->getThreadID()));
155 if ($fmf->isError()) {
156 echo $fmf->getErrorMessage();
160 $title_arr[]=_('Thread');
161 $title_arr[]=_('Author');
162 $title_arr[]=_('Date');
164 $ret_val = $GLOBALS['HTML']->listTableTop ($title_arr);
166 $rows=count($msg_arr[0]);
168 if ($rows > $max_rows) {
172 $current_message=$msg_id;
174 while (($i < $rows) && ($total_rows < $max_rows)) {
175 $msg =& $msg_arr["0"][$i];
178 if ($fm->getID() != $msg->getID()) {
179 $ah_begin='<a href="'.util_make_url ('/forum/message.php?msg_id='.$msg->getID().
180 '&group_id='.$group_id).'">';
186 $ret_val .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($total_rows) .'>
188 html_image('ic/msg.png').' ';
190 See if this message is new or not
191 If so, highlite it in bold
195 if ($f->getSavedDate() < $msg->getPostDate()) {
196 $bold_begin = '<strong>';
197 $bold_end = '</strong>';
200 show the subject and poster
202 $ret_val .= $bold_begin . $msg->getSubject() . $bold_end.$ah_end.'</td>'.
203 '<td><a href="/users/'.$msg->getPosterName().'">'. $msg->getPosterRealName() .'</a></td>'.
204 '<td>'. date(_('Y-m-d H:i'),$msg->getPostDate()) .'</td></tr>';
206 if ($msg->hasFollowups()) {
207 $ret_val .= $fh->showSubmessages($msg_arr,$msg->getID(),1);
212 $ret_val .= $GLOBALS['HTML']->listTableBottom();
218 Show post followup form
220 echo '<h3>'._('Post a followup to this message').'</h3>';
221 $fh->showPostForm($fm->getThreadID(), $msg_id, $fm->getSubject());
225 forum_header(array('title'=>_('You Must Choose a Message First')));
226 echo '<p class="error">'._('You Must Choose a Message First').'</p>';
230 forum_footer(array());