Vergleich inc/functions_rebuild.php - 1.2.7 - 1.2.8

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 37Zeile 37

// Fetch the number of threads and replies in this forum (Approved only)
$query = $db->query("


// Fetch the number of threads and replies in this forum (Approved only)
$query = $db->query("

		SELECT COUNT(*) AS threads, SUM(replies) AS replies

		SELECT COUNT(tid) AS threads, SUM(replies) AS replies

		FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%'
");

		FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%'
");

Zeile 46Zeile 46

// Fetch the number of threads and replies in this forum (Unapproved only)
$query = $db->query("


// Fetch the number of threads and replies in this forum (Unapproved only)
$query = $db->query("

		SELECT COUNT(*) AS threads

		SELECT COUNT(tid) AS threads, SUM(replies) AS impliedunapproved

		FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='0' AND closed NOT LIKE 'moved|%'
");

		FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='0' AND closed NOT LIKE 'moved|%'
");

	$count['unapprovedthreads'] = $db->fetch_field($query, "threads");



	$count2 = $db->fetch_array($query);
$count['unapprovedthreads'] = $count2['threads'];
$count['unapprovedposts'] = $count2['impliedunapproved'];


$query = $db->query("
SELECT SUM(unapprovedposts) AS posts
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND closed NOT LIKE 'moved|%'
");


$query = $db->query("
SELECT SUM(unapprovedposts) AS posts
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND closed NOT LIKE 'moved|%'
");

	$count['unapprovedposts'] = $db->fetch_field($query, "posts");

	$count['unapprovedposts'] += $db->fetch_field($query, "posts");


update_forum_counters($fid, $count);
}

/**
* Completely rebuild the counters for a particular thread (useful if they become out of sync)


update_forum_counters($fid, $count);
}

/**
* Completely rebuild the counters for a particular thread (useful if they become out of sync)

 
 *
* @param int The thread ID
* @param array Optional thread array so we don't have to query it

 */

 */

function rebuild_thread_counters($tid)

function rebuild_thread_counters($tid, $thread=array())

{
global $db;


{
global $db;


	$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(*) AS replies", "tid='{$tid}' AND visible='1'");
$count['replies'] = $db->fetch_field($query, "replies") -1;






	if(!$thread['tid'])
{
$thread = get_thread($tid);
}

$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(*) AS replies", "tid='{$tid}' AND pid!='{$thread['firstpost']}' AND visible='1'");
$count['replies'] = $db->fetch_field($query, "replies");

	if($count['replies'] < 0)
{
$count['replies'] = 0;
}

// Unapproved posts

	if($count['replies'] < 0)
{
$count['replies'] = 0;
}

// Unapproved posts

	$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(*) AS totunposts", "tid='{$tid}' AND visible='0'");

	$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(*) AS totunposts", "tid='{$tid}' AND pid!='{$thread['firstpost']}' AND visible='0'");

	$count['unapprovedposts'] = $db->fetch_field($query, "totunposts");

// Attachment count

	$count['unapprovedposts'] = $db->fetch_field($query, "totunposts");

// Attachment count