Vergleich inc/class_moderation.php - 1.8.0 - 1.8.1

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 238Zeile 238
			}
}


			}
}


		if($forum['usethreadcounts'] != 0)

		if($forum['usethreadcounts'] != 0 && substr($thread['closed'], 0, 6) != 'moved|')

		{
if(!isset($userposts[$thread['uid']]['num_threads']))
{

		{
if(!isset($userposts[$thread['uid']]['num_threads']))
{

Zeile 427Zeile 427
				}
}


				}
}


			if($forum['usethreadcounts'] != 0)

			if($forum['usethreadcounts'] != 0 && substr($thread['closed'], 0, 6) != 'moved|')

			{
++$user_counters[$thread['uid']]['num_threads'];
}

			{
++$user_counters[$thread['uid']]['num_threads'];
}

Zeile 483Zeile 483
					update_forum_lastpost($fid);
}
}

					update_forum_lastpost($fid);
}
}

			



			if(!empty($user_counters))
{
foreach($user_counters as $uid => $counters)

			if(!empty($user_counters))
{
foreach($user_counters as $uid => $counters)

Zeile 498Zeile 498
		}
return true;
}

		}
return true;
}





	/**
* Unapprove one or more threads
*

	/**
* Unapprove one or more threads
*

Zeile 512Zeile 512
		if(!is_array($tids))
{
$tids = array($tids);

		if(!is_array($tids))
{
$tids = array($tids);

		}

		}


if(empty($tids))
{


if(empty($tids))
{

Zeile 541Zeile 541
			if($thread['visible'] == 1 || $thread['visible'] == -1)
{
if(!isset($forum_counters[$forum['fid']]))

			if($thread['visible'] == 1 || $thread['visible'] == -1)
{
if(!isset($forum_counters[$forum['fid']]))

				{

				{

					$forum_counters[$forum['fid']] = array(
'num_threads' => 0,
'num_posts' => 0,

					$forum_counters[$forum['fid']] = array(
'num_threads' => 0,
'num_posts' => 0,

Zeile 586Zeile 586
					}
}


					}
}


				if($thread['visible'] == 1 && $forum['usethreadcounts'] != 0)

				if($thread['visible'] == 1 && $forum['usethreadcounts'] != 0 && substr($thread['closed'], 0, 6) != 'moved|')

				{
++$user_counters[$thread['uid']]['num_threads'];
}

				{
++$user_counters[$thread['uid']]['num_threads'];
}

Zeile 685Zeile 685
		if(!function_exists("remove_attachments"))
{
require MYBB_ROOT."inc/functions_upload.php";

		if(!function_exists("remove_attachments"))
{
require MYBB_ROOT."inc/functions_upload.php";

		}

		}


// Remove attachments
remove_attachments($pid);


// Remove attachments
remove_attachments($pid);





		// Delete the post
$db->delete_query("posts", "pid='$pid'");

		// Delete the post
$db->delete_query("posts", "pid='$pid'");





		// Remove any reports attached to this post
$db->delete_query("reportedcontent", "id='{$pid}' AND (type = 'post' OR type = '')");

// Update unapproved post count
if($post['visible'] == 0)

		// Remove any reports attached to this post
$db->delete_query("reportedcontent", "id='{$pid}' AND (type = 'post' OR type = '')");

// Update unapproved post count
if($post['visible'] == 0)

		{
$update_array = array(

		{
$update_array = array(

				"unapprovedposts" => "-1"
);
}

				"unapprovedposts" => "-1"
);
}

Zeile 713Zeile 713
		{
$update_array = array(
"replies" => "-1"

		{
$update_array = array(
"replies" => "-1"

			);

			);

		}

$plugins->run_hooks("class_moderation_delete_post", $post['pid']);

		}

$plugins->run_hooks("class_moderation_delete_post", $post['pid']);





		update_thread_counters($post['tid'], $update_array);
update_last_post($post['tid']);

// Update unapproved post count
if(($post['visible'] == 0 && $post['threadvisible'] != -1) || $post['threadvisible'] == 0)

		update_thread_counters($post['tid'], $update_array);
update_last_post($post['tid']);

// Update unapproved post count
if(($post['visible'] == 0 && $post['threadvisible'] != -1) || $post['threadvisible'] == 0)

		{

		{

			$update_array = array(
"unapprovedposts" => "-1"

			$update_array = array(
"unapprovedposts" => "-1"

			);
}
elseif($post['visible'] == -1 || $post['threadvisible'] == 0)
{
$update_array = array(

			);
}
elseif($post['visible'] == -1 || $post['threadvisible'] == -1)
{
$update_array = array(

				"deletedposts" => "-1"
);
}

				"deletedposts" => "-1"
);
}

Zeile 739Zeile 739
			$update_array = array(
"posts" => "-1"
);

			$update_array = array(
"posts" => "-1"
);

		}

		}


update_forum_counters($post['fid'], $update_array);
update_forum_lastpost($post['fid']);


update_forum_counters($post['fid'], $update_array);
update_forum_lastpost($post['fid']);

Zeile 813Zeile 813
				else
{
$message .= "[hr]{$post['message']}";

				else
{
$message .= "[hr]{$post['message']}";

				}

				}


if(!isset($forum_counters[$post['fid']]))


if(!isset($forum_counters[$post['fid']]))

				{

				{

					$forum_counters[$post['fid']] = array(
'num_posts' => 0,
'unapprovedposts' => 0,

					$forum_counters[$post['fid']] = array(
'num_posts' => 0,
'unapprovedposts' => 0,

Zeile 828Zeile 828
				{
--$thread_counters[$post['tid']]['replies'];
$forum = get_forum($post['fid']);

				{
--$thread_counters[$post['tid']]['replies'];
$forum = get_forum($post['fid']);

 
					if(!isset($user_counters[$post['uid']]))
{
$user_counters[$post['uid']] = array(
'num_posts' => 0,
'num_threads' => 0
);
}

					// Subtract 1 from user's post count
if($forum['usepostcounts'] != 0 && $post['threadvisible'] == 1)

					// Subtract 1 from user's post count
if($forum['usepostcounts'] != 0 && $post['threadvisible'] == 1)

					{
if(!isset($user_counters[$post['uid']]))
{
$user_counters[$post['uid']] = 0;
}

					{





						// Update post count of the user of the merged posts

						// Update post count of the user of the merged posts

						--$user_counters[$post['uid']];





						--$user_counters[$post['uid']]['num_posts'];
}
if($post['threadfirstpost'] == $post['pid'] && $forum['usethreadcounts'] != 0 && $post['threadvisible'] == 1)
{
--$user_counters[$post['uid']]['num_threads'];

					}
}
elseif($post['visible'] == 0)

					}
}
elseif($post['visible'] == 0)

Zeile 883Zeile 890
		$db->update_query("attachments", $mergepost2, "pid IN({$pidin})");

// If the first post of a thread is merged out, the first should be updated

		$db->update_query("attachments", $mergepost2, "pid IN({$pidin})");

// If the first post of a thread is merged out, the first should be updated

		$query = $db->simple_select("threads", "tid, fid, visible", "firstpost IN({$pidin}) AND firstpost != '{$masterpid}'");

		$query = $db->simple_select("threads", "tid, uid, fid, visible", "firstpost IN({$pidin}) AND firstpost != '{$masterpid}'");

		while($thread = $db->fetch_array($query))
{
// In some cases the first post of a thread changes
// Therefore resync the visible field to make sure they're the same if they're not

		while($thread = $db->fetch_array($query))
{
// In some cases the first post of a thread changes
// Therefore resync the visible field to make sure they're the same if they're not

			$query = $db->simple_select("posts", "pid, visible", "tid='{$thread['tid']}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));

			$query = $db->simple_select("posts", "pid, uid, visible", "tid='{$thread['tid']}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));

			$new_firstpost = $db->fetch_array($query);
if($thread['visible'] != $new_firstpost['visible'])
{

			$new_firstpost = $db->fetch_array($query);
if($thread['visible'] != $new_firstpost['visible'])
{

Zeile 918Zeile 925
				{
++$thread_counters[$thread['tid']]['unapprovedposts'];
}

				{
++$thread_counters[$thread['tid']]['unapprovedposts'];
}

 
			}

if($new_firstpost['uid'] != $thread['uid'] && $forum['usethreadcounts'] != 0 && $thread['visible'] == 1)
{
if(!isset($user_counters[$new_firstpost['uid']]))
{
$user_counters[$new_firstpost['uid']] = array(
'num_posts' => 0,
'num_threads' => 0
);
}
++$user_counters[$new_firstpost['uid']]['num_threads'];

			}
update_first_post($thread['tid']);
}

			}
update_first_post($thread['tid']);
}

Zeile 956Zeile 975

if(!empty($user_counters))
{


if(!empty($user_counters))
{

			foreach($user_counters as $uid => $counter)

			foreach($user_counters as $uid => $counters)

			{

			{

				update_user_counters($uid, array('postnum' => "{$counter}"));





				$update_array = array(
"postnum" => "+{$counters['num_posts']}",
"threadnum" => "+{$counters['num_threads']}"
);
update_user_counters($uid, $update_array);

			}
}


			}
}


Zeile 1266Zeile 1289

// Do post and thread count changes if changing between countable and non-countable forums
$query = $db->query("


// Do post and thread count changes if changing between countable and non-countable forums
$query = $db->query("

			SELECT COUNT(p.pid) AS posts, u.uid, p.visible

			SELECT COUNT(p.pid) AS posts, u.uid

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

			WHERE tid='$tid'
GROUP BY u.uid, p.visible

			WHERE p.tid='$tid' AND p.visible=1
GROUP BY u.uid

			ORDER BY posts DESC
");
while($posters = $db->fetch_array($query))
{
$pcount = 0;

			ORDER BY posts DESC
");
while($posters = $db->fetch_array($query))
{
$pcount = 0;

			if($forum['usepostcounts'] == 1 && $newforum['usepostcounts'] == 0 && $posters['visible'] == 1 && $thread['visible'] == 1)

			if($forum['usepostcounts'] == 1 && $method != 'copy' && $newforum['usepostcounts'] == 0 && $thread['visible'] == 1)

			{
$pcount -= $posters['posts'];
}

			{
$pcount -= $posters['posts'];
}

			if(($forum['usepostcounts'] == 0 || $method == 'copy') && $newforum['usepostcounts'] == 1 && $posters['visible'] == 1 && $thread['visible'] == 1)

			if(($forum['usepostcounts'] == 0 || $method == 'copy') && $newforum['usepostcounts'] == 1 && $thread['visible'] == 1)

			{
$pcount += $posters['posts'];
}

			{
$pcount += $posters['posts'];
}

Zeile 1295Zeile 1318
			}
}


			}
}


		if($forum['usethreadcounts'] == 1 && $newforum['usethreadcounts'] == 0 && $thread['visible'] == 1)

		if($forum['usethreadcounts'] == 1 && $method != 'copy' && $newforum['usethreadcounts'] == 0 && $thread['visible'] == 1)

		{
update_user_counters($thread['uid'], array('threadnum' => "-1"));
}

		{
update_user_counters($thread['uid'], array('threadnum' => "-1"));
}

Zeile 1372Zeile 1395
	 */
