Untitled diff

Created Diff never expires
79 removals
588 lines
138 additions
645 lines
<?php
<?php
/**
/**
* MyBB 1.8
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
* Copyright 2014 MyBB Group, All Rights Reserved
*
*
* Website: http://www.mybb.com
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
* License: http://www.mybb.com/about/license
*
*
*/
*/

/**
/**
* Build a list of forum bits.
* Build a list of forum bits.
*
*
* @param int $pid The parent forum to fetch the child forums for (0 assumes all)
* @param int The parent forum to fetch the child forums for (0 assumes all)
* @param int $depth The depth to return forums with.
* @param int The depth to return forums with.
* @return array Array of information regarding the child forums of this parent forum
* @return array Array of information regarding the child forums of this parent forum
*/
*/
function build_forumbits($pid=0, $depth=1)
function build_forumbits($pid=0, $depth=1)
{
{
global $db, $fcache, $moderatorcache, $forumpermissions, $theme, $mybb, $templates, $bgcolor, $collapsed, $lang, $showdepth, $plugins, $parser, $forum_viewers;
global $db, $fcache, $moderatorcache, $forumpermissions, $theme, $mybb, $templates, $bgcolor, $collapsed, $lang, $showdepth, $plugins, $parser, $forum_viewers;
static $private_forums;
static $private_forums;

$forum_listing = '';
$forum_listing = '';


// If no forums exist with this parent, do nothing
// If no forums exist with this parent, do nothing
if(empty($fcache[$pid]) || !is_array($fcache[$pid]))
if(empty($fcache[$pid]) || !is_array($fcache[$pid]))
{
{
return;
return;
}
}


$parent_counters['threads'] = 0;
$parent_counters['threads'] = 0;
$parent_counters['posts'] = 0;
$parent_counters['posts'] = 0;
$parent_counters['unapprovedposts'] = 0;
$parent_counters['unapprovedposts'] = 0;
$parent_counters['unapprovedthreads'] = 0;
$parent_counters['unapprovedthreads'] = 0;
$parent_counters['viewers'] = 0;
$parent_counters['viewers'] = 0;
$forum_list = $comma = '';
$forum_list = $comma = '';
$donecount = 0;
$donecount = 0;


// Foreach of the forums in this parent
// Foreach of the forums in this parent
foreach($fcache[$pid] as $parent)
foreach($fcache[$pid] as $parent)
{
{
foreach($parent as $forum)
foreach($parent as $forum)
{
{
$subforums = $sub_forums = '';
$subforums = $sub_forums = '';
$lastpost_data = array(
$lastpost_data = array(
'lastpost' => 0
'lastpost' => 0,
'lastposter' => ''
);
);
$forum_viewers_text = '';
$forum_viewers_text = '';
$forum_viewers_text_plain = '';
$forum_viewers_text_plain = '';

// LukasAMD Fix
$unread = false;
$subforums_exist = false;
$parent_unread = false;


// Get the permissions for this forum
// Get the permissions for this forum
$permissions = $forumpermissions[$forum['fid']];
$permissions = $forumpermissions[$forum['fid']];


// If this user doesnt have permission to view this forum and we're hiding private forums, skip this forum
// If this user doesnt have permission to view this forum and we're hiding private forums, skip this forum
if($permissions['canview'] != 1 && $mybb->settings['hideprivateforums'] == 1)
if($permissions['canview'] != 1 && $mybb->settings['hideprivateforums'] == 1)
{
{
continue;
continue;
}
}

$forum = $plugins->run_hooks("build_forumbits_forum", $forum);
$forum = $plugins->run_hooks("build_forumbits_forum", $forum);


// Build the link to this forum
// Build the link to this forum
$forum_url = get_forum_link($forum['fid']);
$forum_url = get_forum_link($forum['fid']);


// This forum has a password, and the user isn't authenticated with it - hide post information
// This forum has a password, and the user isn't authenticated with it - hide post information
$hideinfo = $hidecounters = false;
$hideinfo = $hidecounters = false;
$hidelastpostinfo = false;
$hidelastpostinfo = false;
$showlockicon = 0;
$showlockicon = 0;
if(isset($permissions['canviewthreads']) && $permissions['canviewthreads'] != 1)
if(isset($permissions['canviewthreads']) && $permissions['canviewthreads'] != 1)
{
{
$hideinfo = true;
$hideinfo = true;
}
}

if(isset($permissions['canonlyviewownthreads']) && $permissions['canonlyviewownthreads'] == 1)
if(isset($permissions['canonlyviewownthreads']) && $permissions['canonlyviewownthreads'] == 1)
{
{
$hidecounters = true;
$hidecounters = true;


// If we only see our own threads, find out if there's a new post in one of them so the lightbulb shows
// If we only see our own threads, find out if there's a new post in one of them so the lightbulb shows
if(!is_array($private_forums))
if(!is_array($private_forums))
{
{
$private_forums = $fids = array();
$private_forums = $fids = array();
foreach($fcache as $fcache_p)
foreach($fcache as $fcache_p)
{
{
foreach($fcache_p as $parent_p)
foreach($fcache_p as $parent_p)
{
{
foreach($parent_p as $forum_p)
foreach($parent_p as $forum_p)
{
{
if($forumpermissions[$forum_p['fid']]['canonlyviewownthreads'])
if($forumpermissions[$forum_p['fid']]['canonlyviewownthreads'])
{
{
$fids[] = $forum_p['fid'];
$fids[] = $forum_p['fid'];
}
}
}
}