Vergleich inc/functions_forumlist.php - 1.6.0 - 1.6.17

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
<?php
/**
* MyBB 1.6

<?php
/**
* MyBB 1.6

 * Copyright � 2010 MyBB Group, All Rights Reserved

 * Copyright 2010 MyBB Group, All Rights Reserved

 *
* Website: http://mybb.com
* License: http://mybb.com/about/license
*

 *
* Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: functions_forumlist.php 4941 2010-05-15 18:17:38Z RyanGordon $

 * $Id$

 */

/**

 */

/**

Zeile 18Zeile 18
*/
function build_forumbits($pid=0, $depth=1)
{

*/
function build_forumbits($pid=0, $depth=1)
{

	global $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;


	$forum_listing = '';

// If no forums exist with this parent, do nothing

	$forum_listing = '';

// If no forums exist with this parent, do nothing

	if(!is_array($fcache[$pid]))

	if(empty($fcache[$pid]) || !is_array($fcache[$pid]))

	{
return;
}

	{
return;
}

 

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


// Foreach of the forums in this parent
foreach($fcache[$pid] as $parent)
{
foreach($parent as $forum)
{


// Foreach of the forums in this parent
foreach($fcache[$pid] as $parent)
{
foreach($parent as $forum)
{

			$forums = $subforums = $sub_forums = '';
$lastpost_data = '';
$counters = '';


			$subforums = $sub_forums = '';
$lastpost_data = array(
'lastpost' => 0
);

			$forum_viewers_text = '';
$forum_viewers_text_plain = '';


			$forum_viewers_text = '';
$forum_viewers_text_plain = '';


Zeile 47Zeile 56
			{
continue;
}

			{
continue;
}

			
$plugins->run_hooks_by_ref("build_forumbits_forum", $forum);


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


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


// Build the link to this forum
$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 = false;

			$hideinfo = $hidecounters = false;

			$hidelastpostinfo = false;
$showlockicon = 0;

			$hidelastpostinfo = false;
$showlockicon = 0;

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

if($permissions['canonlyviewownthreads'] == 1)

			if(isset($permissions['canviewthreads']) && $permissions['canviewthreads'] != 1)






			{

			{

				$hidelastpostinfo = true;






























































			    $hideinfo = true;
}

if(isset($permissions['canonlyviewownthreads']) && $permissions['canonlyviewownthreads'] == 1)
{
$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(!is_array($private_forums))
{
$private_forums = $fids = array();
foreach($fcache as $fcache_p)
{
foreach($fcache_p as $parent_p)
{
foreach($parent_p as $forum_p)
{
if($forumpermissions[$forum_p['fid']]['canonlyviewownthreads'])
{
$fids[] = $forum_p['fid'];
}
}
}
}

if(!empty($fids))
{
$fids = implode(',', $fids);
$query = $db->simple_select("threads", "tid, fid, subject, lastpost, lastposter, lastposteruid", "uid = '{$mybb->user['uid']}' AND fid IN ({$fids}) AND visible != '-2'", array("order_by" => "lastpost", "order_dir" => "desc"));

while($thread = $db->fetch_array($query))
{
if(!$private_forums[$thread['fid']])
{
$private_forums[$thread['fid']] = $thread;
}
}
}
}

if($private_forums[$forum['fid']]['lastpost'])
{
$forum['lastpost'] = $private_forums[$forum['fid']]['lastpost'];

$lastpost_data = array(
"lastpost" => $private_forums[$forum['fid']]['lastpost'],
"lastpostsubject" => $private_forums[$forum['fid']]['subject'],
"lastposter" => $private_forums[$forum['fid']]['lastposter'],
"lastposttid" => $private_forums[$forum['fid']]['tid'],
"lastposteruid" => $private_forums[$forum['fid']]['lastposteruid']
);
}
}
else
{
$lastpost_data = array(
"lastpost" => $forum['lastpost'],
"lastpostsubject" => $forum['lastpostsubject'],
"lastposter" => $forum['lastposter'],
"lastposttid" => $forum['lastposttid'],
"lastposteruid" => $forum['lastposteruid']
);

			}

if($forum['password'] != '' && $mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))

			}

if($forum['password'] != '' && $mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))

Zeile 72Zeile 137
			    $hideinfo = true;
$showlockicon = 1;
}

			    $hideinfo = true;
$showlockicon = 1;
}

			
$lastpost_data = array(
"lastpost" => $forum['lastpost'],
"lastpostsubject" => $forum['lastpostsubject'],
"lastposter" => $forum['lastposter'],
"lastposttid" => $forum['lastposttid'],
"lastposteruid" => $forum['lastposteruid']
);












			// Fetch subforums of this forum
if(isset($fcache[$forum['fid']]))
{

			// Fetch subforums of this forum
if(isset($fcache[$forum['fid']]))
{

Zeile 91Zeile 148
				$forum['posts'] += $forum_info['counters']['posts'];
$forum['unapprovedthreads'] += $forum_info['counters']['unapprovedthreads'];
$forum['unapprovedposts'] += $forum_info['counters']['unapprovedposts'];

				$forum['posts'] += $forum_info['counters']['posts'];
$forum['unapprovedthreads'] += $forum_info['counters']['unapprovedthreads'];
$forum['unapprovedposts'] += $forum_info['counters']['unapprovedposts'];

				$forum['viewers'] += $forum_info['counters']['viewing'];






if(!empty($forum_info['counters']['viewing']))
{
$forum['viewers'] += $forum_info['counters']['viewing'];
}


// If the child forums' lastpost is greater than the one for this forum, set it as the child forums greatest.
if($forum_info['lastpost']['lastpost'] > $lastpost_data['lastpost'])
{
$lastpost_data = $forum_info['lastpost'];


// If the child forums' lastpost is greater than the one for this forum, set it as the child forums greatest.
if($forum_info['lastpost']['lastpost'] > $lastpost_data['lastpost'])
{
$lastpost_data = $forum_info['lastpost'];

					



					/*
// If our subforum is unread, then so must be our parents. Force our parents to unread as well
if(strstr($forum_info['lightbulb']['folder'], "on") !== false)

					/*
// If our subforum is unread, then so must be our parents. Force our parents to unread as well
if(strstr($forum_info['lightbulb']['folder'], "on") !== false)

Zeile 115Zeile 176
			}

// If we are hiding information (lastpost) because we aren't authenticated against the password for this forum, remove them

			}

// If we are hiding information (lastpost) because we aren't authenticated against the password for this forum, remove them

			if($hideinfo == true || $hidelastpostinfo == true)

			if($hidelastpostinfo == true)

			{

			{

				unset($lastpost_data);



				$lastpost_data = array(
'lastpost' => 0
);

			}

			}

			



			// If the current forums lastpost is greater than other child forums of the current parent, overwrite it

			// If the current forums lastpost is greater than other child forums of the current parent, overwrite it

			if($lastpost_data['lastpost'] > $parent_lastpost['lastpost'])

			if(!isset($parent_lastpost) || $lastpost_data['lastpost'] > $parent_lastpost['lastpost'])

			{
$parent_lastpost = $lastpost_data;
}


			{
$parent_lastpost = $lastpost_data;
}


			if(is_array($forum_viewers) && $forum_viewers[$forum['fid']] > 0)

			if(is_array($forum_viewers) && isset($forum_viewers[$forum['fid']]) && $forum_viewers[$forum['fid']] > 0)

			{
$forum['viewers'] = $forum_viewers[$forum['fid']];
}

// Increment the counters for the parent forum (returned later)

			{
$forum['viewers'] = $forum_viewers[$forum['fid']];
}

// Increment the counters for the parent forum (returned later)

			if($hideinfo != true)

			if($hideinfo != true && $hidecounters != true)

			{
$parent_counters['threads'] += $forum['threads'];
$parent_counters['posts'] += $forum['posts'];
$parent_counters['unapprovedposts'] += $forum['unapprovedposts'];
$parent_counters['unapprovedthreads'] += $forum['unapprovedthreads'];

			{
$parent_counters['threads'] += $forum['threads'];
$parent_counters['posts'] += $forum['posts'];
$parent_counters['unapprovedposts'] += $forum['unapprovedposts'];
$parent_counters['unapprovedthreads'] += $forum['unapprovedthreads'];

				$parent_counters['viewers'] += $forum['viewers'];






if(!empty($forum['viewers']))
{
$parent_counters['viewers'] += $forum['viewers'];
}

			}

// Done with our math, lets talk about displaying - only display forums which are under a certain depth
if($depth > $showdepth)

			}

// Done with our math, lets talk about displaying - only display forums which are under a certain depth
if($depth > $showdepth)

			{

			{

				continue;
}

				continue;
}

			



			// Get the lightbulb status indicator for this forum based on the lastpost
$lightbulb = get_forum_lightbulb($forum, $lastpost_data, $showlockicon);

			// Get the lightbulb status indicator for this forum based on the lastpost
$lightbulb = get_forum_lightbulb($forum, $lastpost_data, $showlockicon);





			// Fetch the number of unapproved threads and posts for this forum
$unapproved = get_forum_unapproved($forum);

			// Fetch the number of unapproved threads and posts for this forum
$unapproved = get_forum_unapproved($forum);

			



			if($hideinfo == true)
{
unset($unapproved);

			if($hideinfo == true)
{
unset($unapproved);

Zeile 178Zeile 245

// Showing mini status icons for this forum
if($mybb->settings['subforumsstatusicons'] == 1)


// Showing mini status icons for this forum
if($mybb->settings['subforumsstatusicons'] == 1)

					{

					{

						$lightbulb['folder'] = "mini".$lightbulb['folder'];
eval("\$statusicon = \"".$templates->get("forumbit_depth3_statusicon", 1, 0)."\";");
}

						$lightbulb['folder'] = "mini".$lightbulb['folder'];
eval("\$statusicon = \"".$templates->get("forumbit_depth3_statusicon", 1, 0)."\";");
}

Zeile 235Zeile 302
					}
$lastpost_subject = htmlspecialchars_uni($lastpost_subject);
$full_lastpost_subject = htmlspecialchars_uni($full_lastpost_subject);

					}
$lastpost_subject = htmlspecialchars_uni($lastpost_subject);
$full_lastpost_subject = htmlspecialchars_uni($full_lastpost_subject);

					



					// Call lastpost template
if($depth != 1)

					// Call lastpost template
if($depth != 1)

					{						

					{

						eval("\$lastpost = \"".$templates->get("forumbit_depth{$depth}_forum_lastpost")."\";");

						eval("\$lastpost = \"".$templates->get("forumbit_depth{$depth}_forum_lastpost")."\";");

					}
}

					}
}


if($mybb->settings['showforumviewing'] != 0 && $forum['viewers'] > 0)
{
if($forum['viewers'] == 1)
{
$forum_viewers_text = $lang->viewing_one;


if($mybb->settings['showforumviewing'] != 0 && $forum['viewers'] > 0)
{
if($forum['viewers'] == 1)
{
$forum_viewers_text = $lang->viewing_one;

					}

					}

					else
{
$forum_viewers_text = $lang->sprintf($lang->viewing_multiple, $forum['viewers']);
}
$forum_viewers_text_plain = $forum_viewers_text;
$forum_viewers_text = "<span class=\"smalltext\">{$forum_viewers_text}</span>";

					else
{
$forum_viewers_text = $lang->sprintf($lang->viewing_multiple, $forum['viewers']);
}
$forum_viewers_text_plain = $forum_viewers_text;
$forum_viewers_text = "<span class=\"smalltext\">{$forum_viewers_text}</span>";

				}

				}

			}

			}

			// If this forum is a link or is password protected and the user isn't authenticated, set lastpost and counters to "-"
if($forum['linkto'] != '' || $hideinfo == true)

			// If this forum is a link or is password protected and the user isn't authenticated, set counters to "-"
if($forum['linkto'] != '' || $hideinfo == true || $hidecounters == true)

			{

			{

				$lastpost = "<div style=\"text-align: center;\">-</div>";

 
				$posts = "-";
$threads = "-";
}
// Otherwise, format thread and post counts

				$posts = "-";
$threads = "-";
}
// Otherwise, format thread and post counts

			else
{
// If we're only hiding the last post information
if($hidelastpostinfo == true)
{
$lastpost = "<div style=\"text-align: center;\">-</div>";
}


			else
{







				$posts = my_number_format($forum['posts']);
$threads = my_number_format($forum['threads']);

				$posts = my_number_format($forum['posts']);
$threads = my_number_format($forum['threads']);

 
			}

// If this forum is a link or is password protected and the user isn't authenticated, set lastpost to "-"
if($forum['linkto'] != '' || $hideinfo == true || $hidelastpostinfo == true)
{
$lastpost = "<div style=\"text-align: center;\">-</div>";

			}

// Moderator column is not off

			}

// Moderator column is not off

Zeile 391Zeile 457
	else
{
// Fetch the last read date for this forum

	else
{
// Fetch the last read date for this forum

		if($forum['lastread'])

		if(!empty($forum['lastread']))

		{
$forum_read = $forum['lastread'];
}

		{
$forum_read = $forum['lastread'];
}

		else // Is there not a read record for this forum? It must be unread






		elseif(!empty($mybb->cookies['mybb']['readallforums']))
{
// We've hit the read all forums as a guest, so use the lastvisit of the user
$forum_read = $mybb->cookies['mybb']['lastvisit'];
}
else

		{
$forum_read = 0;

		{
$forum_read = 0;

			//$forum_read = my_get_array_cookie("forumread", $forum['fid']);













			$threadcut = TIME_NOW - 60*60*24*$mybb->settings['threadreadcut'];

// If the user is a guest, do they have a forumsread cookie?
if(!$mybb->user['uid'] && $mybb->cookies['mybb']['forumread'])
{
// If they've visited us before, then they'll have this cookie - otherwise everything is unread...
$forum_read = my_get_array_cookie("forumread", $forum['fid']);
}
else if($mybb->user['uid'] && $mybb->settings['threadreadcut'] > 0 && $threadcut > $lastpost['lastpost'])
{
// We have a user, the forum's unread and we're over our threadreadcut limit for the lastpost - we mark these as read
$forum_read = $lastpost['lastpost'] + 1;
}

		}

		}





		//if(!$forum_read)
//{
//$forum_read = $mybb->user['lastvisit'];
//}

		//if(!$forum_read)
//{
//$forum_read = $mybb->user['lastvisit'];
//}

		
// If the lastpost is greater than the last visit and is greater than the forum read date, we have a new post
if($lastpost['lastpost'] > $forum_read && $lastpost['lastpost'] != 0)


// If the lastpost is greater than the last visit and is greater than the forum read date, we have a new post
if($lastpost['lastpost'] > $forum_read && $lastpost['lastpost'] != 0)

		{
$unread_forums++;
$folder = "on";

		{
$unread_forums++;
$folder = "on";