MyBB Community Forums

Full Version: [Plugin] Show threads without posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there any plugin to show me threads without posts[replies]??

Greetings
... and where you want the result to be shown?
It can be as search results.
In that case you don't need a plugin for this. Just open your search.php in a text editor and find the following code line near about line no. 1217

elseif($mybb->input['action'] == "getnew")

Add the following code chunk just BEFORE that line:

elseif($mybb->input['action'] == "noreply")
{
	
	$where_sql = "t.replies <= 0";
	
	$unsearchforums = get_unsearchable_forums();
	if($unsearchforums)
	{
		$where_sql .= " AND t.fid NOT IN ($unsearchforums)";
	}
	$inactiveforums = get_inactive_forums();
	if($inactiveforums)
	{
		$where_sql .= " AND t.fid NOT IN ($inactiveforums)";
	}
	
	$permsql = "";
	$onlyusfids = array();

	// Check group permissions if we can't view threads not started by us
	$group_permissions = forum_permissions();
	foreach($group_permissions as $fid => $forum_permissions)
	{
		if($forum_permissions['canonlyviewownthreads'] == 1)
		{
			$onlyusfids[] = $fid;
		}
	}
	if(!empty($onlyusfids))
	{
		$where_sql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
	}

	$sid = md5(uniqid(microtime(), 1));
	$searcharray = array(
		"sid" => $db->escape_string($sid),
		"uid" => $mybb->user['uid'],
		"dateline" => TIME_NOW,
		"ipaddress" => $db->escape_string($session->ipaddress),
		"threads" => '',
		"posts" => '',
		"resulttype" => "threads",
		"querycache" => $db->escape_string($where_sql),
		"keywords" => ''
	);

	$plugins->run_hooks("search_do_search_process");
	$db->insert_query("searchlog", $searcharray);
	redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);
}

Now, create a link in your template wherever you want like the following:
<a href="search.php?action=noreply">Threads Not Replied</a>

It will show you the threads without any reply as a search result.