Soft Delete

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Locked
W3rtas
Registered User
Posts: 10
Joined: Thu Jun 11, 2009 5:34 pm

Re: Soft Delete

Post by W3rtas » Thu Jun 18, 2009 6:22 pm

<Founded where i can change hard delete permissions>
Last edited by W3rtas on Sat Jun 20, 2009 11:20 am, edited 1 time in total.

User avatar
Fredrik Idestam
Registered User
Posts: 199
Joined: Sat Apr 18, 2009 7:54 am
Contact:

Re: Soft Delete

Post by Fredrik Idestam » Thu Jun 18, 2009 9:56 pm

i don't have option to restore soft deleted post, anyone please help....

NicksNet
Registered User
Posts: 55
Joined: Sat Apr 04, 2009 1:16 pm

Re: Soft Delete

Post by NicksNet » Fri Jun 19, 2009 10:52 am

hello,

thanks for this mod


but i have a question about the log in acp

in the mod-protocol (dont know whats the name in english :oops: ) i have this:

Code: Select all

{LOG SOFT DELETE TOPIC}
{LOG HARD DELETE TOPIC}
where i have to translate it?

thanks nick
Screenshot_195.jpg
Screenshot_195.jpg (18.8 KiB) Viewed 597 times

User avatar
Bigwebmaster
Registered User
Posts: 56
Joined: Sun Dec 22, 2002 1:48 am
Location: Seattle, WA
Contact:

Re: Possible new option?

Post by Bigwebmaster » Tue Jun 30, 2009 6:00 am

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!
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.

Other than that great mod.

User avatar
Bigwebmaster
Registered User
Posts: 56
Joined: Sun Dec 22, 2002 1:48 am
Location: Seattle, WA
Contact:

Re: Soft Delete

Post by Bigwebmaster » Tue Jun 30, 2009 4:23 pm

For those of you who want to be able to "Undelete Topics" I have made the necessary changes so that this works:
undelete.png
undelete.png (17.41 KiB) Viewed 555 times
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.
Last edited by Bigwebmaster on Tue Jul 07, 2009 4:25 am, edited 1 time in total.

User avatar
muggins
Registered User
Posts: 1183
Joined: Fri Feb 22, 2008 5:12 pm
Location: Texas
Name: Donovan
Contact:

Re: Soft Delete

Post by muggins » Tue Jun 30, 2009 5:40 pm

Thanks! A much-needed mod to the mod.

I'll try it, but I await your other enhancements too. :D
Muggins

User avatar
Bigwebmaster
Registered User
Posts: 56
Joined: Sun Dec 22, 2002 1:48 am
Location: Seattle, WA
Contact:

Re: Soft Delete

Post by Bigwebmaster » Tue Jun 30, 2009 11:15 pm

Here are the enhancements which provide two search links you can use to see deleted posts or deleted topics:

http://www.yoursiteblahblah.com/search. ... ted_topics
http://www.yoursiteblahblah.com/search. ... 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.

This additional modification also auto prunes soft deleted posts and topics with a default of age of 30 days. By default it checks once per day to remove any deleted posts or topics that are older than that. I did not write an acp configuration screen as I do not plan to change these defaults on my system, but it might be something useful to be done in the future. On with the changes which by default puts the pruning on:

Execute the following SQL:

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);	
Open language/en/search.php

Find:

Code: Select all

?>
Before Add:

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.',
));
Open search.php

Find:

Code: Select all

			case 'egosearch':
Before Add:

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;
Open cron.php

Find:

Code: Select all

	case 'prune_forum':
Before Add:

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;
Open includes/functions_admin.php

Find:

Code: Select all

	set_config('database_last_gc', time(), true);
}
After Add:

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']);
}
Open language/en/mods/soft_delete.php

Find:

Code: Select all

	'POSTS_MCP_DELETE_SUCCESS'		=> 'The posts have been deleted successfully.',
After Add:

Code: Select all

	'PRUNED_SOFT_DELETED'			=> 'Pruned Soft Deleted Topics/Posts',
