Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezforum/user/messageedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: messageedit.php 9550 2002-05-21 09:19:02Z jhe $
5 //
6 // Created on: <21-Feb-2001 18:00:00 pkej>
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( "classes/ezlocale.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "ezforum/classes/ezforum.php" );
30 // include_once( "ezforum/classes/ezforummessage.php" );
31 // include_once( "ezforum/classes/ezforumcategory.php" );
32
33 $ini =& eZINI::instance( 'site.ini' );
34
35 $wwwDir = $ini->WWWDir;
36 $index = $ini->Index;
37
38 $Language = $ini->variable( "eZForumMain", "Language" );
39 $AllowedTags = $ini->variable( "eZForumMain", "AllowedTags" );
40 $AllowHTML = $ini->variable( "eZForumMain", "AllowHTML" );
41
42 // Migrate the debug variable into a Module Specific Process DebugOutput Variable
43 // Module View Data Context Debug Output
44 $debugMessageEdit = false;
45 $debugMessagePermissions = false; // Set to true to see the debug output
46
47 if ( isset( $EditButton ) )
48 {
49 $Action = "edit";
50 }
51
52 if ( !empty( $CancelButton ) )
53 {
54 $Action = "cancel";
55 }
56
57 if ( !empty( $PreviewButton ) )
58 {
59 $Action = "preview";
60 }
61
62 if ( $Action == "preview" )
63 {
64 $NewMessageTopic = trim( $NewMessageTopic );
65 $NewMessageBody = $NewMessageBody;
66
67 if ( empty( $NewMessageTopic ) || empty( $NewMessageBody ) )
68 {
69 $Error = true;
70 $Action = $StartAction;
71 }
72 }
73 // Select which main page we are going to view.
74
75 switch ( $Action )
76 {
77 case "reply":
78 case "new":
79 case "edit":
80 {
81 $t = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
82 "kernel/ezforum/user/intl", $Language, "message.php" );
83
84 $t->set_file( "page", "messageedit.tpl" );
85 $t->set_block( "page", "errors_tpl", "errors_item" );
86 $t->set_var( "errors_item", "" );
87 }
88 break;
89
90 case "delete":
91 {
92 $t = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
93 "kernel/ezforum/user/intl", $Language, "message.php" );
94
95 $t->set_file( "page", "messagedelete.tpl" );
96 }
97 break;
98
99 case "preview":
100 {
101 $t = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
102 "kernel/ezforum/user/intl", $Language, "message.php" );
103
104 $t->set_file( "page", "messagepreview.tpl" );
105 $t->set_block( "page", "moderated_tpl", "moderated" );
106 $t->set_var( "moderated", "" );
107 }
108 break;
109
110 /*
111 case "preview":
112 {
113 $t = new eZTemplate( "ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
114 "ezforum/user/intl", $Language, "message.php" );
115
116 $t->set_file( "page", "messagepreview.tpl" );
117 }
118 break;
119 */
120
121 case "completed":
122 {
123 $t = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
124 "kernel/ezforum/user/intl", $Language, "message.php" );
125
126 $t->set_file( "page", "messageposted.tpl" );
127 $t->setAllStrings();
128 }
129 break;
130 }
131
132
133 // Any errors?
134 $Error = false;
135 $Errors = false;
136
137 $Locale = new eZLocale( $Language );
138
139 // Do some action!
140 switch ( $Action )
141 {
142 case "dodelete":
143 {
144 $msg = new eZForumMessage( $MessageID );
145
146 $CheckMessageID = $MessageID;
147 $CheckForumID = $msg->forumID();
148
149 include( "kernel/ezforum/user/messagepermissions.php" );
150 // include_once( "classes/ezhttptool.php" );
151 if ( $MessageDelete == false )
152 {
153 eZHTTPTool::header( "Location: /error/403?Info=" . errorPage( "forum_main", "/forum/categorylist/", 403 ) );
154 }
155
156 $msg->delete();
157 eZHTTPTool::header( "Location: /forum/messagelist/$CheckForumID" );
158
159 }
160 break;
161
162 case "delete":
163 {
164 $ActionValue = "dodelete";
165 $StartAction = "delete";
166 $EndAction = "dodelete";
167
168 $msg = new eZForumMessage( $MessageID );
169
170 $CheckMessageID = $MessageID;
171 $CheckForumID = $msg->forumID();
172 include( "kernel/ezforum/user/messagepermissions.php" );
173
174 // include_once( "classes/ezhttptool.php" );
175 if ( !$MessageDelete )
176 {
177 eZHTTPTool::header( "Location: /forum/messageedit/forbidden/?Tried=$Action&TriedMessage=$CheckMessageID&TriedForum=$CheckForumID" );
178 }
179
180 $doParse = true;
181 $ShowPath = true;
182 $isPreview = false;
183 include_once( "kernel/ezforum/user/messagepath.php" );
184
185 $ShowMessage = true;
186 include_once( "kernel/ezforum/user/messagebody.php" );
187 }
188 break;
189
190 case "completed":
191 {
192 $msg = new eZForumMessage( $MessageID );
193
194 $CheckMessageID = $msg->id();
195 $CheckForumID = $msg->forumID();
196 include( "kernel/ezforum/user/messagepermissions.php" );
197
198 // include_once( "classes/ezhttptool.php" );
199 if ( isset( $MessageEdit ) && $MessageEdit == false )
200 {
201 eZHTTPTool::header( "Location: /error/403?Info=" . errorPage( "forum_main", "/forum/categorylist/", 403 ) );
202 }
203
204 // Just tell the geezers that their posting has been sent or queued for moderation.
205 // Also inform of any e-mails sent.
206
207 $doParse = true;
208 $ShowPath = true;
209 $isPreview = false;
210 include_once( "kernel/ezforum/user/messagepath.php" );
211
212 $ShowMessage = true;
213 include_once( "kernel/ezforum/user/messagebody.php" );
214 }
215 break;
216
217 case "cancel":
218 {
219 // If PreviewID is set then we need to delete the object.
220 // Since all objects are smart enough to not generate any
221 // error messages if we new an empty object and then delete it
222 // no ifs are neccessary.
223 $msg = new eZForumMessage( $PreviewID );
224 $msg->delete();
225
226 // include_once( "classes/ezhttptool.php" );
227 if ( empty( $RedirectURL ) )
228 {
229 if ( empty( $ForumID ) )
230 {
231 eZHTTPTool::header( "Location: /forum/categorylist" );
232 }
233 else
234 {
235 eZHTTPTool::header( "Location: /forum/messagelist/$ForumID" );
236 }
237 }
238 else
239 {
240 eZHTTPTool::header( "Location: $RedirectURL" );
241 }
242 }
243 break;
244
245 case "insert":
246 {
247 $ActionValue = "completed";
248 $msg = new eZForumMessage( $OriginalID );
249
250 $CheckMessageID = $OriginalID;
251 $ForumID = $msg->forumID();
252 $CheckForumID = $ForumID;
253
254 include( "kernel/ezforum/user/messagepermissions.php" );
255
256 // include_once( "classes/ezhttptool.php" );
257
258 if ( isset( $ForumPost ) && !$ForumPost )
259 {
260 eZHTTPTool::header( "Location: /error/403?Info=" . errorPage( "forum_main", "/forum/categorylist/", 403 ) );
261 }
262
263 $linkModules = $ini->variable( "eZForumMain", "LinkModules" );
264 $module_array = explode(',', $linkModules );
265 unset ($linkModules);
266 foreach ( $module_array as $module)
267 {
268 $moduleSubArray = explode( ':', $module );
269 list($module_name, $forum_id) = $moduleSubArray;
270 $linkModules[$module_name] = $forum_id;
271 }
272
273 // echo "<hr>";
274 // var_dump($linkModules);
275 // echo "<hr>";
276 // var_dump($ForumID);
277 // echo "<hr>";
278
279 $forum = new eZForum( $ForumID );
280 $messageCount = $forum->messageCount( false, true );
281 $categories = $forum->categories( false );
282
283 $count = count ( array_intersect( $linkModules, $categories ) );
284
285 /* echo "<pre>LinkModules:";
286 print_r ( $linkModules );
287 echo "Categories:";
288 print_r ( $categories );
289 echo "Count:";
290 print_r ($count);
291 echo "<br>Messagecount: ".$messageCount."<br>";
292 echo "RedirectURL: ".$HTTP_HOST.$wwwDir.$index.$RedirectURL."<br>";
293 echo "</pre>";
294 exit(); */
295
296 if ( ( $count > 0 )
297 &&
298 ( $messageCount == 0 ) )
299
300 {
301 $mailTemplateIni = new eZINI( "kernel/ezforum/user/intl/" . $Language . "/message.php.ini", false );
302 // $Topic = $mailTemplateIni->variable( "strings", "auto_topic" )
303 $body_prefix = $mailTemplateIni->variable( "strings", "auto_body" );
304
305 // graham : the old index.php way (re: update db content please)
306 // $new_body = "<p>".$body_prefix." "."<a href=\"http://".$HTTP_HOST.$wwwDir.$index.$RedirectURL."\">".$forum->name()."</a>.<br/></br>".$msg->body();
307 $new_body = "<p>".$body_prefix." "."<a href=\"http://".$HTTP_HOST.$RedirectURL."\">".$forum->name()."</a>.<br/></br>".$msg->body();
308 $msg->setBody( $new_body );
309 //$UserName = $ini->variable( "eZForumMain", "AnonymousPoster" );
310 //$auto_msg = new eZForumMessage();
311 //$auto_msg->setIsTemporary( false );
312 //$auto_msg->setForumID( $ForumID );
313 //$auto_msg->disableEmailNotice();
314 //$auto_msg->setUserID( 0 );
315 //$auto_msg->setUserName( $UserName );
316 //$auto_msg->setTopic( $forum->name() );
317 //$auto_msg->setBody( $Body );
318 //if ( $forum->isModerated() )
319 //{
320 // $auto_msg->setIsApproved ( false );
321 //}
322 //$auto_msg->store();
323 }
324
325 $msg->setIsTemporary( false );
326 $msg->store();
327
328 if ( $StartAction == "reply" )
329 {
330 include_once( "kernel/ezforum/user/messagereply.php" );
331 }
332 else
333 {
334 if ( !is_object( $forum ) )
335 {
336 $forum = new eZForum( $ForumID );
337 }
338
339 // send mail to admin
340
341 // include_once( "ezmail/classes/ezmail.php" );
342 $mail = new eZMail();
343 $replyAddress = $ini->variable( "eZForumMain", "ReplyAddress" );
344
345 $locale = new eZLocale( $Language );
346
347 $mailTemplate = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
348 "kernel/ezforum/user/intl", $Language, "mailreply.php" );
349
350 $mailTemplate->set_file( "mailreply", "mailreply.tpl" );
351 $mailTemplate->setAllStrings();
352 $mailTemplate->set_block( "mailreply", "link_tpl", "link" );
353
354 $author = $msg->user();
355
356 $headersInfo = ( getallheaders() );
357
358 if ( $author->id() == 0 )
359 {
360 $mailTemplate->set_var( "author", $ini->variable( "eZForumMain", "AnonymousPoster" ) );
361 }
362 else
363 {
364 $mailTemplate->set_var( "author", $author->firstName() . " " . $author->lastName() );
365 }
366 $mailTemplate->set_var( "posted_at", $locale->format( $msg->postingTime() ) );
367
368 $subject_line = $mailTemplate->Ini->variable( "strings", "admin_subject" );
369
370
371 $mailTemplate->set_var( "link_1", "http://" . $headersInfo["Host"] . $wwwDir. $index. "/forum/message/" . $msg->id() );
372 $mailTemplate->parse( "link", "link_tpl" );
373
374 $mailTemplate->set_var( "topic", $msg->topic() );
375 $mailTemplate->set_var( "body", $msg->body() );
376 $ForumID = $msg->forumID();
377 $forum = new eZForum( $ForumID );
378 $mailTemplate->set_var( "forum_name", $forum->name() );
379 $mailTemplate->set_var( "forum_link", "http://" . $headersInfo["Host"] . $wwwDir . $index. "/forum/messagelist/" . $forum->id() );
380 $mailTemplate->set_var( "link_2", "http://" . $ini->variable( "site", "AdminSiteURL" ) . "/forum/messageedit/edit/" . $msg->id() );
381 $mailTemplate->set_var( "intl-info_message_1", $mailTemplate->Ini->variable( "strings", "admin_info_message_1" ) );
382 $mailTemplate->set_var( "intl-info_message_2", $mailTemplate->Ini->variable( "strings", "admin_info_message_2" ) );
383 $mailTemplate->set_var( "intl-info_message_3", $mailTemplate->Ini->variable( "strings", "admin_info_message_3" ) );
384 $mailTemplate->set_var( "intl-info_message_4", $mailTemplate->Ini->variable( "strings", "admin_info_message_4" ) );
385
386 $bodyText = ( $mailTemplate->parse( "dummy", "mailreply" ) );
387
388 $mail->setSubject( $subject_line );
389 $mail->setBody( $bodyText );
390
391 $mail->setFrom( $author->email() );
392 $mail->setTo( $replyAddress );
393
394 $mail->send();
395
396 // send mail to forum moderator
397 $moderator = $forum->moderator();
398
399 if ( is_object( $moderator ) )
400 {
401 $moderators =& eZUserGroup::users( $moderator->id() );
402
403 if ( count( $moderators ) > 0 )
404 {
405 foreach ( $moderators as $moderatorItem )
406 {
407 // include_once( "ezmail/classes/ezmail.php" );
408 $mail = new eZMail();
409
410 $locale = new eZLocale( $Language );
411
412 $mailTemplate = new eZTemplate( "kernel/ezforum/user/" . $ini->variable( "eZForumMain", "TemplateDir" ),
413 "kernel/ezforum/user/intl", $Language, "mailreply.php" );
414
415 $mailTemplate->set_file( "mailreply", "mailreply.tpl" );
416 $mailTemplate->setAllStrings();
417 $mailTemplate->set_block( "mailreply", "link_tpl", "link" );
418 $headersInfo = getallheaders();
419
420 $author = $msg->user();
421
422 if ( $author->id() == 0 )
423 {
424 if ( $msg->userName() )
425 $mailTemplate->set_var( "author", $msg->userName() );
426 else
427 $mailTemplate->set_var( "author", $ini->variable( "eZForumMain", "AnonymousPoster" ) );
428 }
429 else
430 {
431 $mailTemplate->set_var( "author", $author->firstName() . " " . $author->lastName() );
432 }
433 $mailTemplate->set_var( "posted_at", $locale->format( $msg->postingTime() ) );
434
435 $subject_line = $mailTemplate->Ini->variable( "strings", "moderator_subject" );
436
437 $mailTemplate->set_var( "topic", $msg->topic() );
438 $mailTemplate->set_var( "body", $msg->body() );
439
440 $mailTemplate->set_var( "forum_name", $forum->name() );
441 $mailTemplate->set_var( "forum_link", "http://" . $headersInfo["Host"] . "/forum/messagelist/" . $forum->id() );
442
443 if ( $forum->isModerated() )
444 {
445 $mailTemplate->set_var( "link_1", "" );
446 $mailTemplate->set_var( "link", "" );
447 }
448 else
449 {
450 $mailTemplate->set_var( "link_1", "http://" . $headersInfo["Host"] . "/forum/message/" . $msg->id() );
451 $mailTemplate->parse( "link", "link_tpl" );
452 }
453 $mailTemplate->set_var( "link_2", "http://" . $ini->variable( "site", "AdminSiteURL" ) . "/forum/messageedit/edit/" . $msg->id() );
454 $mailTemplate->set_var( "intl-info_message_1", $mailTemplate->Ini->variable( "strings", "moderator_info_message_1" ) );
455 $mailTemplate->set_var( "intl-info_message_2", $mailTemplate->Ini->variable( "strings", "moderator_info_message_2" ) );
456 $mailTemplate->set_var( "intl-info_message_3", $mailTemplate->Ini->variable( "strings", "moderator_info_message_3" ) );
457 $mailTemplate->set_var( "intl-info_message_4", $mailTemplate->Ini->variable( "strings", "moderator_info_message_4" ) );
458
459 $bodyText = $mailTemplate->parse( "dummy", "mailreply" );
460
461 $mail->setSubject( $subject_line );
462 $mail->setBody( $bodyText );
463
464 $mail->setFrom( $moderatorItem->email() );
465 $mail->setTo( $moderatorItem->email() );
466
467 $mail->send();
468 }
469 }
470 }
471
472 if ( $forum->isModerated() )
473 {
474 $msg->setIsApproved ( false );
475 $msg->store();
476 }
477 }
478
479 if ( isset( $RedirectURL ) && $RedirectURL != "" )
480 {
481 eZHTTPTool::header( "Location: $RedirectURL" );
482 }
483 else
484 {
485 eZHTTPTool::header( "Location: /forum/messageedit/$ActionValue/$OriginalID?ReplyToID=$ReplyToID&ActionStart=$ActionStart" );
486 }
487 exit();
488 }
489 break;
490
491 case "update":
492 {
493 $ActionValue = "completed";
494 $msg = new eZForumMessage( $OriginalID );
495 $tmpmsg = new eZForumMessage( $PreviewID );
496
497 $CheckMessageID = $OriginalID;
498 $CheckForumID = $msg->forumID();
499 include( "kernel/ezforum/user/messagepermissions.php" );
500
501 // include_once( "classes/ezhttptool.php" );
502 if ( isset( $MessageEdit ) && $MessageEdit == false )
503 {
504 eZHTTPTool::header( "Location: /error/403?Info=" . errorPage( "forum_main", "/forum/categorylist/", 403 ) );
505 }
506
507 $msg->setTopic( $tmpmsg->topic() );
508 $msg->setBody( $tmpmsg->body() );
509 $msg->setEmailNotice( $tmpmsg->emailNotice() );
510
511 $msg->store();
512 if ( $RedirectURL != "" )
513 {
514 eZHTTPTool::header( "Location: $RedirectURL" );
515 }
516 else
517 {
518 eZHTTPTool::header( "Location: /forum/messageedit/$ActionValue/$OriginalID?ActionStart=$ActionStart" );
519 }
520 exit();
521 }
522
523 case "new":
524 {
525 $StartAction = "new";
526 $EndAction = "insert";
527 $ActionValue = "preview";
528 $NewMessagePostedAt = htmlspecialchars( $ini->variable( "eZForumMain", "FutureDate" ) );
529
530 $ShowMessage = false;
531 include_once( "kernel/ezforum/user/messagebody.php" );
532
533 $msg = new eZForumMessage();
534 $msg->setIsTemporary( true );
535 $msg->setForumID( $ForumID );
536
537 $CheckMessageID = 0;
538 $CheckForumID = $msg->forumID();
539 $MessageOwner = true;
540 include( "kernel/ezforum/user/messagepermissions.php" );
541
542 if ( !$ForumPost )
543 {
544 // include_once( "classes/ezhttptool.php" );
545 eZHTTPTool::header( "Location: /error/403?Info=" . errorPage( "forum_main", "/forum/categorylist/", 403 ) );
546 }
547
548 $doParse = true;
549 $ShowPath = true;
550 $isPreview = true;
551 include_once( "kernel/ezforum/user/messagepath.php" );
552
553 $ShowMessageForm = true;
554 $ShowEmptyMessageForm = true;
555 $ShowVisibleMessageForm = true;
556 $ShowHiddenMessageForm = true;
557 $ShowReplyInfo = true;
558 $ShowBodyInfo = true;
559 include_once( "kernel/ezforum/user/messageform.php" );
560
561 }
562 break;
563
564 case "edit":
565 {
566 if ( !isset( $StartAction ) )
567 {
568 $StartAction = "edit";
569 $EndAction = "update";
570 }
571
572 unset( $NewMessageAuthor );
573 unset( $NewMessagePostedAt );
574
575 $NewMessagePostedAt = htmlspecialchars( $ini->variable( "eZForumMain", "FutureDate" ) );
576
577 $msg = new eZForumMessage( $MessageID );
578
579 if ( $msg->id() >= 1 )
580 {
581 $ForumID = $msg->forumID();
582 }
583
584 $ActionValue = "preview";
585
586 $CheckMessageID = $MessageID;
587 $CheckForumID = $ForumID;
588
589
590 include( "kernel/ezforum/user/messagepermissions.php" );
591
592 if ( isset( $MessageEdit ) && !$MessageEdit && !$Error )
593 {
594 //include_once( "classes/ezhttptool.php" );
595 eZHTTPTool::header( "Location: /error/403?Info=" . errorPage( "forum_main", "/forum/categorylist/", 403 ) );
596 }
597
598
599 $doParse = true;
600 $ShowPath = true;
601 $isPreview = false;
602 include_once( "kernel/ezforum/user/messagepath.php" );
603
604 $ShowMessageForm = true;
605 $ShowEmptyMessageForm = false;
606 $ShowVisibleMessageForm = true;
607 $ShowHiddenMessageForm = true;
608 $ShowReplyInfo = true;
609 $ShowBodyInfo = true;
610 include_once( "kernel/ezforum/user/messageform.php" );
611
612 $doPrint = true;
613 }
614 break;
615
616 case "reply":
617 {
618 $StartAction = $Action;
619 $ActionValue = "preview";
620 $EndAction = "insert";
621
622 $MessageID = $ReplyToID;
623 $NewMessagePostedAt = htmlspecialchars( $ini->variable( "eZForumMain", "FutureDate" ) );
624 $ReplyTags = $ini->variable( "eZForumMain", "ReplyTags" );
625 $ReplyStartTag = $ini->variable( "eZForumMain", "ReplyStartTag" );
626 $ReplyEndTag = $ini->variable( "eZForumMain", "ReplyEndTag" );
627
628 $msg = new eZForumMessage( $MessageID );
629 $forum = new eZForum( $msg->forumID() );
630 $ForumID = $forum->id();
631 $CheckMessageID = $MessageID;
632 $CheckForumID = $ForumID;
633
634 include( "kernel/ezforum/user/messagepermissions.php" );
635
636 /* Please clarify this block of code.
637 if ( isset( $MessageReply ) && !$MessageReply )
638 {
639 //#// include_once( "classes/ezhttptool.php" );
640 //#eZHTTPTool::header( "Location: /error/403?Info=" . errorPage( "forum_main", "/forum/categorylist/", 403 ) );
641 }
642 */
643
644 if ( $ReplyTags == "enabled" )
645 {
646 $NewMessageBody = $ReplyStartTag . "\n" . $msg->body() . "\n" . $ReplyEndTag;
647 }
648 else
649 {
650 // include_once( "classes/eztexttool.php" );
651 $NewMessageBody = eZTextTool::addPre( $msg->body() );
652 }
653
654 $user =& eZUser::currentUser();
655
656 $NewMessageTopic = $msg->topic();
657
658 $ReplyPrefix = $ini->variable( "eZForumMain", "ReplyPrefix" );
659
660 if ( !is_null( $NewMessageTopic) && !preg_match( "/^$ReplyPrefix/", $NewMessageTopic ) )
661 {
662 $NewMessageTopic = $ReplyPrefix . $NewMessageTopic;
663 $MessageTopic = $NewMessageTopic;
664 }
665
666 $doParse = true;
667 $ShowMessage = true;
668 include_once( "kernel/ezforum/user/messagebody.php" );
669
670 $ShowPath = true;
671 $isPreview = false;
672 include_once( "kernel/ezforum/user/messagepath.php" );
673
674 $ShowMessageForm = true;
675 $ShowEmptyMessageForm = false;
676 $ShowVisibleMessageForm = true;
677 $ShowHiddenMessageForm = true;
678 $ShowReplyInfo = true;
679 $ShowBodyInfo = true;
680 $NewMessageAuthor = true;
681 include_once( "kernel/ezforum/user/messageform.php" );
682
683 $doPrint = true;
684 }
685 break;
686
687 case "preview":
688 {
689 $ActionValue = $EndAction;
690 if ( isset( $Error ) && $Error == false )
691 {
692 if ( empty( $PreviewID ) )
693 {
694 switch ( $StartAction )
695 {
696 case "edit":
697 {
698 $msg = new eZForumMessage();
699 $tmpmsg = new eZForumMessage( $MessageID );
700 $msg = $tmpmsg->cloneObject();
701 }
702 break;
703
704 case "reply":
705 {
706 $msg = new eZForumMessage();
707 $tmpmsg = new eZForumMessage( $ReplyToID );
708 $ForumID = $tmpmsg->forumID();
709 $msg->setForumID( $ForumID );
710 $msg->setParent( $ReplyToID );
711
712 $forum = new eZForum( $ForumID );
713
714 if ( $forum->isModerated() )
715 {
716 $msg->setIsApproved( false );
717 }
718 else
719 {
720 $msg->setIsApproved( true );
721 }
722 }
723 break;
724
725 case "new":
726 {
727 $msg = new eZForumMessage();
728 $msg->setForumID( $ForumID );
729 }
730 break;
731
732 default:
733 {
734 $msg = new eZForumMessage( $OriginalID );
735 }
736 break;
737
738 }
739
740 if ( is_object( $user ) )
741 {
742 $msg->setUserID( $user->id() );
743 }
744 else
745 {
746 $msg->setUserID( 0 );
747 $msg->setUserName( $AuthorName );
748 }
749 }
750 else
751 {
752 $msg = new eZForumMessage( $PreviewID );
753 }
754
755 if ( isset( $NewMessageNotice ) && (string)$NewMessageNotice == "on" )
756 {
757 $msg->enableEmailNotice();
758 }
759 else
760 {
761 $msg->disableEmailNotice();
762 }
763
764 $AllowedTags = $ini->variable( "eZForumMain", "AllowedTags" );
765 $AllowHTML = $ini->variable( "eZForumMain", "AllowHTML" );
766
767 if ( isset( $AllowHTML ) && (string)$AllowHTML == "enabled" )
768 {
769 $msg->setTopic( $NewMessageTopic );
770 $msg->setBody( $NewMessageBody );
771 }
772 else
773 {
774 $msg->setTopic( strip_tags( $NewMessageTopic ) );
775 $msg->setBody( strip_tags( $NewMessageBody, $AllowedTags ) );
776 }
777
778 $msg->setIsTemporary( true );
779
780 $msg->store();
781 $PreviewID = $msg->id();
782
783 if ( isset( $EndAction ) && $EndAction == "insert" )
784 {
785 $OriginalID = $PreviewID;
786 }
787 else
788 {
789 $OriginalID = $MessageID;
790 }
791
792 $MessageID = $PreviewID;
793
794 $CheckMessageID = $msg->id();
795 $CheckForumID = $msg->forumID();
796 include( "kernel/ezforum/user/messagepermissions.php" );
797
798 if ( isset( $MessageEdit ) && $MessageEdit == false )
799 {
800 // include_once( "classes/ezhttptool.php" );
801 eZHTTPTool::header( "Location: /error/403?Info=" . errorPage( "forum_main", "/forum/categorylist/", 403 ) );
802 }
803
804 $ShowPath = true;
805 $isPreview = false;
806 include_once( "kernel/ezforum/user/messagepath.php" );
807 $forum = new eZForum( $CheckForumID );
808 if ( $forum->isModerated() )
809 {
810 $t->parse( "moderated", "moderated_tpl", true );
811 }
812 $ShowMessage = true;
813 include_once( "kernel/ezforum/user/messagebody.php" );
814
815 $ShowMessageForm = true;
816 $ShowEmptyMessageForm = false;
817 $ShowVisibleMessageForm = false;
818 $ShowHiddenMessageForm = true;
819 $ShowReplyInfo = true;
820 $ShowBodyInfo = true;
821 include_once( "kernel/ezforum/user/messageform.php" );
822 }
823
824 $doPrint = true;
825 }
826 break;
827
828 default:
829 {
830 // include_once( "classes/ezhttptool.php" );
831 eZHTTPTool::header( "Location: /error/404?Info=" . errorPage( "forum_main", "/forum/categorylist/", 404 ) );
832 }
833 break;
834 }
835
836 if( $debugMessageEdit === true )
837 {
838 print( "ActionValue = " . ( isset( $ActionValue ) ? $ActionValue : false ) . " <br>" );
839 print( "NewMessageBody = " . ( isset( $NewMessageBody ) ? $NewMessageBody : false ) . " <br>" );
840 print( "MessageBody = " . ( isset( $MessageBody ) ? $MessageBody : false ) . " <br>" );
841 print( "PreviewID = " . ( isset( $PreviewID ) ? $PreviewID : false ) . " <br>" );
842 print( "ReplyToID = " . ( isset( $ReplyToID ) ? $ReplyToID : false ) . " <br>" );
843 print( "OriginalID = " . ( isset( $OriginalID ) ? $OriginalID : false ) . " <br>" );
844 print( "MessageID = " . ( isset( $MessageID ) ? $MessageID : false ) . " <br>" );
845 print( "RedirectURL = " . ( isset( $RedirectURL ) ? $RedirectURL : false ) . " <br>" );
846 print( "ForumID = " . ( isset( $ForumID ) ? $ForumID : false ) . " <br>" );
847 }
848
849 $t->set_var( "start_action", $StartAction );
850 $t->set_var( "end_action", $EndAction );
851 $t->set_var( "action_value", $ActionValue );
852 $t->set_var( "message_id", isset( $MessageID ) ? $MessageID : false );
853
854
855 if ( isset( $AllowHTML ) && $AllowHTML == "enabled" )
856 {
857 $t->set_var( "html_tags", $AllowedTags );
858 }
859 else
860 $t->set_var( "html_tags", "" );
861
862 $t->setAllStrings();
863
864 if ( isset( $doPrint ) && $doPrint == true )
865 {
866 $t->pparse( "output", "page" );
867 }
868 else
869 {
870 $t->pparse( "output", "page" );
871 }
872
873 ?>
$locale
$locale
Definition: admin/adlist.php:127
$author
$author
Definition: admin/articleedit.php:834
$forum
$forum
Definition: admin/forumlist.php:50
eZForumMessage
Definition: ezforummessage.php:42
eZForum
Definition: ezforum.php:44
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZLocale
Definition: ezlocale.php:119
eZMail
Definition: ezmail.php:57
eZTemplate
Definition: eztemplate.php:107
eZTextTool\addPre
static addPre( $string, $char=">")
Definition: eztexttool.php:83
eZUserGroup\users
static users( $GroupID=false, $order="Login", $search=false)
Definition: ezusergroup.php:291
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$t
foreach( $Modules as $module) if(isset( $ItemInsert)) $t
Definition: classes/admin/linklist.php:168
$module
$module
Definition: classes/admin/linkselect.php:219
$Action
$Action
Definition: companysearch.php:80
$msg
$msg
Definition: editmessage.php:47
$ActionValue
$ActionValue
Definition: ezarticle/admin/attributeedit.php:79
$categories
$categories
Definition: ezarticle/admin/categoryedit.php:636
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
errorPage
& errorPage( $PrimaryName, $PrimaryURL, $type)
Definition: ezform/user/datasupplier.php:35
$messageCount
$messageCount
Definition: ezforum/admin/messagelist.php:70
$AllowHTML
$AllowHTML
Definition: ezforum/user/messageedit.php:40
$AllowedTags
$AllowedTags
Definition: ezforum/user/messageedit.php:39
$wwwDir
$wwwDir
Definition: ezforum/user/messageedit.php:35
$index
$index
Definition: ezforum/user/messageedit.php:36
$Error
if(isset( $EditButton)) if(!empty( $CancelButton)) if(!empty( $PreviewButton)) if( $Action=="preview") switch( $Action) $Error
Definition: ezforum/user/messageedit.php:134
$Locale
$Locale
Definition: ezforum/user/messageedit.php:137
$Errors
$Errors
Definition: ezforum/user/messageedit.php:135
$Language
$Language
Definition: ezforum/user/messageedit.php:38
$ini
$ini
Definition: ezforum/user/messageedit.php:33
$debugMessageEdit
$debugMessageEdit
Definition: ezforum/user/messageedit.php:44
$debugMessagePermissions
$debugMessagePermissions
Definition: ezforum/user/messageedit.php:45
$RedirectURL
$RedirectURL
Definition: ezforum/user/userlogin.php:91
exit
exit
Definition: folder.php:81
$headersInfo
$headersInfo
Definition: forgot.php:32
$ForumPost
$ForumPost
Definition: messagepermissions.php:43
$MessageDelete
$MessageDelete
Definition: messagepermissions.php:37
$MessageEdit
$MessageEdit
Definition: messagepermissions.php:34
$CheckMessageID
$CheckMessageID
Definition: messagepermissions.php:81
$count
$count
Definition: onlinetypelist.php:108
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.