function merge_threads($mergetid, $tid, $subject)
{

	 */
function merge_threads($mergetid, $tid, $subject)
{

		global $db, $mybb, $mergethread, $thread, $plugins;

		global $db, $mybb, $mergethread, $thread, $plugins, $cache;


$mergetid = (int)$mergetid;
$tid = (int)$tid;


$mergetid = (int)$mergetid;
$tid = (int)$tid;

Zeile 1385Zeile 1408
		{
$thread = get_thread($tid);
}

		{
$thread = get_thread($tid);
}

		



		if(!$mergethread || !$thread)
{
return false;

		if(!$mergethread || !$thread)
{
return false;

		}



		}

$forum_cache = $cache->read('forums');


$threadarray = array();
if(!$thread['poll'] && $mergethread['poll'])


$threadarray = array();
if(!$thread['poll'] && $mergethread['poll'])

Zeile 1411Zeile 1436
		$threadarray['subject'] = $subject;

$user_posts = array();

		$threadarray['subject'] = $subject;

$user_posts = array();

		$query = $db->query("



		if($thread['visible'] != $mergethread['visible'] || $forum_cache[$thread['fid']]['usepostcounts'] != $forum_cache[$mergethread['fid']]['usepostcounts'])
{
$query = $db->query("

				SELECT uid, COUNT(pid) AS postnum
FROM ".TABLE_PREFIX."posts
WHERE tid='{$mergetid}' AND visible=1
GROUP BY uid

				SELECT uid, COUNT(pid) AS postnum
FROM ".TABLE_PREFIX."posts
WHERE tid='{$mergetid}' AND visible=1
GROUP BY uid

		");
while($post = $db->fetch_array($query))
{
$user_posts[$post['uid']]['postnum'] = $post['postnum'];










			");
while($post = $db->fetch_array($query))
{
// Update user counters
if($mergethread['visible'] == 1 && $forum_cache[$mergethread['fid']]['usepostcounts'] == 1)
{
$user_posts[$post['uid']]['postnum'] -= $post['postnum'];
}
elseif($thread['visible'] == 1 && $forum_cache[$thread['fid']]['usepostcounts'] == 1)
{
$user_posts[$post['uid']]['postnum'] += $post['postnum'];
}
}

		}

$sqlarray = array(
"tid" => $tid,
"fid" => $thread['fid'],
"replyto" => 0,

		}

$sqlarray = array(
"tid" => $tid,
"fid" => $thread['fid'],
"replyto" => 0,

		);

		);

		$db->update_query("posts", $sqlarray, "tid='{$mergetid}'");

$sqlarray = array(

		$db->update_query("posts", $sqlarray, "tid='{$mergetid}'");

$sqlarray = array(

Zeile 1464Zeile 1500
			$update_users = array();
foreach($subscriptions[$mergetid] as $user)
{

			$update_users = array();
foreach($subscriptions[$mergetid] as $user)
{

				if(!in_array($user, $subscriptions[$tid]))

				if(!isset($subscriptions[$tid]) || !in_array($user, $subscriptions[$tid]))

				{
// User doesn't have a $tid subscription
$update_users[] = $user;

				{
// User doesn't have a $tid subscription
$update_users[] = $user;

Zeile 1481Zeile 1517
				$db->update_query("threadsubscriptions", $update_array, "tid = '{$mergetid}' AND uid IN ({$update_users})");
}
}

				$db->update_query("threadsubscriptions", $update_array, "tid = '{$mergetid}' AND uid IN ({$update_users})");
}
}





		// Remove source thread subscriptions
$db->delete_query("threadsubscriptions", "tid = '{$mergetid}'");


		// Remove source thread subscriptions
$db->delete_query("threadsubscriptions", "tid = '{$mergetid}'");


Zeile 1494Zeile 1530
		if($mergethread['visible'] == 1)
{
++$mergethread['replies'];

		if($mergethread['visible'] == 1)
{
++$mergethread['replies'];

		}

		}

		elseif($mergethread['visible'] == -1)
{
++$mergethread['deletedposts'];

		elseif($mergethread['visible'] == -1)
{
++$mergethread['deletedposts'];

Zeile 1511Zeile 1547
		if($thread['visible'] != $new_firstpost['visible'])
{
$db->update_query("posts", array('visible' => $thread['visible']), "pid='{$new_firstpost['pid']}'");

		if($thread['visible'] != $new_firstpost['visible'])
{
$db->update_query("posts", array('visible' => $thread['visible']), "pid='{$new_firstpost['pid']}'");

			if($new_firstpost['visible'] == 1)
{

			if($new_firstpost['visible'] == 1 && $forum_cache[$thread['fid']]['usepostcounts'] == 1)
{

				--$user_posts[$post['uid']]['postnum'];

				--$user_posts[$post['uid']]['postnum'];

			}
elseif($thread['visible'] == 1)
{

			}
elseif($thread['visible'] == 1 && $forum_cache[$thread['fid']]['usepostcounts'] == 1)
{

				++$user_posts[$post['uid']]['postnum'];

				++$user_posts[$post['uid']]['postnum'];

			}
















			}
}
// Update first post if needed
if($new_firstpost['pid'] != $thread['firstpost'])
{
update_first_post($thread['tid']);
}

// Subtract merged thread from user counter
if($mergethread['visible'] == 1 && $forum_cache[$mergethread['fid']]['usethreadcounts'] == 1)
{
if(!isset($user_posts[$mergethread['uid']]['threadnum']))
{
$user_posts[$mergethread['uid']]['threadnum'] = 0;
}
--$user_posts[$mergethread['uid']]['threadnum'];

		}

// Update thread count if thread has a new firstpost and is visible

		}

// Update thread count if thread has a new firstpost and is visible

		++$user_posts[$mergethread['uid']]['threadnum'];
if($thread['uid'] != $new_firstpost['uid'] && $new_firstpost['visible'] == 1)

		if($thread['uid'] != $new_firstpost['uid'] && $thread['visible'] == 1 && $forum_cache[$thread['fid']]['usethreadcounts'] == 1)


		{

		{

 
			if(!isset($user_posts[$thread['uid']]['threadnum']))
{
$user_posts[$thread['uid']]['threadnum'] = 0;
}
--$user_posts[$thread['uid']]['threadnum'];
if(!isset($user_posts[$new_firstpost['uid']]['threadnum']))
{
$user_posts[$new_firstpost['uid']]['threadnum'] = 0;
}

			++$user_posts[$new_firstpost['uid']]['threadnum'];
}


			++$user_posts[$new_firstpost['uid']]['threadnum'];
}


Zeile 1553Zeile 1612
				);
}
update_forum_counters($thread['fid'], $updated_stats);

				);
}
update_forum_counters($thread['fid'], $updated_stats);

			update_forum_lastpost($thread['fid']);

 

// If old thread is unapproved, implied counter comes in to effect
if($mergethread['visible'] == 0)


// If old thread is unapproved, implied counter comes in to effect
if($mergethread['visible'] == 0)

Zeile 1649Zeile 1707
				update_forum_counters($mergethread['fid'], $new_stats);
update_forum_lastpost($mergethread['fid']);
}

				update_forum_counters($mergethread['fid'], $new_stats);
update_forum_lastpost($mergethread['fid']);
}

		}
// If we're in the same forum we need to at least update the last post information
else
{
update_forum_lastpost($thread['fid']);

 
		}

if($thread['visible'] != $new_firstpost['visible'])

		}

