############################################################## ## MOD Title: Post move instead deleting ## MOD Author: oxpus < webmaster@oxpus.de > (Karsten Ude) http://www.oxpus.de ## MOD Description: This mod will move posts to a hidden forum instead deleting them by an user or mod. ## The admin can alltimes delete and mods if they are allowed to, too. ## MOD Version: 1.0.4 ## ## Installation Level: Intermediate ## Installation Time: 5-10 min ## Files To Edit: 8 ## admin/admin_boards.php ## includes/functions_post.php ## language/lang_english/lang_admin.php ## language/lang_english/lang_main.php ## language/lang_german/lang_admin.php ## language/lang_german/lang_main.php ## templates/subSilver/admin/board_config_body.tpl ## modcp.php ## Included Files: n/a ## ## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 ############################################################## ## For security purposes, please check: http://www.phpbb.com/mods/ ## for the latest version of this MOD. Although MODs are checked ## before being allowed in the MODs Database there is no guarantee ## that there are no security problems within the MOD. No support ## will be given for MODs not found within the MODs Database which ## can be found at http://www.phpbb.com/mods/ ############################################################## ## Author Notes: ## ## Upload the file ## db_update.php ## to your phpbb root directory and run this with your browser. ## This file will do all nessassary changes in the database for you. ## After using this file, please delete it to avoid errors. ## ## Hint for delete posts from modcp ## -------------------------------- ## Regard that moderators will be able to delete posts from the modcp, too. ## To avoid to loose "moved" posts, do not allow these users to moderate the bin forum. ## The "normal" forums are protected in the modcp, but not the bin forum! ## ############################################################## ## MOD History: ## ## 2007-08-25 - Version 1.0.3 ## - ADD Delete post method on modcp for moderators ## - FIX Display now the topic title instead topic id on "moved" topic subject ## - FIX Userpost count for delete/move topic ## For update this mod use the file update_top_1_0_3.txt ## ## 2006-03-11 - Version 1.0.2 ## - FIX Missing sync forums after moving a post ## ## 2005-06-17 - Version 1.0.1 ## - FIX little bug in functions_post.php. Reinstall the part for this file ## ## 2005-02-26 - Version 1.0.0 ## - First release ## ############################################################## ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ############################################################## # #-----[ OPEN ]------------------------------------------ # admin/admin_board.php # #-----[ FIND ]------------------------------------------ # $namechange_yes = ( $new['allow_namechange'] ) ? "checked=\"checked\"" : ""; $namechange_no = ( !$new['allow_namechange'] ) ? "checked=\"checked\"" : ""; # #-----[ AFTER, ADD ]------------------------------------------ # $mod_allow_delete_post_yes = ( $new['mod_allow_delete_post'] ) ? "checked=\"checked\"" : ""; $mod_allow_delete_post_no = ( !$new['mod_allow_delete_post'] ) ? "checked=\"checked\"" : ""; # #-----[ FIND ]------------------------------------------ # "L_RESET" => $lang['Reset'], # #-----[ AFTER, ADD ]------------------------------------------ # "L_DELETE_POST_FORUM" => $lang['Delete_post_forum'], "L_DELETE_POST_FORUM_EXPLAIN" => $lang['Delete_post_forum_explain'], "L_MOD_ALLOW_DELETE_POST" => $lang['Mod_allow_delete_post'], "L_MOD_ALLOW_DELETE_POST_EXPLAIN" => $lang['Mod_allow_delete_post_explain'], "DELETE_POST_FORUM" => $new['delete_post_forum'], "MOD_ALLOW_DELETE_POST_YES" => $mod_allow_delete_post_yes, "MOD_ALLOW_DELETE_POST_NO" => $mod_allow_delete_post_no, # #-----[ OPEN ]------------------------------------------ # includes/functions_post.php # #-----[ FIND ]------------------------------------------ # function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id) { global $db; # #-----[ AFTER, ADD ]------------------------------------------ # global $board_config, $userdata; if ((int) $board_config['delete_post_forum'] && $mode == 'delete') { $sql = "SELECT * FROM " . FORUMS_TABLE . " WHERE forum_id = " . (int) $board_config['delete_post_forum']; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } $forum_count = $db->sql_numrows($result); $db->sql_freeresult($result); $forum_check = ($forum_count != 0) ? TRUE : 0; } else { $forum_check = 0; } # #-----[ FIND ]------------------------------------------ # if ($mode != 'poll_delete') { $sql = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts $sign WHERE user_id = $user_id"; if (!$db->sql_query($sql, END_TRANSACTION)) { message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql); } } # #-----[ REPLACE WITH ]------------------------------------------ # if (($mode == 'delete' && ($forum_id != (int) $board_config['delete_post_forum'])) || ($mode != 'poll_delete' && $mode != 'delete')) { $sql = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts $sign WHERE user_id = $user_id"; if (!$db->sql_query($sql, END_TRANSACTION)) { message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql); } } # #-----[ FIND ]------------------------------------------ # function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id) { global $board_config, $lang, $db, $phpbb_root_path, $phpEx; global $userdata, $user_ip; # #-----[ AFTER, ADD ]------------------------------------------ # if ((int) $board_config['delete_post_forum']) { $sql = "SELECT * FROM " . FORUMS_TABLE . " WHERE forum_id = " . (int) $board_config['delete_post_forum']; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } $forum_count = $db->sql_numrows($result); $db->sql_freeresult($result); $forum_check = ($forum_count != 0) ? TRUE : 0; } else { $forum_check = 0; } # #-----[ FIND ]------------------------------------------ # if ($mode != 'poll_delete') { include($phpbb_root_path . 'includes/functions_search.'.$phpEx); # #-----[ AFTER, ADD ]------------------------------------------ # include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); if ($userdata['user_level'] == ADMIN || ($userdata['user_level'] == MOD && $board_config['mod_allow_delete_post'] == 1)) { # #-----[ FIND ]------------------------------------------ # $sql = "DELETE FROM " . POSTS_TEXT_TABLE . " WHERE post_id = $post_id"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } # #-----[ AFTER, ADD ]------------------------------------------ # } else if ($post_data['first_post'] == '' && $forum_check == TRUE) { $sql = "SELECT topic_title FROM " . TOPICS_TABLE . " WHERE topic_id = $topic_id"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $topic_title = $row['topic_title']; $db->sql_freeresult($result); $sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_status, topic_vote, topic_type, topic_first_post_id, topic_last_post_id, topic_moved_id) VALUES (".(int) $board_config['delete_post_forum'].", '".sprintf($lang['Deleted_post_from_topic'], $topic_title)."', ".$post_data['poster_id'].", ".time().", 0, 0, ".TOPIC_UNLOCKED.", 0, ".POST_NORMAL.", $post_id, $post_id, 0)"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } $new_topic_id = $db->sql_nextid(); $sql = "UPDATE " . POSTS_TABLE . " SET topic_id = $new_topic_id, forum_id = ".$board_config['delete_post_forum']." WHERE post_id = $post_id"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } sync('topic', $new_topic_id); sync('forum', $board_config['delete_post_forum']); } # #-----[ FIND ]------------------------------------------ # $sql = "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = $topic_id OR topic_moved_id = $topic_id"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } # #-----[ REPLACE WITH ]------------------------------------------ # if ($userdata['user_level'] == ADMIN || ($userdata['user_level'] == MOD && $board_config['mod_allow_delete_post'] == 1)) { $sql = "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = $topic_id OR topic_moved_id = $topic_id"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } } else if ($forum_check == TRUE) { $sql = "UPDATE " . TOPICS_TABLE . " SET forum_id = " . $board_config['delete_post_forum'] . " WHERE topic_id = $topic_id"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } $sql = "UPDATE " . POSTS_TABLE . " SET forum_id = " . $board_config['delete_post_forum'] . " WHERE topic_id = $topic_id"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } sync('topic', $topic_id); sync('forum', $board_config['delete_post_forum']); } # #-----[ OPEN ]------------------------------------------ # language/lang_english/lang_admin.php # #-----[ FIND ]------------------------------------------ # ?> # #-----[ BEFORE, ADD ]------------------------------------------ # $lang['Delete_post_forum'] = 'Forum for deleted posts'; $lang['Delete_post_forum_explain'] = 'This forum will content all posts a user or mod (next option!) have deleted. Enter 0 or nothing at this field to disable this function.'; $lang['Mod_allow_delete_post'] = 'Allow Moderators to delete posts'; $lang['Mod_allow_delete_post_explain'] = 'To allow Moderators to delete posts instead moving them say YES to this option. The forum permissions to delete posts will not be changed by this function!'; # #-----[ OPEN ]------------------------------------------ # language/lang_english/lang_main.php # #-----[ FIND ]------------------------------------------ # ?> # #-----[ BEFORE, ADD ]------------------------------------------ # $lang['Deleted_post_from_topic'] = 'Deleted post from topic %s'; # #-----[ OPEN ]------------------------------------------ # language/lang_german/lang_admin.php # #-----[ FIND ]------------------------------------------ # ?> # #-----[ BEFORE, ADD ]------------------------------------------ # $lang['Delete_post_forum'] = 'Forum für gelöschte Beiträge'; $lang['Delete_post_forum_explain'] = 'Dieses Forum beinhaltet alle Beiträge die ein User oder Mod (siehe nächste Option!) gelöscht hat. Gib 0 ein oder lass dieses Feld leer, wenn Du diese Funktion abschalten willst.'; $lang['Mod_allow_delete_post'] = 'Erlaube Moderatoren Beiträge zu löschen'; $lang['Mod_allow_delete_post_explain'] = 'Um Moderatoren zu erlauben, Beiträge zu löschen, anstelle diese zu verschieben, wähle hier JA. Die Foren Berechtigungen zum Löschen werden mit dieser Funktion nicht geändert!'; # #-----[ OPEN ]------------------------------------------ # language/lang_german/lang_main.php # #-----[ FIND ]------------------------------------------ # ?> # #-----[ BEFORE, ADD ]------------------------------------------ # $lang['Deleted_post_from_topic'] = 'Gelöschter Beitrag von Topic %s'; # #-----[ OPEN ]------------------------------------------ # modcp.php # #-----[ FIND ]------------------------------------------ # case 'delete': if (!$is_auth['auth_delete']) { message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type'])); } $page_title = $lang['Mod_CP']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); if ( $confirm ) { # #-----[ AFTER, ADD ]------------------------------------------ # if ($userdata['user_level'] == ADMIN) { $delete_direct = true; } else if ($board_config['mod_allow_delete_post']) { $delete_direct = true; } else { $delete_direct = false; } if ($forum_id == (int) $board_config['delete_post_forum']) { $update_user_stats = false; } else { $update_user_stats = true; } # #-----[ FIND ]------------------------------------------ # $sql = "SELECT poster_id, COUNT(post_id) AS posts FROM " . POSTS_TABLE . " WHERE topic_id IN ($topic_id_sql) GROUP BY poster_id"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql); } $count_sql = array(); while ( $row = $db->sql_fetchrow($result) ) { $count_sql[] = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts - " . $row['posts'] . " WHERE user_id = " . $row['poster_id']; } $db->sql_freeresult($result); if ( sizeof($count_sql) ) { for($i = 0; $i < sizeof($count_sql); $i++) { if ( !$db->sql_query($count_sql[$i]) ) { message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql); } } } # #-----[ BEFORE, ADD ]------------------------------------------ # if ($update_user_stats) { # #-----[ AFTER, ADD ]------------------------------------------ # } # #-----[ FIND ]------------------------------------------ # // // Got all required info so go ahead and start deleting everything // # #-----[ AFTER, ADD ]------------------------------------------ # if ($delete_direct) { # #-----[ FIND ]------------------------------------------ # remove_search_post($post_id_sql); } # #-----[ AFTER, ADD ]------------------------------------------ # } else { $sql = "UPDATE " . TOPICS_TABLE . " SET forum_id = " . (int) $board_config['delete_post_forum'] . " WHERE topic_id IN ($topic_id_sql) OR topic_moved_id IN ($topic_id_sql)"; if ( !$db->sql_query($sql, BEGIN_TRANSACTION) ) { message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql); } if ($post_id_sql) { $sql = "UPDATE " . POSTS_TABLE . " SET forum_id = " . (int) $board_config['delete_post_forum'] . " WHERE post_id IN ($post_id_sql)"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql); } } sync('forum', (int) $board_config['delete_post_forum']); } # #-----[ OPEN ]------------------------------------------ # templates/subSilver/admin/board_config_body.tpl # #-----[ FIND ]------------------------------------------ # {L_ENABLE_PRUNE} {L_YES}   {L_NO} # #-----[ AFTER, ADD ]------------------------------------------ # {L_DELETE_POST_FORUM}
{L_DELETE_POST_FORUM_EXPLAIN} {L_MOD_ALLOW_DELETE_POST}
{L_MOD_ALLOW_DELETE_POST_EXPLAIN} {L_YES}   {L_NO} # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM