Vergleich inc/class_moderation.php - 1.8.0 - 1.8.5

  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 508Zeile 508
	function unapprove_threads($tids)
{
global $db, $cache, $plugins;

	function unapprove_threads($tids)
{
global $db, $cache, $plugins;





		if(!is_array($tids))

		if(!is_array($tids))

		{

		{

			$tids = array($tids);

			$tids = array($tids);

		}

if(empty($tids))
{
return false;
}


		}

if(empty($tids))
{
return false;
}


		// Make sure we only have valid values
$tids = array_map('intval', $tids);


		// Make sure we only have valid values
$tids = array_map('intval', $tids);


Zeile 532Zeile 532
		}

$forum_counters = $user_counters = $posts_to_unapprove = array();

		}

$forum_counters = $user_counters = $posts_to_unapprove = array();





		foreach($tids as $tid)
{
$thread = get_thread($tid);

		foreach($tids as $tid)
{
$thread = get_thread($tid);

Zeile 553Zeile 553
				}

if(!isset($user_counters[$thread['uid']]))

				}

if(!isset($user_counters[$thread['uid']]))

				{

				{

					$user_counters[$thread['uid']] = array(
'num_posts' => 0,
'num_threads' => 0

					$user_counters[$thread['uid']] = array(
'num_posts' => 0,
'num_threads' => 0

Zeile 570Zeile 570
					$forum_counters[$forum['fid']]['num_deletedposts'] += $thread['deletedposts'];
}
else

					$forum_counters[$forum['fid']]['num_deletedposts'] += $thread['deletedposts'];
}
else

				{

				{

					++$forum_counters[$forum['fid']]['num_deletedthreads'];
$forum_counters[$forum['fid']]['num_deletedposts'] += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1; // Add implied invisible to count
$forum_counters[$forum['fid']]['num_unapprovedposts'] += $thread['unapprovedposts'];

					++$forum_counters[$forum['fid']]['num_deletedthreads'];
$forum_counters[$forum['fid']]['num_deletedposts'] += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1; // Add implied invisible to count
$forum_counters[$forum['fid']]['num_unapprovedposts'] += $thread['unapprovedposts'];

				}


				}


				// On unapproving thread update user post counts
if($thread['visible'] == 1 && $forum['usepostcounts'] != 0)
{

				// On unapproving thread update user post counts
if($thread['visible'] == 1 && $forum['usepostcounts'] != 0)
{

Zeile 584Zeile 584
					{
$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}

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

				}

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'];
}





			}
$posts_to_unapprove[] = $thread['firstpost'];
}

			}
$posts_to_unapprove[] = $thread['firstpost'];
}

Zeile 695Zeile 695

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


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


// Update unapproved post count


// Update unapproved post count

		if($post['visible'] == 0)
{
$update_array = array(

		if($post['visible'] == 0)
{
$update_array = array(

				"unapprovedposts" => "-1"
);
}
elseif($post['visible'] == -1)
{
$update_array = array(
"deletedposts" => "-1"
);
}
else
{
$update_array = array(
"replies" => "-1"

				"unapprovedposts" => "-1"
);
}
elseif($post['visible'] == -1)
{
$update_array = array(
"deletedposts" => "-1"
);
}
else
{
$update_array = array(
"replies" => "-1"

			);
}


			);
}


Zeile 723Zeile 723

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


// 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)

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

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

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

			);

			);

		}
else
{

		}
else
{

Zeile 746Zeile 746

return true;
}


