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 boolean 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'));
200 $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)',
201 array ($group_forum_id,
203 htmlspecialchars($subject),
208 $most_recent_date)) ;
210 if (!$result || db_affected_rows($result) < 1) {
211 $this->setError(_('Posting Failed').' '.db_error());
215 $msg_id=db_insertid($result,'forum','msg_id');
216 if (!$this->fetchData($msg_id)) {
217 $this->setError(_('Posting Failed').' '.db_error());
222 $this->setError(_('Unable to get new message id'));
226 if (!$this->sendNotice()) {
231 $this->awaits_moderation = false;
238 * insertmsg - inserts the message into the main table (forum)
240 * @param string $subject The subject of the message.
241 * @param string $body The body of the message.
242 * @param int $thread_id The thread_id of the message, if known.
243 * @param int $is_followup_to The message_id of the parent message, if any.
244 * @param int $user_id The id of the user that is posting the message
245 * @param bool $has_attach Whether the message has an attach associated. Defaults to false
246 * @param int $timestamp The timestamp of the message to insert, defaults to 0.
247 * @return boolean success.
249 function insertmsg($subject, $body, $thread_id=0, $is_followup_to=0,
250 $user_id, $has_attach=false, $timestamp=0) {
251 if ($timestamp == 0){
255 $thread_id=$this->Forum->getNextThreadID();
258 $this->setError('ForumMessage: '._('Getting next thread_id failed'));
263 $most_recent_lookup = db_query_params ('SELECT most_recent_date FROM forum WHERE thread_id=$1 AND is_followup_to=0',array($thread_id));
264 if (db_result($most_recent_lookup, 0, 'most_recent_date') <= $timestamp) {
266 // increment the parent's followup count if necessary
268 $res4 = db_query_params ('UPDATE forum SET most_recent_date=$1 WHERE thread_id=$2 AND is_followup_to=0',
271 if (!$res4 || db_affected_rows($res4) < 1) {
272 $this->setError(_('Could not Update Master Thread parent with current time'));
277 // Only update the time if set time < timestamp (set to current time if not done for an import)
279 $res3 = db_query_params ('UPDATE forum SET most_recent_date=$1 WHERE msg_id=$2',
283 $this->setError(_('Could Not Update Parent'));
290 // mark the parent with followups as an optimization later
292 $res3 = db_query_params ('UPDATE forum SET has_followups=1 WHERE msg_id=$1',
293 array ($is_followup_to)) ;
295 $this->setError(_('Could Not Update Parent'));
301 $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)',
302 array ($this->Forum->getID(),
304 htmlspecialchars($subject),
310 if (!$result || db_affected_rows($result) < 1) {
311 $this->setError(_('Posting Failed').' '.db_error());
316 $msg_id=db_insertid($result,'forum','msg_id');
317 if (!$this->fetchData($msg_id)) {
323 $this->setError(_('Unable to get new message id'));
328 if (!$this->sendNotice($has_attach)) {
334 //echo "db_error()".db_error();
335 $this->awaits_moderation = false;
340 * create - use this function to create a new message in the database.
342 * @param string $subject The subject of the message.
343 * @param string $body The body of the message.
344 * @param int $thread_id The thread_id of the message, if known.
345 * @param int $is_followup_to The message_id of the parent message, if any.
346 * @param bool $has_attach Whether the message has an attach associated. Defaults to false
347 * @param int $timestamp The timestamp of the message to create. Defaults to 0, meaning the timestamp used for this message will be "time()"
348 * @return boolean success.
350 function create($subject, $body, $thread_id=0, $is_followup_to=0, $has_attach=false, $timestamp = 0) {
351 if (!strlen(trim($body)) || !strlen(trim($subject))) {
352 $this->setError(_('Error: a forum message must include a message body and a subject.'));
355 if (!forge_check_perm ('forum', $this->Forum->getID(), 'post')) {
356 $this->setPermissionDeniedError();
359 if (!session_loggedin()) {
362 $user_id=user_getid();
365 if ($is_followup_to) {
366 $ParentMessage=new ForumMessage($this->Forum,$is_followup_to);
367 if (!$ParentMessage || !is_object($ParentMessage)) {
368 $this->setError(_('Invalid ParentMessage Object'));
371 if ($ParentMessage->isError()) {
372 $this->setError('ForumMessage '.$ParentMessage->getErrorMessage());
376 if (!$is_followup_to) {
382 //now we check the moderation status of the forum and act accordingly
383 if (forge_check_perm ('forum', $this->Forum->getID(), 'unmoderated_post')) {
385 return $this->insertmsg($subject, $body, $thread_id, $is_followup_to,$user_id,$has_attach,$timestamp);
387 return $this->insertmoderated($subject, $body, $thread_id, $is_followup_to,$user_id);
392 * fetchData - re-fetch the data for this forum_message from the database.
394 * @param int $msg_id The message ID.
395 * @return boolean success.
397 function fetchData($msg_id) {
398 $res = db_query_params ('SELECT * FROM forum_user_vw WHERE msg_id=$1 AND group_forum_id=$2',
399 array($msg_id, $this->Forum->getID()));
400 if (!$res || db_numrows($res) < 1) {
401 $this->setError(_('Invalid Message Id'));
404 $this->data_array = db_fetch_array($res);
405 db_free_result($res);
410 * fetchModeratedData - re-fetch the data for this forum_message from the database, for pending messages
412 * @param int The message ID.
413 * @return boolean success.
415 function fetchModeratedData($msg_id) {
416 $res = db_query_params ('SELECT * FROM forum_pending_user_vw WHERE msg_id=$1 AND group_forum_id=$2',
417 array($msg_id, $this->Forum->getID()));
418 if (!$res || db_numrows($res) < 1) {
419 $this->setError(_('Invalid Message Id'));
422 $this->data_array = db_fetch_array($res);
423 db_free_result($res);
428 * getForum - get the Forum object this ForumMessage is associated with.
430 * @return object The Forum object.
432 function &getForum() {
437 * getID - get this message_id.
439 * @return int The message_id.
442 return $this->data_array['msg_id'];
446 * getPosterName - get the unix user_name of this message's poster.
448 * @return string The poster's unix name.
450 function getPosterName() {
451 return $this->data_array['user_name'];
455 * getPosterID - get this user_id of this message's poster.
457 * @return int The user_id.
459 function getPosterID() {
460 return $this->data_array['posted_by'];
464 * getPosterRealName - get the real name of this message's poster.
466 * @return string The real name.
468 function getPosterRealName() {
469 return $this->data_array['realname'];
473 * getSubject - get the subject of this message.
475 * @return string The subject.
477 function getSubject() {
478 return $this->data_array['subject'];
482 * getBody - get the body of this message.
484 * @return String The body.
487 return $this->data_array['body'];
491 * getPostDate - get the post date of this message.
493 * @return int The post date.
495 function getPostDate() {
496 return $this->data_array['post_date'];
500 * getParentID - get the id of the parent message, if this is a followup.
502 * @return int The parent id.
504 function getParentID() {
505 return $this->data_array['is_followup_to'];
509 * isPending - is the message pending, awaiting moderation?
511 * @return int awaits_moderation
513 function isPending() {
514 return $this->awaits_moderation;
518 * getThreadID - get the thread_id of the message.
520 * @return int The thread_id.
522 function getThreadID() {
523 return $this->data_array['thread_id'];
527 * getMostRecentDate - get the date of the most recent followup.
529 * @return int The date of the most recent followup.
531 function getMostRecentDate() {
532 return $this->data_array['most_recent_date'];
536 * hasFollowups - whether this message has any followups.
538 * @return boolean has_followups.
540 function hasFollowups() {
541 return $this->data_array['has_followups'];
545 * hasAttach - whether this message has an attachment.
547 * @return boolean has_attach.
549 function hasAttach() {
550 if ($this->isPending()) {
551 $res = db_query_params ('SELECT attachmentid FROM forum_pending_attachment WHERE msg_id=$1',
552 array ($this->getID())) ;
554 $res = db_query_params ('SELECT attachmentid FROM forum_attachment WHERE msg_id=$1',
555 array ($this->getID())) ;
557 if (db_numrows($res) > 0) {
564 * delete - Delete this message and its followups.
566 * @return int The count of deleted messages.
569 $msg_id=$this->getID();
571 $this->setError(_('Invalid Message Id'));
575 if (!forge_check_perm ('forum_admin', $this->Forum->Group->getID())) {
576 $this->setPermissionDeniedError();
580 $result = db_query_params ('SELECT msg_id FROM forum
581 WHERE is_followup_to=$1
582 AND group_forum_id=$2',
584 $this->Forum->getID())) ;
585 $rows=db_numrows($result);
588 for ($i=0;$i<$rows;$i++) {
589 $msg = new ForumMessage($this->Forum,db_result($result,$i,'msg_id'));
590 $count += $msg->delete();
593 $res_pa = db_query_params('SELECT attachmentid FROM forum_attachment WHERE msg_id=$1',
595 while ($pa = db_fetch_array($res_pa)) {
596 ForumStorage::instance()->delete($pa['attachmentid']);
597 db_query_params('DELETE FROM forum_attachment WHERE attachmentid=$1',
598 array($pa['attachmentid']));
600 ForumStorage::instance()->commit();
602 db_query_params('DELETE FROM forum WHERE msg_id=$1 AND group_forum_id=$2',
603 array ($msg_id, $this->Forum->getID()));
609 * removebbcode - workaround to remove bbcode tags.
611 * @param string $text
612 * @return string converted text
614 function removebbcode($text) {
615 //$replaced = preg_replace("/\[[_a-zA-Z]:.+\](.+)\[\/[_a-zA-Z]:.*\]/","$1",$text);
616 $replaced = preg_replace("/\[.+\](.+)\[\/.+\]/","$1",$text);
621 * sendNotice - contains the logic to send out email followups when a message is posted.
623 * @param boolean $has_attach Whether the message has an attach associated. Defaults to false
624 * @return boolean success.
626 function sendNotice($has_attach=false) {
627 $ids = $this->Forum->getMonitoringIDs();
629 $recipients = array ();
630 foreach ($ids as $id) {
631 $recipient = user_get_object ($id) ;
632 if ($recipient->isActive()) {
633 $recipients[] = $recipient ;
636 if ($this->Forum->getSendAllPostsTo()) {
637 $sapt = explode (',', $this->Forum->getSendAllPostsTo()) ;
638 foreach ($sapt as $r) {
643 if (count ($recipients) == 0) {
647 foreach ($recipients as $recipient) {
648 if ($recipient instanceof FFUser) {
649 setup_gettext_for_user ($recipient) ;
650 $dest_email = $recipient->getEmail ();
652 setup_gettext_from_sys_lang ();
653 $dest_email = $recipient ;
656 $body = sprintf(_("\nRead and respond to this message at: \n%s"), util_make_url ('/forum/message.php?msg_id='.$this->getID()));
657 if (forge_get_config('use_mail') && forge_get_config('use_forum_mail_replies')) {
658 $body .= stripcslashes(sprintf(_('
659 Or reply to this e-mail entering your response between the following markers:
661 (enter your response here)
662 %1$s'), FORUM_MAIL_MARKER));
664 $body .= "\n\n\n"._('By')._(': ').$this->getPosterRealName()."\n";
667 //if there's an attachment for the message, make it note.
668 //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
669 $body .= _("A file has been uploaded with this message.")."\n\n";
673 $sanitizer = new TextSanitizer();
674 $text = $this->getBody();
675 $text = $sanitizer->convertNeededTagsForEmail($text);
676 $text = strip_tags($this->removebbcode(util_line_wrap($text)));
677 $text = $sanitizer->convertExtendedCharsForEmail($text);
679 "%s\n\n______________________________________________________________________\n".
680 _("You are receiving this email because you elected to monitor this forum.".
681 "\nTo stop monitoring this forum, login to %s and visit: \n%s\n"),
683 forge_get_config ('forge_name'),
684 util_make_url('/forum/monitor.php?forum_id='.$this->Forum->getID().
685 '&group_id='.$this->Forum->Group->getID().'&stop=1')
688 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
689 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
690 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n";
691 if (forge_get_config('use_mail') && forge_get_config('use_forum_mail_replies')) {
692 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
694 $extra_headers .= "Precedence: Bulk\n"
695 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getID()."@".forge_get_config('web_host').">\n"
696 ."List-Help: ".util_make_url ('/forum/forum.php?id='.$this->Forum->getID())."\n"
697 ."Message-Id: <forumpost".$this->getID()."@".forge_get_config('web_host').">";
698 $parentid = $this->getParentID();
699 if (!empty($parentid)) {
700 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
701 ."References: <forumpost".$this->getParentID()."@".forge_get_config('web_host').">";
704 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
706 util_send_message($dest_email,$subject,$body,"noreply@".forge_get_config('web_host'),'','Forum',$extra_headers);
709 // Switch back to the user language settings
710 setup_gettext_from_context();
715 * sendNewModeratedMsgNotice - contains the logic to send out email notifications to the forum admins when a new moderated message is posted
717 * @return boolean success.
719 function sendNewModeratedMsgNotice() {
721 $engine = RBACEngine::getInstance();
722 $moderators = $engine->getUsersByAllowedAction('forum', $this->Forum->getID(), 'moderate');
724 foreach ($moderators as $m) {
725 $ids[] = $m->getID();
729 // See if there is anyone to send messages to
731 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
735 $f =& $this->getForum();
736 $g =& $f->getGroup();
738 $body = "\nRead to this message and approve/reject it at: ".
739 "\n".util_make_url('/forum/admin/pending.php?action=view_pending&group_id='. $g->getID() . "&forum_id=" . $f->getID()) .
740 "\nBy: " . $this->getPosterRealName() . "\n\n";
742 $text = $this->getBody();
743 $sanitizer = new TextSanitizer();
744 $text = $sanitizer->convertNeededTagsForEmail($text);
745 $text = strip_tags($this->removebbcode(util_line_wrap($text)));
746 $text = $sanitizer->convertExtendedCharsForEmail($text);
748 "\n\n______________________________________________________________________".
749 "\nYou are receiving this email because the forum you administrate has a new moderated message awaiting your approval.";
751 //$extra_headers = 'Reply-to: '.$this->Forum->getUnixName().'@'.forge_get_config('web_host');
752 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
753 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
754 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n";
755 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
756 $extra_headers .= "Precedence: Bulk\n"
757 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getID()."@".forge_get_config('web_host').">\n"
758 ."List-Help: ".util_make_url('/forum/forum.php?id='.$this->Forum->getID())."\n"
759 ."Message-Id: <forumpost".$this->getID()."@".forge_get_config('web_host').">";
760 $parentid = $this->getParentID();
761 if (!empty($parentid)) {
762 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
763 ."References: <forumpost".$this->getParentID()."@".forge_get_config('web_host').">";
766 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
767 if (count($ids) != 0) {
768 $bccres = db_query_params ('SELECT email FROM users WHERE status=$1 AND user_id = ANY ($2)',
770 db_int_array_to_any_clause ($ids))) ;
773 $BCC = implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
774 util_send_message('',$subject,$body,"noreply@".forge_get_config('web_host'),$BCC,'Forum',$extra_headers);
775 // util_handle_message(array_unique($ids),$subject,$body,$this->Forum->getSendAllPostsTo(),'','forumgateway@'.forge_get_config('web_host'));
780 * updatemsg - impacts in the DB the new content of the message
782 * @param string $group_forum_id The forum ID
783 * @param int $posted_by The id of the user that is posting the message
784 * @param string $subject The subject of the message.
785 * @param string $body The body of the message.
786 * @param string $post_date The post date
787 * @param int $is_followup_to The message_id of the parent message, if any.
788 * @param int $thread_id The thread_id of the message, if known.
789 * @param int $has_followups has followups?
790 * @param string $most_recent_date The most recent date.
791 * @return boolean success.
793 function updatemsg($group_forum_id, $posted_by, $subject, $body,
794 $post_date, $is_followup_to, $thread_id, $has_followups, $most_recent_date) {
795 if (!strlen(trim($body)) || !strlen(trim($subject))) {
796 $this->setError(_('Error: a forum message must include a message body and a subject.'));
799 $subject = htmlspecialchars($subject);
800 $msg_id = $this->getID();
801 $res = db_query_params ('UPDATE forum
802 SET group_forum_id=$1, posted_by=$2, subject=$3,
803 body=$4, post_date=$5, is_followup_to=$6,
804 thread_id=$7, most_recent_date=$8
806 array ($group_forum_id,
816 $this->setError(db_error());
819 if (db_affected_rows($res)<1) {
820 $this->setError(_("Message not found"));
828 * sendAttachNotice - contains the logic to send out email attachement followups when a message is posted.
830 * @param int $attach_id - The id of the file that has been attached
831 * @return boolean success.
833 function sendAttachNotice($attach_id) {
835 $ids = $this->Forum->getMonitoringIDs();
838 // See if there is anyone to send messages to
840 if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
844 $body = "\nRead and respond to this message at: ".
845 "\n".util_make_url('/forum/message.php?msg_id='.$this->getID()).
846 "\nBy: " . $this->getPosterRealName() . "\n\n";
848 $body .= "A file has been uploaded to this message, you can download it at: ".
849 "\n".util_make_url('/forum/attachment.php?attachid='. $attach_id . "&group_id=" . $this->Forum->Group->getID() . "&forum_id=" . $this->Forum->getID()) . "\n\n";
852 "\n\n______________________________________________________________________".
853 "\nYou are receiving this email because you elected to monitor this forum.".
854 "\nTo stop monitoring this forum, login to ".forge_get_config ('forge_name')." and visit: ".
855 "\n".util_make_url ('/forum/monitor.php?forum_id='.$this->Forum->getID() .'&group_id='.$this->Forum->Group->getID().'&stop=1');
857 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
858 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
859 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">\n";
860 $extra_headers .= "Reply-To: ".$this->Forum->getReturnEmailAddress()."\n";
861 $extra_headers .= "Precedence: Bulk\n"
862 ."List-Id: ".$this->Forum->getName()." <forum".$this->Forum->getID()."@".forge_get_config('web_host').">\n"
863 ."List-Help: ".util_make_url('/forum/forum.php?id='.$this->Forum->getID())."\n"
864 ."Message-Id: <forumpost".$this->getID()."@".forge_get_config('web_host').">";
865 $parentid = $this->getParentID();
866 if (!empty($parentid)) {
867 $extra_headers .= "\nIn-Reply-To: ".$this->Forum->getReturnEmailAddress()."\n"
868 ."References: <forumpost".$this->getParentID()."@".forge_get_config('web_host').">";
871 $subject="[" . $this->Forum->getUnixName() ."][".$this->getID()."] ".util_unconvert_htmlspecialchars($this->getSubject());
872 if (count($ids) != 0) {
873 $bccres = db_query_params ('SELECT email FROM users WHERE status=$1 AND user_id = ANY ($2)',
875 db_int_array_to_any_clause ($ids))) ;
877 $BCC = implode(util_result_column_to_array($bccres),',').','.$this->Forum->getSendAllPostsTo();
878 util_send_message('',$subject,$body,"noreply@".forge_get_config('web_host'),$BCC,'Forum',$extra_headers);
887 // c-file-style: "bsd"