Vergleich inc/class_moderation.php - 1.8.27 - 1.8.37

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 254Zeile 254
			{
foreach($userposts as $uid => $subtract)
{

			{
foreach($userposts as $uid => $subtract)
{

					$update_array = array(
"postnum" => "-{$subtract['num_posts']}",
"threadnum" => "-{$subtract['num_threads']}",
);









					$update_array = array();

if(isset($subtract['num_posts']))
{
$update_array['postnum'] = "-{$subtract['num_posts']}";
}

if(isset($subtract['num_threads']))
{
$update_array['threadnum'] = "-{$subtract['num_threads']}";
}


					update_user_counters($uid, $update_array);
}
}

					update_user_counters($uid, $update_array);
}
}

Zeile 275Zeile 283
		$db->delete_query("threads", "tid='$tid'");
$query = $db->simple_select('threads', 'tid', "closed='moved|$tid'");
while($redirect_tid = $db->fetch_field($query, 'tid'))

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

		{

		{

			$this->delete_thread($redirect_tid);
}
$db->delete_query("threadsubscriptions", "tid='$tid'");

			$this->delete_thread($redirect_tid);
}
$db->delete_query("threadsubscriptions", "tid='$tid'");

Zeile 307Zeile 315
		{
// Redirect
if($thread['visible'] == 1)

		{
// Redirect
if($thread['visible'] == 1)

			{

			{

				$updated_counters['posts'] = -1;
}
elseif($thread['visible'] == -1)

				$updated_counters['posts'] = -1;
}
elseif($thread['visible'] == -1)

Zeile 318Zeile 326
			{
$updated_counters['unapprovedposts'] = -1;
}

			{
$updated_counters['unapprovedposts'] = -1;
}

		}


		}


		// Update forum count
update_forum_counters($thread['fid'], $updated_counters);
update_forum_lastpost($thread['fid']);
mark_reports($tid, 'thread');

		// Update forum count
update_forum_counters($thread['fid'], $updated_counters);
update_forum_lastpost($thread['fid']);
mark_reports($tid, 'thread');





		$plugins->run_hooks("class_moderation_delete_thread", $tid);

return true;

		$plugins->run_hooks("class_moderation_delete_thread", $tid);

return true;

Zeile 348Zeile 356
		}

$plugins->run_hooks("class_moderation_delete_poll", $pid);

		}

$plugins->run_hooks("class_moderation_delete_poll", $pid);





		$db->delete_query("polls", "pid='$pid'");
$db->delete_query("pollvotes", "pid='$pid'");
$pollarray = array(
'poll' => '0',
);
$db->update_query("threads", $pollarray, "poll='$pid'");

		$db->delete_query("polls", "pid='$pid'");
$db->delete_query("pollvotes", "pid='$pid'");
$pollarray = array(
'poll' => '0',
);
$db->update_query("threads", $pollarray, "poll='$pid'");


return true;
}



