MyBB Community Forums

Full Version: A little PHP help?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(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
What are you trying to do and what problems do you get? Do you get an error?
I'm trying to get it so guests can see the threads in a section BUT when that user goes to click on a thread, it asks him to login. Labrocca said to edit those if statements, I got the first one, but I don't know what to edit on the others Sad