if($thread['visible'] != $new_firstpost['visible'])

Zeile 1664Zeile 1717
				--$mergethread['replies'];
}
elseif($new_firstpost['visible'] == -1)

				--$mergethread['replies'];
}
elseif($new_firstpost['visible'] == -1)

			{

			{

				--$mergethread['deletedposts'];
}

				--$mergethread['deletedposts'];
}

			else
{
--$mergethread['unapprovedposts'];
}
if($thread['visible'] == 1)

			else
{
--$mergethread['unapprovedposts'];
}
if($thread['visible'] == 1)

			{
++$mergethread['replies'];

			{
++$mergethread['replies'];

			}

			}

			elseif($thread['visible'] == -1)

			elseif($thread['visible'] == -1)

			{

			{

				++$mergethread['deletedposts'];

				++$mergethread['deletedposts'];

			}
else
{

			}
else
{

				++$mergethread['unapprovedposts'];
}
}


				++$mergethread['unapprovedposts'];
}
}


		if($thread['visible'] != $mergethread['visible'])
{
// Update user counters
if($thread['visible'] == 1)
{
foreach($user_posts as $uid => $user_counter)
{
update_user_counters($uid, array('postnum' => "+{$user_counter['postnum']}"));
}
}
elseif($mergethread['visible'] == 1)
{
foreach($user_posts as $uid => $user_counter)
{
update_user_counters($uid, array('postnum' => "-{$user_counter['postnum']}"));
}
}
}