And again hopefully I didn't miss anything. I have done some testing and things seem to work okay. There could be bugs though that I overlooked. Would love to see this get worked into this mod officially, but if not it doesn't matter to me. Hopefully it helps some of you!
Last edited by Bigwebmaster on Wed Jul 01, 2009 4:00 pm, edited 3 times in total.

User avatar
muggins
Registered User
Posts: 1183
Joined: Fri Feb 22, 2008 5:12 pm
Location: Texas
Name: Donovan
Contact:

Re: Soft Delete

Post by muggins » Wed Jul 01, 2009 1:18 pm

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.
Since the above links take us to a hosting company, would you mind including the code here? :lol:

Edit: Sorry, I missed it in your included code. May we see it without the SEO mod code?
Muggins

User avatar
Bigwebmaster
Registered User
Posts: 56
Joined: Sun Dec 22, 2002 1:48 am
Location: Seattle, WA
Contact:

Re: Soft Delete

Post by Bigwebmaster » Wed Jul 01, 2009 3:58 pm

Didn't even realize that one had the SEO code in it. Simply replace that one section by taking out the seo part:

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;
I fixed it in the other post too.

Holger
Registered User
Posts: 1761
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Re: Soft Delete

Post by Holger » Mon Jul 06, 2009 2:23 pm

Hm, I wanted to implement those changes, but the FIND-code does not fit.
http://www.phpbb.com/community/viewtopi ... #p10076455

What am I doing wrong?

MoBuzzCut
Registered User
Posts: 15
Joined: Tue Jun 16, 2009 12:48 pm

Re: Soft Delete

Post by MoBuzzCut » Mon Jul 06, 2009 2:39 pm

I used auto mod to install this mod but it does not seem to be working so what am I doing wrong.
Last edited by MoBuzzCut on Mon Jul 06, 2009 3:59 pm, edited 2 times in total.

User avatar
muggins
Registered User
Posts: 1183
Joined: Fri Feb 22, 2008 5:12 pm
Location: Texas
Name: Donovan
Contact:

Re: Soft Delete

Post by muggins » Mon Jul 06, 2009 3:07 pm

I'd love to include this, but as far as the missing finds go, these were my results:
Bigwebmaster wrote: Open include/mods/soft_delete.php

Partial Find:

Code: Select all

	function handle_undelete($post_id, $topic_id = false)
What I found is this:

Code: Select all

	function handle_undelete($post_id)
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>' : '';
I found this:

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>' : '';
Replace with ...snipped...
My phpBB is version 3.01. Do we have different versions of the soft_delete mod?

The rest of it seems to be good. ;)
Muggins

User avatar
Bigwebmaster
Registered User
Posts: 56
Joined: Sun Dec 22, 2002 1:48 am
Location: Seattle, WA
Contact:

Re: Soft Delete

Post by Bigwebmaster » Tue Jul 07, 2009 4:19 am

Change this:

Partial Find:

Code: Select all

	function handle_undelete($post_id, $topic_id = false)
to:

Partial Find:

Code: Select all

	function handle_undelete($post_id
...
...
Basically take the entire function and replace with the code I posted (which does add a new function as well). I updated the above as well.

Holger
Registered User
Posts: 1761
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Re: Soft Delete

Post by Holger » Tue Jul 07, 2009 8:17 am

I would like to uninstall this mod, I have put back all files, but how do I remove the mod from the DB?
The install.php is cryptic for me! :oops:

JBosman
Registered User
Posts: 117
Joined: Sun Apr 30, 2006 10:01 pm
Location: The Netherlands
Contact:

Re: Soft Delete

Post by JBosman » Wed Jul 08, 2009 9:30 pm

I have searched the topics but could not find a solution for the following problem.

I am a board founder as I am the one who installed the forum, however when I want to hard delete a post, after soft deleted it, in the MCP I am unable to do so because it tells me that I do not have persmissions to do so. Why is that?
With the love for all things and especialy this, figure it out!

Locked

Return to “[3.0.x] MOD Database Releases”