5 * Copyright 1999-2000, Tim Perdue/Sourceforge
6 * Copyright 2002, Tim Perdue/GForge, LLC
7 * Copyright 2009, Roland Mas
8 * Copyright 2013, Franck Villaume - TrivialDev
9 * Copyright 2013, French Ministry of National Education
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 $gfcommon.'include/Error.class.php';
28 include_once $gfcommon.'include/TextSanitizer.class.php'; // for parsing the mail body
29 include_once $gfcommon.'include/User.class.php';
31 class ForumMessage extends FFError {
33 var $awaits_moderation;//boolean -> true if the message was inserted for approval (pending), false if not
35 * Associative array of data from db.
37 * @var array $data_array.
51 * @param object $Forum The Forum object to which this ForumMessage is associated.
52 * @param bool|int $msg_id The message_id.
53 * @param array $arr The associative array of data.
54 * @param bool $pending Whether the message is a pending one.
55 * @return bool success.
57 function ForumMessage(&$Forum, $msg_id=false, $arr=array(), $pending=false) {
59 if (!$Forum || !is_object($Forum)) {
60 $this->setError(_('Invalid Forum Object'));
63 if ($Forum->isError()) {
64 $this->setError('ForumMessage: '.$Forum->getErrorMessage());
67 $this->Forum =& $Forum;
71 //we are going to create the pending message to show it to the admin for moderation
72 if (!$this->fetchModeratedData($msg_id)) {
75 $this->awaits_moderation = true;
77 $this->awaits_moderation = false;
78 if (!$arr || !is_array($arr)) {
79 if (!$this->fetchData($msg_id)) {
83 $this->data_array =& $arr;
85 // Verify this message truly belongs to this Forum
87 if ($this->data_array['group_forum_id'] != $this->Forum->getID()) {
88 $this->setError(_('Group_forum_id in db result does not match Forum Object'));
89 $this->data_array=null;
99 * insertmoderated - inserts the message into the table for moderation (forum_pending_messages)
101 * @param string $subject The subject of the message.
102 * @param string $body The body of the message.
103 * @param int $thread_id The thread_id of the message, if known.
104 * @param int $is_followup_to The message_id of the parent message, if any.
105 * @param int $user_id The id of the user that is posting the message
106 * @return boolean success.
108 function insertmoderated($subject, $body, $thread_id=0, $is_followup_to=0,$user_id) {
110 $thread_id=$this->Forum->getNextThreadID();
113 $this->setError('ForumMessage: '._('Getting next thread_id failed'));
119 $result = db_query_params ('INSERT INTO forum_pending_messages (group_forum_id,posted_by,subject,
120 body,post_date,is_followup_to,thread_id,most_recent_date) VALUES ($1,$2,$3,$4,$5,$6,$7,$8)',
121 array ($this->Forum->getID(),
123 htmlspecialchars($subject),
129 if (!$result || db_affected_rows($result) < 1) {
130 $this->setError(_('Posting Failed').' '.db_error());
134 $msg_id=db_insertid($result,'forum_pending_messages','msg_id');
135 if (!$this->fetchModeratedData($msg_id)) {
141 $this->setError(_('Unable to get new message id'));
144 if (!$this->sendNewModeratedMsgNotice()) {
149 $this->awaits_moderation = true;
156 * insertreleasedmsg - inserts the released message into the main table (forum)
158 * @param string $group_forum_id The Forum id
159 * @param string $subject The subject of the message.
160 * @param string $body The body of the message.
161 * @param string $post_date The post date
162 * @param int $thread_id The thread_id of the message
163 * @param int $is_followup_to The message_id of the parent message, if any.
164 * @param int $posted_by The id of the user that is posting the message
165 * @param int $has_followups has followups?
166 * @param int $most_recent_date most recent date
167 * @return bool success.
169 function insertreleasedmsg($group_forum_id, $subject, $body, $post_date, $thread_id,
170 $is_followup_to, $posted_by, $has_followups, $most_recent_date) {
171 if ($is_followup_to != 0) {
173 //was posted in reply to another thread
174 //we must check whether that thread still exists. if it does, post the message. else, set the error
176 // increment the parent's followup count if necessary
179 $res4 = db_query_params ('UPDATE forum SET most_recent_date=$1 WHERE thread_id=$2 AND is_followup_to=0',
182 if (!$res4 || db_affected_rows($res4) < 1) {
183 $this->setError(_('Could not Update Master Thread parent with current time'));
188 // mark the parent with followups as an optimization later
190 $res3 = db_query_params ('UPDATE forum SET has_followups=1,most_recent_date=$1 WHERE msg_id=$2',
194 $this->setError(_('Could Not Update Parent'));
204 $result = db_query_params ('INSERT INTO forum (group_forum_id,posted_by,subject,body,post_date,is_followup_to,thread_id,most_recent_date) VALUES ($1,$2,$3,$4,$5,$6,$7,$8)',
205 array ($group_forum_id,
207 htmlspecialchars($subject),
212 $most_recent_date)) ;
214 if (!$result || db_affected_rows($result) < 1) {
215 $this->setError(_('Posting Failed').' '.db_error());
219 $msg_id=db_insertid($result,'forum','msg_id');
220 if (!$this->fetchData($msg_id)) {
221 $this->setError(_('Posting Failed').' '.db_error());
226 $this->setError(_('Unable to get new message id'));
230 if (!$this->sendNotice()) {
235 $this->awaits_moderation = false;
242 * insertmsg - inserts the message into the main table (forum)
244 * @param string $subject The subject of the message.
245 * @param string $body The body of the message.
246 * @param int $thread_id The thread_id of the message, if known.
247 * @param int $is_followup_to The message_id of the parent message, if any.
248 * @param int $user_id The id of the user that is posting the message
249 * @param bool $has_attach Whether the message has an attach associated. Defaults to false
250 * @param int $timestamp The timestamp of the message to insert, defaults to 0.
251 * @return boolean success.
253 function insertmsg($subject, $body, $thread_id=0, $is_followup_to=0,
254 $user_id, $has_attach=false, $timestamp=0) {
255 if ($timestamp == 0){
259 $thread_id=$this->Forum->getNextThreadID();
262 $this->setError('ForumMessage: '._('Getting next thread_id failed'));
267 $most_recent_lookup = db_query_params ('SELECT most_recent_date FROM forum WHERE thread_id=$1 AND is_followup_to=0',array($thread_id));
268 if (db_result($most_recent_lookup, 0, 'most_recent_date') <= $timestamp) {
270 // increment the parent's followup count if necessary
272 $res4 = db_query_params ('UPDATE forum SET most_recent_date=$1 WHERE thread_id=$2 AND is_followup_to=0',
275 if (!$res4 || db_affected_rows($res4) < 1) {
276 $this->setError(_('Could not Update Master Thread parent with current time'));
281 // Only update the time if set time < timestamp (set to current time if not done for an import)
283 $res3 = db_query_params ('UPDATE forum SET most_recent_date=$1 WHERE msg_id=$2',
287 $this->setError(_('Could Not Update Parent'));
294 // mark the parent with followups as an optimization later
296 $res3 = db_query_params ('UPDATE forum SET has_followups=1 WHERE msg_id=$1',
297 array ($is_followup_to)) ;
299 $this->setError(_('Could Not Update Parent'));
305 $result = db_query_params ('INSERT INTO forum (group_forum_id,posted_by,subject,body,post_date,is_followup_to,thread_id,most_recent_date) VALUES ($1,$2,$3,$4,$5,$6,$7,$8)',
306 array ($this->Forum->getID(),
308 htmlspecialchars($subject),
314 if (!$result || db_affected_rows($result) < 1) {
315 $this->setError(_('Posting Failed').' '.db_error());
320 $msg_id=db_insertid($result,'forum','msg_id');
321 if (!$this->fetchData($msg_id)) {
327 $this->setError(_('Unable to get new message id'));
332 if (!$this->sendNotice($has_attach)) {
338 //echo "db_error()".db_error();
339 $this->awaits_moderation = false;
344 * create - use this function to create a new message in the database.
346 * @param string $subject The subject of the message.
347 * @param string $body The body of the message.
348 * @param int $thread_id The thread_id of the message, if known.
349 * @param int $is_followup_to The message_id of the parent message, if any.
350 * @param bool $has_attach Whether the message has an attach associated. Defaults to false
351 * @param int $timestamp The timestamp of the message to create. Defaults to 0, meaning the timestamp used for this message will be "time()"
352 * @return boolean success.
354 function create($subject, $body, $thread_id=0, $is_followup_to=0, $has_attach=false, $timestamp = 0) {
355 if (!strlen(trim($body)) || !strlen(trim($subject))) {
356 $this->setError(_('Error: a forum message must include a message body and a subject.'));
359 if (!forge_check_perm ('forum', $this->Forum->getID(), 'post')) {
360 $this->setPermissionDeniedError();
363 if (!session_loggedin()) {
366 $user_id=user_getid();
369 if ($is_followup_to) {
370 $ParentMessage=new ForumMessage($this->Forum,$is_followup_to);
371 if (!$ParentMessage || !is_object($ParentMessage)) {
372 $this->setError(_('Invalid ParentMessage Object'));
375 if ($ParentMessage->isError()) {
376 $this->setError('ForumMessage '.$ParentMessage->getErrorMessage());
380 if (!$is_followup_to) {
386 //now we check the moderation status of the forum and act accordingly
387 if (forge_check_perm ('forum', $this->Forum->getID(), 'unmoderated_post')) {
389 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach,$timestamp);
391 return $this->insertmoderated($subject, $body, $thread_id, $is_followup_to,$user_id);
396 * fetchData - re-fetch the data for this forum_message from the database.
398 * @param int $msg_id The message ID.
399 * @return boolean success.
401 function fetchData($msg_id) {
402 $res = db_query_params ('SELECT * FROM forum_user_vw WHERE msg_id=$1 AND group_forum_id=$2',
403 array($msg_id, $this->Forum->getID()));
404 if (!$res || db_numrows($res) < 1) {
405 $this->setError(_('Invalid Message Id'));
408 $this->data_array = db_fetch_array($res);
409 db_free_result($res);
414 * fetchModeratedData - re-fetch the data for this forum_message from the database, for pending messages
416 * @param int The message ID.
417 * @return boolean success.
419 function fetchModeratedData($msg_id) {
420 $res = db_query_params ('SELECT * FROM forum_pending_user_vw WHERE msg_id=$1 AND group_forum_id=$2',
421 array($msg_id, $this->Forum->getID()));
422 if (!$res || db_numrows($res) < 1) {
423 $this->setError(_('Invalid Message Id'));
426 $this->data_array = db_fetch_array($res);
427 db_free_result($res);
432 * getForum - get the Forum object this ForumMessage is associated with.
434 * @return object The Forum object.
436 function &getForum() {
441 * getID - get this message_id.
443 * @return int The message_id.
446 return $this->data_array['msg_id'];
450 * getPosterName - get the unix user_name of this message's poster.
452 * @return string The poster's unix name.
454 function getPosterName() {
455 return $this->data_array['user_name'];
459 * getPosterID - get this user_id of this message's poster.
461 * @return int The user_id.
463 function getPosterID() {
464 return $this->data_array['posted_by'];
468 * getPosterRealName - get the real name of this message's poster.
470 * @return string The real name.
472 function getPosterRealName() {
473 return $this->data_array['realname'];
477 * getSubject - get the subject of this message.
479 * @return string The subject.
481 function getSubject() {
482 return $this->data_array['subject'];
486 * getBody - get the body of this message.
488 * @return String The body.
491 return $this->data_array['body'];
495 * getPostDate - get the post date of this message.
497 * @return int The post date.
499 function getPostDate() {
500 return $this->data_array['post_date'];
504 * getParentID - get the id of the parent message, if this is a followup.
506 * @return int The parent id.
508 function getParentID() {
509 return $this->data_array['is_followup_to'];
513 * isPending - is the message pending, awaiting moderation?
515 * @return int awaits_moderation
517 function isPending() {
518 return $this->awaits_moderation;
522 * getThreadID - get the thread_id of the message.
524 * @return int The thread_id.
526 function getThreadID() {
527 return $this->data_array['thread_id'];
531 * getMostRecentDate - get the date of the most recent followup.
533 * @return int The date of the most recent followup.
535 function getMostRecentDate() {
536 return $this->data_array['most_recent_date'];
540 * hasFollowups - whether this message has any followups.
542 * @return boolean has_followups.
544 function hasFollowups() {
545 return $this->data_array['has_followups'];
549 * hasAttach - whether this message has an attachment.
551 * @return boolean has_attach.
553 function hasAttach() {
554 if ($this->isPending()) {
555 $res = db_query_params ('SELECT attachmentid FROM forum_pending_attachment WHERE msg_id=$1',
556 array ($this->getID())) ;
558 $res = db_query_params ('SELECT attachmentid FROM forum_attachment WHERE msg_id=$1',
559 array ($this->getID())) ;
561 if (db_numrows($res) > 0) {
568 * delete - Delete this message and its followups.
570 * @return int The count of deleted messages.
573 $msg_id=$this->getID();
575 $this->setError(_('Invalid Message Id'));
579 if (!forge_check_perm ('forum_admin', $this->Forum->Group->getID())) {
580 $this->setPermissionDeniedError();
584 $result = db_query_params ('SELECT msg_id FROM forum
585 WHERE is_followup_to=$1
586 AND group_forum_id=$2',
588 $this->Forum->getID())) ;
589 $rows=db_numrows($result);
592 for ($i=0;$i<$rows;$i++) {
593 $msg = new ForumMessage($this->Forum,db_result($result,$i,'msg_id'));
594 $count += $msg->delete();
597 $res_pa = db_query_params('SELECT attachmentid FROM forum_attachment WHERE msg_id=$1',
599 while ($pa = db_fetch_array($res_pa)) {
600 ForumStorage::instance()->delete($pa['attachmentid']);
601 db_query_params('DELETE FROM forum_attachment WHERE attachmentid=$1',
602 array($pa['attachmentid']));
604 ForumStorage::instance()->commit();
606 $toss = db_query_params('DELETE FROM forum WHERE msg_id=$1 AND group_forum_id=$2',
607 array ($msg_id, $this->Forum->getID()));
613 * removebbcode - workaround to remove bbcode tags.
615 * @param string $text
616 * @return string converted text
618 function removebbcode($text) {
619 //$replaced = preg_replace("/\[[_a-zA-Z]:.+\](.+)\[\/[_a-zA-Z]:.*\]/","$1",$text);
620 $replaced = preg_replace("/\[.+\](.+)\[\/.+\]/","$1",$text);
625 * sendNotice - contains the logic to send out email followups when a message is posted.
627 * @param boolean $has_attach Whether the message has an attach associated. Defaults to false
628 * @return boolean success.
630 function sendNotice($has_attach=false) {
631 $ids = $this->Forum->getMonitoringIDs();
633 $recipients = array ();
634 foreach ($ids as $id) {
635 $recipient = user_get_object ($id) ;
636 if ($recipient->isActive()) {
637 $recipients[] = $recipient ;
640 if ($this->Forum->getSendAllPostsTo()) {
641 $sapt = explode (',', $this->Forum->getSendAllPostsTo()) ;
642 foreach ($sapt as $r) {
647 if (count ($recipients) == 0) {
651 foreach ($recipients as $recipient) {
652 if ($recipient instanceof GFUser) {
653 setup_gettext_for_user ($recipient) ;
654 $dest_email = $recipient->getEmail ();
656 setup_gettext_from_sys_lang ();
657 $dest_email = $recipient ;
660 $body = sprintf(_("\nRead and respond to this message at: \n%s"), util_make_url ('/forum/message.php?msg_id='.$this->getID()));
661 if (forge_get_config('use_mail') && forge_get_config('use_forum_mail_replies')) {
662 $body .= stripcslashes(sprintf(_('
663 Or reply to this e-mail entering your response between the following markers:
665 (enter your response here)
666 %1$s'), FORUM_MAIL_MARKER));
668 $body .= "\n\n\n"._('By')._(': ').$this->getPosterRealName()."\n";
671 //if there's an attachment for the message, make it note.
672 //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
673 $body .= _("A file has been uploaded with this message.")."\n\n";
677 $sanitizer = new TextSanitizer();
678 $text = $this->getBody();
679 $text = $sanitizer->convertNeededTagsForEmail($text);
680 $text = strip_tags($this->removebbcode(util_line_wrap($text)));
681 $text = $sanitizer->convertExtendedCharsForEmail($text);
683 "%s\n\n______________________________________________________________________\n".
684 _("You are receiving this email because you elected to monitor this forum.".
685 "\nTo stop monitoring this forum, login to %s and visit: \n%s\n"),
687 forge_get_config ('forge_name'),
688 util_make_url('/forum/monitor.php?forum_id='.$this->Forum->getID().
689 '&group_id='.$this->Forum->Group->getID().'&stop=1')
692 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
693 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
694 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n";
695 if (forge_get_config('use_mail') && forge_get_config('use_forum_mail_replies')) {
696 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
698 $extra_headers .= "Precedence: Bulk\n"
699 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".forge_get_config('web_host').">\n"
700 ."List-Help: ".util_make_url ('/forum/forum.php?id='.$this->Forum->getId())."\n"
701 ."Message-Id: <forumpost".$this->getId()."@".forge_get_config('web_host').">";
702 $parentid = $this->getParentId();
703 if (!empty($parentid)) {
704 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
705 ."References: <forumpost".$this->getParentId()."@".forge_get_config('web_host').">";
708 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
710 util_send_message($dest_email,$subject,$body,"noreply@".forge_get_config('web_host'),'','Forum',$extra_headers);
713 // Switch back to the user language settings
714 setup_gettext_from_context();
719 * sendNewModeratedMsgNotice - contains the logic to send out email notifications to the forum admins when a new moderated message is posted
721 * @return boolean success.
723 function sendNewModeratedMsgNotice() {
725 $engine = RBACEngine::getInstance();
726 $moderators = $engine->getUsersByAllowedAction('forum', $this->Forum->getID(), 'moderate');
728 foreach ($moderators as $m) {
729 $ids[] = $m->getID();
733 // See if there is anyone to send messages to
735 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
739 $f =& $this->getForum();
740 $g =& $f->getGroup();
742 $body = "\nRead to this message and approve/reject it at: ".
743 "\n".util_make_url('/forum/admin/pending.php?action=view_pending&group_id='. $g->getID() . "&forum_id=" . $f->getID()) .
744 "\nBy: " . $this->getPosterRealName() . "\n\n";
746 $text = $this->getBody();
747 $sanitizer = new TextSanitizer();
748 $text = $sanitizer->convertNeededTagsForEmail($text);
749 $text= strip_tags($this->removebbcode(util_line_wrap($text)));
750 $text = $sanitizer->convertExtendedCharsForEmail($text);
752 "\n\n______________________________________________________________________".
753 "\nYou are receiving this email because the forum you administrate has a new moderated message awaiting your approval.";
755 //$extra_headers = 'Reply-to: '.$this->Forum->getUnixName().'@'.forge_get_config('web_host');
756 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
757 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
758 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n";
759 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
760 $extra_headers .= "Precedence: Bulk\n"
761 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".forge_get_config('web_host').">\n"
762 ."List-Help: ".util_make_url('/forum/forum.php?id='.$this->Forum->getId())."\n"
763 ."Message-Id: <forumpost".$this->getId()."@".forge_get_config('web_host').">";
764 $parentid = $this->getParentId();
765 if (!empty($parentid)) {
766 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
767 ."References: <forumpost".$this->getParentId()."@".forge_get_config('web_host').">";
770 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
771 if (count($ids) != 0) {
772 $bccres = db_query_params ('SELECT email FROM users WHERE status=$1 AND user_id = ANY ($2)',
774 db_int_array_to_any_clause ($ids))) ;
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@".forge_get_config('web_host'),$BCC,'Forum',$extra_headers);
781 // util_handle_message(array_unique($ids),$subject,$body,$this->Forum->getSendAllPostsTo(),'','forumgateway@'.forge_get_config('web_host'));
786 * updatemsg - impacts in the DB the new content of the message
788 * @param string $group_forum_id The forum ID
789 * @param int $posted_by The id of the user that is posting the message
790 * @param string $subject The subject of the message.
791 * @param string $body The body of the message.
792 * @param string $post_date The post date
793 * @param int $is_followup_to The message_id of the parent message, if any.
794 * @param int $thread_id The thread_id of the message, if known.
795 * @param int $has_followups has followups?
796 * @param string $most_recent_date The most recent date.
797 * @return boolean success.
799 function updatemsg($group_forum_id, $posted_by, $subject, $body,
800 $post_date, $is_followup_to, $thread_id, $has_followups, $most_recent_date) {
801 if (!strlen(trim($body)) || !strlen(trim($subject))) {
802 $this->setError(_('Error: a forum message must include a message body and a subject.'));
805 $subject = htmlspecialchars($subject);
806 $msg_id = $this->getID();
807 $res = db_query_params ('UPDATE forum
808 SET group_forum_id=$1, posted_by=$2, subject=$3,
809 body=$4, post_date=$5, is_followup_to=$6,
810 thread_id=$7, most_recent_date=$8
812 array ($group_forum_id,
822 $this->setError(db_error());
825 if (db_affected_rows($res)<1) {
826 $this->setError(_("Message not found"));
834 * sendAttachNotice - contains the logic to send out email attachement followups when a message is posted.
836 * @param int $attach_id - The id of the file that has been attached
837 * @return boolean success.
839 function sendAttachNotice($attach_id) {
841 $ids = $this->Forum->getMonitoringIDs();
844 // See if there is anyone to send messages to
846 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
850 $body = "\nRead and respond to this message at: ".
851 "\n".util_make_url('/forum/message.php?msg_id='.$this->getID()).
852 "\nBy: " . $this->getPosterRealName() . "\n\n";
854 $body .= "A file has been uploaded to this message, you can download it at: ".
855 "\n".util_make_url('/forum/attachment.php?attachid='. $attach_id . "&group_id=" . $this->Forum->Group->getID() . "&forum_id=" . $this->Forum->getID()) . "\n\n";
858 "\n\n______________________________________________________________________".
859 "\nYou are receiving this email because you elected to monitor this forum.".
860 "\nTo stop monitoring this forum, login to ".forge_get_config ('forge_name')." and visit: ".
861 "\n".util_make_url ('/forum/monitor.php?forum_id='.$this->Forum->getID() .'&group_id='.$this->Forum->Group->getID().'&stop=1');
863 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
864 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
865 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n";
866 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
867 $extra_headers .= "Precedence: Bulk\n"
868 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getId()."@".forge_get_config('web_host').">\n"
869 ."List-Help: ".util_make_url('/forum/forum.php?id='.$this->Forum->getId())."\n"
870 ."Message-Id: <forumpost".$this->getId()."@".forge_get_config('web_host').">";
871 $parentid = $this->getParentId();
872 if (!empty($parentid)) {
873 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
874 ."References: <forumpost".$this->getParentId()."@".forge_get_config('web_host').">";
877 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
878 if (count($ids) != 0) {
879 $bccres = db_query_params ('SELECT email FROM users WHERE status=$1 AND user_id = ANY ($2)',
881 db_int_array_to_any_clause ($ids))) ;
883 $BCC = implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
884 $User = user_get_object($this->getPosterID());
885 util_send_message('',$subject,$body,"noreply@".forge_get_config('web_host'),$BCC,'Forum',$extra_headers);
894 // c-file-style: "bsd"