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/FFError.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.
49 * @param object $Forum The Forum object to which this ForumMessage is associated.
50 * @param bool|int $msg_id The message_id.
51 * @param array $arr The associative array of data.
52 * @param bool $pending Whether the message is a pending one.
54 function __construct(&$Forum, $msg_id=false, $arr=array(), $pending=false) {
55 parent::__construct();
56 if (!$Forum || !is_object($Forum)) {
57 $this->setError(_('Invalid Forum Object'));
60 if ($Forum->isError()) {
61 $this->setError('ForumMessage: '.$Forum->getErrorMessage());
64 $this->Forum =& $Forum;
68 //we are going to create the pending message to show it to the admin for moderation
69 if (!$this->fetchModeratedData($msg_id)) {
72 $this->awaits_moderation = true;
74 $this->awaits_moderation = false;
75 if (!$arr || !is_array($arr)) {
76 if (!$this->fetchData($msg_id)) {
80 $this->data_array =& $arr;
82 // Verify this message truly belongs to this Forum
84 if ($this->data_array['group_forum_id'] != $this->Forum->getID()) {
85 $this->setError(_('Group_forum_id in db result does not match Forum Object'));
86 $this->data_array=null;
95 * insertmoderated - inserts the message into the table for moderation (forum_pending_messages)
97 * @param string $subject The subject of the message.
98 * @param string $body The body of the message.
99 * @param int $thread_id The thread_id of the message, if known.
100 * @param int $is_followup_to The message_id of the parent message, if any.
101 * @param int $user_id The id of the user that is posting the message
102 * @return bool success.
104 function insertmoderated($subject, $body, $thread_id=0, $is_followup_to=0,$user_id) {
106 $thread_id=$this->Forum->getNextThreadID();
109 $this->setError('ForumMessage: '._('Getting next thread_id failed'));
115 $result = db_query_params ('INSERT INTO forum_pending_messages (group_forum_id,posted_by,subject,
116 body,post_date,is_followup_to,thread_id,most_recent_date) VALUES ($1,$2,$3,$4,$5,$6,$7,$8)',
117 array ($this->Forum->getID(),
119 htmlspecialchars($subject),
125 if (!$result || db_affected_rows($result) < 1) {
126 $this->setError(_('Posting Failed').' '.db_error());
130 $msg_id=db_insertid($result,'forum_pending_messages','msg_id');
131 if (!$this->fetchModeratedData($msg_id)) {
137 $this->setError(_('Unable to get new message id'));
140 if (!$this->sendNewModeratedMsgNotice()) {
145 $this->awaits_moderation = true;
152 * insertreleasedmsg - inserts the released message into the main table (forum)
154 * @param string $group_forum_id The Forum id
155 * @param string $subject The subject of the message.
156 * @param string $body The body of the message.
157 * @param string $post_date The post date
158 * @param int $thread_id The thread_id of the message
159 * @param int $is_followup_to The message_id of the parent message, if any.
160 * @param int $posted_by The id of the user that is posting the message
161 * @param int $has_followups has followups?
162 * @param int $most_recent_date most recent date
163 * @return bool success.
165 function insertreleasedmsg($group_forum_id, $subject, $body, $post_date, $thread_id,
166 $is_followup_to, $posted_by, $has_followups, $most_recent_date) {
167 if ($is_followup_to != 0) {
169 //was posted in reply to another thread
170 //we must check whether that thread still exists. if it does, post the message. else, set the error
172 // increment the parent's followup count if necessary
175 $res4 = db_query_params ('UPDATE forum SET most_recent_date=$1 WHERE thread_id=$2 AND is_followup_to=0',
178 if (!$res4 || db_affected_rows($res4) < 1) {
179 $this->setError(_('Could not Update Master Thread parent with current time'));
184 // mark the parent with followups as an optimization later
186 $res3 = db_query_params ('UPDATE forum SET has_followups=1,most_recent_date=$1 WHERE msg_id=$2',
190 $this->setError(_('Could Not Update Parent'));
201 if (ForumHTML::getIsPinned($thread_id)) $is_pinned = 't';
202 $result = db_query_params ('INSERT INTO forum (group_forum_id,posted_by,subject,body,post_date,is_followup_to,thread_id,most_recent_date,is_pinned) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)',
203 array ($group_forum_id,
205 htmlspecialchars($subject),
213 if (!$result || db_affected_rows($result) < 1) {
214 $this->setError(_('Posting Failed').' '.db_error());
218 $msg_id=db_insertid($result,'forum','msg_id');
219 if (!$this->fetchData($msg_id)) {
220 $this->setError(_('Posting Failed').' '.db_error());
225 $this->setError(_('Unable to get new message id'));
229 if (!$this->sendNotice()) {
234 $this->awaits_moderation = false;
241 * insertmsg - inserts the message into the main table (forum)
243 * @param string $subject The subject of the message.
244 * @param string $body The body of the message.
245 * @param int $thread_id The thread_id of the message, if known.
246 * @param int $is_followup_to The message_id of the parent message, if any.
247 * @param int $user_id The id of the user that is posting the message
248 * @param bool $has_attach Whether the message has an attach associated. Defaults to false
249 * @param int $timestamp The timestamp of the message to insert, defaults to 0.
250 * @return bool success.
252 function insertmsg($subject, $body, $thread_id=0, $is_followup_to=0,
253 $user_id, $has_attach=false, $timestamp=0) {
254 if ($timestamp == 0){
258 $thread_id=$this->Forum->getNextThreadID();
261 $this->setError('ForumMessage: '._('Getting next thread_id failed'));
266 $most_recent_lookup = db_query_params ('SELECT most_recent_date FROM forum WHERE thread_id=$1 AND is_followup_to=0',array($thread_id));
267 if (db_result($most_recent_lookup, 0, 'most_recent_date') <= $timestamp) {
269 // increment the parent's followup count if necessary
271 $res4 = db_query_params ('UPDATE forum SET most_recent_date=$1 WHERE thread_id=$2 AND is_followup_to=0',
274 if (!$res4 || db_affected_rows($res4) < 1) {
275 $this->setError(_('Could not Update Master Thread parent with current time'));
280 // Only update the time if set time < timestamp (set to current time if not done for an import)
282 $res3 = db_query_params ('UPDATE forum SET most_recent_date=$1 WHERE msg_id=$2',
286 $this->setError(_('Could Not Update Parent'));
293 // mark the parent with followups as an optimization later
295 $res3 = db_query_params ('UPDATE forum SET has_followups=1 WHERE msg_id=$1',
296 array ($is_followup_to)) ;
298 $this->setError(_('Could Not Update Parent'));
305 if(ForumHTML::getIsPinned($thread_id)) $is_pinned = 't';
306 $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,$9)',
307 array ($this->Forum->getID(),
309 htmlspecialchars($subject),
316 if (!$result || db_affected_rows($result) < 1) {
317 $this->setError(_('Posting Failed').' '.db_error());
322 $msg_id=db_insertid($result,'forum','msg_id');
323 if (!$this->fetchData($msg_id)) {
329 $this->setError(_('Unable to get new message id'));
334 if (!$this->sendNotice($has_attach)) {
340 //echo "db_error()".db_error();
341 $this->awaits_moderation = false;
346 * create - use this function to create a new message in the database.
348 * @param string $subject The subject of the message.
349 * @param string $body The body of the message.
350 * @param int $thread_id The thread_id of the message, if known.
351 * @param int $is_followup_to The message_id of the parent message, if any.
352 * @param bool $has_attach Whether the message has an attach associated. Defaults to false
353 * @param int $timestamp The timestamp of the message to create. Defaults to 0, meaning the timestamp used for this message will be "time()"
354 * @return bool success.
356 function create($subject, $body, $thread_id=0, $is_followup_to=0, $has_attach=false, $timestamp = 0) {
357 if (!strlen(trim($body)) || !strlen(trim($subject))) {
358 $this->setError(_('Error: a forum message must include a message body and a subject.'));
361 if (!forge_check_perm ('forum', $this->Forum->getID(), 'post')) {
362 $this->setPermissionDeniedError();
365 if (!session_loggedin()) {
368 $user_id=user_getid();
371 if ($is_followup_to) {
372 $ParentMessage=new ForumMessage($this->Forum,$is_followup_to);
373 if (!$ParentMessage || !is_object($ParentMessage)) {
374 $this->setError(_('Invalid ParentMessage Object'));
377 if ($ParentMessage->isError()) {
378 $this->setError('ForumMessage '.$ParentMessage->getErrorMessage());
382 if (!$is_followup_to) {
388 //now we check the moderation status of the forum and act accordingly
389 if (forge_check_perm ('forum', $this->Forum->getID(), 'unmoderated_post')) {
391 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach,$timestamp);
393 return $this->insertmoderated($subject, $body, $thread_id, $is_followup_to,$user_id);
398 * fetchData - re-fetch the data for this forum_message from the database.
400 * @param int $msg_id The message ID.
401 * @return bool success.
403 function fetchData($msg_id) {
404 $res = db_query_params ('SELECT * FROM forum_user_vw WHERE msg_id=$1 AND group_forum_id=$2',
405 array($msg_id, $this->Forum->getID()));
406 if (!$res || db_numrows($res) < 1) {
407 $this->setError(_('Invalid Message Id'));
410 $this->data_array = db_fetch_array($res);
411 db_free_result($res);
416 * fetchModeratedData - re-fetch the data for this forum_message from the database, for pending messages
418 * @param int The message ID.
419 * @return bool success.
421 function fetchModeratedData($msg_id) {
422 $res = db_query_params ('SELECT * FROM forum_pending_user_vw WHERE msg_id=$1 AND group_forum_id=$2',
423 array($msg_id, $this->Forum->getID()));
424 if (!$res || db_numrows($res) < 1) {
425 $this->setError(_('Invalid Message Id'));
428 $this->data_array = db_fetch_array($res);
429 db_free_result($res);
434 * getForum - get the Forum object this ForumMessage is associated with.
436 * @return object The Forum object.
438 function &getForum() {
443 * getID - get this message_id.
445 * @return int The message_id.
448 return $this->data_array['msg_id'];
452 * getPosterName - get the unix user_name of this message's poster.
454 * @return string The poster's unix name.
456 function getPosterName() {
457 return $this->data_array['user_name'];
461 * getPosterID - get this user_id of this message's poster.
463 * @return int The user_id.
465 function getPosterID() {
466 return $this->data_array['posted_by'];
470 * getPosterRealName - get the real name of this message's poster.
472 * @return string The real name.
474 function getPosterRealName() {
475 return $this->data_array['realname'];
479 * getSubject - get the subject of this message.
481 * @return string The subject.
483 function getSubject() {
484 return $this->data_array['subject'];
488 * getBody - get the body of this message.
490 * @return String The body.
493 return $this->data_array['body'];
497 * getPostDate - get the post date of this message.
499 * @return int The post date.
501 function getPostDate() {
502 return $this->data_array['post_date'];
506 * getParentID - get the id of the parent message, if this is a followup.
508 * @return int The parent id.
510 function getParentID() {
511 return $this->data_array['is_followup_to'];
515 * isPending - is the message pending, awaiting moderation?
517 * @return int awaits_moderation
519 function isPending() {
520 return $this->awaits_moderation;
524 * getThreadID - get the thread_id of the message.
526 * @return int The thread_id.
528 function getThreadID() {
529 return $this->data_array['thread_id'];
533 * getMostRecentDate - get the date of the most recent followup.
535 * @return int The date of the most recent followup.
537 function getMostRecentDate() {
538 return $this->data_array['most_recent_date'];
542 * hasFollowups - whether this message has any followups.
544 * @return bool has_followups.
546 function hasFollowups() {
547 return $this->data_array['has_followups'];
551 * hasAttach - whether this message has an attachment.
553 * @return bool has_attach.
555 function hasAttach() {
556 if ($this->isPending()) {
557 $res = db_query_params ('SELECT attachmentid FROM forum_pending_attachment WHERE msg_id=$1',
558 array ($this->getID())) ;
560 $res = db_query_params ('SELECT attachmentid FROM forum_attachment WHERE msg_id=$1',
561 array ($this->getID())) ;
563 if (db_numrows($res) > 0) {
570 * delete - Delete this message and its followups.
572 * @return int The count of deleted messages.
575 $msg_id=$this->getID();
577 $this->setError(_('Invalid Message Id'));
581 if (!forge_check_perm ('forum_admin', $this->Forum->Group->getID())) {
582 $this->setPermissionDeniedError();
586 $result = db_query_params ('SELECT msg_id FROM forum
587 WHERE is_followup_to=$1
588 AND group_forum_id=$2',
590 $this->Forum->getID())) ;
591 $rows=db_numrows($result);
594 for ($i=0;$i<$rows;$i++) {
595 $msg = new ForumMessage($this->Forum,db_result($result,$i,'msg_id'));
596 $count += $msg->delete();
599 $res_pa = db_query_params('SELECT attachmentid FROM forum_attachment WHERE msg_id=$1',
601 while ($pa = db_fetch_array($res_pa)) {
602 ForumStorage::instance()->delete($pa['attachmentid']);
603 db_query_params('DELETE FROM forum_attachment WHERE attachmentid=$1',
604 array($pa['attachmentid']));
606 ForumStorage::instance()->commit();
608 db_query_params('DELETE FROM forum WHERE msg_id=$1 AND group_forum_id=$2',
609 array ($msg_id, $this->Forum->getID()));
615 * removebbcode - workaround to remove bbcode tags.
617 * @param string $text
618 * @return string converted text
620 function removebbcode($text) {
621 //$replaced = preg_replace("/\[[_a-zA-Z]:.+\](.+)\[\/[_a-zA-Z]:.*\]/","$1",$text);
622 $replaced = preg_replace("/\[.+\](.+)\[\/.+\]/","$1",$text);
627 * sendNotice - contains the logic to send out email followups when a message is posted.
629 * @param bool $has_attach Whether the message has an attach associated. Defaults to false
630 * @return bool success.
632 function sendNotice($has_attach=false) {
633 $ids = $this->Forum->getMonitoringIDs();
635 $recipients = array ();
636 foreach ($ids as $id) {
637 $recipient = user_get_object ($id) ;
638 if ($recipient->isActive()) {
639 $recipients[] = $recipient ;
642 if ($this->Forum->getSendAllPostsTo()) {
643 $sapt = explode (',', $this->Forum->getSendAllPostsTo()) ;
644 foreach ($sapt as $r) {
649 if (count ($recipients) == 0) {
653 foreach ($recipients as $recipient) {
654 if ($recipient instanceof FFUser) {
655 setup_gettext_for_user ($recipient) ;
656 $dest_email = $recipient->getEmail ();
658 setup_gettext_from_sys_lang ();
659 $dest_email = $recipient ;
662 $body = sprintf(_("\nRead and respond to this message at: \n%s"), util_make_url ('/forum/message.php?msg_id='.$this->getID()));
663 if (forge_get_config('use_mail') && forge_get_config('use_forum_mail_replies')) {
664 $body .= stripcslashes(sprintf(_('
665 Or reply to this e-mail entering your response between the following markers:
667 (enter your response here)
668 %1$s'), FORUM_MAIL_MARKER));
670 $body .= "\n\n\n"._('By')._(': ').$this->getPosterRealName()."\n";
673 //if there's an attachment for the message, make it note.
674 //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
675 $body .= _("A file has been uploaded with this message.")."\n\n";
679 $sanitizer = new TextSanitizer();
680 $text = $this->getBody();
681 $text = $sanitizer->convertNeededTagsForEmail($text);
682 $text = strip_tags($this->removebbcode(util_line_wrap($text)));
683 $text = $sanitizer->convertExtendedCharsForEmail($text);
685 "%s\n\n______________________________________________________________________\n".
686 _("You are receiving this email because you elected to monitor this forum.".
687 "\nTo stop monitoring this forum, login to %s and visit: \n%s\n"),
689 forge_get_config ('forge_name'),
690 util_make_url('/forum/monitor.php?forum_id='.$this->Forum->getID().
691 '&group_id='.$this->Forum->Group->getID().'&stop=1')
694 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
695 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
696 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n";
697 if (forge_get_config('use_mail') && forge_get_config('use_forum_mail_replies')) {
698 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
700 $extra_headers .= "Precedence: Bulk\n"
701 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getID()."@".forge_get_config('web_host').">\n"
702 ."List-Help: ".util_make_url ('/forum/forum.php?id='.$this->Forum->getID())."\n"
703 ."Message-Id: <forumpost".$this->getID()."@".forge_get_config('web_host').">";
704 $parentid = $this->getParentID();
705 if (!empty($parentid)) {
706 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
707 ."References: <forumpost".$this->getParentID()."@".forge_get_config('web_host').">";
710 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
712 util_send_message($dest_email,$subject,$body,"noreply@".forge_get_config('web_host'),'','Forum',$extra_headers);
715 // Switch back to the user language settings
716 setup_gettext_from_context();
721 * sendNewModeratedMsgNotice - contains the logic to send out email notifications to the forum admins when a new moderated message is posted
723 * @return bool success.
725 function sendNewModeratedMsgNotice() {
727 $engine = RBACEngine::getInstance();
728 $moderators = $engine->getUsersByAllowedAction('forum', $this->Forum->getID(), 'moderate');
730 foreach ($moderators as $m) {
731 $ids[] = $m->getID();
735 // See if there is anyone to send messages to
737 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
741 $f =& $this->getForum();
742 $g =& $f->getGroup();
744 $body = "\nRead to this message and approve/reject it at: ".
745 "\n".util_make_url('/forum/admin/pending.php?action=view_pending&group_id='. $g->getID() . "&forum_id=" . $f->getID()) .
746 "\nBy: " . $this->getPosterRealName() . "\n\n";
748 $text = $this->getBody();
749 $sanitizer = new TextSanitizer();
750 $text = $sanitizer->convertNeededTagsForEmail($text);
751 $text = strip_tags($this->removebbcode(util_line_wrap($text)));
752 $text = $sanitizer->convertExtendedCharsForEmail($text);
754 "\n\n______________________________________________________________________".
755 "\nYou are receiving this email because the forum you administrate has a new moderated message awaiting your approval.";
757 //$extra_headers = 'Reply-to: '.$this->Forum->getUnixName().'@'.forge_get_config('web_host');
758 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
759 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
760 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n";
761 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
762 $extra_headers .= "Precedence: Bulk\n"
763 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getID()."@".forge_get_config('web_host').">\n"
764 ."List-Help: ".util_make_url('/forum/forum.php?id='.$this->Forum->getID())."\n"
765 ."Message-Id: <forumpost".$this->getID()."@".forge_get_config('web_host').">";
766 $parentid = $this->getParentID();
767 if (!empty($parentid)) {
768 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
769 ."References: <forumpost".$this->getParentID()."@".forge_get_config('web_host').">";
772 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
773 if (count($ids) != 0) {
774 $bccres = db_query_params ('SELECT email FROM users WHERE status=$1 AND user_id = ANY ($2)',
776 db_int_array_to_any_clause ($ids))) ;
779 $BCC = implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
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 bool 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 bool 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 util_send_message('',$subject,$body,"noreply@".forge_get_config('web_host'),$BCC,'Forum',$extra_headers);
893 // c-file-style: "bsd"