示例#1
0
 *     </hookcode>
 */
if (isset($PHORUM["hooks"]["before_post"])) {
    $message = phorum_hook("before_post", $message);
}
// Keep a copy of the message we have got now.
$message_copy = $message;
// Store the message in the database.
$success = phorum_db_post_message($message);
if ($success) {
    // Handle linking and deleting of attachments to synchronize
    // the message attachments with the working copy list
    // of attachments.
    foreach ($message_copy["attachments"] as $info) {
        if ($info["keep"]) {
            phorum_db_file_link($info["file_id"], $message["message_id"], PHORUM_LINK_MESSAGE);
        } else {
            if (phorum_api_file_check_delete_access($info["file_id"])) {
                phorum_api_file_delete($info["file_id"]);
            }
        }
    }
    // Retrieve the message again to have it in the correct
    // format (otherwise it's a bit messed up in the
    // post-function). Do merge back data which is not
    // stored in the database, but which we might need later on.
    $message = phorum_db_get_message($message["message_id"], 'message_id', false, true);
    foreach ($message_copy as $key => $val) {
        if (!isset($message[$key])) {
            $message[$key] = $val;
        }
示例#2
0
     $msg['sort'] = $target['sort'];
     // the sort type of the new thread
     if ($msg['message_id'] == $msg['thread']) {
         $msg['parent_id'] = $target['thread'];
     } elseif (isset($msgid_translation[$msg['parent_id']])) {
         $msg['parent_id'] = $msgid_translation[$msg['parent_id']];
     } else {
         $msg['parent_id'] = $msg['thread'];
     }
     unset($msg['message_id']);
     unset($msg['modifystamp']);
     phorum_db_post_message($msg, true);
     // Link attached files to the new message id.
     $linked_files = phorum_db_get_message_file_list($oldid);
     foreach ($linked_files as $linked_file) {
         phorum_db_file_link($linked_file["file_id"], $msg["message_id"], PHORUM_LINK_MESSAGE);
     }
     // save the new message-id for later use
     $msgid_translation[$oldid] = $msg['message_id'];
 }
 // deleting messages which are now doubled
 phorum_db_delete_message($_POST['thread'], PHORUM_DELETE_TREE);
 // update message count / stats
 phorum_db_update_forum_stats(true);
 // change forum_id for the following calls to update the right forum
 $PHORUM["forum_id"] = $target['forum_id'];
 // update message count / stats
 phorum_update_thread_info($target['thread']);
 phorum_db_update_forum_stats(true);
 /*
  * [hook]