00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: forum.php 5439 2006-02-19 13:00:17Z toddy $
00006 #
00007 # Copyright 1999-2000 (c) The SourceForge Crew
00008 # Copyright 2000-2003 (c) Free Software Foundation
00009 #
00010 # Copyright 2004-2005 (c) Mathieu Roy <yeupou--gnu.org>.
00011 #
00012 # The Savane project is free software; you can redistribute it and/or
00013 # modify it under the terms of the GNU General Public License
00014 # as published by the Free Software Foundation; either version 2
00015 # of the License, or (at your option) any later version.
00016 #
00017 # The Savane project is distributed in the hope that it will be useful,
00018 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 # GNU General Public License for more details.
00021 #
00022 # You should have received a copy of the GNU General Public License
00023 # along with the Savane project; if not, write to the Free Software
00024 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00025
00026 function forum_show_a_nested_message ($result,$row=0)
00027 {
00028
00029
00030
00031
00032
00033
00034
00035
00036 global $sys_datefmt;
00037
00038 $g_id = db_result($result,$row,'group_id');
00039
00040 # if the forum is a piece of news then get the real group_id from the
00041 # news_byte table
00042 if ($g_id == $GLOBALS['sys_group_id'])
00043 {
00044 $f_id = db_result($result,$row,'group_forum_id');
00045 $gr = db_query("SELECT group_id FROM news_bytes WHERE forum_id='$f_id'");
00046 $g_id = db_result($gr,0,'group_id');
00047 }
00048
00049 $ret_val = '
00050 <table border="0" width="100%">
00051 <tr>
00052 <td class="boxitem">'.
00053 '<strong>'.db_result($result, $row, 'subject').'</strong>'.
00054 ' ('._("posted by").' <a href="'.$GLOBALS['sys_home'].'users/'.
00055 db_result($result, $row, 'user_name') .'/">'.
00056 db_result($result, $row, 'realname') .'</a>, '.
00057 format_date($sys_datefmt,db_result($result,$row,'date')).')'.
00058 ' </td>
00059 </tr><tr>
00060 <td>
00061 '. utils_rich_markup(db_result($result,$row,'body')) .
00062 ' <p><a href="'.$GLOBALS['sys_home'].'forum/message.php?msg_id='.db_result($result, $row, 'msg_id') .'#followup">[ '._("Reply").' ]</a>'.
00063 ' </p></td>
00064 </tr>
00065 </table>';
00066 return $ret_val;
00067 }
00068
00069 function forum_show_nested_messages ($thread_id, $msg_id) {
00070 global $total_rows,$sys_datefmt;
00071
00072 $sql="SELECT user.user_name,forum.has_followups,user.realname,user.user_id,forum.msg_id,forum.group_forum_id,forum.subject,forum.thread_id,forum.body,forum.date,forum.is_followup_to, forum_group_list.group_id ".
00073 "FROM forum,user,forum_group_list WHERE forum.thread_id='$thread_id' AND user.user_id=forum.posted_by AND forum.is_followup_to='$msg_id' AND forum_group_list.group_forum_id = forum.group_forum_id ".
00074 "ORDER BY forum.date ASC;";
00075
00076 $result=db_query($sql);
00077 $rows=db_numrows($result);
00078
00079 $ret_val='';
00080
00081 if ($result && $rows > 0)
00082 {
00083 $ret_val .= '
00084 <UL>';
00085
00086
00087
00088
00089
00090
00091
00092
00093 for ($i=0; $i<$rows; $i++)
00094 {
00095 # increment the global total count
00096 $total_rows++;
00097
00098 # show the actual nested message
00099 $ret_val .= forum_show_a_nested_message ($result,$i).'<P>';
00100 if (db_result($result,$i,'has_followups') > 0)
00101 {
00102 # Call yourself if there are followups
00103 $ret_val .= forum_show_nested_messages ( $thread_id, db_result($result,$i,'msg_id') );
00104 }
00105 }
00106 $ret_val .= '
00107 </UL>';
00108 }
00109
00110 return $ret_val;
00111 }
00112
00113 # FIXME: site_project_header function should be used instead
00114 function forum_header($params)
00115 {
00116 global $DOCUMENT_ROOT,$HTML,$group_id,$forum_name,$thread_id,$msg_id,$forum_id,$REQUEST_URI,$sys_datefmt,$et,$et_cookie;
00117
00118 $params['group']=$group_id;
00119 $params['toptab']='forum';
00120
00121 # NEWS ADMIN
00122 #this is a news item for the whole system or a for a project,
00123 # not a regular forum: forum are deactivated in savannah
00124 if ($forum_id)
00125 {
00126 # Show this news item at the top of the page
00127 $sql="SELECT * FROM news_bytes WHERE forum_id='$forum_id'";
00128 $result=db_query($sql);
00129
00130 # if the result is empty, this is not a news item, but a forum.
00131 if (!$result || db_numrows($result) < 1)
00132 {
00133 $is_news=0;
00134 #print '<span class="error">'._("Error").' - '._("This news item was not found").'</span>';
00135 #print "forum_name=$forum_name<br />";
00136 site_project_header($params);
00137 #site_project_header(array('group'=>$group_id,'context'=>'forum'));
00138
00139 }
00140 else
00141 {
00142 $is_news=1;
00143 #backwards shim for all "generic news" that used to be submitted
00144 #as of may, "generic news" is not permitted - only project-specific news
00145
00146 # FIXME: group_name is not set, it brokes the top menu.
00147
00148 $params['group']=db_result($result,0,'group_id');
00149
00150 $group_id = db_result($result,0,'group_id');
00151 $params['toptab']='news';
00152 site_project_header($params);
00153
00154 print '
00155 <div class="indexright">
00156 ';
00157 print $HTML->box_top(_("Latest News"));
00158 print news_show_latest(db_result($result,0,'group_id'),5, "false");
00159 print $HTML->box_bottom();
00160 print '</div>
00161 <div class="indexcenter">
00162 ';
00163
00164 print '<h3>'.html_anchor(db_result($result,0,'summary'), "content").'</h3>';
00165 print '<p><em>'.sprintf(_("Item posted by %s on %s."),
00166 utils_user_link(user_getname(db_result($result,0,'submitted_by')),
00167 user_getrealname(db_result($result,0,'submitted_by'))),
00168 format_date($sys_datefmt,db_result($result,0,'date')))
00169 .'</em></p>';
00170 print utils_rich_markup(db_result($result,0,'details'));
00171
00172 # could this fix the bug #409 ?
00173 $forum_name = db_result($result,0,'summary');
00174 print '</div>
00175 ';
00176
00177 }
00178 }
00179
00180
00181
00182
00183
00184 if ($forum_id && $forum_name && $is_news)
00185 {
00186 print '<h3 class="clearr">'.html_anchor(_("Comments:"), "comments").'</h3>';
00187 }
00188 print '<P><strong>';
00189
00190 if ($forum_id && user_isloggedin())
00191 {
00192 print '<a href="'.$GLOBALS['sys_home'].'forum/monitor.php?forum_id='.$forum_id.'">' .
00193 #'<img src="'.$GLOBALS['sys_home'].'images/ic/check.png" alt="monitor" />
00194 _("Monitor Forum (toggle)").'</a> | '.
00195 '<a href="'.$GLOBALS['sys_home'].'forum/save.php?forum_id='.$forum_id.'">'.
00196 #'<img src="'.$GLOBALS['sys_home'].'images/ic/save.png" alt="save" />
00197 _("Save Place").'</a> | '.
00198 '<A HREF="'.$GLOBALS['sys_home'].'forum/who_monitors.php?forum_id='.$forum_id.'?group_id='.$group_id.'">'.
00199 'Who\'s monitoring</A> | '.
00200 '<A HREF="'.$GLOBALS['sys_home'].'forum/forum.php?forum_id='.$forum_id.'">'.
00201 'View Forum</A>';
00202 }
00203
00204
00205
00206
00207
00208
00209
00210 print '</P>';
00211 }
00212
00213 # Backward compatibility
00214 function forum_footer($params){
00215 site_project_footer($params);
00216 }
00217
00218 function forum_create_forum($group_id,$forum_name,$is_public=1,$create_default_message=1,$description='')
00219 {
00220 global $feedback;
00221
00222
00223
00224 $sql="INSERT INTO forum_group_list (group_id,forum_name,is_public,description) ".
00225 "VALUES ('$group_id','". htmlspecialchars($forum_name) ."','$is_public','". htmlspecialchars($description) ."')";
00226
00227 $result=db_query($sql);
00228 if (!$result)
00229 {
00230 " Error Adding Forum ";
00231 }
00232 else
00233 {
00234 " Forum Added ";
00235 }
00236 $forum_id=db_insertid($result);
00237
00238 if ($create_default_message)
00239 {
00240 #set up a cheap default message
00241 $result2=db_query("INSERT INTO forum ".
00242 "(group_forum_id,posted_by,subject,body,date,is_followup_to,thread_id) ".
00243 "VALUES ('$forum_id','100','Welcome to $forum_name',".
00244 "'Welcome to $forum_name','".time()."','0','".get_next_thread_id()."')");
00245 }
00246 return $forum_id;
00247 }
00248
00249 function get_forum_name($id){
00250
00251
00252
00253 $sql="SELECT forum_name FROM forum_group_list WHERE group_forum_id='$id'";
00254 $result=db_query($sql);
00255 if (!$result || db_numrows($result) < 1)
00256 {
00257 return "Not Found";
00258 }
00259 else
00260 {
00261 return db_result($result, 0, "forum_name");
00262 }
00263
00264 }
00265
00266 function show_thread($thread_id,$et=0)
00267 {
00268
00269
00270
00271
00272
00273 global $total_rows,$sys_datefmt,$is_followup_to,$subject,$forum_id,$current_message;
00274
00275 $sql="SELECT user.user_name,forum.has_followups,forum.msg_id,forum.subject,forum.thread_id,forum.body,forum.date,forum.is_followup_to ".
00276 "FROM forum,user WHERE forum.thread_id='$thread_id' AND user.user_id=forum.posted_by AND forum.is_followup_to='0' ".
00277 "ORDER BY forum.msg_id DESC;";
00278
00279 $result=db_query($sql);
00280
00281 $total_rows=0;
00282
00283 if (!$result || db_numrows($result) < 1)
00284 {
00285 return 'Broken Thread';
00286 }
00287 else
00288 {
00289
00290 $title_arr=array();
00291 $title_arr[]='Thread';
00292 $title_arr[]='Author';
00293 $title_arr[]='Date';
00294
00295 $ret_val .= html_build_list_table_top ($title_arr);
00296
00297 $rows=db_numrows($result);
00298 $is_followup_to=db_result($result, ($rows-1), 'msg_id');
00299 $subject=db_result($result, ($rows-1), 'subject');
00300
00301
00302
00303
00304
00305
00306
00307 for ($i=0; $i<$rows; $i++)
00308 {
00309 $total_rows++;
00310 $ret_val .= '<TR class="'. utils_get_alt_row_color($total_rows) .'"><TD>'.
00311 (($current_message != db_result($result, $i, 'msg_id'))?'<A HREF="'.$GLOBALS['sys_home'].'forum/message.php?msg_id='.db_result($result, $i, 'msg_id').'">':'').
00312 '<IMG SRC="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/mail.png" BORDER=0 HEIGHT=12 WIDTH=12 /> ';
00313
00314
00315
00316 if (get_forum_saved_date($forum_id) < db_result($result,$i,'date'))
00317 { $ret_val .= '<strong>'; }
00318
00319 $ret_val .= db_result($result, $i, 'subject') .'</A></TD>'.
00320 '<TD>'.db_result($result, $i, 'user_name').'</TD>'.
00321 '<TD>'.format_date($sys_datefmt,db_result($result,$i,'date')).'</TD></TR>';
00322
00323
00324
00325 if ($et == 1)
00326 {
00327 $ret_val .= '
00328 <TR class="'. utils_get_alt_row_color($total_rows) .'"><TD> </TD><TD COLSPAN=2>'.
00329 nl2br(db_result($result, $i, 'body')).'</TD><TR>';
00330 }
00331
00332 if (db_result($result,$i,'has_followups') > 0)
00333 {
00334 $ret_val .= show_submessages($thread_id,db_result($result, $i, 'msg_id'),1,$et);
00335 }
00336 }
00337 $ret_val .= '</TABLE>';
00338 }
00339 return $ret_val;
00340 }
00341
00342 function show_submessages($thread_id, $msg_id, $level,$et=0)
00343 {
00344
00345
00346
00347
00348
00349
00350 global $total_rows,$sys_datefmt,$forum_id,$current_message;
00351
00352 $sql="SELECT user.user_name,forum.has_followups,forum.msg_id,forum.subject,forum.thread_id,forum.body,forum.date,forum.is_followup_to ".
00353 "FROM forum,user WHERE forum.thread_id='$thread_id' AND user.user_id=forum.posted_by AND forum.is_followup_to='$msg_id' ".
00354 "ORDER BY forum.msg_id ASC;";
00355
00356 $result=db_query($sql);
00357 $rows=db_numrows($result);
00358
00359 if ($result && $rows > 0) {
00360
00361
00362
00363 for ($i=0; $i<$rows; $i++) {
00364
00365
00366
00367
00368 $total_rows++;
00369
00370 $ret_val .= '<TR class="'. utils_get_alt_row_color($total_rows) .'"><TD NOWRAP>';
00371
00372
00373
00374
00375 for ($i2=0; $i2<$level; $i2++)
00376 {
00377 $ret_val .= ' ';
00378 }
00379
00380
00381 $ret_val .= '<IMG SRC="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/mail.png" BORDER=0 HEIGHT=12 WIDTH=12 /> ';
00382
00383
00384
00385
00386
00387 $ret_val .= (($current_message != db_result($result, $i, 'msg_id'))?
00388 '<A HREF="'.$GLOBALS['sys_home'].'forum/message.php?msg_id='.db_result($result, $i, 'msg_id').'">':'');
00389
00390
00391
00392 if (get_forum_saved_date($forum_id) < db_result($result,$i,'date'))
00393 { $ret_val .= '<strong>'; }
00394
00395 $ret_val .= db_result($result, $i, 'subject').'</A></TD>'.
00396 '<TD>'.db_result($result, $i, 'user_name').'</TD>'.
00397 '<TD>'.format_date($sys_datefmt,db_result($result,$i,'date')).'</TD></TR>';
00398
00399
00400
00401
00402 if ($et == 1)
00403 {
00404 $ret_val .= '
00405 <TR class="'. utils_get_alt_row_color($total_rows) .'"><TD> </TD><TD COLSPAN=2>'.
00406 nl2br(db_result($result, $i, 'body')).'</TD><TR>';
00407 }
00408
00409 if (db_result($result,$i,'has_followups') > 0)
00410 {
00411
00412
00413
00414 $ret_val .= show_submessages($thread_id,db_result($result, $i, 'msg_id'),($level+1),$et);
00415 }
00416 }
00417 }
00418 return $ret_val;
00419 }
00420
00421 function get_next_thread_id()
00422 {
00423
00424
00425
00426 $result=db_query("INSERT INTO forum_thread_id VALUES ('')");
00427
00428 if (!$result)
00429 {
00430 print '<H1>Error!</H1>';
00431 print db_error();
00432 exit;
00433 }
00434 else
00435 {
00436 return db_insertid($result);
00437 }
00438 }
00439
00440 function get_forum_saved_date($forum_id)
00441 {
00442
00443
00444
00445 global $forum_saved_date;
00446
00447
00448 if ($forum_saved_date)
00449 {
00450 return $forum_saved_date;
00451 }
00452 else
00453 {
00454 $sql="SELECT save_date FROM forum_saved_place WHERE user_id='".user_getid()."' AND forum_id='$forum_id';";
00455 $result = db_query($sql);
00456 if ($result && db_numrows($result) > 0)
00457 {
00458 $forum_saved_date=db_result($result,0,'save_date');
00459 return $forum_saved_date;
00460 }
00461 else
00462 {
00463 #highlight new messages from the past week only
00464 $forum_saved_date=(time()-604800);
00465 return $forum_saved_date;
00466 }
00467 }
00468 }
00469
00470 function post_message($thread_id, $is_followup_to, $subject, $body, $group_forum_id)
00471 {
00472 global $feedback;
00473 if (user_isloggedin())
00474 {
00475 if (!$group_forum_id)
00476 {
00477 exit_error('Error',_("Trying to post without a forum ID"));
00478 }
00479 if (!$body || !$subject)
00480 {
00481 exit_error('Error',_("Must include a message body and subject"));
00482 }
00483
00484 #see if that message has been posted already for all the idiots that double-post
00485 $res3=db_query("SELECT * FROM forum ".
00486 "WHERE is_followup_to='$is_followup_to' ".
00487 "AND subject='". htmlspecialchars($subject) ."' ".
00488 "AND group_forum_id='$group_forum_id' ".
00489 "AND posted_by='". user_getid() ."'");
00490
00491 if (db_numrows($res3) > 0)
00492 {
00493 #already posted this message
00494 exit_error('Error',_("You appear to be double-posting this message, since it has the same subject and followup information as a prior post."));
00495 }
00496 else
00497 {
00498 print db_error();
00499 }
00500
00501 if (!$thread_id)
00502 {
00503 $thread_id=get_next_thread_id();
00504 $is_followup_to=0;
00505 }
00506 else
00507 {
00508 if ($is_followup_to)
00509 {
00510 #increment the parent's followup count if necessary
00511 $res2=db_query("SELECT * FROM forum WHERE msg_id='$is_followup_to' AND thread_id='$thread_id' AND group_forum_id='$group_forum_id'");
00512 if (db_numrows($res2) > 0)
00513 {
00514 if (db_result($result,0,'has_followups') > 0)
00515 {
00516 #parent already is marked with followups
00517 }
00518 else
00519 {
00520 #mark the parent with followups as an optimization later
00521 db_query("UPDATE forum SET has_followups='1' WHERE msg_id='$is_followup_to' AND thread_id='$thread_id' AND group_forum_id='$group_forum_id'");
00522 }
00523 }
00524 else
00525 {
00526 exit_error('Error',_("Trying to followup to a message that doesn't exist."));
00527 }
00528 }
00529 else
00530 {
00531 #should never happen except with shoddy browsers or mucking with the HTML form
00532 exit_error('Error',_("No followup ID present when trying to post to an existing thread."));
00533 }
00534 }
00535
00536 $sql="INSERT INTO forum (group_forum_id,posted_by,subject,body,date,is_followup_to,thread_id) ".
00537 "VALUES ('$group_forum_id', '".user_getid()."', '".htmlspecialchars($subject)."', '".htmlspecialchars($body)."', '".time()."','$is_followup_to','$thread_id')";
00538
00539 $result=db_query($sql);
00540
00541 if (!$result)
00542 {
00543 print "INSERT FAILED";
00544 print db_error();
00545 ' '._("Posting Failed").' ';
00546 }
00547 else
00548 {
00549 ' '._("Message Posted").' ';
00550 }
00551
00552 $msg_id=db_insertid($result);
00553 handle_monitoring($group_forum_id,$msg_id);
00554
00555 }
00556 else
00557 {
00558
00559 print '<h3>'._("You could post if you were logged in").'.</h3>';
00560
00561 }
00562
00563 }
00564
00565 function show_post_form($forum_id, $thread_id=0, $is_followup_to=0, $subject="")
00566 {
00567
00568 if (user_isloggedin())
00569 {
00570 if ($subject)
00571 {
00572 #if this is a followup, put a RE: before it if needed
00573 if (!eregi('RE:',$subject,$test))
00574 {
00575 $subject ='RE: '.$subject;
00576 }
00577 }
00578
00579 print '<center>';
00580 print '<form action="'.$GLOBALS['sys_home'].'forum/forum.php" method="POST">';
00581 print '<input type="hidden" name="post_message" value="y" />';
00582 print '<input type="HIDDEN" name="forum_id" value="'.$forum_id.'" />';
00583 print '<input type="HIDDEN" name="thread_id" value="'.$thread_id.'" />';
00584 print '<input type="HIDDEN" name="msg_id" value="'.$is_followup_to.'" />';
00585 print '<input type="HIDDEN" name="is_followup_to" value="'.$is_followup_to.'" />';
00586 print '<table><tr><td><strong>'._("Subject").':</td><td>';
00587 print '<input type="TEXT" name="subject" value="'.$subject.'" size="60" maxlength="45" />';
00588 print '</td></tr>';
00589 print '<tr><td><strong>'._("Message").':</td><td>';
00590 print '<textarea name="body" value="" rows="25" cols="60" wrap="SOFT"></textarea>';
00591 print '</td></tr>';
00592 print '<tr><td colspan="2" align="MIDDLE">';
00593 print '<span class="warn">HTML tags will display in your post as text</span>';
00594 print '<br />';
00595 print '<input type="SUBMIT" name="SUBMIT" value="'._("Post Comment").'" />';
00596 print '</td></tr></table>';
00597 print '</form>';
00598 print '</center>';
00599
00600 }
00601 else
00602 {
00603 print "<center>";
00604 print "\n\n<span class=\"error\">"._("You could post if you were logged in").'</span>';
00605 print "</center>";
00606
00607 }
00608
00609 }
00610
00611 function handle_monitoring($forum_id,$msg_id)
00612 {
00613 global $feedback;
00614
00615
00616
00617
00618
00619 $sql="SELECT user.email from forum_monitored_forums,user ".
00620 "WHERE forum_monitored_forums.user_id=user.user_id AND forum_monitored_forums.forum_id='$forum_id'";
00621
00622 $result=db_query($sql);
00623 $rows=db_numrows($result);
00624
00625 if ($result && $rows > 0)
00626 {
00627 $tolist=implode(result_column_to_array($result),', ');
00628
00629 $sql="SELECT groups.unix_group_name,user.user_name,forum_group_list.forum_name,user.email,user.realname,".
00630 "forum.group_forum_id,forum.thread_id,forum.subject,forum.date,forum.body ".
00631 "FROM forum,user,forum_group_list,groups ".
00632 "WHERE user.user_id=forum.posted_by ".
00633 "AND forum_group_list.group_forum_id=forum.group_forum_id ".
00634 "AND groups.group_id=forum_group_list.group_id ".
00635 "AND forum.msg_id='$msg_id'";
00636
00637 $result = db_query ($sql);
00638
00639 if ($result && db_numrows($result) > 0)
00640 {
00641 if ($GLOBALS['sys_lists_enable'] == "yes")
00642 {
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654 $decid = sprintf("%07d",$msg_id);
00655 $checksum = md5($decid);
00656 $gpkaid = $decid . substr($checksum,0,1) . substr($checksum,2,1) .
00657 substr($checksum,26,1) . substr($checksum,28,1) . substr($checksum,30,1);
00658
00659
00660 $from=db_result($result,0,'realname')." <" . db_result($result,0, 'email') . ">";
00661 $to=$GLOBALS[sys_mail_replyto];
00662 $subject= "[" . db_result($result,0,'unix_group_name').
00663 "_" . db_result($result,0,'forum_name')."] ".
00664 utils_unconvert_htmlspecialchars(db_result($result,0,'subject')).
00665 " #" . $gpkaid . "#";
00666 $message="\n\n".
00667 "\nBy: " . db_result($result,0,'realname') ." <" .db_result($result,0, 'email') . ">" .
00668 "\n\n" . utils_unconvert_htmlspecialchars(db_result($result,0, 'body')).
00669 "\n\n_______________________________________________".
00670 "\nRead and respond to this message at: ".
00671 "\nhttp://$GLOBALS[sys_default_domain]/forum/message.php?msg_id=".$msg_id.
00672 "\nDo not alter the subject when replying! ".
00673 "\nTo stop monitoring this forum, login to Savannah and visit: ".
00674 "\nhttp://$GLOBALS[sys_default_domain]/forum/monitor.php?forum_id=$forum_id";
00675 $savannah_project=db_result($result,0,'unix_group_name');
00676 #$savannah_artifact="Forum";
00677 #$savannah_artifact_id=$forum_id;
00678 $savannah_artifact=0; # these must stay zero to not mess up the subject any further
00679 $savannah_artifact_id=0;
00680 $reply_to=$GLOBALS['sys_lists_prefix'] . db_result($result,0,'unix_group_name').
00681 "_" . db_result($result,0,'forum_name') . "@" . $GLOBALS['sys_mail_domain'];
00682 $additional_headers="BCC: $tolist";
00683
00684 # Custom extensions to the header:
00685
00686
00687
00688
00689
00690
00691
00692
00693 sendmail_mail ($from, $to, $subject, $message,
00694 $savannah_project, $savannah_artifact,
00695 $savannah_artifact_id, $reply_to,
00696 $additional_headers);
00697
00698
00699 }
00700 else
00701 {
00702
00703 $from=$GLOBALS[sys_mail_replyto];
00704 $to=$GLOBALS[sys_mail_replyto];
00705 $subject="[" .db_result($result,0,'unix_group_name').
00706 " - " . db_result($result,0,'forum_name')."] ".
00707 utils_unconvert_htmlspecialchars(db_result($result,0,'subject'));
00708 $message="\n\nRead and respond to this message at: ".
00709 "\nhttp://$GLOBALS[sys_default_domain]/forum/message.php?msg_id=".$msg_id.
00710 "\nBy: " . db_result($result,0, 'user_name') .
00711 "\n\n" . utils_unconvert_htmlspecialchars(db_result($result,0, 'body')).
00712 "\n\n______________________________________________________________________".
00713 "\nYou are receiving this email because you elected to monitor this forum.".
00714 "\nTo stop monitoring this forum, login to Savannah and visit: ".
00715 "\nhttp://$GLOBALS[sys_default_domain]/forum/monitor.php?forum_id=$forum_id";
00716 $savannah_project=db_result($result,0,'unix_group_name');
00717 $savannah_artifact="Forum";
00718 $savannah_artifact_id=$forum_id;
00719 $reply_to=$GLOBALS[sys_mail_replyto];
00720 $additional_headers="BCC: $tolist";
00721
00722 sendmail_mail ($from, $to, $subject, $message,
00723 $savannah_project, $savannah_artifact,
00724 $savannah_artifact_id, $reply_to,
00725 $additional_headers);
00726
00727 }
00728
00729 ' email sent - people monitoring ';
00730 }
00731 else
00732 {
00733 ' email not sent - people monitoring ';
00734 print db_error();
00735 }
00736 }
00737 else
00738 {
00739 ' email not sent - no one monitoring ';
00740 print db_error();
00741 }
00742 }
00743
00744 function recursive_delete($msg_id,$forum_id)
00745 {
00746
00747
00748
00749
00750 if ($msg_id=='' || $msg_id=='0' || (strlen($msg_id) < 1))
00751 {
00752 return 0;
00753 }
00754
00755 $sql="SELECT msg_id FROM forum WHERE is_followup_to='$msg_id' AND group_forum_id='$forum_id'";
00756 $result=db_query($sql);
00757 $rows=db_numrows($result);
00758 $count=1;
00759
00760 for ($i=0;$i<$rows;$i++)
00761 {
00762 $count += recursive_delete(db_result($result,$i,'msg_id'),$forum_id);
00763 }
00764 $sql="DELETE FROM forum WHERE msg_id='$msg_id' AND group_forum_id='$forum_id'";
00765 $toss=db_query($sql);
00766
00767 return $count;
00768 }
00769
00770 # US validate forum
00771 function validate_forum_name ($forum_name) {
00772 return (ereg('^[a-zA-Z0-9\-]+$',$forum_name));
00773 }
00774
00775 ?>