831 |
florian |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
4 |
// //
|
|
|
5 |
// Copyright (C) 2006 Phorum Development Team //
|
|
|
6 |
// http://www.phorum.org //
|
|
|
7 |
// //
|
|
|
8 |
// This program is free software. You can redistribute it and/or modify //
|
|
|
9 |
// it under the terms of either the current Phorum License (viewable at //
|
|
|
10 |
// phorum.org) or the Phorum License that was distributed with this file //
|
|
|
11 |
// //
|
|
|
12 |
// This program is distributed in the hope that it will be useful, //
|
|
|
13 |
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
|
|
|
14 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
|
|
|
15 |
// //
|
|
|
16 |
// You should have received a copy of the Phorum License //
|
|
|
17 |
// along with this program. //
|
|
|
18 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
19 |
|
|
|
20 |
if(!defined("PHORUM")) return;
|
|
|
21 |
|
|
|
22 |
// Retrieve the message id to work with.
|
|
|
23 |
$message_id = 0;
|
|
|
24 |
|
|
|
25 |
if ($mode != "post") {
|
|
|
26 |
if (! isset($PHORUM["postingargs"][2])) {
|
|
|
27 |
die("Missing message_id parameter in request for mode $mode");
|
|
|
28 |
}
|
|
|
29 |
$message_id = $PHORUM["postingargs"][2];
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
// Create an initial message structure.
|
|
|
33 |
$message = array();
|
|
|
34 |
foreach ($PHORUM["post_fields"] as $key => $info) {
|
|
|
35 |
$message[$key] = $info[pf_INIT];
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
// Retrieve the message replied to or the message being edited.
|
|
|
39 |
if ($mode != "post")
|
|
|
40 |
{
|
|
|
41 |
// Check read access on the forum that we're handling.
|
|
|
42 |
if (!phorum_check_read_common()) exit;
|
|
|
43 |
|
|
|
44 |
// Retrieve the message from the database. If the message can't be
|
|
|
45 |
// retrieved, then return to the message list.
|
|
|
46 |
$dbmessage = phorum_db_get_message($message_id);
|
|
|
47 |
if (! $dbmessage) {
|
|
|
48 |
phorum_redirect_by_url(phorum_get_url(PHORUM_LIST_URL));
|
|
|
49 |
exit;
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
// Set message data for replying to posts.
|
|
|
54 |
if ($mode == "reply" || $mode == "quote")
|
|
|
55 |
{
|
|
|
56 |
// Set thread and parent information.
|
|
|
57 |
$message["parent_id"] = $dbmessage["message_id"];
|
|
|
58 |
$message["thread"] = $dbmessage["thread"];
|
|
|
59 |
|
|
|
60 |
// Create Re: subject prefix.
|
|
|
61 |
if (substr($dbmessage["subject"], 0, 4) != "Re: ") {
|
|
|
62 |
$dbmessage["subject"] = "Re: " . $dbmessage["subject"];
|
|
|
63 |
}
|
|
|
64 |
$message["subject"] = $dbmessage["subject"];
|
|
|
65 |
|
|
|
66 |
// Add a quoted version of the body for quoted reply messages.
|
|
|
67 |
if ($mode == "quote")
|
|
|
68 |
{
|
|
|
69 |
$quoted = phorum_hook("quote", array($dbmessage["author"], $dbmessage["body"]));
|
|
|
70 |
|
|
|
71 |
if (empty($quoted) || is_array($quoted))
|
|
|
72 |
{
|
|
|
73 |
$quoted = phorum_strip_body($dbmessage["body"]);
|
|
|
74 |
$quoted = str_replace("\n", "\n> ", $quoted);
|
|
|
75 |
$quoted = wordwrap(trim($quoted), 50, "\n> ", true);
|
|
|
76 |
$quoted = "{$dbmessage["author"]} " .
|
|
|
77 |
"{$PHORUM["DATA"]["LANG"]["Wrote"]}:\n" .
|
|
|
78 |
str_repeat("-", 55) . "\n> $quoted\n\n\n";
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
$message["body"] = $quoted;
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
// Set message data for editing posts.
|
|
|
86 |
if ($mode == "edit" || $mode == "moderation") {
|
|
|
87 |
// Transfer all database fields to the form fields.
|
|
|
88 |
$message = phorum_posting_merge_db2form($message, $dbmessage, ALLFIELDS);
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
// For new messages, set some default values for logged in users.
|
|
|
92 |
if (($mode == "post" || $mode == "reply" || $mode == "quote") && $PHORUM["DATA"]["LOGGEDIN"])
|
|
|
93 |
{
|
|
|
94 |
if (isset($PHORUM["user"]["show_signature"]) &&
|
|
|
95 |
$PHORUM["user"]["show_signature"]) {
|
|
|
96 |
$message["show_signature"] = 1;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
if (isset($PHORUM["user"]["email_notify"]) &&
|
|
|
100 |
$PHORUM["user"]["email_notify"]) {
|
|
|
101 |
$message["email_notify"] = 1;
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
?>
|