Vergleich inc/functions_indicators.php - 1.6.0 - 1.6.10

  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_indicators.php 4941 2010-05-15 18:17:38Z RyanGordon $

 * $Id$

 */

/**

 */

/**

Zeile 39Zeile 39
	// Default back to cookie marking
else
{

	// Default back to cookie marking
else
{

		my_set_array_cookie("threadread", $tid, TIME_NOW);

		my_set_array_cookie("threadread", $tid, TIME_NOW, -1);

	}

$unread_count = fetch_unread_count($fid);

	}

$unread_count = fetch_unread_count($fid);

Zeile 57Zeile 57
 */
function fetch_unread_count($fid)
{

 */
function fetch_unread_count($fid)
{

	global $db, $mybb;

	global $cache, $db, $mybb;





 
	$onlyview = $onlyview2 = '';
$permissions = forum_permissions($fid);

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

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

 

if(!empty($permissions['canonlyviewownthreads']))
{
$onlyview = " AND uid = '{$mybb->user['uid']}'";
$onlyview2 = " AND t.uid = '{$mybb->user['uid']}'";
}


if($mybb->user['uid'] == 0)
{
$comma = '';
$tids = '';


if($mybb->user['uid'] == 0)
{
$comma = '';
$tids = '';

		$threadsread = unserialize($mybb->cookies['mybb']['threadread']);
$forumsread = unserialize($mybb->cookies['mybb']['forumread']);
if(is_array($threadsread))


		$threadsread = my_unserialize($mybb->cookies['mybb']['threadread']);
$forumsread = my_unserialize($mybb->cookies['mybb']['forumread']);

if(!empty($threadsread))

		{
foreach($threadsread as $key => $value)
{

		{
foreach($threadsread as $key => $value)
{

Zeile 75Zeile 84
				$comma = ',';
}
}

				$comma = ',';
}
}

		



		if(!empty($tids))
{
$count = 0;

		if(!empty($tids))
{
$count = 0;

			
// We set a limit to 100 otherwise it'll become too processor intensive, especially if we have many threads.
$query = $db->query("
SELECT lastpost, tid, fid
FROM ".TABLE_PREFIX."threads
WHERE visible=1 AND closed NOT LIKE 'moved|%' AND fid IN ($fid) AND tid IN ($tids) AND lastpost > '{$cutoff}'
LIMIT 100
");


// We've read at least some threads, are they here?
$query = $db->simple_select("threads", "lastpost, tid, fid", "visible=1 AND closed NOT LIKE 'moved|%' AND fid IN ($fid) AND lastpost > '{$cutoff}'{$onlyview}", array("limit" => 100));






			while($thread = $db->fetch_array($query))
{
if($thread['lastpost'] > intval($threadsread[$thread['tid']]) && $thread['lastpost'] > intval($forumsread[$thread['fid']]))
{
++$count;

			while($thread = $db->fetch_array($query))
{
if($thread['lastpost'] > intval($threadsread[$thread['tid']]) && $thread['lastpost'] > intval($forumsread[$thread['fid']]))
{
++$count;

				}
}


				}
}


			return $count;
}

			return $count;
}

 

// Not read any threads?
return false;

	}
else
{

	}
else
{

Zeile 107Zeile 116
					FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."threadsread tr ON (tr.tid=t.tid AND tr.uid='{$mybb->user['uid']}')
LEFT JOIN ".TABLE_PREFIX."forumsread fr ON (fr.fid=t.fid AND fr.uid='{$mybb->user['uid']}')

					FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."threadsread tr ON (tr.tid=t.tid AND tr.uid='{$mybb->user['uid']}')
LEFT JOIN ".TABLE_PREFIX."forumsread fr ON (fr.fid=t.fid AND fr.uid='{$mybb->user['uid']}')

					WHERE t.visible=1 AND t.closed NOT LIKE 'moved|%' AND t.fid IN ($fid) AND t.lastpost > COALESCE(tr.dateline,$cutoff) AND t.lastpost > COALESCE(fr.dateline,$cutoff) AND t.lastpost>$cutoff

					WHERE t.visible=1 AND t.closed NOT LIKE 'moved|%' AND t.fid IN ($fid) AND t.lastpost > COALESCE(tr.dateline,$cutoff) AND t.lastpost > COALESCE(fr.dateline,$cutoff) AND t.lastpost>$cutoff{$onlyview2}

				");
break;
default:

				");
break;
default:

Zeile 116Zeile 125
					FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."threadsread tr ON (tr.tid=t.tid AND tr.uid='{$mybb->user['uid']}')
LEFT JOIN ".TABLE_PREFIX."forumsread fr ON (fr.fid=t.fid AND fr.uid='{$mybb->user['uid']}')

					FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."threadsread tr ON (tr.tid=t.tid AND tr.uid='{$mybb->user['uid']}')
LEFT JOIN ".TABLE_PREFIX."forumsread fr ON (fr.fid=t.fid AND fr.uid='{$mybb->user['uid']}')

					WHERE t.visible=1 AND t.closed NOT LIKE 'moved|%' AND t.fid IN ($fid) AND t.lastpost > IFNULL(tr.dateline,$cutoff) AND t.lastpost > IFNULL(fr.dateline,$cutoff) AND t.lastpost>$cutoff

					WHERE t.visible=1 AND t.closed NOT LIKE 'moved|%' AND t.fid IN ($fid) AND t.lastpost > IFNULL(tr.dateline,$cutoff) AND t.lastpost > IFNULL(fr.dateline,$cutoff) AND t.lastpost>$cutoff{$onlyview2}

				");
}
return $db->fetch_field($query, "unread_count");

				");
}
return $db->fetch_field($query, "unread_count");

Zeile 135Zeile 144
	// Can only do "true" tracking for registered users
if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'])
{

	// Can only do "true" tracking for registered users
if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'])
{

 
		// Experimental setting to mark parent forums as read
$forums_to_read = array();

if($mybb->settings['readparentforums'])
{
$ignored_forums = array();
$forums = array_reverse(explode(",", get_parent_list($fid)));

unset($forums[0]);
if(!empty($forums))
{
$ignored_forums[] = $fid;

foreach($forums as $forum)
{
$fids = array($forum);
$ignored_forums[] = $forum;

$children = explode(",", get_parent_list($forum));
foreach($children as $child)
{
if(in_array($child, $ignored_forums))
{
continue;
}

$fids[] = $child;
$ignored_forums[] = $child;
}

if(fetch_unread_count(implode(",", $fids)) == 0)
{
$forums_to_read[] = $forum;
}
}
}
}


		switch($db->type)
{
case "pgsql":
case "sqlite":
add_shutdown(array($db, "replace_query"), array("forumsread", array('fid' => $fid, 'uid' => $mybb->user['uid'], 'dateline' => TIME_NOW), array("fid", "uid")));

		switch($db->type)
{
case "pgsql":
case "sqlite":
add_shutdown(array($db, "replace_query"), array("forumsread", array('fid' => $fid, 'uid' => $mybb->user['uid'], 'dateline' => TIME_NOW), array("fid", "uid")));

 
				
if(!empty($forums_to_read))
{
foreach($forums_to_read as $forum)
{
add_shutdown(array($db, "replace_query"), array("forumsread", array('fid' => $forum, 'uid' => $mybb->user['uid'], 'dateline' => TIME_NOW), array('fid', 'uid')));
}
}

				break;
default:

				break;
default:

 
				$child_sql = '';
if(!empty($forums_to_read))
{
foreach($forums_to_read as $forum)
{
$child_sql .= ", ('{$forum}', '{$mybb->user['uid']}', '".TIME_NOW."')";
}
}


				$db->shutdown_query("
REPLACE INTO ".TABLE_PREFIX."forumsread (fid, uid, dateline)

				$db->shutdown_query("
REPLACE INTO ".TABLE_PREFIX."forumsread (fid, uid, dateline)

					VALUES('{$fid}', '{$mybb->user['uid']}', '".TIME_NOW."')

					VALUES('{$fid}', '{$mybb->user['uid']}', '".TIME_NOW."'){$child_sql}

				");
}
}
// Mark in a cookie
else
{

				");
}
}
// Mark in a cookie
else
{

		my_set_array_cookie("forumread", $fid, TIME_NOW);

		my_set_array_cookie("forumread", $fid, TIME_NOW, -1);

	}
}


	}
}


Zeile 246Zeile 310
	}
else
{

	}
else
{

 
		my_setcookie("mybb[readallforums]", 1);

		my_setcookie("mybb[lastvisit]", TIME_NOW);

		my_setcookie("mybb[lastvisit]", TIME_NOW);

 


		my_unsetcookie("mybb[threadread]");
my_unsetcookie("mybb[forumread]");
}

		my_unsetcookie("mybb[threadread]");
my_unsetcookie("mybb[forumread]");
}