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';
38 $msg_id = getIntFromRequest('msg_id');
39 $total_rows = getIntFromRequest('total_rows');
40 $ret_val = getIntFromRequest('ret_val');
41 $reply = getIntFromRequest('reply', 1);
46 Figure out which group this message is in, for the sake of the admin links
48 $result=db_query_params ('SELECT forum_group_list.group_id,forum_group_list.group_forum_id
49 FROM forum_group_list,forum
50 WHERE forum_group_list.group_forum_id=forum.group_forum_id
54 if (!$result || db_numrows($result) < 1) {
58 exit_error(_('This message does not (any longer) exist'),'forums');
61 $group_id=db_result($result,0,'group_id');
62 $forum_id=db_result($result,0,'group_forum_id');
65 // Set up local objects
67 $g = group_get_object($group_id);
68 if (!$g || !is_object($g) || $g->isError()) {
72 $f=new Forum($g,$forum_id);
73 if (!$f || !is_object($f)) {
74 exit_error(_('Error getting new Forum'),'forums');
75 } elseif ($f->isError()) {
76 if ($f->isPermissionDeniedError()) {
77 exit_permission_denied();
79 exit_error($f->getErrorMessage(),'forums');
82 $fm=new ForumMessage($f,$msg_id);
83 if (!$fm || !is_object($fm)) {
84 exit_error(_('Error getting new forum message'),'forums');
85 } elseif ($fm->isError()) {
86 exit_error($fm->getErrorMessage(),'forums');
89 $fmf = new ForumMessageFactory($f);
90 if (!$fmf || !is_object($fmf)) {
91 exit_error(_('Error getting new ForumMessageFactory'),'forums');
92 } elseif ($fmf->isError()) {
93 exit_error($fmf->getErrorMessage(),'forums');
96 $fmf->setup(0,'threaded',200,'');
97 $style=$fmf->getStyle();
98 $max_rows=$fmf->max_rows;
101 $fh = new ForumHTML($f);
102 if (!$fh || !is_object($fh)) {
103 exit_error(_('Error getting new ForumHTML'),'forums');
104 } elseif ($fh->isError()) {
105 exit_error($fh->getErrorMessage(),'forums');
109 session_require_perm ('forum', $f->getID(), 'post') ;
112 forum_header(array('title'=>$fm->getSubject(),'forum_id'=>$forum_id));
114 // $title_arr=array();
115 // $title_arr[]=_('Message')._(': ').$msg_id;
117 // echo $GLOBALS['HTML']->listTableTop($title_arr);
119 $url = util_make_url('/forum/message.php?msg_id='. $msg_id .'&group_id='.$group_id);
121 echo '<br /><br /><table class="fullwidth">';
122 echo '<tr class="tablecontent"><td class="top">'."\n";
123 echo '<strong>'.$fm->getSubject() .'</strong>';
125 echo ' <a href="'.$url.'&reply=1">[ '._("Reply").' ]</a>';
128 echo _("By")._(': '). util_make_link_u($fm->getPosterName(), $fm->getPosterID(), $fm->getPosterRealName());
129 echo ' on '. date(_('Y-m-d H:i'), $fm->getPostDate()) .'</td><td class="align-right">';
130 echo '<a href="'.$url.'">[forum:'.$msg_id.']</a><br/>';
131 $fa = new ForumAdmin($f->Group->getID());
132 if (forge_check_perm('forum_admin', $f->Group->getID())) {
133 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
135 $am = new AttachManager();
136 echo $am->PrintHelperFunctions();
137 echo $am->PrintAttachLink($fm,$group_id,$forum_id) . '</td></tr><tr><td colspan="2"><br/><br />';
139 if (strpos($fm->getBody(), '>') === false) {
140 echo util_make_links(nl2br($fm->getBody())); //backwards compatibility for non html messages
142 echo util_make_links($fm->getBody());
144 echo '</td></tr></table>';
146 // echo $GLOBALS['HTML']->listTableBottom();
153 echo '<h2>'._('Thread View').'</h2>';
155 $msg_arr = $fmf->nestArray($fmf->getThreaded($fm->getThreadID()));
156 if ($fmf->isError()) {
157 echo $fmf->getErrorMessage();
161 $title_arr[]=_('Thread');
162 $title_arr[]=_('Author');
163 $title_arr[]=_('Date');
165 $ret_val = $HTML->listTableTop($title_arr);
167 $rows=count($msg_arr[0]);
169 if ($rows > $max_rows) {
173 $current_message=$msg_id;
175 while (($i < $rows) && ($total_rows < $max_rows)) {
176 $msg =& $msg_arr["0"][$i];
179 if ($fm->getID() != $msg->getID()) {
180 $ah_begin='<a href="'.util_make_url ('/forum/message.php?msg_id='.$msg->getID().
181 '&group_id='.$group_id).'">';
189 html_image('ic/msg.png').' ';
191 See if this message is new or not
192 If so, highlite it in bold
196 if ($f->getSavedDate() < $msg->getPostDate()) {
197 $bold_begin = '<strong>';
198 $bold_end = '</strong>';
201 show the subject and poster
203 $ret_val .= $bold_begin . $msg->getSubject() . $bold_end.$ah_end.'</td>'.
204 '<td>'. util_display_user($msg->getPosterName(), $msg->getPosterID(), $msg->getPosterRealName()).'</td>'.
205 '<td>'. relative_date($msg->getPostDate()) .'</td></tr>';
207 if ($msg->hasFollowups()) {
208 $ret_val .= $fh->showSubmessages($msg_arr,$msg->getID(),1);
213 $ret_val .= $HTML->listTableBottom();
219 Show post comment form
221 echo '<h3>'._('Post a comment to this message').'</h3>';
222 $fh->showPostForm($fm->getThreadID(), $msg_id, $fm->getSubject());
226 forum_header(array('title'=>_('You Must Choose a Message First')));
227 echo $HTML->error_msg(_('You Must Choose a Message First'));