3 * GForge Forums Facility
5 * Copyright 2002 GForge, LLC
14 By Tim Perdue, Sourceforge, 11/99
16 Massive rewrite by Tim Perdue 7/2000 (nested/views/save)
18 Complete OO rewrite by Tim Perdue 12/2002
21 require_once('../env.inc.php');
22 require_once('pre.php');
23 require_once('www/forum/include/ForumHTML.class');
24 require_once('www/forum/include/AttachManager.class');
25 require_once('common/forum/Forum.class');
26 require_once('common/forum/ForumFactory.class');
27 require_once('common/forum/ForumMessageFactory.class');
28 require_once('common/forum/ForumMessage.class');
30 $msg_id = getIntFromRequest('msg_id');
31 $total_rows = getIntFromRequest('total_rows');
32 $ret_val = getIntFromRequest('ret_val');
36 Figure out which group this message is in, for the sake of the admin links
38 $result=db_query("SELECT forum_group_list.group_id,forum_group_list.group_forum_id
39 FROM forum_group_list,forum
40 WHERE forum_group_list.group_forum_id=forum.group_forum_id
41 AND forum.msg_id='$msg_id'");
43 if (!$result || db_numrows($result) < 1) {
47 exit_error(_('Message Not Found'),
48 _('This message does not (any longer) exist'));
51 $group_id=db_result($result,0,'group_id');
52 $forum_id=db_result($result,0,'group_forum_id');
55 // Set up local objects
57 $g =& group_get_object($group_id);
58 if (!$g || !is_object($g) || $g->isError()) {
62 $f=new Forum($g,$forum_id);
63 if (!$f || !is_object($f)) {
64 exit_error(_('Error'),_('Error'));
65 } elseif ($f->isError()) {
66 exit_error(_('Error'),$f->getErrorMessage());
69 $fm=new ForumMessage($f,$msg_id);
70 if (!$fm || !is_object($fm)) {
71 exit_error(_('Error'),_('Error'));
72 } elseif ($fm->isError()) {
73 exit_error(_('Error'),$fm->getErrorMessage());
76 $fmf = new ForumMessageFactory($f);
77 if (!$fmf || !is_object($fmf)) {
78 exit_error(_('Error'),_('Error'));
79 } elseif ($fmf->isError()) {
80 exit_error(_('Error'),$fmf->getErrorMessage());
83 $fmf->setUp(0,'threaded',200,'');
84 $style=$fmf->getStyle();
85 $max_rows=$fmf->max_rows;
88 $fh = new ForumHTML($f);
89 if (!$fh || !is_object($fh)) {
90 exit_error(_('Error'),_('Error'));
91 } elseif ($fh->isError()) {
92 exit_error(_('Error'),$fh->getErrorMessage());
95 forum_header(array('title'=>db_result($result,0,'subject'),'forum_id'=>$forum_id));
98 $title_arr[]=_('Message').': '.$msg_id;
100 echo $GLOBALS['HTML']->listTableTop ($title_arr);
102 echo "<tr class=\"tablecontent\"><td>\n";
103 $fa = new ForumAdmin();
104 if ($f->userIsAdmin()) {
105 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
107 echo _('BY').': '. $fm->getPosterRealName() .' (<a href="'.$GLOBALS['sys_urlprefix'].'/users/'.$fm->getPosterName().'/">'. $fm->getPosterName() .'</a>)<br />';
108 echo _('DATE').': '. date($sys_datefmt, $fm->getPostDate()) .'<br />';
109 $am = new AttachManager();
110 echo $am->PrintHelperFunctions();
111 echo $am->PrintAttachLink($fm,$group_id,$forum_id) . '<br/>';
113 echo _('SUBJECT').': '. $fm->getSubject() .'<p> </p>';
115 if (!strstr('<',$fm->getBody())) {
116 echo nl2br($fm->getBody()); //backwards compatibility for non html messages
122 echo $GLOBALS['HTML']->listTableBottom();
130 <h3>'._('Thread View').'</h3>';
132 $msg_arr =& $fmf->nestArray($fmf->getThreaded($fm->getThreadID()));
133 if ($fmf->isError()) {
134 echo $fmf->getErrorMessage();
138 $title_arr[]=_('Thread');
139 $title_arr[]=_('Author');
140 $title_arr[]=_('Date');
142 $ret_val = $GLOBALS['HTML']->listTableTop ($title_arr);
144 $rows=count($msg_arr[0]);
146 if ($rows > $max_rows) {
150 $current_message=$msg_id;
152 while (($i < $rows) && ($total_rows < $max_rows)) {
153 $msg =& $msg_arr["0"][$i];
157 if ($fm->getID() != $msg->getID()) {
158 $ah_begin='<a href="'.$GLOBALS['sys_urlprefix'].'/forum/message.php?msg_id='.$msg->getID().
159 '&group_id='.$group_id.'">';
165 $ret_val .= '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($total_rows) .'>
167 html_image('ic/msg.png',"10","12",array("border"=>"0"));
169 See if this message is new or not
170 If so, highlite it in bold
174 if ($f->getSavedDate() < $msg->getPostDate()) {
175 $bold_begin = '<strong>';
176 $bold_end = '</strong>';
179 show the subject and poster
181 $ret_val .= $bold_begin . $msg->getSubject() . $bold_end.$ah_end.'</td>'.
182 '<td>'. $msg->getPosterRealName() .'</td>'.
183 '<td>'. date($sys_datefmt,$msg->getPostDate()) .'</td></tr>';
185 if ($msg->hasFollowups()) {
186 $ret_val .= $fh->showSubmessages($msg_arr,$msg->getID(),1);
191 $ret_val .= $GLOBALS['HTML']->listTableBottom();
196 Show post followup form
199 // echo '<p> <p>';
200 echo '<div align="center"><h3>'._('Post a followup to this message').'</h3></div>';
202 $fh->showPostForm($fm->getThreadID(), $msg_id, $fm->getSubject());
205 forum_header(array('title'=>_('Must Choose A Message First')));
206 echo '<h1>'._('You Must Choose A Message First').'</h1>';
210 forum_footer(array());