
Bigwebmaster wrote:For those of you who want to be able to "Undelete Topics" I have made the necessary changes so that this works:
This allows you to undelete a topic and all of its posts instead of having to go through and undelete each and every post in that topic the way its currently setup.
There could be bugs, but I have done some tests and everything seems to work as expected for me at this point. Here are the changes:
Open language/en/mods/soft_delete.php
Find:
- Code: Select all
));
?>
Before Add:
- 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?',
Open include/mods/soft_delete.php
Partial Find:
- Code: Select all
function handle_undelete($post_id
Replace entire function with this:
- 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");
}
Open: includes/mcp/mcp_main.php
Find:
- Code: Select all
case 'delete_post':
Before Add:
- 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;
Open posting.php
Find something like:
- 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);
}
Replace with:
- 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);
}
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>' : '';
Replace with:
- 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>' : '';
Open mcp.php
Find:
- Code: Select all
case 'delete_topic':
After add:
- Code: Select all
case 'undelete_topic':
And I think that should do it. Hopefully I didn't miss anything. I also created additional modifications (not shown above) to be able to use search.php to find all deleted topics or deleted posts in case you have deleted topics hidden from the forums for moderators. I wanted that feature because I want the deleted topics to not be visible in the forums.
I plan to also create a modification to auto delete (prune) soft deleted topics/posts after a certain time period since they were soft deleted.

EXreaction wrote:The mod has already been updated, just get the latest version.
http://www.lithiumstudios.org/forum/viewforum.php?f=31


Title:
Soft Delete 1.0.14 to 1.0.15 upgrade
Description:
Changes the current hard delete scheme to all soft deleting for posts and topics.
Also includes the option to undelete posts and topics after they have been soft deleted.
New permissions give the option to allow administrators and/or moderators to hard delete posts/topics after they have already been soft deleted.
Version:
1.0.15
Installation level:
Easy
Installation time:
~0 minutes
Author notes:
Please ask for support at my website if you need any: http://www.lithiumstudios.org. Soft deleting of Private Messages is not included in this modification.
Author
Username:
EXreaction
Email:
exreaction@lithiumstudios.org
Name:
Nathan Guse
WWW:
http://www.lithiumstudios.org
Included files
No files have been included with this MOD.


Return to [3.0.x] MOD Database Releases
Users browsing this forum: bet-winners, codfather, FladeX, iWisdom, klone, moonlightkisu, MSNbot Media, Redy, RMcGirr83, Twiceler [Bot], WolfSoul, Xtracker! and 44 guests