Code: Select all
{LOG SOFT DELETE TOPIC}
{LOG HARD DELETE TOPIC}
I would also like this feature, but in the meantime will be implementing it myself as I cannot wait. When you delete an entire topic (which we do on our boards if the entire topic is questionable), there are times that we do actually undelete it. Some topics have numerous replies and its very tedious having to go through each post to actually really undelete a topic. In my opinion you shouldn't have a "Delete Topic" option if you don't have a "Undelete Topic" option. Works great one way, not the reverse though.jmjm003 wrote:EXreaction,
In a future release of this MOD. Would it be possible to add an option to un-delete a soft deleted topic using Quick-mod tools. At this point from the best I can tell. You have to un-delete each post in order to un-delete a topic. It's not that big of a deal if the topic only has a few post in it. Once you get into 20 or more post it takes quite a while to un-delete each post.
I personally hope to never have a mod or admin soft delete such a topic. You would think they would delete a few select post that might be the cause of the problems within that topic.
Thank you!
Code: Select all
));
?>
Code: Select all
'TOPIC_NOT_DELETED' => 'The topic is not deleted already.',
'UNDELETE_TOPIC' => 'Undelete Topic',
'UNDELETE_TOPIC_CONFIRM' => 'Undeleting a topic undeletes all posts too. Are you sure you want to undelete this topic?',
Code: Select all
function handle_undelete($post_id
Code: Select all
/**
* Handles undeleting of an entire topic
*/
function handle_undelete_topic($topic_ids)
{
global $db;
if (!is_array($topic_ids))
{
$topic_ids = array($topic_ids);
}
if (sizeof($topic_ids))
{
$sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$post_ids[] = $row['post_id'];
}
}
handle_undelete($post_ids, $topic_ids);
}
/**
* Handles undeleting of posts/topics for posting.php
*/
function handle_undelete($post_id, $topic_id = false)
{
global $user, $db, $auth, $phpbb_root_path, $phpEx;
$user->setup('common');
$user->add_lang('mods/soft_delete');
if (!$post_id)
{
trigger_error('NO_POST');
}
if (!is_array($post_id))
{
$post_id = array($post_id);
}
if (!is_array($topic_id))
{
$topic_id = array($topic_id);
}
include($phpbb_root_path . 'includes/mods/soft_delete_class.' . $phpEx);
$delete = new delete();
$delete->get_post_data($post_id);
$delete->undelete_check($post_id, $topic_id);
if($topic_id[0] && $delete->topic_data[$topic_id[0]]['topic_deleted'] == 0)
{
trigger_error('TOPIC_NOT_DELETED');
}
if (!sizeof($delete->undelete['p']))
{
trigger_error('NO_AUTH_OPERATION');
}
if (confirm_box(true))
{
$delete->undelete_posts();
$redirect_post = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$delete->post_data[$post_id[0]]['forum_id']}&t={$delete->post_data[$post_id[0]]['topic_id']}&p={$post_id[0]}#p$post_id[0]");
$redirect_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$delete->post_data[$post_id[0]]['forum_id']}&t={$delete->post_data[$post_id[0]]['topic_id']}");
$redirect_forum = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$delete->post_data[$post_id[0]]['forum_id']}");
if (sizeof($delete->undelete['t']))
{
$message = $user->lang['TOPIC_UNDELETE_SUCCESS'] . '<br/><br/>';
}
else
{
$message = $user->lang['POST_UNDELETE_SUCCESS'] . '<br/><br/>';
$message .= sprintf($user->lang['CLICK_RETURN_POST'], "<a href=\"{$redirect_post}\">", '</a><br/>');
}
$message .= sprintf($user->lang['CLICK_RETURN_TOPIC'], "<a href=\"{$redirect_topic}\">", '</a><br/>');
$message .= sprintf($user->lang['CLICK_RETURN_FORUM'], "<a href=\"{$redirect_forum}\">", '</a><br/>');
meta_refresh(3, $redirect_post);
trigger_error($message);
}
else
{
if($topic_id[0])
{
$s_hidden_fields = build_hidden_fields(array(
't' => $topic_id[0],
'mode' => 'undelete',
'action' => 'undelete_topic')
);
confirm_box(false, 'UNDELETE_TOPIC', $s_hidden_fields);
}
else {
$s_hidden_fields = build_hidden_fields(array(
'p' => $post_id[0],
'mode' => 'undelete')
);
confirm_box(false, 'UNDELETE_POST', $s_hidden_fields);
}
}
redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $post_id[0]) . "#p$post_id");
}
Code: Select all
case 'delete_post':
Code: Select all
case 'undelete_topic':
$user->add_lang('viewtopic');
$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
if (!sizeof($topic_ids))
{
trigger_error('NO_TOPIC_SELECTED');
}
include("{$phpbb_root_path}includes/mods/soft_delete.$phpEx");
handle_undelete_topic($topic_ids);
break;
Code: Select all
include("{$phpbb_root_path}includes/mods/soft_delete.$phpEx");
if ($mode == 'undelete')
{
handle_undelete($post_id); }
}
else if ($mode == 'delete')
{
handle_delete($post_id);
}
Code: Select all
include("{$phpbb_root_path}includes/mods/soft_delete.$phpEx");
if ($mode == 'undelete')
{
if($topic_id) { handle_undelete_topic($topic_id); }
else if($post_id) { handle_undelete($post_id); }
}
else if ($mode == 'delete')
{
handle_delete($post_id);
}
Code: Select all
$topic_mod .= (($auth->acl_get('m_harddelete', $forum_id) || $auth->acl_get('m_delete', $forum_id)) && !$topic_data['topic_deleted']) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
Code: Select all
$topic_mod .= (($auth->acl_get('m_harddelete', $forum_id) || $auth->acl_get('m_delete', $forum_id)) && !$topic_data['topic_deleted']) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
if (!isset($user->lang['UNDELETE_TOPIC']) && (($auth->acl_get('m_harddelete', $forum_id) || $auth->acl_get('m_delete', $forum_id)) && $topic_data['topic_deleted']))
{
$user->add_lang('mods/soft_delete');
}
$topic_mod .= (($auth->acl_get('m_harddelete', $forum_id) || $auth->acl_get('m_delete', $forum_id)) && $topic_data['topic_deleted']) ? '<option value="undelete_topic">' . $user->lang['UNDELETE_TOPIC'] . '</option>' : '';
Code: Select all
case 'delete_topic':
Code: Select all
case 'undelete_topic':
Code: Select all
INSERT INTO phpbb_config VALUES ('softdelete_enable_prune', '1', 0);
INSERT INTO phpbb_config VALUES ('softdelete_prune_frequency', '1', 0);
INSERT INTO phpbb_config VALUES ('softdelete_days_maxage', '30', 0);
INSERT INTO phpbb_config VALUES ('softdelete_last_run', '0', 1);
Code: Select all
?>
Code: Select all
$lang = array_merge($lang, array(
'DELETED_POSTS' => 'Deleted Posts',
'DELETED_POSTS_DESC' => 'This is a list of topics that contain soft deleted posts. The topics themselves are not deleted.',
'DELETED_TOPICS' => 'Deleted Topics',
'DELETED_TOPICS_DESC' => 'This is a list of topics that have been deleted. Undeleting a topic undeletes all posts in that thread.',
));
Code: Select all
case 'egosearch':
Code: Select all
case 'deleted_posts':
// Do the Deleted Topics/Posts Prune thang - cron type job ...
if(time() - ($config['softdelete_prune_frequency'] * 86400) >= $config['softdelete_last_run'] && $config['softdelete_enable_prune'])
{
$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_softdeleted') . '" alt="cron" width="1" height="1">');
}
$l_search_title = $user->lang['DELETED_POSTS'];
$l_search_desc = $user->lang['DELETED_POSTS_DESC'];
$show_results = request_var('sr', 'topics');
$show_results = ($show_results == 'posts') ? 'posts' : 'topics';
$sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_deleted_time' : 't.topic_deleted_time';
$sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title';
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
if ($sort_days)
{
$last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600));
}
else
{
$last_post_time = '';
}
if ($sort_key == 'a')
{
$sort_join = USERS_TABLE . ' u, ';
$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;
}
if ($show_results == 'posts')
{
$sql = "SELECT p.post_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE p.post_deleted != 0
AND t.topic_deleted = 0
AND p.topic_id = t.topic_id
$last_post_time
$m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'post_id';
}
else
{
$sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE p.post_deleted != 0
AND t.topic_deleted = 0
AND t.topic_moved_id = 0
AND p.topic_id = t.topic_id
$last_post_time
$m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'topic_id';
}
break;
case 'deleted_topics':
// Do the Deleted Topics/Posts Prune thang - cron type job ...
if(time() - ($config['softdelete_prune_frequency'] * 86400) >= $config['softdelete_last_run'] && $config['softdelete_enable_prune'])
{
$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_softdeleted') . '" alt="cron" width="1" height="1">');
}
$l_search_title = $user->lang['DELETED_TOPICS'];
$l_search_desc = $user->lang['DELETED_TOPICS_DESC'];
$show_results = request_var('sr', 'topics');
$show_results = ($show_results == 'posts') ? 'posts' : 'topics';
$sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_deleted_time' : 't.topic_deleted_time';
$sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title';
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
if ($sort_days)
{
$last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600));
}
else
{
$last_post_time = '';
}
if ($sort_key == 'a')
{
$sort_join = USERS_TABLE . ' u, ';
$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;
}
if ($show_results == 'posts')
{
$sql = "SELECT p.post_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE t.topic_deleted != 0
AND p.topic_id = t.topic_id
$last_post_time
$m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'post_id';
}
else
{
$sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE t.topic_deleted != 0
AND t.topic_moved_id = 0
AND p.topic_id = t.topic_id
$last_post_time
$m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'topic_id';
}
break;
Code: Select all
case 'prune_forum':
Code: Select all
case 'prune_softdeleted':
if(time() - ($config['softdelete_prune_frequency'] * 86400) < $config['softdelete_last_run'] && $config['softdelete_enable_prune'])
{
break;
}
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
if ($use_shutdown_function)
{
register_shutdown_function('prune_softdeleted');
}
else
{
prune_softdeleted();
}
break;
Code: Select all
set_config('database_last_gc', time(), true);
}
Code: Select all
/**
* Prune soft deleted topics/posts (actually hard delete them)
*/
function prune_softdeleted()
{
global $db, $user, $config;
$expire_date = time() - ($config['softdelete_days_maxage'] * 86400);
$post_ids = array();
$topic_ids = array();
$sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE . '
WHERE topic_deleted != 0
AND topic_deleted_time < ' . $expire_date;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$topic_ids[] = $row['topic_id'];
}
$db->sql_freeresult($result);
delete_topics('topic_id', $topic_ids, false);
$sql = 'SELECT post_id
FROM ' . POSTS_TABLE . '
WHERE post_deleted != 0
AND post_deleted_time < ' . $expire_date;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$post_ids[] = $row['post_id'];
}
$db->sql_freeresult($result);
delete_posts('post_id', $post_ids, false, false);
$user->add_lang('mods/soft_delete');
set_config('softdelete_last_run', time(), true);
add_log('admin', 'LOG_AUTO_PRUNE', $user->lang['PRUNED_SOFT_DELETED']);
}
Code: Select all
'POSTS_MCP_DELETE_SUCCESS' => 'The posts have been deleted successfully.',
Code: Select all
'PRUNED_SOFT_DELETED' => 'Pruned Soft Deleted Topics/Posts',
Since the above links take us to a hosting company, would you mind including the code here?Bigwebmaster wrote:Here are the enhancements which provide two search links you can use to see deleted posts or deleted topics:
http://www.yoursite.com/search.php?sear ... ted_topics
http://www.yoursite.com/search.php?sear ... eted_posts
I did not include in this modification making links for those, you will need to do that yourself or manually put them in. I am not sure I will be putting them in.
Code: Select all
case 'deleted_posts':
// Do the Deleted Topics/Posts Prune thang - cron type job ...
if(time() - ($config['softdelete_prune_frequency'] * 86400) >= $config['softdelete_last_run'] && $config['softdelete_enable_prune'])
{
$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_softdeleted') . '" alt="cron" width="1" height="1">');
}
$l_search_title = $user->lang['DELETED_POSTS'];
$l_search_desc = $user->lang['DELETED_POSTS_DESC'];
$show_results = request_var('sr', 'topics');
$show_results = ($show_results == 'posts') ? 'posts' : 'topics';
$sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_deleted_time' : 't.topic_deleted_time';
$sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title';
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
if ($sort_days)
{
$last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600));
}
else
{
$last_post_time = '';
}
if ($sort_key == 'a')
{
$sort_join = USERS_TABLE . ' u, ';
$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;
}
if ($show_results == 'posts')
{
$sql = "SELECT p.post_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE p.post_deleted != 0
AND t.topic_deleted = 0
AND p.topic_id = t.topic_id
$last_post_time
$m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'post_id';
}
else
{
$sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE p.post_deleted != 0
AND t.topic_deleted = 0
AND t.topic_moved_id = 0
AND p.topic_id = t.topic_id
$last_post_time
$m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'topic_id';
}
break;
case 'deleted_topics':
// Do the Deleted Topics/Posts Prune thang - cron type job ...
if(time() - ($config['softdelete_prune_frequency'] * 86400) >= $config['softdelete_last_run'] && $config['softdelete_enable_prune'])
{
$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_softdeleted') . '" alt="cron" width="1" height="1">');
}
$l_search_title = $user->lang['DELETED_TOPICS'];
$l_search_desc = $user->lang['DELETED_TOPICS_DESC'];
$show_results = request_var('sr', 'topics');
$show_results = ($show_results == 'posts') ? 'posts' : 'topics';
$sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_deleted_time' : 't.topic_deleted_time';
$sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title';
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
if ($sort_days)
{
$last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600));
}
else
{
$last_post_time = '';
}
if ($sort_key == 'a')
{
$sort_join = USERS_TABLE . ' u, ';
$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;
}
if ($show_results == 'posts')
{
$sql = "SELECT p.post_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE t.topic_deleted != 0
AND p.topic_id = t.topic_id
$last_post_time
$m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'post_id';
}
else
{
$sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id
FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE t.topic_deleted != 0
AND t.topic_moved_id = 0
AND p.topic_id = t.topic_id
$last_post_time
$m_approve_fid_sql
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'topic_id';
}
break;
What I found is this:Bigwebmaster wrote: Open include/mods/soft_delete.php
Partial Find:Code: Select all
function handle_undelete($post_id, $topic_id = false)
Code: Select all
function handle_undelete($post_id)
I found this:Replace entire function with ...snipped...
Open viewtopic.php
Find:
Code: Select all
$topic_mod .= (($auth->acl_get('m_harddelete', $forum_id) || $auth->acl_get('m_delete', $forum_id)) && !$topic_data['topic_deleted']) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
Code: Select all
$topic_mod .= ($auth->acl_get('m_harddelete', $forum_id) || $auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
My phpBB is version 3.01. Do we have different versions of the soft_delete mod?Replace with ...snipped...
Code: Select all
function handle_undelete($post_id, $topic_id = false)
Code: Select all
function handle_undelete($post_id
...
...