return true;
}


	/**
* Approve one or more threads
*

	/**
* Approve one or more threads
*

Zeile 423Zeile 431
			if($forum['usepostcounts'] != 0)
{
// On approving thread restore user post counts

			if($forum['usepostcounts'] != 0)
{
// On approving thread restore user post counts

				$query = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query))

				$query2 = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))

				{

				{

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

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

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

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

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

		}

		}


if(empty($tids))
{


if(empty($tids))
{

Zeile 584Zeile 599
				// 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)
{

					$query = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query))

					$query2 = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))

					{

					{

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

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

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

				}

				}


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


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

Zeile 618Zeile 640
		if(!empty($posts_to_unapprove))
{
$db->update_query("posts", $approve, "pid IN (".implode(',', $posts_to_unapprove).")");

		if(!empty($posts_to_unapprove))
{
$db->update_query("posts", $approve, "pid IN (".implode(',', $posts_to_unapprove).")");

		}

$plugins->run_hooks("class_moderation_unapprove_threads", $tids);

		}

$plugins->run_hooks("class_moderation_unapprove_threads", $tids);


if(!empty($forum_counters))
{
foreach($forum_counters as $fid => $counters)
{
// Update stats


if(!empty($forum_counters))
{
foreach($forum_counters as $fid => $counters)
{
// Update stats

				$update_array = array(

				$update_array = array(

					"threads" => "-{$counters['num_threads']}",
"unapprovedthreads" => "+{$counters['num_unapprovedthreads']}",
"posts" => "-{$counters['num_posts']}",

					"threads" => "-{$counters['num_threads']}",
"unapprovedthreads" => "+{$counters['num_unapprovedthreads']}",
"posts" => "-{$counters['num_posts']}",

Zeile 670Zeile 692
		$pid = (int)$pid;
$query = $db->query("
SELECT p.pid, p.uid, p.fid, p.tid, p.visible, t.visible as threadvisible

		$pid = (int)$pid;
$query = $db->query("
SELECT p.pid, p.uid, p.fid, p.tid, p.visible, t.visible as threadvisible

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)

			WHERE p.pid='$pid'
");
$post = $db->fetch_array($query);

			WHERE p.pid='$pid'
");
$post = $db->fetch_array($query);

Zeile 683Zeile 705
		$forum = get_forum($post['fid']);
// If post counts enabled in this forum and it hasn't already been unapproved, remove 1
if($forum['usepostcounts'] != 0 && $post['visible'] != -1 && $post['visible'] != 0 && $post['threadvisible'] != 0 && $post['threadvisible'] != -1)

		$forum = get_forum($post['fid']);
// If post counts enabled in this forum and it hasn't already been unapproved, remove 1
if($forum['usepostcounts'] != 0 && $post['visible'] != -1 && $post['visible'] != 0 && $post['threadvisible'] != 0 && $post['threadvisible'] != -1)

		{

		{

			update_user_counters($post['uid'], array('postnum' => "-1"));
}


			update_user_counters($post['uid'], array('postnum' => "-1"));
}


Zeile 694Zeile 716

// 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'");


Zeile 706Zeile 728
		{
$update_array = array(
"unapprovedposts" => "-1"

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

			);

			);

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

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

			);
}

			);
}

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

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

			);
}

			);
}


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



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


Zeile 748Zeile 770

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


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





		return true;
}


		return true;
}


Zeile 767Zeile 789
		$pids = array_map('intval', $pids);

if(empty($pids) || count($pids) < 2)

		$pids = array_map('intval', $pids);

if(empty($pids) || count($pids) < 2)

		{
return false;

		{
return false;

		}

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

		}

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

Zeile 812Zeile 834
			{
// these are the selected posts
if($sep == "new_line")

			{
// these are the selected posts
if($sep == "new_line")

				{

				{

					$message .= "\n\n {$post['message']}";

					$message .= "\n\n {$post['message']}";

				}

				}

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

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

				}

				}


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


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

Zeile 830Zeile 852
				}

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

				}

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

				{

				{

					--$thread_counters[$post['tid']]['replies'];
$forum = get_forum($post['fid']);
if(!isset($user_counters[$post['uid']]))

					--$thread_counters[$post['tid']]['replies'];
$forum = get_forum($post['fid']);
if(!isset($user_counters[$post['uid']]))

Zeile 842Zeile 864
					}
// 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)

					{

					{

						// Update post count of the user of the merged posts
--$user_counters[$post['uid']]['num_posts'];
}

						// Update post count of the user of the merged posts
--$user_counters[$post['uid']]['num_posts'];
}

Zeile 867Zeile 889
				if($post['threadvisible'] == 1 && $post['visible'] == 1)
{
--$forum_counters[$post['fid']]['num_posts'];

				if($post['threadvisible'] == 1 && $post['visible'] == 1)
{
--$forum_counters[$post['fid']]['num_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'];

Zeile 1065Zeile 1087
				);
$db->update_query("threads", $changefid, "tid='$tid'");
$db->update_query("posts", $changefid, "tid='$tid'");

				);
$db->update_query("threads", $changefid, "tid='$tid'");
$db->update_query("posts", $changefid, "tid='$tid'");


// 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":
case "sqlite":
$query = $db->simple_select("threadprefixes", "COUNT(*) as num_prefixes", "(','||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(
"prefix" => 0,
);
$db->update_query("threads", $sqlarray, "tid='$tid'");


// 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":
case "sqlite":
$query = $db->simple_select("threadprefixes", "COUNT(*) as num_prefixes", "(','||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(
"prefix" => 0,
);
$db->update_query("threads", $sqlarray, "tid='$tid'");

					}
}


					}
}


Zeile 1901Zeile 1923
					'unapprovedposts' => 0,
'deletedposts' => 0,
'attachmentcount' => 0

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

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

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

					'deletedposts' => 0
);
}

					'deletedposts' => 0
);
}

Zeile 2061Zeile 2083
						$user_counters[$newthread['uid']] = array(
'postnum' => 0,
'threadnum' => 0

						$user_counters[$newthread['uid']] = array(
'postnum' => 0,
'threadnum' => 0

						);
}

						);
}

					// Subtract thread from old thread opener
--$user_counters[$newthread['uid']]['threadnum'];
}

					// Subtract thread from old thread opener
--$user_counters[$newthread['uid']]['threadnum'];
}

Zeile 2082Zeile 2104
				++$thread_counters[$newtid]['replies'];
}
elseif($post['visible'] == 0)

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

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

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

Zeile 2113Zeile 2135
		{
// 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)
{
// If splitting into a new thread, subtract one from the thread's reply count to compensate for the original post

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

Zeile 2319Zeile 2341
				$total_deleted_posts += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1;

$forum_counters[$thread['fid']]['deletedposts'] += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1; // Implied deleted posts counter for deleted threads

				$total_deleted_posts += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1;

$forum_counters[$thread['fid']]['deletedposts'] += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1; // Implied deleted posts counter for deleted threads





				$forum_counters[$thread['fid']]['deletedthreads']++;
++$total_deleted_threads;
}

				$forum_counters[$thread['fid']]['deletedthreads']++;
++$total_deleted_threads;
}

Zeile 2416Zeile 2438

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


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


return true;
}



return true;
}


	/**
* Approve multiple posts
*

	/**
* Approve multiple posts
*

Zeile 2433Zeile 2455
		$num_posts = 0;

if(empty($pids))

		$num_posts = 0;

if(empty($pids))

		{

		{

			return false;
}

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

			return false;
}

// 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 2463Zeile 2485
		while($post = $db->fetch_array($query))
{
// This is the first post in the thread so we're approving the whole thread.

		while($post = $db->fetch_array($query))
{
// 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))
{
$this->approve_threads($threads_to_update);
}


			$threads_to_update[] = $post['tid'];
}

if(!empty($threads_to_update))
{
$this->approve_threads($threads_to_update);
}


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

$query = $db->query("

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

$query = $db->query("

Zeile 2488Zeile 2510
				$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
if($post['threadvisible'] == 1)

			++$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'] == 1)

			{

			{

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

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

Zeile 2515Zeile 2537
					$user_counters[$post['uid']] = 0;
}
++$user_counters[$post['uid']];

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

			}
}

if(empty($pids) && empty($threads_to_update))
{
return false;

			}
}

if(empty($pids) && empty($threads_to_update))
{
return false;

		}

if(!empty($pids))

		}

if(!empty($pids))

Zeile 2670Zeile 2692
				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']);


Zeile 2683Zeile 2705
					$user_counters[$post['uid']] = 0;
}
--$user_counters[$post['uid']];

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

			}
}


			}
}


		if(empty($pids) && empty($threads_to_update))
{
return false;

		if(empty($pids) && empty($threads_to_update))
{
return false;

		}


		}


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

		if(!empty($pids))
{
$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))

Zeile 2715Zeile 2737
		}

if(!empty($forum_counters))

		}

if(!empty($forum_counters))

		{

		{

			foreach($forum_counters as $fid => $counters)

			foreach($forum_counters as $fid => $counters)

			{

			{

				$updated_forum_stats = array(
'posts' => "-{$counters['num_posts']}",
'unapprovedposts' => "+{$counters['num_unapproved_posts']}",
'deletedposts' => "-{$counters['num_deleted_posts']}"

				$updated_forum_stats = array(
'posts' => "-{$counters['num_posts']}",
'unapprovedposts' => "+{$counters['num_unapproved_posts']}",
'deletedposts' => "-{$counters['num_deleted_posts']}"

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

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

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

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

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

return true;
}

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

return true;
}





	/**
* Change thread subject
*

	/**
* Change thread subject
*

Zeile 2777Zeile 2799
			// Update threads and first posts with new subject
$find = array('{username}', 'author', '{subject}');
$replace = array($mybb->user['username'], $thread['username'], $thread['subject']);

			// Update threads and first posts with new subject
$find = array('{username}', 'author', '{subject}');
$replace = array($mybb->user['username'], $thread['username'], $thread['subject']);





			$new_subject = str_ireplace($find, $replace, $format);

$args = array(
'thread' => &$thread,
'new_subject' => &$new_subject,

			$new_subject = str_ireplace($find, $replace, $format);

$args = array(
'thread' => &$thread,
'new_subject' => &$new_subject,

			);

			);


$plugins->run_hooks("class_moderation_change_thread_subject_newsubject", $args);



$plugins->run_hooks("class_moderation_change_thread_subject_newsubject", $args);


Zeile 2796Zeile 2818

$arguments = array("tids" => $tids, "format" => $format);
$plugins->run_hooks("class_moderation_change_thread_subject", $arguments);


$arguments = array("tids" => $tids, "format" => $format);
$plugins->run_hooks("class_moderation_change_thread_subject", $arguments);


return true;
}

/**


return true;
}

/**

	 * Add thread expiry
*
* @param int $tid Thread ID
* @param int $deletetime Timestamp when the thread is deleted
* @return boolean

	 * Add thread expiry
*
* @param int $tid Thread ID
* @param int $deletetime Timestamp when the thread is deleted
* @return boolean

	 */

	 */

	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 2831Zeile 2853

