3 * GForge Forums Facility
5 * Copyright 2002 GForge, LLC
10 * This file is part of GForge.
12 * GForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * GForge 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
23 * along with GForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 By Tim Perdue, Sourceforge, 11/99
32 Massive rewrite by Tim Perdue 7/2000 (nested/views/save)
34 Complete OO rewrite by Tim Perdue 12/2002
37 require_once $gfcommon.'include/Error.class.php';
38 include_once $gfcommon.'include/TextSanitizer.class.php'; // for parsing the mail body
39 include_once $gfcommon.'include/User.class.php';
41 class ForumMessage extends Error {
43 var $awaits_moderation;//boolean -> true if the message was inserted for approval (pending), false if not
45 * Associative array of data from db.
47 * @var array $data_array.
61 * @param object The Forum object to which this ForumMessage is associated.
62 * @param int The message_id.
63 * @param array The associative array of data.
64 * @param boolean Whether the message is a pending one.
65 * @return boolean success.
67 function ForumMessage(&$Forum, $msg_id=false, $arr=false, $pending=false) {
69 if (!$Forum || !is_object($Forum)) {
70 $this->setError(_('ForumMessage:: No Valid Forum Object'));
73 if ($Forum->isError()) {
74 $this->setError('ForumMessage:: '.$Forum->getErrorMessage());
77 $this->Forum =& $Forum;
81 //we are going to create the pending message to show it to the admin for moderation
82 if (!$this->fetchModeratedData($msg_id)) {
85 $this->awaits_moderation = true;
87 $this->awaits_moderation = false;
88 if (!$arr || !is_array($arr)) {
89 if (!$this->fetchData($msg_id)) {
93 $this->data_array =& $arr;
95 // Verify this message truly belongs to this Forum
97 if ($this->data_array['group_forum_id'] != $this->Forum->getID()) {
98 $this->setError(_('Group_forum_id in db result does not match Forum Object'));
99 $this->data_array=null;
109 * insertmoderated - inserts the message into the table for moderation (forum_pending_messages)
110 * @param string The subject of the message.
111 * @param string The body of the message.
112 * @param int The thread_id of the message, if known.
113 * @param int The message_id of the parent message, if any.
114 * @param int The id of the user that is posting the message
115 * @return boolean success.
118 function insertmoderated($subject, $body, $thread_id='', $is_followup_to='',$user_id) {
120 $thread_id=$this->Forum->getNextThreadID();
123 $this->setError('ForumMessage::create() '._('Getting next thread_id failed'));
129 $sql="INSERT INTO forum_pending_messages (group_forum_id,posted_by,subject,
130 body,post_date,is_followup_to,thread_id,most_recent_date)
131 VALUES ('". $this->Forum->getID() ."', '$user_id', '". htmlspecialchars($subject) ."',
132 '". $body ."', '". time() ."','$is_followup_to','$thread_id','". time() ."')";
134 $result=db_query($sql);
135 if (!$result || db_affected_rows($result) < 1) {
136 $this->setError(_('ForumMessage::create() Posting Failed').' '.db_error());
140 $msg_id=db_insertid($result,'forum_pending_messages','msg_id');
141 if (!$this->fetchModeratedData($msg_id)) {
147 $this->setError(_('ForumMessage::create() Unable to get new message id'));
150 if (!$this->sendNewModeratedMsgNotice()) {
155 $this->awaits_moderation = true;
163 * insertreleasedmsg - inserts the released message into the main table (forum)
164 * @param string The Forum id
165 * @param string The subject of the message.
166 * @param string The body of the message.
167 * @param string The post date
168 * @param int The thread_id of the message
169 * @param int The message_id of the parent message, if any.
170 * @param int The id of the user that is posting the message
171 * @param int has followups?
172 * @param int most recent date
173 * @return boolean success.
176 function insertreleasedmsg($group_forum_id,$subject, $body,$post_date, $thread_id, $is_followup_to,$posted_by,$has_followups,$most_recent_date) {
177 if ($is_followup_to != 0) {
179 //was posted in reply to another thread
180 //we must check whether that thread still exists. if it does, post the message. else, set the error
182 // increment the parent's followup count if necessary
185 $res4=db_query("UPDATE forum SET most_recent_date='". time() ."'
186 WHERE thread_id='$thread_id' AND is_followup_to='0'");
187 if (!$res4 || db_affected_rows($res4) < 1) {
188 $this->setError(_('Couldn\'t Update Master Thread parent with current time'));
193 // mark the parent with followups as an optimization later
195 $res3=db_query("UPDATE forum SET has_followups='1',most_recent_date='". time() ."'
196 WHERE msg_id='$is_followup_to'");
198 $this->setError(_('Could Not Update Parent'));
208 $sql="INSERT INTO forum (group_forum_id,posted_by,subject,
209 body,post_date,is_followup_to,thread_id,most_recent_date)
210 VALUES ('". $group_forum_id ."', '$posted_by', '". htmlspecialchars($subject) ."',
211 '". $body ."', '". $post_date ."','$is_followup_to','$thread_id','". $most_recent_date ."')";
213 $result=db_query($sql);
214 if (!$result || db_affected_rows($result) < 1) {
215 $this->setError(_('ForumMessage::create() Posting Failed').' '.db_error());
219 $msg_id=db_insertid($result,'forum','msg_id');
220 if (!$this->fetchData($msg_id)) {
222 $this->setError(_('ForumMessage::create() Posting Failed').' '.db_error());
227 $this->setError(_('ForumMessage::create() Unable to get new message id'));
230 if (!$this->sendNotice()) {
235 $this->awaits_moderation = false;
244 * insertmsg - inserts the message into the main table (forum)
245 * @param string The subject of the message.
246 * @param string The body of the message.
247 * @param int The thread_id of the message, if known.
248 * @param int The message_id of the parent message, if any.
249 * @param int The id of the user that is posting the message
250 * @param boolean Whether the message has an attach associated. Defaults to false
251 * @return boolean success.
254 function insertmsg($subject, $body, $thread_id='', $is_followup_to='',$user_id,$has_attach=false) {
256 $thread_id=$this->Forum->getNextThreadID();
259 $this->setError('ForumMessage::create() '._('Getting next thread_id failed'));
265 // increment the parent's followup count if necessary
267 $res4=db_query("UPDATE forum SET most_recent_date='". time() ."'
268 WHERE thread_id='$thread_id' AND is_followup_to='0'");
269 if (!$res4 || db_affected_rows($res4) < 1) {
270 $this->setError(_('Couldn\'t Update Master Thread parent with current time'));
275 // mark the parent with followups as an optimization later
277 $res3=db_query("UPDATE forum SET has_followups='1',most_recent_date='". time() ."'
278 WHERE msg_id='$is_followup_to'");
280 $this->setError(_('Could Not Update Parent'));
287 $sql="INSERT INTO forum (group_forum_id,posted_by,subject,
288 body,post_date,is_followup_to,thread_id,most_recent_date)
289 VALUES ('". $this->Forum->getID() ."', '$user_id', '". htmlspecialchars($subject) ."',
290 '". $body ."', '". time() ."','$is_followup_to','$thread_id','". time() ."')";
292 $result=db_query($sql);
293 if (!$result || db_affected_rows($result) < 1) {
294 $this->setError(_('ForumMessage::create() Posting Failed').' '.db_error());
299 $msg_id=db_insertid($result,'forum','msg_id');
300 if (!$this->fetchData($msg_id)) {
307 $this->setError(_('ForumMessage::create() Unable to get new message id'));
311 if (!$this->sendNotice($has_attach)) {
317 //echo "db_error()".db_error();
318 $this->awaits_moderation = false;
324 * create - use this function to create a new message in the database.
326 * @param string The subject of the message.
327 * @param string The body of the message.
328 * @param int The thread_id of the message, if known.
329 * @param int The message_id of the parent message, if any.
330 * @param boolean Whether the message has an attach associated. Defaults to false
331 * @return boolean success.
333 function create($subject, $body, $thread_id='', $is_followup_to='',$has_attach=false) {
334 if (!$body || !$subject) {
335 $this->setError(_('Must Include A Message Body And Subject'));
338 if (!$this->Forum->userCanPost()) {
339 $this->setPermissionDeniedError();
342 if (!session_loggedin()) {
345 $user_id=user_getid();
348 if ($is_followup_to) {
349 $ParentMessage=new ForumMessage($this->Forum,$is_followup_to);
350 if (!$ParentMessage || !is_object($ParentMessage)) {
351 $this->setError("ForumMessage::create()"._('ForumMessage::create() No Valid ParentMessage Object'));
354 if ($ParentMessage->isError()) {
355 $this->setError('ForumMessage::create() '.$ParentMessage->getErrorMessage());
359 if (!$is_followup_to) {
363 //see if that message has been posted already for all the idiots that double-post
364 //we shouldn't need this, the double post checker functions solve this issue now
365 /*$res3=db_query("SELECT * FROM forum
366 WHERE is_followup_to='$is_followup_to'
367 AND body='". htmlspecialchars($body) ."'
368 AND subject='". htmlspecialchars($subject) ."'
369 AND group_forum_id='". $this->Forum->getId() ."'
370 AND posted_by='$user_id'");
372 if (db_numrows($res3) > 0) {
373 //already posted this message
374 $this->setError(_('You appear to be double-posting this message, since it has the same subject and followup information as a prior post.'));
382 //now we check the moderation status of the forum and act accordingly
383 $mod_level = $this->Forum->GetModerationLevel();
384 switch ($mod_level) {
387 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach);
390 //moderation for anonymous & non project users
391 if ($this->Forum->userIsModLvl1()) {
392 return $this->insertmoderated($subject, $body, $thread_id, $is_followup_to,$user_id);
394 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach);
398 //moderation for anyone who can post (even project members). admins can always post...
399 if ($this->Forum->userIsModLvl2()) {
400 return $this->insertmoderated($subject, $body, $thread_id, $is_followup_to,$user_id);
402 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach);
409 * fetchData - re-fetch the data for this forum_message from the database.
411 * @param int The message ID.
412 * @return boolean success.
414 function fetchData($msg_id) {
415 $res=db_query("SELECT * FROM forum_user_vw
416 WHERE msg_id='$msg_id'
417 AND group_forum_id='". $this->Forum->getID() ."'");
418 if (!$res || db_numrows($res) < 1) {
419 $this->setError(_('ForumMessage::fetchData() Invalid MessageID').db_error());
422 $this->data_array =& db_fetch_array($res);
423 db_free_result($res);
428 * fetchModeratedData - re-fetch the data for this forum_message from the database, for pending messages
430 * @param int The message ID.
431 * @return boolean success.
433 function fetchModeratedData($msg_id) {
434 $res=db_query("SELECT * FROM forum_pending_user_vw
435 WHERE msg_id='$msg_id'
436 AND group_forum_id='". $this->Forum->getID() ."'");
437 if (!$res || db_numrows($res) < 1) {
438 $this->setError(_('ForumMessage::fetchData() Invalid MessageID').db_error());
441 $this->data_array =& db_fetch_array($res);
442 db_free_result($res);
447 * getForum - get the Forum object this ForumMessage is associated with.
449 * @return object The Forum object.
451 function &getForum() {
456 * getID - get this message_id.
458 * @return int The message_id.
461 return $this->data_array['msg_id'];
465 * getPosterName - get the unix user_name of this message's poster.
467 * @return string The poster's unix name.
469 function getPosterName() {
470 return $this->data_array['user_name'];
474 * getPosterID - get this user_id of this message's poster.
476 * @return int The user_id.
478 function getPosterID() {
479 return $this->data_array['posted_by'];
483 * getPosterRealName - get the real name of this message's poster.
485 * @return string The real name.
487 function getPosterRealName() {
488 return $this->data_array['realname'];
492 * getSubject - get the subject of this message.
494 * @return string The subject.
496 function getSubject() {
497 return $this->data_array['subject'];
501 * getBody - get the body of this message.
503 * @return String The body.
506 return $this->data_array['body'];
510 * getPostDate - get the post date of this message.
512 * @return int The post date.
514 function getPostDate() {
515 return $this->data_array['post_date'];
519 * getParentID - get the id of the parent message, if this is a followup.
521 * @return int The parent id.
523 function getParentID() {
524 return $this->data_array['is_followup_to'];
528 * isPending - is the message pending, awaiting moderation?
530 * @return int awaits_moderation
532 function isPending() {
533 return $this->awaits_moderation;
537 * getThreadID - get the thread_id of the message.
539 * @return int The thread_id.
541 function getThreadID() {
542 return $this->data_array['thread_id'];
546 * getMostRecentDate - get the date of the most recent followup.
548 * @return int The date of the most recent followup.
550 function getMostRecentDate() {
551 return $this->data_array['most_recent_date'];
555 * hasFollowups - whether this message has any followups.
557 * @return boolean has_followups.
559 function hasFollowups() {
560 return $this->data_array['has_followups'];
564 * hasAttach - whether this message has an attachment.
566 * @return boolean has_attach.
569 function hasAttach() {
570 if ($this->isPending()) {
571 $sql = "SELECT attachmentid FROM forum_pending_attachment WHERE msg_id='$this->getID()'";
573 $sql = "SELECT attachmentid FROM forum_attachment WHERE msg_id='$this->getID()'";
575 if ((db_numrows(db_query($sql)) > 0 )) {
582 * delete - Delete this message and its followups.
584 * @return int The count of deleted messages.
587 $msg_id=$this->getID();
589 $this->setError(_('Invalid Message ID'));
593 if (!$this->Forum->userIsAdmin()) {
594 $this->setPermissionDeniedError();
598 /*$perm =& $this->Forum->Group->getPermission( session_get_user() );
600 if (!$perm || !is_object($perm) || !$perm->isForumAdmin()) {
601 $this->setPermissionDeniedError();
605 $sql="SELECT msg_id FROM forum
606 WHERE is_followup_to='$msg_id'
607 AND group_forum_id='".$this->Forum->getID()."'";
608 $result=db_query($sql);
609 $rows=db_numrows($result);
613 for ($i=0;$i<$rows;$i++) {
614 $msg = new ForumMessage($this->Forum,db_result($result,$i,'msg_id'));
615 $count += $msg->delete();
617 $sql="DELETE FROM forum
618 WHERE msg_id='$msg_id'
619 AND group_forum_id='".$this->Forum->getID()."'";
620 $toss=db_query($sql);
621 $sql = "DELETE FROM forum_attachment where msg_id='$msg_id'";
622 $res = db_query($res);
629 * removebbcode - workaround to remove bbcode tags.
631 * @return string converted text
633 function removebbcode($text) {
634 //$replaced = preg_replace("/\[[_a-zA-Z]:.+\](.+)\[\/[_a-zA-Z]:.*\]/","$1",$text);
635 $replaced = preg_replace("/\[.+\](.+)\[\/.+\]/","$1",$text);
640 * sendNotice - contains the logic to send out email followups when a message is posted.
642 * @param boolean Whether the message has an attach associated. Defaults to false
644 * @return boolean success.
646 function sendNotice($has_attach=false) {
647 $ids =& $this->Forum->getMonitoringIDs();
650 // See if there is anyone to send messages to
652 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
656 $body = "\nRead and respond to this message at: ".
657 "\n".util_make_url ('/forum/message.php?msg_id='.$this->getID()).
658 "\nOr by replying to this e-mail entering your response between the following markers: ".
659 "\n".FORUM_MAIL_MARKER.
660 "\n(enter your response here)".
661 "\n".FORUM_MAIL_MARKER.
663 "\nBy: " . $this->getPosterRealName() . "\n";
666 //if there's an attachment for the message, make it note.
667 //Note: We can't give a link for the attachment here because it hasn't been created yet (first the message needs to be created
668 $body .= "A file has been uploaded with this message\n\n";
672 $sanitizer = new TextSanitizer();
673 $text = $this->getBody();
674 $text = $sanitizer->convertNeededTagsForEmail($text);
675 $text= strip_tags($this->removebbcode(util_line_wrap($text)));
676 $text = $sanitizer->convertExtendedCharsForEmail($text);
678 "\n\n______________________________________________________________________".
679 "\nYou are receiving this email because you elected to monitor this forum.".
680 "\nTo stop monitoring this forum, login to ".$GLOBALS['sys_name']." and visit: ".
681 "\n".util_make_url('/forum/monitor.php?forum_id='.$this->Forum->getID().'&group_id='.$this->Forum->Group->getID().'&stop=1');
683 //$extra_headers = 'Reply-to: '.$this->Forum->getUnixName().'@'.$GLOBALS['sys_default_domain'];
684 $extra_headers = "Return-Path: <noreply@".$GLOBALS['sys_default_domain'].">\n";
685 $extra_headers .= "Errors-To: <noreply@".$GLOBALS['sys_default_domain'].">\n";
686 $extra_headers .= "Sender: <noreply@".$GLOBALS['sys_default_domain'].">\n";
687 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
688 $extra_headers .= "Precedence: Bulk\n"
689 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".$GLOBALS['sys_default_domain'].">\n"
690 ."List-Help: ".util_make_url ('/forum/forum.php?id='.$this->Forum->getId())."\n"
691 ."Message-Id: <forumpost".$this->getId()."@".$GLOBALS['sys_default_domain'].">";
692 $parentid = $this->getParentId();
693 if (!empty($parentid)) {
694 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
695 ."References: <forumpost".$this->getParentId()."@".$GLOBALS['sys_default_domain'].">";
698 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
699 if (count($ids) != 0) {
700 // maybe we have no monitoring ids. this was causing a transaction to be aborted because of being called everytime
701 $sql="SELECT email FROM users WHERE status='A' AND user_id IN ('".implode($ids,'\',\'')."')";
702 $bccres = db_query($sql);
704 $BCC =& implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
706 $User = user_get_object($this->getPosterID());
707 util_send_message('',$subject,$body,"noreply@".$GLOBALS['sys_default_domain'],$BCC,'Forum',$extra_headers);
708 //util_send_message('',$subject,$body,$User->getEmail(),$BCC,$this->getPosterRealName(),$extra_headers);
709 // util_handle_message(array_unique($ids),$subject,$body,$this->Forum->getSendAllPostsTo(),'','forumgateway@'.$GLOBALS[sys_default_domain]);
714 * sendNewModeratedMsgNotice - contains the logic to send out email notifications to the forum admins when a new moderated message is posted
716 * @return boolean success.
718 function sendNewModeratedMsgNotice() {
719 $ids =& $this->Forum->getForumAdminIDs();
722 // See if there is anyone to send messages to
724 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
728 $f =& $this->getForum();
729 $g =& $f->getGroup();
731 $body = "\nRead to this message and approve/reject it at: ".
732 "\n".util_make_url('/forum/admin/pending.php?action=view_pending&group_id='. $g->getID() . "&forum_id=" . $f->getID()) .
733 "\nBy: " . $this->getPosterRealName() . "\n\n";
735 $text = $this->getBody();
736 $sanitizer = new TextSanitizer();
737 $text = $sanitizer->convertNeededTagsForEmail($text);
738 $text= strip_tags($this->removebbcode(util_line_wrap($text)));
739 $text = $sanitizer->convertExtendedCharsForEmail($text);
741 "\n\n______________________________________________________________________".
742 "\nYou are receiving this email because the forum you administrate has a new moderated message awaiting your approval.";
744 //$extra_headers = 'Reply-to: '.$this->Forum->getUnixName().'@'.$GLOBALS['sys_default_domain'];
745 $extra_headers = "Return-Path: <noreply@".$GLOBALS['sys_default_domain'].">\n";
746 $extra_headers .= "Errors-To: <noreply@".$GLOBALS['sys_default_domain'].">\n";
747 $extra_headers .= "Sender: <noreply@".$GLOBALS['sys_default_domain'].">\n";
748 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
749 $extra_headers .= "Precedence: Bulk\n"
750 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".$GLOBALS['sys_default_domain'].">\n"
751 ."List-Help: ".util_make_url('/forum/forum.php?id='.$this->Forum->getId())."\n"
752 ."Message-Id: <forumpost".$this->getId()."@".$GLOBALS['sys_default_domain'].">";
753 $parentid = $this->getParentId();
754 if (!empty($parentid)) {
755 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
756 ."References: <forumpost".$this->getParentId()."@".$GLOBALS['sys_default_domain'].">";
759 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
760 if (count($ids) != 0) {
761 $sql="SELECT email FROM users WHERE status='A' AND user_id IN ('".implode($ids,'\',\'')."')";
762 $bccres = db_query($sql);
765 $BCC =& implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
766 $User = user_get_object($this->getPosterID());
767 //util_send_message('',$subject,$body,$User->getEmail(),$BCC,$this->getPosterRealName(),$extra_headers);
768 util_send_message('',$subject,$body,"noreply@".$GLOBALS['sys_default_domain'],$BCC,'Forum',$extra_headers);
769 // util_handle_message(array_unique($ids),$subject,$body,$this->Forum->getSendAllPostsTo(),'','forumgateway@'.$GLOBALS[sys_default_domain]);
774 * updatemsg - impacts in the DB the new content of the message
776 * @param string The forum ID
777 * @param int The id of the user that is posting the message
778 * @param string The subject of the message.
779 * @param string The body of the message.
780 * @param string The post date
781 * @param int The message_id of the parent message, if any.
782 * @param int The thread_id of the message, if known.
783 * @param int has followups?
784 * @param string The most recent date.
786 * @return boolean success.
788 function updatemsg($group_forum_id,$posted_by,$subject,$body,$post_date,$is_followup_to,$thread_id,$has_followups,$most_recent_date) {
789 $subject = htmlspecialchars($subject);
791 $msg_id = $this->getID();
793 SET group_forum_id='$group_forum_id' , posted_by='$posted_by' , subject='$subject',
794 body='$body', post_date='$post_date' , is_followup_to='$is_followup_to' ,
795 thread_id='$thread_id',most_recent_date='$most_recent_date'
796 WHERE msg_id='$msg_id'";
797 $res = db_query($sql);
799 $this->setError(db_error());
802 if (db_affected_rows($res)<1) {
803 $this->setError("Message not found");
811 * sendAttachNotice - contains the logic to send out email attachement followups when a message is posted.
813 * @param int attach_id - The id of the file that has been attached
815 * @return boolean success.
817 function sendAttachNotice($attach_id) {
819 $ids =& $this->Forum->getMonitoringIDs();
822 // See if there is anyone to send messages to
824 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
828 $body = "\nRead and respond to this message at: ".
829 "\n".util_make_url('/forum/message.php?msg_id='.$this->getID()).
830 "\nBy: " . $this->getPosterRealName() . "\n\n";
832 $body .= "A file has been uploaded to this message, you can download it at: ".
833 "\n".util_make_url('/forum/attachment.php?attachid='. $attach_id . "&group_id=" . $this->Forum->Group->getID() . "&forum_id=" . $this->Forum->getID()) . "\n\n";
836 "\n\n______________________________________________________________________".
837 "\nYou are receiving this email because you elected to monitor this forum.".
838 "\nTo stop monitoring this forum, login to ".$GLOBALS['sys_name']." and visit: ".
839 "\n".util_make_url ('/forum/monitor.php?forum_id='.$this->Forum->getID() .'&group_id='.$this->Forum->Group->getID().'&stop=1');
841 $extra_headers = "Return-Path: <noreply@".$GLOBALS['sys_default_domain'].">\n";
842 $extra_headers .= "Errors-To: <noreply@".$GLOBALS['sys_default_domain'].">\n";
843 $extra_headers .= "Sender: <noreply@".$GLOBALS['sys_default_domain'].">\n";
844 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
845 $extra_headers .= "Precedence: Bulk\n"
846 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".$GLOBALS['sys_default_domain'].">\n"
847 ."List-Help: ".util_make_url('/forum/forum.php?id='.$this->Forum->getId())."\n"
848 ."Message-Id: <forumpost".$this->getId()."@".$GLOBALS['sys_default_domain'].">";
849 $parentid = $this->getParentId();
850 if (!empty($parentid)) {
851 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
852 ."References: <forumpost".$this->getParentId()."@".$GLOBALS['sys_default_domain'].">";
855 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
856 if (count($ids) != 0) {
857 $sql="SELECT email FROM users WHERE status='A' AND user_id IN ('".implode($ids,'\',\'')."')";
858 $bccres = db_query($sql);
860 $BCC =& implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
861 $User = user_get_object($this->getPosterID());
862 util_send_message('',$subject,$body,"noreply@".$GLOBALS['sys_default_domain'],$BCC,'Forum',$extra_headers);
872 // c-file-style: "bsd"