if($mergethread['visible'] == 1)
{
foreach($user_posts as $uid => $user_counter)
{
update_user_counters($uid, array('threadnum' => "-{$user_counter['threadnum']}"));
}
}


		// Update user counters
foreach($user_posts as $uid => $counters)
{
$update_array = array(
"postnum" => "+{$counters['postnum']}",
"threadnum" => "+{$counters['threadnum']}",
);
update_user_counters($uid, $update_array);
}



















		$updated_stats = array(
"replies" => "+{$mergethread['replies']}",
"attachmentcount" => "+{$mergethread['attachmentcount']}",

		$updated_stats = array(
"replies" => "+{$mergethread['replies']}",
"attachmentcount" => "+{$mergethread['attachmentcount']}",

Zeile 1721Zeile 1757
		);
update_thread_counters($tid, $updated_stats);
update_last_post($tid);

		);
update_thread_counters($tid, $updated_stats);
update_last_post($tid);

 

// Forum last post has to be updated after thread
update_forum_lastpost($thread['fid']);

		return true;
}


		return true;
}


Zeile 1758Zeile 1797
		}

// Get the first split post

		}

// Get the first split post

		$post_info = get_post($pids[0]);




		$query = $db->simple_select('posts', 'pid,uid,visible,icon,username,dateline', 'pid IN ('.$pids_list.')', array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));