/**
* Toggle post visibility (approved/unapproved)


/**
* Toggle post visibility (approved/unapproved)

	 *
* @param array $pids Post IDs
* @return boolean true
*/

	 *
* @param array $pids Post IDs
* @return boolean true
*/

	function toggle_post_visibility($pids)

	function toggle_post_visibility($pids)

	{
global $db;

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


	{
global $db;

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


		$pid_list = implode(',', $pids);
$query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)");
while($post = $db->fetch_array($query))
{
if($post['visible'] != 0)

		$pid_list = implode(',', $pids);
$query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)");
while($post = $db->fetch_array($query))
{
if($post['visible'] != 0)

			{

			{

				$unapprove[] = $post['pid'];

				$unapprove[] = $post['pid'];

			}

			}

			else
{
$approve[] = $post['pid'];
}

			else
{
$approve[] = $post['pid'];
}

		}

		}

		if(is_array($unapprove))
{
$this->unapprove_posts($unapprove);
}
if(is_array($approve))

		if(is_array($unapprove))
{
$this->unapprove_posts($unapprove);
}
if(is_array($approve))

		{

		{

			$this->approve_posts($approve);
}
return true;

			$this->approve_posts($approve);
}
return true;

Zeile 2886Zeile 2908
			if($post['visible'] != -1)
{
$delete[] = $post['pid'];

			if($post['visible'] != -1)
{
$delete[] = $post['pid'];

			}

			}

			else
{
$restore[] = $post['pid'];

			else
{
$restore[] = $post['pid'];

			}
}

			}
}

		if(is_array($delete))

		if(is_array($delete))

		{
$this->soft_delete_posts($delete);
}
if(is_array($restore))
{

		{
$this->soft_delete_posts($delete);
}
if(is_array($restore))
{

			$this->restore_posts($restore);
}
return true;

			$this->restore_posts($restore);
}
return true;

