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('common/include/Error.class');
38 include_once('common/include/TextSanitizer.class'); // for parsing the mail body
39 include_once('common/include/User.class');
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) {
70 if (!$Forum || !is_object($Forum)) {
71 $this->setError(_('ForumMessage:: No Valid Forum Object'));
74 if ($Forum->isError()) {
75 $this->setError('ForumMessage:: '.$Forum->getErrorMessage());
78 $this->Forum =& $Forum;
82 //we are going to create the pending message to show it to the admin for moderation
83 if (!$this->fetchModeratedData($msg_id)) {
86 $this->awaits_moderation = true;
88 $this->awaits_moderation = false;
89 if (!$arr || !is_array($arr)) {
90 if (!$this->fetchData($msg_id)) {
94 $this->data_array =& $arr;
96 // Verify this message truly belongs to this Forum
98 if ($this->data_array['group_forum_id'] != $this->Forum->getID()) {
99 $this->setError(_('Group_forum_id in db result does not match Forum Object'));
100 $this->data_array=null;
110 * insertmoderated - inserts the message into the table for moderation (forum_pending_messages)
111 * @param string The subject of the message.
112 * @param string The body of the message.
113 * @param int The thread_id of the message, if known.
114 * @param int The message_id of the parent message, if any.
115 * @param int The id of the user that is posting the message
116 * @return boolean success.
119 function insertmoderated($subject, $body, $thread_id='', $is_followup_to='',$user_id) {
121 $thread_id=$this->Forum->getNextThreadID();
124 $this->setError('ForumMessage::create() '._('Getting next thread_id failed'));
130 $sql="INSERT INTO forum_pending_messages (group_forum_id,posted_by,subject,
131 body,post_date,is_followup_to,thread_id,most_recent_date)
132 VALUES ('". $this->Forum->getID() ."', '$user_id', '". htmlspecialchars($subject) ."',
133 '". $body ."', '". time() ."','$is_followup_to','$thread_id','". time() ."')";
135 $result=db_query($sql);
136 if (!$result || db_affected_rows($result) < 1) {
137 $this->setError(_('ForumMessage::create() Posting Failed').' '.db_error());
141 $msg_id=db_insertid($result,'forum_pending_messages','msg_id');
142 if (!$this->fetchModeratedData($msg_id)) {
148 $this->setError(_('ForumMessage::create() Unable to get new message id'));
151 if (!$this->sendNewModeratedMsgNotice()) {
156 $this->awaits_moderation = true;
164 * insertreleasedmsg - inserts the released message into the main table (forum)
165 * @param string The Forum id
166 * @param string The subject of the message.
167 * @param string The body of the message.
168 * @param string The post date
169 * @param int The thread_id of the message
170 * @param int The message_id of the parent message, if any.
171 * @param int The id of the user that is posting the message
172 * @param int has followups?
173 * @param int most recent date
174 * @return boolean success.
177 function insertreleasedmsg($group_forum_id,$subject, $body,$post_date, $thread_id, $is_followup_to,$posted_by,$has_followups,$most_recent_date) {
180 if ($is_followup_to != 0) {
182 //was posted in reply to another thread
183 //we must check whether that thread still exists. if it does, post the message. else, set the error
185 // increment the parent's followup count if necessary
188 $res4=db_query("UPDATE forum SET most_recent_date='". time() ."'
189 WHERE thread_id='$thread_id' AND is_followup_to='0'");
190 if (!$res4 || db_affected_rows($res4) < 1) {
191 $this->setError(_('Couldn\'t Update Master Thread parent with current time'));
196 // mark the parent with followups as an optimization later
198 $res3=db_query("UPDATE forum SET has_followups='1',most_recent_date='". time() ."'
199 WHERE msg_id='$is_followup_to'");
201 $this->setError(_('Could Not Update Parent'));
211 $sql="INSERT INTO forum (group_forum_id,posted_by,subject,
212 body,post_date,is_followup_to,thread_id,most_recent_date)
213 VALUES ('". $group_forum_id ."', '$posted_by', '". htmlspecialchars($subject) ."',
214 '". $body ."', '". $post_date ."','$is_followup_to','$thread_id','". $most_recent_date ."')";
216 $result=db_query($sql);
217 if (!$result || db_affected_rows($result) < 1) {
218 $this->setError(_('ForumMessage::create() Posting Failed').' '.db_error());
222 $msg_id=db_insertid($result,'forum','msg_id');
223 if (!$this->fetchData($msg_id)) {
225 $this->setError(_('ForumMessage::create() Posting Failed').' '.db_error());
230 $this->setError(_('ForumMessage::create() Unable to get new message id'));
233 if (!$this->sendNotice()) {
238 $this->awaits_moderation = false;
247 * insertmsg - inserts the message into the main table (forum)
248 * @param string The subject of the message.
249 * @param string The body of the message.
250 * @param int The thread_id of the message, if known.
251 * @param int The message_id of the parent message, if any.
252 * @param int The id of the user that is posting the message
253 * @param boolean Whether the message has an attach associated. Defaults to false
254 * @return boolean success.
257 function insertmsg($subject, $body, $thread_id='', $is_followup_to='',$user_id,$has_attach=false) {
261 $thread_id=$this->Forum->getNextThreadID();
264 $this->setError('ForumMessage::create() '._('Getting next thread_id failed'));
270 // increment the parent's followup count if necessary
272 $res4=db_query("UPDATE forum SET most_recent_date='". time() ."'
273 WHERE thread_id='$thread_id' AND is_followup_to='0'");
274 if (!$res4 || db_affected_rows($res4) < 1) {
275 $this->setError(_('Couldn\'t Update Master Thread parent with current time'));
280 // mark the parent with followups as an optimization later
282 $res3=db_query("UPDATE forum SET has_followups='1',most_recent_date='". time() ."'
283 WHERE msg_id='$is_followup_to'");
285 $this->setError(_('Could Not Update Parent'));
292 $sql="INSERT INTO forum (group_forum_id,posted_by,subject,
293 body,post_date,is_followup_to,thread_id,most_recent_date)
294 VALUES ('". $this->Forum->getID() ."', '$user_id', '". htmlspecialchars($subject) ."',
295 '". $body ."', '". time() ."','$is_followup_to','$thread_id','". time() ."')";
297 $result=db_query($sql);
298 if (!$result || db_affected_rows($result) < 1) {
299 $this->setError(_('ForumMessage::create() Posting Failed').' '.db_error());
304 $msg_id=db_insertid($result,'forum','msg_id');
305 if (!$this->fetchData($msg_id)) {
312 $this->setError(_('ForumMessage::create() Unable to get new message id'));
316 if (!$this->sendNotice($has_attach)) {
322 //echo "db_error()".db_error();
323 $this->awaits_moderation = false;
329 * create - use this function to create a new message in the database.
331 * @param string The subject of the message.
332 * @param string The body of the message.
333 * @param int The thread_id of the message, if known.
334 * @param int The message_id of the parent message, if any.
335 * @param boolean Whether the message has an attach associated. Defaults to false
336 * @return boolean success.
338 function create($subject, $body, $thread_id='', $is_followup_to='',$has_attach=false) {
340 if (!$body || !$subject) {
341 $this->setError(_('Must Include A Message Body And Subject'));
344 if (!$this->Forum->userCanPost()) {
345 $this->setPermissionDeniedError();
348 if (!session_loggedin()) {
351 $user_id=user_getid();
354 if ($is_follow_up_to) {
355 $ParentMessage=new ForumMessage($this->Forum,$is_followup_to);
356 if (!$ParentMessage || !is_object($ParentMessage)) {
357 $this->setError("ForumMessage::create()"._('ForumMessage::create() No Valid ParentMessage Object'));
360 if ($ParentMessage->isError()) {
361 $this->setError('ForumMessage::create() '.$ParentMessage->getErrorMessage());
365 if (!$is_followup_to) {
369 //see if that message has been posted already for all the idiots that double-post
370 //we shouldn't need this, the double post checker functions solve this issue now
371 /*$res3=db_query("SELECT * FROM forum
372 WHERE is_followup_to='$is_followup_to'
373 AND body='". htmlspecialchars($body) ."'
374 AND subject='". htmlspecialchars($subject) ."'
375 AND group_forum_id='". $this->Forum->getId() ."'
376 AND posted_by='$user_id'");
378 if (db_numrows($res3) > 0) {
379 //already posted this message
380 $this->setError(_('You appear to be double-posting this message, since it has the same subject and followup information as a prior post.'));
388 //now we check the moderation status of the forum and act accordingly
389 $mod_level = $this->Forum->GetModerationLevel();
390 switch ($mod_level) {
393 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach);
396 //moderation for anonymous & non project users
397 if ($this->Forum->userIsModLvl1()) {
398 return $this->insertmoderated($subject, $body, $thread_id, $is_followup_to,$user_id);
400 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach);
404 //moderation for anyone who can post (even project members). admins can always post...
405 if ($this->Forum->userIsModLvl2()) {
406 return $this->insertmoderated($subject, $body, $thread_id, $is_followup_to,$user_id);
408 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach);
415 * fetchData - re-fetch the data for this forum_message from the database.
417 * @param int The message ID.
418 * @return boolean success.
420 function fetchData($msg_id) {
422 $res=db_query("SELECT * FROM forum_user_vw
423 WHERE msg_id='$msg_id'
424 AND group_forum_id='". $this->Forum->getID() ."'");
425 if (!$res || db_numrows($res) < 1) {
426 $this->setError(_('ForumMessage::fetchData() Invalid MessageID').db_error());
429 $this->data_array =& db_fetch_array($res);
430 db_free_result($res);
435 * fetchModeratedData - re-fetch the data for this forum_message from the database, for pending messages
437 * @param int The message ID.
438 * @return boolean success.
440 function fetchModeratedData($msg_id) {
442 $res=db_query("SELECT * FROM forum_pending_user_vw
443 WHERE msg_id='$msg_id'
444 AND group_forum_id='". $this->Forum->getID() ."'");
445 if (!$res || db_numrows($res) < 1) {
446 $this->setError(_('ForumMessage::fetchData() Invalid MessageID').db_error());
449 $this->data_array =& db_fetch_array($res);
450 db_free_result($res);
455 * getForum - get the Forum object this ForumMessage is associated with.
457 * @return object The Forum object.
459 function &getForum() {
464 * getID - get this message_id.
466 * @return int The message_id.
469 return $this->data_array['msg_id'];
473 * getPosterName - get the unix user_name of this message's poster.
475 * @return string The poster's unix name.
477 function getPosterName() {
478 return $this->data_array['user_name'];
482 * getPosterID - get this user_id of this message's poster.
484 * @return int The user_id.
486 function getPosterID() {
487 return $this->data_array['posted_by'];
491 * getPosterRealName - get the real name of this message's poster.
493 * @return string The real name.
495 function getPosterRealName() {
496 return $this->data_array['realname'];
500 * getSubject - get the subject of this message.
502 * @return string The subject.
504 function getSubject() {
505 return $this->data_array['subject'];
509 * getBody - get the body of this message.
511 * @return String The body.
514 return $this->data_array['body'];
518 * getPostDate - get the post date of this message.
520 * @return int The post date.
522 function getPostDate() {
523 return $this->data_array['post_date'];
527 * getParentID - get the id of the parent message, if this is a followup.
529 * @return int The parent id.
531 function getParentID() {
532 return $this->data_array['is_followup_to'];
536 * isPending - is the message pending, awaiting moderation?
538 * @return int awaits_moderation
540 function isPending() {
541 return $this->awaits_moderation;
545 * getThreadID - get the thread_id of the message.
547 * @return int The thread_id.
549 function getThreadID() {
550 return $this->data_array['thread_id'];
554 * getMostRecentDate - get the date of the most recent followup.
556 * @return int The date of the most recent followup.
558 function getMostRecentDate() {
559 return $this->data_array['most_recent_date'];
563 * hasFollowups - whether this message has any followups.
565 * @return boolean has_followups.
567 function hasFollowups() {
568 return $this->data_array['has_followups'];
572 * hasAttach - whether this message has an attachment.
574 * @return boolean has_attach.
577 function hasAttach() {
578 if ($this->isPending()) {
579 $sql = "SELECT attachmentid FROM forum_pending_attachment WHERE msg_id='$this->getID()'";
581 $sql = "SELECT attachmentid FROM forum_attachment WHERE msg_id='$this->getID()'";
583 if ((db_numrows(db_query($sql)) > 0 )) {
590 * delete - Delete this message and its followups.
592 * @return int The count of deleted messages.
596 $msg_id=$this->getID();
598 $this->setError(_('Invalid Message ID'));
602 if (!$this->Forum->userIsAdmin()) {
603 $this->setPermissionDeniedError();
607 /*$perm =& $this->Forum->Group->getPermission( session_get_user() );
609 if (!$perm || !is_object($perm) || !$perm->isForumAdmin()) {
610 $this->setPermissionDeniedError();
614 $sql="SELECT msg_id FROM forum
615 WHERE is_followup_to='$msg_id'
616 AND group_forum_id='".$this->Forum->getID()."'";
617 $result=db_query($sql);
618 $rows=db_numrows($result);
622 for ($i=0;$i<$rows;$i++) {
623 $msg = new ForumMessage($this->Forum,db_result($result,$i,'msg_id'));
624 $count += $msg->delete();
626 $sql="DELETE FROM forum
627 WHERE msg_id='$msg_id'
628 AND group_forum_id='".$this->Forum->getID()."'";
629 $toss=db_query($sql);
630 $sql = "DELETE FROM forum_attachment where msg_id='$msg_id'";
631 $res = db_query($res);
638 * removebbcode - workaround to remove bbcode tags.
640 * @return string converted text
642 function removebbcode($text) {
643 //$replaced = preg_replace("/\[[_a-zA-Z]:.+\](.+)\[\/[_a-zA-Z]:.*\]/","$1",$text);
644 $replaced = preg_replace("/\[.+\](.+)\[\/.+\]/","$1",$text);
649 * sendNotice - contains the logic to send out email followups when a message is posted.
651 * @param boolean Whether the message has an attach associated. Defaults to false
653 * @return boolean success.
655 function sendNotice($has_attach=false) {
657 $ids =& $this->Forum->getMonitoringIDs();
660 // See if there is anyone to send messages to
662 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
666 $body = "\nRead and respond to this message at: ".
667 "\nhttp://".$GLOBALS['sys_default_domain']."/forum/message.php?msg_id=".$this->getID().
668 "\nOr by replying to this e-mail entering your response between the following markers: ".
669 "\n".FORUM_MAIL_MARKER.
670 "\n(enter your response here)".
671 "\n".FORUM_MAIL_MARKER.
673 "\nBy: " . $this->getPosterRealName() . "\n";
676 //if there's an attachment for the message, make it note.
677 //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
678 $body .= "A file has been uploaded with this message\n\n";
682 $sanitizer = new TextSanitizer();
683 $text = $this->getBody();
684 $text = $sanitizer->convertNeededTagsForEmail($text);
685 $text= strip_tags($this->removebbcode(util_line_wrap($text)));
686 $text = $sanitizer->convertExtendedCharsForEmail($text);
688 "\n\n______________________________________________________________________".
689 "\nYou are receiving this email because you elected to monitor this forum.".
690 "\nTo stop monitoring this forum, login to ".$GLOBALS['sys_name']." and visit: ".
691 "\nhttp://".$GLOBALS['sys_default_domain']."/forum/monitor.php?forum_id=".$this->Forum->getID() .'&group_id='.$this->Forum->Group->getID().'&stop=1';
693 //$extra_headers = 'Reply-to: '.$this->Forum->getUnixName().'@'.$GLOBALS['sys_default_domain'];
694 $extra_headers = "Return-Path: <noreply@".$GLOBALS['sys_default_domain'].">\n";
695 $extra_headers .= "Errors-To: <noreply@".$GLOBALS['sys_default_domain'].">\n";
696 $extra_headers .= "Sender: <noreply@".$GLOBALS['sys_default_domain'].">\n";
697 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
698 $extra_headers .= "Precedence: Bulk\n"
699 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".$GLOBALS['sys_default_domain'].">\n"
700 ."List-Help: http://".$GLOBALS['sys_default_domain']."/forum/forum.php?id=".$this->Forum->getId()."\n"
701 ."Message-Id: <forumpost".$this->getId()."@".$GLOBALS['sys_default_domain'].">";
702 $parentid = $this->getParentId();
703 if (!empty($parentid)) {
704 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
705 ."References: <forumpost".$this->getParentId()."@".$GLOBALS['sys_default_domain'].">";
708 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
709 if (count($ids) != 0) {
710 // maybe we have no monitoring ids. this was causing a transaction to be aborted because of being called everytime
711 $sql="SELECT email FROM users WHERE status='A' AND user_id IN ('".implode($ids,'\',\'')."')";
712 $bccres = db_query($sql);
714 $BCC =& implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
716 $User = user_get_object($this->getPosterID());
717 util_send_message('',$subject,$body,"noreply@".$GLOBALS['sys_default_domain'],$BCC,'Forum',$extra_headers);
718 //util_send_message('',$subject,$body,$User->getEmail(),$BCC,$this->getPosterRealName(),$extra_headers);
719 // util_handle_message(array_unique($ids),$subject,$body,$this->Forum->getSendAllPostsTo(),'','forumgateway@'.$GLOBALS[sys_default_domain]);
724 * sendNewModeratedMsgNotice - contains the logic to send out email notifications to the forum admins when a new moderated message is posted
726 * @return boolean success.
728 function sendNewModeratedMsgNotice() {
731 $ids =& $this->Forum->getForumAdminIDs();
734 // See if there is anyone to send messages to
736 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
740 $f =& $this->getForum();
741 $g =& $f->getGroup();
743 $body = "\nRead to this message and approve/reject it at: ".
744 "\nhttp://".$GLOBALS['sys_default_domain']."/forum/admin/pending.php?action=view_pending&group_id=". $g->getID() . "&forum_id=" . $f->getID() .
745 "\nBy: " . $this->getPosterRealName() . "\n\n";
747 $text = $this->getBody();
748 $sanitizer = new TextSanitizer();
749 $text = $sanitizer->convertNeededTagsForEmail($text);
750 $text= strip_tags($this->removebbcode(util_line_wrap($text)));
751 $text = $sanitizer->convertExtendedCharsForEmail($text);
753 "\n\n______________________________________________________________________".
754 "\nYou are receiving this email because the forum you administrate has a new moderated message awaiting your approval.";
756 //$extra_headers = 'Reply-to: '.$this->Forum->getUnixName().'@'.$GLOBALS['sys_default_domain'];
757 $extra_headers = "Return-Path: <noreply@".$GLOBALS['sys_default_domain'].">\n";
758 $extra_headers .= "Errors-To: <noreply@".$GLOBALS['sys_default_domain'].">\n";
759 $extra_headers .= "Sender: <noreply@".$GLOBALS['sys_default_domain'].">\n";
760 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
761 $extra_headers .= "Precedence: Bulk\n"
762 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".$GLOBALS['sys_default_domain'].">\n"
763 ."List-Help: http://".$GLOBALS['sys_default_domain']."/forum/forum.php?id=".$this->Forum->getId()."\n"
764 ."Message-Id: <forumpost".$this->getId()."@".$GLOBALS['sys_default_domain'].">";
765 $parentid = $this->getParentId();
766 if (!empty($parentid)) {
767 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
768 ."References: <forumpost".$this->getParentId()."@".$GLOBALS['sys_default_domain'].">";
771 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
772 if (count($ids) != 0) {
773 $sql="SELECT email FROM users WHERE status='A' AND user_id IN ('".implode($ids,'\',\'')."')";
774 $bccres = db_query($sql);
777 $BCC =& implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
778 $User = user_get_object($this->getPosterID());
779 //util_send_message('',$subject,$body,$User->getEmail(),$BCC,$this->getPosterRealName(),$extra_headers);
780 util_send_message('',$subject,$body,"noreply@".$GLOBALS['sys_default_domain'],$BCC,'Forum',$extra_headers);
781 // util_handle_message(array_unique($ids),$subject,$body,$this->Forum->getSendAllPostsTo(),'','forumgateway@'.$GLOBALS[sys_default_domain]);
786 * updatemsg - impacts in the DB the new content of the message
788 * @param string The forum ID
789 * @param int The id of the user that is posting the message
790 * @param string The subject of the message.
791 * @param string The body of the message.
792 * @param string The post date
793 * @param int The message_id of the parent message, if any.
794 * @param int The thread_id of the message, if known.
795 * @param int has followups?
796 * @param string The most recent date.
798 * @return boolean success.
800 function updatemsg($group_forum_id,$posted_by,$subject,$body,$post_date,$is_followup_to,$thread_id,$has_followups,$most_recent_date) {
801 $subject = htmlspecialchars($subject);
803 $msg_id = $this->getID();
805 SET group_forum_id='$group_forum_id' , posted_by='$posted_by' , subject='$subject',
806 body='$body', post_date='$post_date' , is_followup_to='$is_followup_to' ,
807 thread_id='$thread_id',most_recent_date='$most_recent_date'
808 WHERE msg_id='$msg_id'";
809 $res = db_query($sql);
811 $this->setError(db_error());
814 if (db_affected_rows($res)<1) {
815 $this->setError("Message not found");
823 * sendAttachNotice - contains the logic to send out email attachement followups when a message is posted.
825 * @param int attach_id - The id of the file that has been attached
827 * @return boolean success.
829 function sendAttachNotice($attach_id) {
833 $ids =& $this->Forum->getMonitoringIDs();
836 // See if there is anyone to send messages to
838 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
842 $body = "\nRead and respond to this message at: ".
843 "\nhttp://".$GLOBALS['sys_default_domain']."/forum/message.php?msg_id=".$this->getID().
844 "\nBy: " . $this->getPosterRealName() . "\n\n";
846 $body .= "A file has been uploaded to this message, you can download it at: ".
847 "\nhttp://".$GLOBALS['sys_default_domain']."/forum/attachment.php?attachid=". $attach_id . "&group_id=" . $this->Forum->Group->getID() . "&forum_id=" . $this->Forum->getID() . "\n\n";
850 "\n\n______________________________________________________________________".
851 "\nYou are receiving this email because you elected to monitor this forum.".
852 "\nTo stop monitoring this forum, login to ".$GLOBALS['sys_name']." and visit: ".
853 "\nhttp://".$GLOBALS['sys_default_domain']."/forum/monitor.php?forum_id=".$this->Forum->getID() .'&group_id='.$this->Forum->Group->getID().'&stop=1';
855 $extra_headers = "Return-Path: <noreply@".$GLOBALS['sys_default_domain'].">\n";
856 $extra_headers .= "Errors-To: <noreply@".$GLOBALS['sys_default_domain'].">\n";
857 $extra_headers .= "Sender: <noreply@".$GLOBALS['sys_default_domain'].">\n";
858 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
859 $extra_headers .= "Precedence: Bulk\n"
860 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".$GLOBALS['sys_default_domain'].">\n"
861 ."List-Help: http://".$GLOBALS['sys_default_domain']."/forum/forum.php?id=".$this->Forum->getId()."\n"
862 ."Message-Id: <forumpost".$this->getId()."@".$GLOBALS['sys_default_domain'].">";
863 $parentid = $this->getParentId();
864 if (!empty($parentid)) {
865 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
866 ."References: <forumpost".$this->getParentId()."@".$GLOBALS['sys_default_domain'].">";
869 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
870 if (count($ids) != 0) {
871 $sql="SELECT email FROM users WHERE status='A' AND user_id IN ('".implode($ids,'\',\'')."')";
872 $bccres = db_query($sql);
874 $BCC =& implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
875 $User = user_get_object($this->getPosterID());
876 util_send_message('',$subject,$body,"noreply@".$GLOBALS['sys_default_domain'],$BCC,'Forum',$extra_headers);