$post_info = $db->fetch_array($query);


		$visible = $post_info['visible'];

$forum_counters[$moveto] = array(

		$visible = $post_info['visible'];

$forum_counters[$moveto] = array(

Zeile 1782Zeile 1824
				"uid" => (int)$post_info['uid'],
"username" => $db->escape_string($post_info['username']),
"dateline" => (int)$post_info['dateline'],

				"uid" => (int)$post_info['uid'],
"username" => $db->escape_string($post_info['username']),
"dateline" => (int)$post_info['dateline'],

 
				"firstpost" => $post_info['pid'],

				"lastpost" => 0,
"lastposter" => '',
"visible" => (int)$visible,

				"lastpost" => 0,
"lastposter" => '',
"visible" => (int)$visible,

Zeile 1792Zeile 1835
			if($visible == 1)
{
++$forum_counters[$moveto]['threads'];

			if($visible == 1)
{
++$forum_counters[$moveto]['threads'];

 
				if(!isset($user_counters[$newthread['uid']]))
{
$user_counters[$newthread['uid']] = array(
'postnum' => 0,
'threadnum' => 0
);
}
// Subtract thread from old thread opener
--$user_counters[$newthread['uid']]['threadnum'];

			}
elseif($visible == -1)

			}
elseif($visible == -1)

			{

			{

				++$forum_counters[$moveto]['deletedthreads'];
}
else

				++$forum_counters[$moveto]['deletedthreads'];
}
else

Zeile 1815Zeile 1867

// Get selected posts before moving forums to keep old fid
$original_posts_query = $db->query("


// Get selected posts before moving forums to keep old fid
$original_posts_query = $db->query("

			SELECT p.pid, p.tid, p.fid, p.visible, p.uid, t.visible as threadvisible, t.firstpost, COUNT(a.aid) as postattachmentcount

			SELECT p.pid, p.tid, p.fid, p.visible, p.uid, p.dateline, t.visible as threadvisible, t.firstpost, COUNT(a.aid) as postattachmentcount

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid)
LEFT JOIN ".TABLE_PREFIX."attachments a ON (a.pid=p.pid AND a.visible=1)

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid)
LEFT JOIN ".TABLE_PREFIX."attachments a ON (a.pid=p.pid AND a.visible=1)

Zeile 1845Zeile 1897
			{
$thread_counters[$post['tid']] = array(
'replies' => 0,

			{
$thread_counters[$post['tid']] = array(
'replies' => 0,

					'unapprovedposts' => 0,

					'unapprovedposts' => 0,

					'deletedposts' => 0,
'attachmentcount' => 0

					'deletedposts' => 0,
'attachmentcount' => 0

				);
}

				);
}

			if(!isset($forum_counters[$post['fid']]))
{
$forum_counters[$post['fid']] = array(
'posts' => 0,
'unapprovedposts' => 0,
'deletedposts' => 0

			if(!isset($forum_counters[$post['fid']]))
{
$forum_counters[$post['fid']] = array(
'posts' => 0,
'unapprovedposts' => 0,
'deletedposts' => 0

 
				);
}
if(!isset($user_counters[$post['uid']]))
{
$user_counters[$post['uid']] = array(
'postnum' => 0,
'threadnum' => 0

				);
}
if($post['visible'] == 1)
{

				);
}
if($post['visible'] == 1)
{

				if(!isset($user_counters[$post['uid']]))
{
$user_counters[$post['uid']] = array(
'postnum' => 0,
'threadnum' => 0
);
}

 
				// Modify users' post counts
if($post['threadvisible'] == 1 && $forum_cache[$post['fid']]['usepostcounts'] == 1 && ($forum_cache[$moveto]['usepostcounts'] == 0 || $newthread['visible'] != 1))
{
// Moving into a forum that doesn't count post counts
--$user_counters[$post['uid']]['postnum'];
}

				// Modify users' post counts
if($post['threadvisible'] == 1 && $forum_cache[$post['fid']]['usepostcounts'] == 1 && ($forum_cache[$moveto]['usepostcounts'] == 0 || $newthread['visible'] != 1))
{
// Moving into a forum that doesn't count post counts
--$user_counters[$post['uid']]['postnum'];
}

				elseif($newthread['visible'] == 1 && ($forum_cache[$post['fid']]['usepostcounts'] == 0 || $post['threadvisible'] != 1) && $forum_cache[$moveto]['usepostcounts'] == 1)
{
// Moving into a forum that does count post counts
++$user_counters[$post['uid']]['postnum'];
}

// Modify users' thread counts
if($post_info['uid'] == $post['uid'] && $forum_cache[$moveto]['usethreadcounts'] == 1 && $newthread['visible'] == 1)
{
// Moving into a forum that does count thread counts
++$user_counters[$post['uid']]['threadnum'];
}
















				// Subtract 1 from the old thread's replies

				// Subtract 1 from the old thread's replies

				--$thread_counters[$post['tid']]['replies'];

// Add 1 to the new thread's replies
++$thread_counters[$newtid]['replies'];

}

				--$thread_counters[$post['tid']]['replies'];
}





			elseif($post['visible'] == 0)
{
// Unapproved post
// Subtract 1 from the old thread's unapproved posts
--$thread_counters[$post['tid']]['unapprovedposts'];

			elseif($post['visible'] == 0)
{
// Unapproved post
// Subtract 1 from the old thread's unapproved posts
--$thread_counters[$post['tid']]['unapprovedposts'];


// Add 1 to the new thread's unapproved posts
++$thread_counters[$newtid]['unapprovedposts'];
}

			}




			elseif($post['visible'] == -1)

			elseif($post['visible'] == -1)

			{

			{

				// Soft deleted post
// Subtract 1 from the old thread's deleted posts
--$thread_counters[$post['tid']]['deletedposts'];

				// Soft deleted post
// Subtract 1 from the old thread's deleted posts
--$thread_counters[$post['tid']]['deletedposts'];

 
			}





				// Add 1 to the new thread's deleted posts
++$thread_counters[$newtid]['deletedposts'];
}


 
			// Subtract 1 from the old forum's posts
if($post['threadvisible'] == 1 && $post['visible'] == 1)
{
--$forum_counters[$post['fid']]['posts'];
}

			// Subtract 1 from the old forum's posts
if($post['threadvisible'] == 1 && $post['visible'] == 1)
{
--$forum_counters[$post['fid']]['posts'];
}

			elseif($post['threadvisible'] == 0 || ($post['visible'] == 0 && $post['threadvisible'] == 1))
{
--$forum_counters[$post['fid']]['unapprovedposts'];
}
else
{

			elseif($post['threadvisible'] == 0 || ($post['visible'] == 0 && $post['threadvisible'] == 1))
{
--$forum_counters[$post['fid']]['unapprovedposts'];
}
else
{

				--$forum_counters[$post['fid']]['deletedposts'];

				--$forum_counters[$post['fid']]['deletedposts'];

			}

// Add 1 to the new forum's posts
if($newthread['visible'] == 1 && $post['visible'] == 1)
{
++$forum_counters[$moveto]['posts'];
}
elseif($newthread['visible'] == 0 || ($post['visible'] == 0 && $newthread['visible'] == 1))
{
++$forum_counters[$moveto]['unapprovedposts'];
}
else
{
++$forum_counters[$moveto]['deletedposts'];

 
			}

// Subtract attachment counts from old thread and add to new thread (which are counted regardless of post or attachment unapproval at time of coding)

			}

// Subtract attachment counts from old thread and add to new thread (which are counted regardless of post or attachment unapproval at time of coding)

Zeile 1945Zeile 1961
			$thread_counters[$newtid]['attachmentcount'] += $post['postattachmentcount'];

if($post['firstpost'] == $post['pid'])

			$thread_counters[$newtid]['attachmentcount'] += $post['postattachmentcount'];

if($post['firstpost'] == $post['pid'])

			{

			{

				// In some cases the first post of a thread changes
// Therefore resync the visible field to make sure they're the same if they're not

				// In some cases the first post of a thread changes
// Therefore resync the visible field to make sure they're the same if they're not

				$query = $db->simple_select("posts", "pid, visible", "tid='{$post['tid']}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));

				$query = $db->simple_select("posts", "pid, visible, uid", "tid='{$post['tid']}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));

				$new_firstpost = $db->fetch_array($query);

				$new_firstpost = $db->fetch_array($query);

 

if(!isset($user_counters[$new_firstpost['uid']]))
{
$user_counters[$new_firstpost['uid']] = array(
'postnum' => 0,
'threadnum' => 0
);
}

// Update post counters if visibility changes

				if($post['threadvisible'] != $new_firstpost['visible'])
{
$db->update_query("posts", array('visible' => $post['threadvisible']), "pid='{$new_firstpost['pid']}'");

				if($post['threadvisible'] != $new_firstpost['visible'])
{
$db->update_query("posts", array('visible' => $post['threadvisible']), "pid='{$new_firstpost['pid']}'");

					// Correct counters

					// Subtract new first post

					if($new_firstpost['visible'] == 1)
{
--$thread_counters[$post['tid']]['replies'];

					if($new_firstpost['visible'] == 1)
{
--$thread_counters[$post['tid']]['replies'];

					}





						if($post['threadvisible'] == 1 && $forum_cache[$post['fid']]['usepostcounts'] == 1)
{
--$user_counters[$new_firstpost['uid']]['postnum'];
}
}

					elseif($new_firstpost['visible'] == -1)
{
--$thread_counters[$post['tid']]['deletedposts'];

					elseif($new_firstpost['visible'] == -1)
{
--$thread_counters[$post['tid']]['deletedposts'];

Zeile 1966Zeile 1996
					{
--$thread_counters[$post['tid']]['unapprovedposts'];
}

					{
--$thread_counters[$post['tid']]['unapprovedposts'];
}

					if($post['threadvisible'] == 1)











					if($post['threadvisible'] == 0 || ($new_firstpost['visible'] == 0 && $post['threadvisible'] == 1))
{
--$forum_counters[$post['fid']]['unapprovedposts'];
}
else
{
--$forum_counters[$post['fid']]['deletedposts'];
}

// Add old first post
if($post['threadvisible'] == 1)

					{
++$thread_counters[$post['tid']]['replies'];

					{
++$thread_counters[$post['tid']]['replies'];

 
						++$forum_counters[$post['fid']]['posts'];
if($forum_cache[$post['fid']]['usepostcounts'] == 1)
{
++$user_counters[$new_firstpost['uid']]['postnum'];
}

					}
elseif($post['threadvisible'] == -1)
{
++$thread_counters[$post['tid']]['deletedposts'];

					}
elseif($post['threadvisible'] == -1)
{
++$thread_counters[$post['tid']]['deletedposts'];

					}


						++$forum_counters[$post['fid']]['deletedposts'];
}

					else

					else

					{

					{

						++$thread_counters[$post['tid']]['unapprovedposts'];

						++$thread_counters[$post['tid']]['unapprovedposts'];

 
						++$forum_counters[$post['fid']]['unapprovedposts'];

					}
}

					}
}

				update_first_post($post['tid']);
















































































// Update user thread counter if thread opener changes
if($post['threadvisible'] == 1 && $forum_cache[$post['fid']]['usethreadcounts'] == 1 && $post['uid'] != $new_firstpost['uid'])
{
// Subtract thread from old thread opener
--$user_counters[$post['uid']]['threadnum'];
// Add thread to new thread opener
++$user_counters[$new_firstpost['uid']]['threadnum'];
}
update_first_post($post['tid']);
}

// This is the new first post of an existing thread?
if($post['pid'] == $post_info['pid'] && $post['dateline'] < $newthread['dateline'])
{
// Update post counters if visibility changes
if($post['visible'] != $newthread['visible'])
{
$db->update_query("posts", array('visible' => $newthread['visible']), "pid='{$post['pid']}'");

// This is needed to update the forum counters correctly
$post['visible'] = $newthread['visible'];
}

// Update user thread counter if thread opener changes
if($newthread['visible'] == 1 && $forum_cache[$newthread['fid']]['usethreadcounts'] == 1 && $post['uid'] != $newthread['uid'])
{
// Add thread to new thread opener
++$user_counters[$post['uid']]['threadnum'];
if(!isset($user_counters[$newthread['uid']]))
{
$user_counters[$newthread['uid']] = array(
'postnum' => 0,
'threadnum' => 0
);
}
// Subtract thread from old thread opener
--$user_counters[$newthread['uid']]['threadnum'];
}
update_first_post($newtid);
}

if($post['visible'] == 1)
{
// Modify users' post counts
if($newthread['visible'] == 1 && ($forum_cache[$post['fid']]['usepostcounts'] == 0 || $post['threadvisible'] != 1) && $forum_cache[$moveto]['usepostcounts'] == 1)
{
// Moving into a forum that does count post counts
++$user_counters[$post['uid']]['postnum'];
}

// Add 1 to the new thread's replies
++$thread_counters[$newtid]['replies'];
}
elseif($post['visible'] == 0)
{
// Unapproved post
// Add 1 to the new thread's unapproved posts
++$thread_counters[$newtid]['unapprovedposts'];
}
elseif($post['visible'] == -1)
{
// Soft deleted post
// Add 1 to the new thread's deleted posts
++$thread_counters[$newtid]['deletedposts'];
}

// Add 1 to the new forum's posts
if($newthread['visible'] == 1 && $post['visible'] == 1)
{
++$forum_counters[$moveto]['posts'];
}
elseif($newthread['visible'] == 0 || ($post['visible'] == 0 && $newthread['visible'] == 1))
{
++$forum_counters[$moveto]['unapprovedposts'];
}
else
{
++$forum_counters[$moveto]['deletedposts'];

			}
}

			}
}

 


		if($destination_tid == 0 && $newthread['visible'] == 1)
{
// If splitting into a new thread, subtract one from the thread's reply count to compensate for the original post

		if($destination_tid == 0 && $newthread['visible'] == 1)
{
// If splitting into a new thread, subtract one from the thread's reply count to compensate for the original post

Zeile 2050Zeile 2176
						"replyto" => 0
);
$db->update_query("posts", $sqlarray, "pid='{$oldthread['pid']}'");

						"replyto" => 0
);
$db->update_query("posts", $sqlarray, "pid='{$oldthread['pid']}'");

				}


				}


				foreach($counters as $key => $counter)
{
if($counter >= 0)

				foreach($counters as $key => $counter)
{
if($counter >= 0)

Zeile 2103Zeile 2229
		$moveto = (int)$moveto;

$newforum = get_forum($moveto);

		$moveto = (int)$moveto;

$newforum = get_forum($moveto);

		



		if(empty($tids) || !$newforum)
{
return false;

		if(empty($tids) || !$newforum)
{
return false;

Zeile 2155Zeile 2281
				}

$query1 = $db->query("

				}

$query1 = $db->query("

					SELECT COUNT(p.pid) AS posts, p.visible, u.uid

					SELECT COUNT(p.pid) AS posts, u.uid

					FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

					FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

					WHERE p.tid = '{$thread['tid']}'
GROUP BY p.visible, u.uid

					WHERE p.tid = '{$thread['tid']}' AND p.visible=1
GROUP BY u.uid

					ORDER BY posts DESC
");
while($posters = $db->fetch_array($query1))

					ORDER BY posts DESC
");
while($posters = $db->fetch_array($query1))

Zeile 2169Zeile 2295
						$user_counters[$posters['uid']]['num_posts'] = 0;
}


						$user_counters[$posters['uid']]['num_posts'] = 0;
}


					if($newforum['usepostcounts'] != 0 && $forum['usepostcounts'] == 0 && $posters['visible'] == 1)

					if($newforum['usepostcounts'] != 0 && $forum['usepostcounts'] == 0)

					{
$user_counters[$posters['uid']]['num_posts'] += $posters['posts'];
}

					{
$user_counters[$posters['uid']]['num_posts'] += $posters['posts'];
}

					else if($newforum['usepostcounts'] == 0 && $forum['usepostcounts'] != 0 && $posters['visible'] == 1)

					else if($newforum['usepostcounts'] == 0 && $forum['usepostcounts'] != 0)

					{
$user_counters[$posters['uid']]['num_posts'] -= $posters['posts'];
}

					{
$user_counters[$posters['uid']]['num_posts'] -= $posters['posts'];
}

Zeile 2236Zeile 2362

$arguments = array("tids" => $tids, "moveto" => $moveto);
$plugins->run_hooks("class_moderation_move_threads", $arguments);


$arguments = array("tids" => $tids, "moveto" => $moveto);
$plugins->run_hooks("class_moderation_move_threads", $arguments);

		



		if(!empty($user_counters))

		if(!empty($user_counters))

		{

		{

			foreach($user_counters as $uid => $counters)
{
$update_array = array(

			foreach($user_counters as $uid => $counters)
{
$update_array = array(

Zeile 2252Zeile 2378
		if(is_array($forum_counters))
{
foreach($forum_counters as $fid => $counter)

		if(is_array($forum_counters))
{
foreach($forum_counters as $fid => $counter)

			{

			{

				$updated_count = array(
'posts' => "-{$counter['posts']}",
'threads' => "-{$counter['threads']}",

				$updated_count = array(
'posts' => "-{$counter['posts']}",
'threads' => "-{$counter['threads']}",

Zeile 2260Zeile 2386
					'unapprovedthreads' => "-{$counter['unapprovedthreads']}",
'deletedposts' => "-{$counter['deletedposts']}",
'deletedthreads' => "-{$counter['deletedthreads']}"

					'unapprovedthreads' => "-{$counter['unapprovedthreads']}",
'deletedposts' => "-{$counter['deletedposts']}",
'deletedthreads' => "-{$counter['deletedthreads']}"

					



				);
update_forum_counters($fid, $updated_count);
update_forum_lastpost($fid);

				);
update_forum_counters($fid, $updated_count);
update_forum_lastpost($fid);

Zeile 2298Zeile 2424
		$num_posts = 0;

if(empty($pids))

		$num_posts = 0;

if(empty($pids))

		{

		{

			return false;
}


			return false;
}


Zeile 2329Zeile 2455
		{
// This is the first post in the thread so we're approving the whole thread.
$threads_to_update[] = $post['tid'];

		{
// This is the first post in the thread so we're approving the whole thread.
$threads_to_update[] = $post['tid'];

		}

		}


if(!empty($threads_to_update))
{


if(!empty($threads_to_update))
{

Zeile 2359Zeile 2485

// If the thread of this post is unapproved then we've already taken into account this counter as implied.
// Updating it again would cause it to double count


// If the thread of this post is unapproved then we've already taken into account this counter as implied.
// Updating it again would cause it to double count

			if($post['threadvisible'] != 0)

			if($post['threadvisible'] == 1)

			{
if(!isset($forum_counters[$post['fid']]))
{

			{
if(!isset($forum_counters[$post['fid']]))
{

Zeile 3413Zeile 3539
				}
}


				}
}


			if($forum['usethreadcounts'] != 0)

			if($forum['usethreadcounts'] != 0 && substr($thread['closed'], 0, 6) != 'moved|')

			{
++$user_counters[$thread['uid']]['num_threads'];
}

			{
++$user_counters[$thread['uid']]['num_threads'];
}

Zeile 3576Zeile 3702
					}
}


					}
}


				if($thread['visible'] == 1 && $forum['usethreadcounts'] != 0)

				if($thread['visible'] == 1 && $forum['usethreadcounts'] != 0 && substr($thread['closed'], 0, 6) != 'moved|')

				{
++$user_counters[$thread['uid']]['num_threads'];
}

				{
++$user_counters[$thread['uid']]['num_threads'];
}