if (isset($delete_messages[$msg["message_id"]])) { continue; } $PHORUM["forum_id"] = $msg["forum_id"]; $delmode = $msg["parent_id"] == 0 ? PHORUM_DELETE_TREE : PHORUM_DELETE_MESSAGE; // A hook to allow modules to implement extra or different // delete functionality. list($handled, $delids, $msgid, $msg, $delmode) = phorum_hook("before_delete", array(false, 0, $msg["message_id"], $msg, $delmode)); // If the "before_delete" hook did not handle the delete action, // then we have to handle it here ourselves. if (!$handled) { // Delete the message or thread. $delids = phorum_db_delete_message($msg["message_id"], $delmode); // Cleanup the attachments for all deleted messages. foreach ($delids as $delid) { $files = phorum_db_get_message_file_list($delid); foreach ($files as $file_id => $data) { phorum_api_file_delete($file_id); } } // For deleted threads, check if we have move notifications // to delete. We unset the forum id, so phorum_db_get_messages() // will return messages with the same thread id in // other forums as well (those are the move notifications). if ($delmode == PHORUM_DELETE_TREE) { $forum_id = $PHORUM["forum_id"]; $PHORUM["forum_id"] = 0; $moved = phorum_db_get_messages($msg["message_id"]); $PHORUM["forum_id"] = $forum_id; foreach ($moved as $id => $data) { if (!empty($data["moved"])) {
$delete_messages = phorum_db_get_message(array_keys($deleteids), 'message_id', true); //print_var($delete_messages); foreach ($deleteids as $msgthd_id => $doit) { // A hook to allow modules to implement extra or different // delete functionality. if ($doit && isset($mod_forums[$delete_messages[$msgthd_id]['forum_id']])) { $delete_handled = 0; if (isset($PHORUM["hooks"]["before_delete"])) { list($delete_handled, $msg_ids, $msgthd_id, $delete_messages[$msgthd_id], $delete_mode) = phorum_hook("before_delete", array(0, 0, $msgthd_id, $delete_messages[$msgthd_id], PHORUM_DELETE_MESSAGE)); } // Handle the delete action, unless a module already handled it. if (!$delete_handled) { // Delete the message from the database. phorum_db_delete_message($msgthd_id, PHORUM_DELETE_MESSAGE); // Delete the message attachments from the database. $files = phorum_db_get_message_file_list($msgthd_id); foreach ($files as $file_id => $data) { if (phorum_api_file_check_delete_access($file_id)) { phorum_api_file_delete($file_id); } } } // Run a hook for performing custom actions after cleanup. if (isset($PHORUM["hooks"]["delete"])) { phorum_hook("delete", array($msgthd_id)); } } } } $PHORUM['DATA']['PREPOST'] = array(); if ($gotforums) {
$msg['forum_id'] = $target['forum_id']; // the forum_id of the new thread $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);