Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

messagereply.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: messagereply.php 9887 2003-08-25 10:56:32Z vl $
5 //
6 // Created on: <24-Sep-2000 12:20:32 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program 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.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "ezmail/classes/ezmail.php" );
28 // include_once( "ezuser/classes/ezuser.php" );
29
30 $ini =& eZINI::instance( 'site.ini' );
31 $wwwDir = $ini->WWWDir;
32 $index = $ini->Index;
33 $Language = $ini->variable( "eZForumMain", "Language" );
34
35 if ( $StartAction == "reply" )
36 {
37 if ( !is_object( $msg ) )
38 {
39 $msg = new eZForumMessage( $MessageID );
40 }
41
42 $ForumID = $msg->forumId();
43
44 if ( !is_object( $forum ) )
45 {
46 $forum = new eZForum( $ForumID );
47 }
48
49 // send mail to forum moderator
50 $moderator = $forum->moderator();
51
52 $mail = new eZMail();
53
54 $messages = $forum->messageThreadTree( $msg->threadID() );
55
56 $replyAddress = $ini->variable( "eZForumMain", "ReplyAddress" );
57 $mail->setFrom( $replyAddress );
58
59 $locale = new eZLocale( $Language );
60
61 $mailTemplate = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
62 "kernel/ezforum/user/intl", $Language, "mailreply.php" );
63
64 $mailTemplate->set_file( "mailreply", "mailreply.tpl" );
65 $mailTemplate->setAllStrings();
66 $mailTemplate->set_block( "mailreply", "link_tpl", "link" );
67
68 $emailNoticeArray = array();
69
70 if ( is_object( $moderator ) )
71 {
72 $moderators = eZUserGroup::users( $moderator->id() );
73
74 if ( count( $moderators ) > 0 )
75 {
76 foreach ( $moderators as $moderatorItem )
77 {
78
79 $author = $msg->user();
80 $headersInfo = ( getallheaders() );
81
82 if ( $author->id() == 0 )
83 {
84 $mailTemplate->set_var( "author", $ini->variable( "eZForumMain", "AnonymousPoster" ) );
85 }
86 else
87 {
88 $mailTemplate->set_var( "author", $author->firstName() . " " . $author->lastName() );
89 }
90 $mailTemplate->set_var( "posted_at", $locale->format( $msg->postingTime() ) );
91
92 $subject_line = $mailTemplate->Ini->variable( "strings", "moderator_subject" );
93
94 if ( $forum->isModerated() )
95 {
96 $mailTemplate->set_var( "link_1", "" );
97 $mailTemplate->set_var( "link", "" );
98 }
99 else
100 {
101 $mailTemplate->set_var( "link_1", "https://" . $headersInfo["Host"] . $wwwDir. $index. "/forum/message/" . $msg->id() );
102 $mailTemplate->parse( "link", "link_tpl" );
103 }
104 $mailTemplate->set_var( "topic", $msg->topic() );
105 $mailTemplate->set_var( "body", $msg->body() );
106 $mailTemplate->set_var( "forum_name", $forum->name() );
107 $mailTemplate->set_var( "forum_link", "https://" . $headersInfo["Host"] . $wwwDir . $index. "/forum/messagelist/" . $forum->id() );
108 $mailTemplate->set_var( "link_2", "https://admin." . $headersInfo["Host"] . $wwwDir . $index. "/forum/messageedit/edit/" . $msg->id() );
109 $mailTemplate->set_var( "intl-info_message_1", $mailTemplate->Ini->variable( "strings", "moderator_info_message_1" ) );
110 $mailTemplate->set_var( "intl-info_message_2", $mailTemplate->Ini->variable( "strings", "moderator_info_message_2" ) );
111 $mailTemplate->set_var( "intl-info_message_3", $mailTemplate->Ini->variable( "strings", "moderator_info_message_3" ) );
112 $mailTemplate->set_var( "intl-info_message_4", $mailTemplate->Ini->variable( "strings", "moderator_info_message_4" ) );
113
114 $bodyText = ( $mailTemplate->parse( "dummy", "mailreply" ) );
115
116 $mail->setSubject( $subject_line );
117 $mail->setBody( $bodyText );
118
119 $mail->setFrom( $moderatorItem->email() );
120 $mail->setTo( $moderatorItem->email() );
121
122 $mail->send();
123 $emailNoticeArray[] = $moderatorItem->id();
124 }
125 }
126 }
127
128
129 // We just want to send notifications if forums is not moderated or message is approved
130 if ( $msg->isApproved() )
131 {
132 $mail = new eZMail();
133 $replyAddress = $ini->variable( "eZForumMain", "ReplyAddress" );
134 $mail->setFrom( $replyAddress );
135
136 foreach ( $messages as $message )
137 {
138 if ( $message->id() != $msg->id() )
139 {
140 if ( ( $message->treeID() > $msg->treeID() ) && $message->emailNotice() )
141 {
142 $user =& eZUser::currentUser();
143 $headersInfo = ( getallheaders() );
144
145 // $user may be false (answering an anonymous forum, with user not logged in)
146 if ( $user )
147 {
148 $mailTemplate->set_var( "author", $user->firstName() . " " . $user->lastName() );
149 }
150 else
151 {
152 $mailTemplate->set_var( "author", "Anonymous" );
153 }
154
155 $mailTemplate->set_var( "posted_at", $locale->format( $msg->postingTime() ) );
156
157 $subject_line = $mailTemplate->Ini->variable( "strings", "subject_prepend" );
158 $subject_line = $subject_line . $message->topic();
159 $subject_line = $subject_line . $mailTemplate->Ini->variable( "strings", "subject_append" );
160
161 $mailTemplate->set_var( "topic", $msg->topic() );
162 $mailTemplate->set_var( "body", $msg->body() );
163 $mailTemplate->set_var( "forum_name", $forum->name() );
164 $mailTemplate->set_var( "forum_link", "http://" . $headersInfo["Host"] . $wwwDir. $index. "/forum/message/" . $message->id() );
165 $mailTemplate->set_var( "link_1", "http://" . $headersInfo["Host"] . $wwwDir. $index. "/forum/message/" . $msg->id() );
166 $mailTemplate->set_var( "link_2", "http://" . $headersInfo["Host"] . $wwwDir. $index. "/forum/message/" . $msg->id() );
167 $mailTemplate->parse( "link", "link_tpl" );
168
169 $bodyText = $mailTemplate->parse( "dummy", "mailreply" );
170
171 $mail->setSubject( $subject_line );
172
173 $author =& $message->user();
174
175 $mail->setTo( $author->email() );
176 $mail->setBody( $bodyText );
177
178 // only send replies to a user once
179 if ( !in_array( $author->id(), $emailNoticeArray ) )
180 {
181 $mail->send();
182 $emailNoticeArray[] = $author->id();
183 }
184 }
185 }
186 }
187 }
188 }
189
190 if ( $StartAction == "moderatorapprove" )
191 {
192
193 if ( !is_object( $msg ) )
194 {
195 $msg = new eZForumMessage( $MessageID );
196 }
197
198 $ForumID = $msg->forumId();
199
200 if ( !is_object( $forum ) )
201 {
202 $forum = new eZForum( $ForumID );
203 }
204
205 $messages = $forum->messageThreadTree( $msg->threadID() );
206
207 $locale = new eZLocale( $Language );
208
209 $mailTemplate = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
210 "kernel/ezforum/user/intl", $Language, "mailreply.php" );
211
212 $mailTemplate->set_file( "mailreply", "mailreply.tpl" );
213 $mailTemplate->setAllStrings();
214 $mailTemplate->set_block( "mailreply", "link_tpl", "link" );
215
216 $emailNoticeArray = array();
217
218 // We just want to send notifications if forums is not moderated or message is approved
219 if ( $msg->isApproved() )
220 {
221 $mail = new eZMail();
222 $replyAddress = $ini->variable( "eZForumMain", "ReplyAddress" );
223 $mail->setFrom( $replyAddress );
224
225 foreach ( $messages as $message )
226 {
227 if ( $message->id() != $msg->id() )
228 {
229 if ( ( $message->treeID() > $msg->treeID() ) && $message->emailNotice() )
230 {
231 $user =& eZUser::currentUser();
232 $headersInfo = ( getallheaders() );
233
234 // $user may be false (answering an anonymous forum, with user not logged in)
235 if ( $user )
236 {
237 $mailTemplate->set_var( "author", $user->firstName() . " " . $user->lastName() );
238 }
239 else
240 {
241 $mailTemplate->set_var( "author", "Anonymous" );
242 }
243
244 $mailTemplate->set_var( "posted_at", $locale->format( $msg->postingTime() ) );
245
246 $subject_line = $mailTemplate->Ini->variable( "strings", "subject_prepend" );
247 $subject_line = $subject_line . $message->topic();
248 $subject_line = $subject_line . $mailTemplate->Ini->variable( "strings", "subject_append" );
249
250 $mailTemplate->set_var( "topic", $msg->topic() );
251 $mailTemplate->set_var( "body", $msg->body() );
252 $mailTemplate->set_var( "forum_name", $forum->name() );
253 $mailTemplate->set_var( "forum_link", "http://" . $headersInfo["Host"] . "/forum/message/" . $message->id() );
254 $mailTemplate->set_var( "link_1", "http://" . $headersInfo["Host"] . "/forum/message/" . $msg->id() );
255 $mailTemplate->set_var( "link_2", "http://" . $headersInfo["Host"] . "/forum/message/" . $msg->id() );
256 $mailTemplate->parse( "link", "link_tpl" );
257
258 $bodyText = $mailTemplate->parse( "dummy", "mailreply" );
259
260 $mail->setSubject( $subject_line );
261
262 $author =& $message->user();
263
264 $mail->setTo( $author->email() );
265 $mail->setBody( $bodyText );
266
267 // only send replies to a user once
268 if ( !in_array( $author->id(), $emailNoticeArray ) )
269 {
270 $mail->send();
271 $emailNoticeArray[] = $author->id();
272 }
273 }
274 }
275 }
276 }
277 }
278
279 ?>
$locale
$locale
Definition: admin/adlist.php:127
$author
$author
Definition: admin/articleedit.php:834
$forum
$forum
Definition: admin/forumlist.php:50
$message
$message
Definition: admin/message.php:51
eZForumMessage
Definition: ezforummessage.php:42
eZForum
Definition: ezforum.php:44
eZLocale
Definition: ezlocale.php:119
eZMail
Definition: ezmail.php:57
eZTemplate
Definition: eztemplate.php:107
eZUserGroup\users
static users( $GroupID=false, $order="Login", $search=false)
Definition: ezusergroup.php:291
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$msg
$msg
Definition: editmessage.php:47
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
$headersInfo
$headersInfo
Definition: forgot.php:32
$messages
$messages
Definition: homepage.php:328
$wwwDir
$wwwDir
Definition: messagereply.php:31
$index
$index
Definition: messagereply.php:32
$Language
$Language
Definition: messagereply.php:33
$ini
$ini
Definition: messagereply.php:30
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.