MyBB Community Forums

Full Version: A mod that disallows guests to view threads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
One that doesn't mess up admin powers >.< It messed me up a lot when I used it!
Any particular reason not to simply go to the ACP -> Forums & Posts -> Forum Management -> EACH FORUM -> Permissions -> Guests -> Set permissions -> Untick "Can view threads within forum?"
ACP -> Users & Groups -> Groups -> Guests -> Forums and Posts -> untick it there? Or are there some forums you want to allow guest viewing maybe?
(2010-04-08, 07:58 PM)ladyunicornejg Wrote: [ -> ]Any particular reason not to simply go to the ACP -> Forums & Posts -> Forum Management -> EACH FORUM -> Permissions -> Guests -> Set permissions -> Untick "Can view threads within forum?"

I have tried that. That shows -- for topics/posts in forum, that will make the guest think they are no topics/posts and a useless forum.

I want one that will show the topics/posts in a forum BUT when the user goes to click on a thread, it asks him to login to view it.
I see. Maybe someone will make it then.
You have to make core file edits for that. That is what I did at HF.

Here is my short-hand instructions if you can figure it out.

###### For the canviewthreads permissions to change
inc/functions_forumlist.php 

			if($permissions['canviewthreads'] != 1)
			{
			    $hideinfo = true;
			}
			
to

			if($permissions['canviewthreads'] != 1)
			{
			    $hideinfo = false;
			}			
			

in forumdisplay.php 
 find $fpermissions['canviewthreads']
 alter the appropriate if statements
(2010-04-09, 02:22 AM)labrocca Wrote: [ -> ]You have to make core file edits for that. That is what I did at HF.

Here is my short-hand instructions if you can figure it out.

###### For the canviewthreads permissions to change
inc/functions_forumlist.php 

			if($permissions['canviewthreads'] != 1)
			{
			    $hideinfo = true;
			}
			
to

			if($permissions['canviewthreads'] != 1)
			{
			    $hideinfo = false;
			}			
			

in forumdisplay.php 
 find $fpermissions['canviewthreads']
 alter the appropriate if statements

Thanks and I got the 1st one down corrected. Though, the 2nd one I find these 3 if statements when I search for that:
if($fpermissions['canviewthreads'] != 0)
{
	// How many posts are there?
	if($datecut > 0)
	{
		$query = $db->simple_select("threads", "COUNT(tid) AS threads", "fid = '$fid' $visibleonly $datecutsql");
		$threadcount = $db->fetch_field($query, "threads");
	}
	else
	{
		$query = $db->simple_select("forums", "threads, unapprovedthreads", "fid = '{$fid}'", array('limit' => 1));
		$forum_threads = $db->fetch_array($query);
		$threadcount = $forum_threads['threads'];
		if($ismod == true)
		{
			$threadcount += $forum_threads['unapprovedthreads'];
		}
		
		// If we have 0 threads double check there aren't any "moved" threads
		if($threadcount == 0)
		{
			$query = $db->simple_select("threads", "COUNT(tid) AS threads", "fid = '$fid' $visibleonly", array('limit' => 1));
			$threadcount = $db->fetch_field($query, "threads");
		}
	}
}

if($foruminfo['allowtratings'] != 0 && $fpermissions['canviewthreads'] != 0)
{
	$lang->load("ratethread");
	switch($db->type)
	{
		case "pgsql":
			$ratingadd = "CASE WHEN t.numratings=0 THEN 0 ELSE t.totalratings/t.numratings::numeric END AS averagerating, ";
			break;
		default:
			$ratingadd = "(t.totalratings/t.numratings) AS averagerating, ";
	}
	$lpbackground = "trow2";
	eval("\$ratingcol = \"".$templates->get("forumdisplay_threadlist_rating")."\";");
	eval("\$ratingsort = \"".$templates->get("forumdisplay_threadlist_sortrating")."\";");
	$colspan = "7";
	$select_voting = "\nLEFT JOIN ".TABLE_PREFIX."threadratings r ON(r.tid=t.tid AND r.uid='{$mybb->user['uid']}')";
	$select_rating_user = "r.uid AS rated, ";
}
else
{
	if($sortfield == "averagerating")
	{
		$t = "t.";
		$sortfield = "lastpost";
	}
	$ratingadd = '';
	$lpbackground = "trow1";
	$colspan = "6";
}

if($fpermissions['canviewthreads'] != 0)
{
	// Start Getting Threads
	$query = $db->query("
		SELECT t.*, {$ratingadd}{$select_rating_user}t.username AS threadusername, u.username
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid){$select_voting}
		WHERE t.fid='$fid' $tvisibleonly $datecutsql2
		ORDER BY t.sticky DESC, {$t}{$sortfield} $sortordernow $sortfield2
		LIMIT $start, $perpage
	");
	while($thread = $db->fetch_array($query))
	{
		$threadcache[$thread['tid']] = $thread;

		// If this is a moved thread - set the tid for participation marking and thread read marking to that of the moved thread
		if(substr($thread['closed'], 0, 5) == "moved")
		{
			$tid = substr($thread['closed'], 6);
			if(!$tids[$tid])
			{
				$moved_threads[$tid] = $thread['tid'];
				$tids[$thread['tid']] = $tid;
			}
		}
		// Otherwise - set it to the plain thread ID
		else
		{
			$tids[$thread['tid']] = $thread['tid'];
			if($moved_threads[$tid])
			{
				unset($moved_threads[$tid]);
			}
		}
	}
}
else
{
	$tids = $threadcache = null;
}


I'm not an advanced PHP programmer so I'm not sure how to change those Undecided
For me this is also interesting, in a earlier post I wrote this

For me guest may know how many threads and how many posts there are in a (sub) forum.

I tried several things.

1. forum permission for guest view no, subforum permission for guest view no
Now guests cannot see even the name of the forum

2. forum permission for guest view no, subforum permission for guest view yes
Now guests can see the name of the forum but not how many posts and threads there are

3. forum permission for guest view yes, subforum permission for guest view no
Now guests can see the name of the forum but not how many posts and threads there are

I think when a guest see the name of the forum but not how many posts there made in it they think it is empty.
I think it is better that they can see how many posts and threads there are and they get the message by clicking on it they get the message you must be a registered member to view this forum, they get interested to sign in. For example a forum with photos is then interested for guests to become a member.


So I tried to use your modification but what do you mean with:
alter the appropriate if statements
Theres a mod for this.
Dunlop... Why don't you link the mod, instead of saying "Theres a mod for this."? Posting like an idiot for more post count makes you superior?
I found something else where you can do the samething with as I want.

minimum post to enter a forum: http://www.mybbaddons.com/board/thread-1215.html

When you put this on 1 or perhaps 0 a guest can see how many threads and post there are in a forum, but they cannot enter it.
Pages: 1 2 3