Zeile 2921Zeile 2943
		$tid_list = implode(',', $tids);
$query = $db->simple_select("threads", 'tid, visible', "tid IN ($tid_list)");
while($thread = $db->fetch_array($query))

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

		{

		{

			if($thread['visible'] != 0)
{
$unapprove[] = $thread['tid'];

			if($thread['visible'] != 0)
{
$unapprove[] = $thread['tid'];

Zeile 2935Zeile 2957
		{
$this->unapprove_threads($unapprove, $fid);
}

		{
$this->unapprove_threads($unapprove, $fid);
}

		if(is_array($approve))
{
$this->approve_threads($approve, $fid);
}

		if(is_array($approve))
{
$this->approve_threads($approve, $fid);
}

		return true;
}

/**
* Toggle thread visibility (deleted/restored)

		return true;
}

/**
* Toggle thread visibility (deleted/restored)

	 *
* @param array $tids Thread IDs

	 *
* @param array $tids Thread IDs

	 * @return boolean true
*/
function toggle_thread_softdelete($tids)
{
global $db;

	 * @return boolean true
*/
function toggle_thread_softdelete($tids)
{
global $db;





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

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

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

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

		{

		{

			if($thread['visible'] != -1)
{
$delete[] = $thread['tid'];

			if($thread['visible'] != -1)
{
$delete[] = $thread['tid'];

Zeile 2986Zeile 3008
	 * @return boolean true
*/
function toggle_thread_status($tids)

	 * @return boolean true
*/
function toggle_thread_status($tids)

	{
global $db;

// Make sure we only have valid values

	{
global $db;

// Make sure we only have valid values

		$tids = array_map('intval', $tids);

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

		$tids = array_map('intval', $tids);

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

Zeile 3143Zeile 3165
	 * @return bool
*/
function apply_thread_prefix($tids, $prefix = 0)

	 * @return bool
*/
function apply_thread_prefix($tids, $prefix = 0)

	{

	{

		global $db, $plugins;

// Format thread IDs

		global $db, $plugins;

// Format thread IDs

Zeile 3152Zeile 3174
			$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);
$tids_csv = implode(',', $tids);

$update_thread = array('prefix' => (int)$prefix);

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

$update_thread = array('prefix' => (int)$prefix);

		$db->update_query('threads', $update_thread, "tid IN ({$tids_csv})");


		$db->update_query('threads', $update_thread, "tid IN ({$tids_csv})");


		$arguments = array('tids' => $tids, 'prefix' => $prefix);

$plugins->run_hooks('class_moderation_apply_thread_prefix', $arguments);

		$arguments = array('tids' => $tids, 'prefix' => $prefix);

$plugins->run_hooks('class_moderation_apply_thread_prefix', $arguments);

Zeile 3195Zeile 3217
		// Make invisible
$update = array(
"visible" => -1,

		// Make invisible
$update = array(
"visible" => -1,

		);

		);


// We have three cases we deal with in these code segments:
// 1) We're deleting specific approved posts


// We have three cases we deal with in these code segments:
// 1) We're deleting specific approved posts

Zeile 3206Zeile 3228
		// 3) We're doing both 1 and 2
$query = $db->query("
SELECT p.tid

		// 3) We're doing both 1 and 2
$query = $db->query("
SELECT p.tid

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)

			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 IN (0,1) AND t.firstpost = p.pid AND t.visible IN (0,1)
");
while($post = $db->fetch_array($query))

			WHERE p.pid IN ($pid_list) AND p.visible IN (0,1) AND t.firstpost = p.pid AND t.visible IN (0,1)
");
while($post = $db->fetch_array($query))

Zeile 3245Zeile 3267

++$thread_counters[$post['tid']]['deletedposts'];
if($post['visible'] == 1)


++$thread_counters[$post['tid']]['deletedposts'];
if($post['visible'] == 1)

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

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

			}
else
{

			}
else
{

Zeile 3272Zeile 3294
					++$forum_counters[$post['fid']]['num_posts'];
}
else

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

				{

				{

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

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

Zeile 3298Zeile 3320
			$where = "pid IN (".implode(',', $pids).")";
$db->update_query("posts", $update, $where);
mark_reports($pids, "posts");

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

		}


		}


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

if(is_array($thread_counters))
{
foreach($thread_counters as $tid => $counters)

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

if(is_array($thread_counters))
{
foreach($thread_counters as $tid => $counters)

			{

			{

				$counters_update = array(
"unapprovedposts" => "-".$counters['unapprovedposts'],
"replies" => "-".$counters['replies'],
"deletedposts" => "+".$counters['deletedposts']

				$counters_update = array(
"unapprovedposts" => "-".$counters['unapprovedposts'],
"replies" => "-".$counters['replies'],
"deletedposts" => "+".$counters['deletedposts']

				);


				);


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

if(is_array($forum_counters))

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

if(is_array($forum_counters))

		{

		{

			foreach($forum_counters as $fid => $counters)
{
$updated_forum_stats = array(

			foreach($forum_counters as $fid => $counters)
{
$updated_forum_stats = array(

Zeile 3328Zeile 3350
				);
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))
{
foreach($user_counters as $uid => $counter)

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

Zeile 3349Zeile 3371
	 * @return boolean
*/
function restore_posts($pids)

	 * @return boolean
*/
function restore_posts($pids)

	{

	{

		global $db, $cache, $plugins;

$num_posts = 0;

		global $db, $cache, $plugins;

$num_posts = 0;

Zeile 3449Zeile 3471
		{
$where = "pid IN (".implode(',', $pids).")";
$db->update_query("posts", $update, $where);

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

		}

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


		}

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


		if(is_array($thread_counters))
{
foreach($thread_counters as $tid => $counters)

		if(is_array($thread_counters))
{
foreach($thread_counters as $tid => $counters)

Zeile 3463Zeile 3485
				);
update_thread_counters($tid, $counters_update);
update_last_post($tid);

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

			}
}


			}
}


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

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

Zeile 3476Zeile 3498
				);
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))
{
foreach($user_counters as $uid => $counter)

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

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

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

		}


		}


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

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

Zeile 3517Zeile 3539

$tids_list = implode(",", $tids);
$query = $db->simple_select("threads", "*", "tid IN ($tids_list)");


$tids_list = implode(",", $tids);
$query = $db->simple_select("threads", "*", "tid IN ($tids_list)");





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

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

Zeile 3535Zeile 3557
					'num_threads' => 0,
'num_deleted_posts' => 0,
'num_unapproved_posts' => 0

					'num_threads' => 0,
'num_deleted_posts' => 0,
'num_unapproved_posts' => 0

				);
}

				);
}


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


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

Zeile 3554Zeile 3576
			if($forum['usepostcounts'] != 0)
{
// On approving thread restore user post counts

			if($forum['usepostcounts'] != 0)
{
// On approving thread restore user post counts

				$query = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query))

				$query2 = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))

				{

				{

					if(!isset($user_counters[$counter['uid']]['num_posts']))

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

					{

					{

						$user_counters[$counter['uid']]['num_posts'] = 0;




						$user_counters[$counter['uid']] = array(
'num_posts' => 0,
'num_threads' => 0
);

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

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

Zeile 3719Zeile 3744
				// 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)
{

					$query = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query))

					$query2 = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))

					{

					{

						if(!isset($user_counters[$counter['uid']]['num_posts']))

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

						{

						{

							$user_counters[$counter['uid']]['num_posts'] = 0;




							$user_counters[$counter['uid']] = array(
'num_posts' => 0,
'num_threads' => 0
);

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

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