return true;
}





	/**
* Merge posts within thread
*

	/**
* Merge posts within thread
*

Zeile 768Zeile 768
		}

$pidin = implode(',', $pids);

		}

$pidin = implode(',', $pids);

		$attachment_count = 0;


		$attachment_count = 0;


		$first = 1;
// Get the messages to be merged
$query = $db->query("

		$first = 1;
// Get the messages to be merged
$query = $db->query("

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)
{
// Subtract 1 unapproved post from post's thread
--$thread_counters[$post['tid']]['unapprovedposts'];

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

				}

				}

				elseif($post['visible'] == -1)
{
// Subtract 1 deleted post from post's thread

				elseif($post['visible'] == -1)
{
// Subtract 1 deleted post from post's thread

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 931Zeile 950
			{
$counters = array(
'replies' => signed($counters['replies']),

			{
$counters = array(
'replies' => signed($counters['replies']),

					'unapprovedposts' => signed($counters['unapprovedposts']),

					'unapprovedposts' => signed($counters['unapprovedposts']),

					'deletedposts' => signed($counters['deletedposts']),
'attachmentcount' => signed($counters['attachmentcount'])
);

					'deletedposts' => signed($counters['deletedposts']),
'attachmentcount' => signed($counters['attachmentcount'])
);

Zeile 951Zeile 970
				);
update_forum_counters($fid, $updated_forum_stats);
update_forum_lastpost($fid);

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

			}
}

			}
}


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);

			}
}

			}
}





		return $masterpid;
}


		return $masterpid;
}


Zeile 987Zeile 1010

$newforum = get_forum($new_fid);
if(!$thread || !$newforum)


$newforum = get_forum($new_fid);
if(!$thread || !$newforum)

		{

		{

			return false;
}
$fid = $thread['fid'];
$forum = get_forum($fid);

			return false;
}
$fid = $thread['fid'];
$forum = get_forum($fid);





		$num_threads = $num_unapproved_threads = $num_posts = $num_unapproved_posts = $num_deleted_posts = $num_deleted_threads = 0;

if($thread['visible'] == 1)

		$num_threads = $num_unapproved_threads = $num_posts = $num_unapproved_posts = $num_deleted_posts = $num_deleted_threads = 0;

if($thread['visible'] == 1)

		{

		{

			$num_threads++;
$num_posts = $thread['replies']+1;
$num_unapproved_posts = $thread['unapprovedposts'];
$num_deleted_posts = $thread['deletedposts'];

			$num_threads++;
$num_posts = $thread['replies']+1;
$num_unapproved_posts = $thread['unapprovedposts'];
$num_deleted_posts = $thread['deletedposts'];

		}

		}

		elseif($thread['visible'] == -1)
{
$num_deleted_threads++;

		elseif($thread['visible'] == -1)
{
$num_deleted_threads++;

Zeile 1014Zeile 1037
			// Implied forum unapproved count for unapproved threads
$num_unapproved_posts = $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1;
}

			// Implied forum unapproved count for unapproved threads
$num_unapproved_posts = $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1;
}





		switch($method)
{
case "redirect": // move (and leave redirect) thread

		switch($method)
{
case "redirect": // move (and leave redirect) thread

Zeile 1023Zeile 1046

$query = $db->simple_select('threads', 'tid', "closed='moved|$tid' AND fid='$new_fid'");
while($redirect_tid = $db->fetch_field($query, 'tid'))


$query = $db->simple_select('threads', 'tid', "closed='moved|$tid' AND fid='$new_fid'");
while($redirect_tid = $db->fetch_field($query, 'tid'))

				{

				{

					$this->delete_thread($redirect_tid);
}
$changefid = array(

					$this->delete_thread($redirect_tid);
}
$changefid = array(

Zeile 1055Zeile 1078

$threadarray = array(
"fid" => $thread['fid'],


$threadarray = array(
"fid" => $thread['fid'],

					"subject" => $db->escape_string($thread['subject']),
"icon" => $thread['icon'],
"uid" => $thread['uid'],
"username" => $db->escape_string($thread['username']),

					"subject" => $db->escape_string($thread['subject']),
"icon" => $thread['icon'],
"uid" => $thread['uid'],
"username" => $db->escape_string($thread['username']),

					"dateline" => $thread['dateline'],
"lastpost" => $thread['lastpost'],
"lastposteruid" => $thread['lastposteruid'],

					"dateline" => $thread['dateline'],
"lastpost" => $thread['lastpost'],
"lastposteruid" => $thread['lastposteruid'],

Zeile 1126Zeile 1149
					if($db->fetch_field($query, "num_prefixes") == 0)
{
$threadarray['prefix'] = 0;

					if($db->fetch_field($query, "num_prefixes") == 0)
{
$threadarray['prefix'] = 0;

					}
}

$newtid = $db->insert_query("threads", $threadarray);

					}
}

$newtid = $db->insert_query("threads", $threadarray);


if($thread['poll'] != 0)
{


if($thread['poll'] != 0)
{

Zeile 1164Zeile 1187
					}

$db->update_query("threads", array('poll' => $new_pid), "tid='{$newtid}'");

					}

$db->update_query("threads", array('poll' => $new_pid), "tid='{$newtid}'");

				}


				}


				$query = $db->simple_select("posts", "*", "tid = '{$thread['tid']}'");
while($post = $db->fetch_array($query))
{

				$query = $db->simple_select("posts", "*", "tid = '{$thread['tid']}'");
while($post = $db->fetch_array($query))
{

Zeile 1236Zeile 1259

// If the thread has a prefix and the destination forum doesn't accept that prefix, remove the prefix
if($thread['prefix'] != 0)


// If the thread has a prefix and the destination forum doesn't accept that prefix, remove the prefix
if($thread['prefix'] != 0)

				{

				{

					switch($db->type)
{
case "pgsql":

					switch($db->type)
{
case "pgsql":

Zeile 1245Zeile 1268
							break;
default:
$query = $db->simple_select("threadprefixes", "COUNT(*) as num_prefixes", "(CONCAT(',',forums,',') LIKE '%,$new_fid,%' OR forums='-1') AND pid='".$thread['prefix']."'");

							break;
default:
$query = $db->simple_select("threadprefixes", "COUNT(*) as num_prefixes", "(CONCAT(',',forums,',') LIKE '%,$new_fid,%' OR forums='-1') AND pid='".$thread['prefix']."'");

					}

					}

					if($db->fetch_field($query, "num_prefixes") == 0)
{
$sqlarray = array(

					if($db->fetch_field($query, "num_prefixes") == 0)
{
$sqlarray = array(

Zeile 1253Zeile 1276
						);
$db->update_query("threads", $sqlarray, "tid='$tid'");
}

						);
$db->update_query("threads", $sqlarray, "tid='$tid'");
}

				}


				}


				// If we're moving back to a forum where we left a redirect, delete the rediect
$query = $db->simple_select("threads", "tid", "closed LIKE 'moved|".(int)$tid."' AND fid='".(int)$new_fid."'");
while($redirect_tid = $db->fetch_field($query, 'tid'))

				// If we're moving back to a forum where we left a redirect, delete the rediect
$query = $db->simple_select("threads", "tid", "closed LIKE 'moved|".(int)$tid."' AND fid='".(int)$new_fid."'");
while($redirect_tid = $db->fetch_field($query, 'tid'))

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))

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

		{

		{

			$pcount = 0;

			$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 1347Zeile 1370
			);
update_forum_counters($fid, $update_array);
update_forum_lastpost($fid);

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

		}


		}


		if(isset($newtid))
{
return $newtid;

		if(isset($newtid))
{
return $newtid;

Zeile 1357Zeile 1380
		{
// Remove thread subscriptions for the users who no longer have permission to view the thread
$this->remove_thread_subscriptions($tid, false, $new_fid);

		{
// Remove thread subscriptions for the users who no longer have permission to view the thread
$this->remove_thread_subscriptions($tid, false, $new_fid);





			return $tid;
}
}

			return $tid;
}
}

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;





		if(!isset($mergethread['tid']) || $mergethread['tid'] != $mergetid)
{
$mergethread = get_thread($mergetid);

		if(!isset($mergethread['tid']) || $mergethread['tid'] != $mergetid)
{
$mergethread = get_thread($mergetid);

		}

		}

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

		if(!isset($thread['tid']) || $thread['tid'] != $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 1399Zeile 1424
				"tid" => $tid,
);
$db->update_query("polls", $sqlarray, "tid='".(int)$mergethread['tid']."'");

				"tid" => $tid,
);
$db->update_query("polls", $sqlarray, "tid='".(int)$mergethread['tid']."'");

		}

		}

		// Both the old and the new thread have polls? Remove one
elseif($mergethread['poll'])

		// Both the old and the new thread have polls? Remove one
elseif($mergethread['poll'])

		{

		{

			$db->delete_query("polls", "pid='{$mergethread['poll']}'");
$db->delete_query("pollvotes", "pid='{$mergethread['poll']}'");

			$db->delete_query("polls", "pid='{$mergethread['poll']}'");
$db->delete_query("pollvotes", "pid='{$mergethread['poll']}'");

		}


		}


		$subject = $db->escape_string($subject);
$threadarray['subject'] = $subject;

		$subject = $db->escape_string($subject);
$threadarray['subject'] = $subject;





		$user_posts = array();

		$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'];
}

$sqlarray = array(










			");
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,

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

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 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 1502Zeile 1538
		else
{
++$mergethread['unapprovedposts'];

		else
{
++$mergethread['unapprovedposts'];

		}


		}


		// In some cases the thread we may be merging with may cause us to have a new firstpost if it is an older thread
// Therefore resync the visible field to make sure they're the same if they're not
$query = $db->simple_select("posts", "pid, uid, visible", "tid='{$tid}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));

		// In some cases the thread we may be merging with may cause us to have a new firstpost if it is an older thread
// Therefore resync the visible field to make sure they're the same if they're not
$query = $db->simple_select("posts", "pid, uid, visible", "tid='{$tid}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));

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'];
}

// Thread is not in current forum
if($mergethread['fid'] != $thread['fid'])

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

// Thread is not in current forum
if($mergethread['fid'] != $thread['fid'])

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

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

				$updated_stats = array(
"unapprovedposts" => '+'.($mergethread['replies']+$mergethread['unapprovedposts']+$mergethread['deletedposts'])
);

				$updated_stats = array(
"unapprovedposts" => '+'.($mergethread['replies']+$mergethread['unapprovedposts']+$mergethread['deletedposts'])
);

Zeile 1542Zeile 1601
			{
$updated_stats = array(
"deletedposts" => '+'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts'])

			{
$updated_stats = array(
"deletedposts" => '+'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts'])

				);

				);

			}
else
{

			}
else
{

Zeile 1550Zeile 1609
					"posts" => "+{$mergethread['replies']}",
"unapprovedposts" => "+{$mergethread['unapprovedposts']}",
"deletedposts" => "+{$mergethread['deletedposts']}"

					"posts" => "+{$mergethread['replies']}",
"unapprovedposts" => "+{$mergethread['unapprovedposts']}",
"deletedposts" => "+{$mergethread['deletedposts']}"

				);
}

				);
}

			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 1566Zeile 1624
			{
$updated_stats = array(
"deletedposts" => '-'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts'])

			{
$updated_stats = array(
"deletedposts" => '-'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts'])

				);
}
else
{

				);
}
else
{

				$updated_stats = array(
"posts" => "-{$mergethread['replies']}",
"unapprovedposts" => "-{$mergethread['unapprovedposts']}",

				$updated_stats = array(
"posts" => "-{$mergethread['replies']}",
"unapprovedposts" => "-{$mergethread['unapprovedposts']}",

Zeile 1640Zeile 1698
				$new_stats['deletedposts'] = $updated_stats['deletedposts'];
}
elseif($updated_stats['deletedposts'] > 0)

				$new_stats['deletedposts'] = $updated_stats['deletedposts'];
}
elseif($updated_stats['deletedposts'] > 0)

			{

			{

				$new_stats['deletedposts'] = "+{$updated_stats['deletedposts']}";

				$new_stats['deletedposts'] = "+{$updated_stats['deletedposts']}";

			}

			}


if(!empty($new_stats))
{
update_forum_counters($mergethread['fid'], $new_stats);
update_forum_lastpost($mergethread['fid']);
}


if(!empty($new_stats))
{
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 1685Zeile 1738
			}
}


			}
}


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


		// Update user counters
foreach($user_posts as $uid => $counters)

		{

		{

			// 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_array = array(
"postnum" => "+{$counters['postnum']}",
"threadnum" => "+{$counters['threadnum']}",
);
update_user_counters($uid, $update_array);



















		}

$updated_stats = array(

		}

$updated_stats = array(

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 1755Zeile 1794
		if(empty($pids) || !$forum_cache[$moveto])
{
return false;

		if(empty($pids) || !$forum_cache[$moveto])
{
return false;

		}


		}


		// 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)
{

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 1856Zeile 1908
					'posts' => 0,
'unapprovedposts' => 0,
'deletedposts' => 0

					'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))

				// 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'];

					// 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
--$thread_counters[$post['tid']]['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'];


 
			}
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)
{
// Soft deleted post
// Subtract 1 from the old thread's deleted posts
--$thread_counters[$post['tid']]['deletedposts'];

			}
elseif($post['visible'] == -1)
{
// 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'];

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

			}
else
{
--$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
{

			else
{

				++$forum_counters[$moveto]['deletedposts'];

				--$forum_counters[$post['fid']]['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)
$thread_counters[$post['tid']]['attachmentcount'] -= $post['postattachmentcount'];

			}

// Subtract attachment counts from old thread and add to new thread (which are counted regardless of post or attachment unapproval at time of coding)
$thread_counters[$post['tid']]['attachmentcount'] -= $post['postattachmentcount'];

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


			$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

			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

				$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)

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

					{

					{

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

						--$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)
{

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

Zeile 1965Zeile 1995
					else
{
--$thread_counters[$post['tid']]['unapprovedposts'];

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

					}











					}
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'];

					if($post['threadvisible'] == 1)
{
++$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($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
--$thread_counters[$newtid]['replies'];

		{
// If splitting into a new thread, subtract one from the thread's reply count to compensate for the original post
--$thread_counters[$newtid]['replies'];

		}
elseif($destination_tid == 0 && $newthread['visible'] == 0)
{

		}
elseif($destination_tid == 0 && $newthread['visible'] == 0)
{

Zeile 2061Zeile 2187
				}
update_thread_counters($tid, $counters);
update_last_post($tid);

				}
update_thread_counters($tid, $counters);
update_last_post($tid);

			}
}


			}
}


		// Update forum counters
if(!empty($forum_counters))
{

		// Update forum counters
if(!empty($forum_counters))
{

Zeile 2083Zeile 2209

return $newtid;
}


return $newtid;
}





	/**
* Move multiple threads to new forum
*

	/**
* Move multiple threads to new forum
*

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))
{
foreach($user_counters as $uid => $counters)

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

Zeile 2248Zeile 2374
				update_user_counters($uid, $update_array);
}
}

				update_user_counters($uid, $update_array);
}
}





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

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

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 2343Zeile 2469
			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
WHERE p.pid IN ($pid_list) AND p.visible = '0' AND t.firstpost != p.pid

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
WHERE p.pid IN ($pid_list) AND p.visible = '0' AND t.firstpost != p.pid

		");
while($post = $db->fetch_array($query))

		");
while($post = $db->fetch_array($query))

		{
$pids[] = $post['pid'];

if(!isset($thread_counters[$post['tid']]))

		{
$pids[] = $post['pid'];

if(!isset($thread_counters[$post['tid']]))

			{

			{

				$thread_counters[$post['tid']] = array(
'replies' => 0
);

				$thread_counters[$post['tid']] = array(
'replies' => 0
);

			}

			}


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

// 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


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

// 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']]))

				{

				{

					$forum_counters[$post['fid']] = array(
'num_posts' => 0
);

					$forum_counters[$post['fid']] = array(
'num_posts' => 0
);

				}

				}

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


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


Zeile 2379Zeile 2505
				{
$user_counters[$post['uid']] = 0;
}

				{
$user_counters[$post['uid']] = 0;
}

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

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

			}
}


			}
}


Zeile 2450Zeile 2576

// Make sure we only have valid values
$pids = array_map('intval', $pids);


// Make sure we only have valid values
$pids = array_map('intval', $pids);





		$pid_list = implode(',', $pids);
$pids = $threads_to_update = array();


		$pid_list = implode(',', $pids);
$pids = $threads_to_update = array();


Zeile 2520Zeile 2646
					'num_posts' => 0,
'num_unapproved_posts' => 0,
'num_deleted_posts' => 0

					'num_posts' => 0,
'num_unapproved_posts' => 0,
'num_deleted_posts' => 0

				);
}

				);
}


// 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 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)

			{

			{

				++$forum_counters[$post['fid']]['num_unapproved_posts'];
if($post['visible'] == 1)
{

				++$forum_counters[$post['fid']]['num_unapproved_posts'];
if($post['visible'] == 1)
{

Zeile 2535Zeile 2661
				else
{
++$forum_counters[$post['fid']]['num_deleted_posts'];

				else
{
++$forum_counters[$post['fid']]['num_deleted_posts'];

				}
}

$forum = get_forum($post['fid']);


				}
}

$forum = get_forum($post['fid']);


			// If post counts enabled in this forum and the thread is approved, subtract 1
if($forum['usepostcounts'] != 0 && $post['visible'] == 1 && $post['threadvisible'] == 1)
{

			// If post counts enabled in this forum and the thread is approved, subtract 1
if($forum['usepostcounts'] != 0 && $post['visible'] == 1 && $post['threadvisible'] == 1)
{

Zeile 2557Zeile 2683
		}

if(!empty($pids))

		}

if(!empty($pids))

		{

		{

			$where = "pid IN (".implode(',', $pids).")";
$db->update_query("posts", $approve, $where);

			$where = "pid IN (".implode(',', $pids).")";
$db->update_query("posts", $approve, $where);

		}


		}


		$plugins->run_hooks("class_moderation_unapprove_posts", $pids);

if(!empty($thread_counters))

		$plugins->run_hooks("class_moderation_unapprove_posts", $pids);

if(!empty($thread_counters))

		{

		{

			foreach($thread_counters as $tid => $counters)
{
$counters_update = array(
"unapprovedposts" => "+".$counters['unapprovedposts'],
"replies" => "-".$counters['replies'],
"deletedposts" => "-".$counters['deletedposts']

			foreach($thread_counters as $tid => $counters)
{
$counters_update = array(
"unapprovedposts" => "+".$counters['unapprovedposts'],
"replies" => "-".$counters['replies'],
"deletedposts" => "-".$counters['deletedposts']

				);


				);


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

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

			}
}

			}
}


if(!empty($forum_counters))
{


if(!empty($forum_counters))
{

Zeile 2590Zeile 2716
				);
update_forum_counters($fid, $updated_forum_stats);
update_forum_lastpost($fid);

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

			}
}


			}
}


		if(!empty($user_counters))

		if(!empty($user_counters))

		{

		{

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

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

Zeile 2603Zeile 2729

return true;
}


return true;
}





	/**
* Change thread subject
*

	/**
* Change thread subject
*

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

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

		}


		}


		// Make sure we only have valid values
$tids = array_map('intval', $tids);

		// Make sure we only have valid values
$tids = array_map('intval', $tids);





		if(empty($tids))

		if(empty($tids))

		{
return false;
}


		{
return false;
}


		$tid_list = implode(',', $tids);

// Get original subject

		$tid_list = implode(',', $tids);

// Get original subject

Zeile 2661Zeile 2787
	function expire_thread($tid, $deletetime)
{
global $db, $plugins;

	function expire_thread($tid, $deletetime)
{
global $db, $plugins;


$tid = (int)$tid;



$tid = (int)$tid;


		if(empty($tid))
{
return false;

		if(empty($tid))
{
return false;

Zeile 2797Zeile 2923
	 * Toggle thread visibility (deleted/restored)
*
* @param array Thread IDs

	 * Toggle thread visibility (deleted/restored)
*
* @param array Thread IDs

	 * @param int Forum ID

 
	 * @return boolean true
*/

	 * @return boolean true
*/

	function toggle_thread_softdelete($tids, $fid)

	function toggle_thread_softdelete($tids)

	{
global $db;

// Make sure we only have valid values
$tids = array_map('intval', $tids);

	{
global $db;

// Make sure we only have valid values
$tids = array_map('intval', $tids);

		$fid = (int)$fid;

 

$tid_list = implode(',', $tids);
$query = $db->simple_select("threads", 'tid, visible', "tid IN ($tid_list)");


$tid_list = implode(',', $tids);
$query = $db->simple_select("threads", 'tid, visible', "tid IN ($tid_list)");

Zeile 2823Zeile 2947
		}
if(is_array($delete))
{

		}
if(is_array($delete))
{

			$this->soft_delete_threads($delete, $fid);

			$this->soft_delete_threads($delete);

		}
if(is_array($restore))
{

		}
if(is_array($restore))
{

			$this->restore_threads($restore, $fid);

			$this->restore_threads($restore);

		}
return true;
}

		}
return true;
}

Zeile 3413Zeile 3537
				}
}


				}
}


			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 3700
					}
}


					}
}


				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'];
}