Vergleich inc/class_moderation.php - 1.8.21 - 1.8.38

  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 269Zeile 277
			$db->delete_query("posts", "pid IN ($pids)");
$db->delete_query("attachments", "pid IN ($pids)");
$db->delete_query("reportedcontent", "id IN ($pids) AND (type = 'post' OR type = '')");

			$db->delete_query("posts", "pid IN ($pids)");
$db->delete_query("attachments", "pid IN ($pids)");
$db->delete_query("reportedcontent", "id IN ($pids) AND (type = 'post' OR type = '')");

		}

		}


// Delete threads, redirects, subscriptions, polls, and poll votes
$db->delete_query("threads", "tid='$tid'");


// Delete threads, redirects, subscriptions, polls, and poll votes
$db->delete_query("threads", "tid='$tid'");

Zeile 289Zeile 297
			"unapprovedposts" => "-{$num_unapproved_posts}",
"deletedposts" => "-{$num_deleted_posts}"
);

			"unapprovedposts" => "-{$num_unapproved_posts}",
"deletedposts" => "-{$num_deleted_posts}"
);





		if($thread['visible'] == 1)
{
$updated_counters['threads'] = -1;

		if($thread['visible'] == 1)
{
$updated_counters['threads'] = -1;

Zeile 309Zeile 317
			if($thread['visible'] == 1)
{
$updated_counters['posts'] = -1;

			if($thread['visible'] == 1)
{
$updated_counters['posts'] = -1;

			}

			}

			elseif($thread['visible'] == -1)
{
$updated_counters['deletedposts'] = -1;

			elseif($thread['visible'] == -1)
{
$updated_counters['deletedposts'] = -1;

Zeile 326Zeile 334
		mark_reports($tid, 'thread');

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

		mark_reports($tid, 'thread');

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


return true;
}


return true;
}


/**
* Delete a poll
*
* @param int $pid Poll id


/**
* Delete a poll
*
* @param int $pid Poll id

	 * @return boolean

	 * @return boolean

	 */
function delete_poll($pid)
{
global $db, $plugins;

	 */
function delete_poll($pid)
{
global $db, $plugins;





		$pid = (int)$pid;

		$pid = (int)$pid;





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

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

Zeile 361Zeile 369

/**
* Approve one or more threads


/**
* Approve one or more threads

	 *
* @param array|int $tids Thread ID(s)
* @return boolean

	 *
* @param array|int $tids Thread ID(s)
* @return boolean

	 */
function approve_threads($tids)
{

	 */
function approve_threads($tids)
{

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

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

		}

		}


if(empty($tids))


if(empty($tids))

		{

		{

			return false;
}

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





		$tid_list = $forum_counters = $user_counters = $posts_to_approve = array();


		$tid_list = $forum_counters = $user_counters = $posts_to_approve = array();


		foreach($tids as $tid)




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

while($thread = $db->fetch_array($query))

		{

		{

			$thread = get_thread($tid);
if(!$thread || $thread['visible'] == 1 || $thread['visible'] == -1)

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


			{
continue;
}

			{
continue;
}

Zeile 421Zeile 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='{$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 473Zeile 490
				foreach($forum_counters as $fid => $counters)
{
// Update stats

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

					$update_array = array(

					$update_array = array(

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

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

Zeile 513Zeile 530
		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 527Zeile 544
		$tid_moved_list = "";
$comma = "";
foreach($tids as $tid)

		$tid_moved_list = "";
$comma = "";
foreach($tids as $tid)

		{

		{

			$tid_moved_list .= "{$comma}'moved|{$tid}'";
$comma = ",";
}

			$tid_moved_list .= "{$comma}'moved|{$tid}'";
$comma = ",";
}





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

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


foreach($tids as $tid)





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

while($thread = $db->fetch_array($query))

		{

		{

			$thread = get_thread($tid);

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

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

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

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

Zeile 554Zeile 573
				}

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 580Zeile 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='{$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 637Zeile 663
		}

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 674Zeile 700
		if(!$post)
{
return false;

		if(!$post)
{
return false;

		}


		}


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

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

		}


		}


		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

		remove_attachments($pid);


		remove_attachments($pid);


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


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


Zeile 779Zeile 805
			LEFT JOIN ".TABLE_PREFIX."attachments a ON (a.pid=p.pid AND a.visible=1)
WHERE p.pid IN($pidin)
GROUP BY p.pid

			LEFT JOIN ".TABLE_PREFIX."attachments a ON (a.pid=p.pid AND a.visible=1)
WHERE p.pid IN($pidin)
GROUP BY p.pid

			ORDER BY p.dateline ASC

			ORDER BY p.dateline ASC, p.pid ASC

		");
$message = '';
$threads = $forum_counters = $thread_counters = $user_counters = array();

		");
$message = '';
$threads = $forum_counters = $thread_counters = $user_counters = array();

Zeile 902Zeile 928
		{
// 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, uid, 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, pid', '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 1171Zeile 1197
						'question' => $db->escape_string($poll['question']),
'dateline' => $poll['dateline'],
'options' => $db->escape_string($poll['options']),

						'question' => $db->escape_string($poll['question']),
'dateline' => $poll['dateline'],
'options' => $db->escape_string($poll['options']),

						'votes' => $poll['votes'],

						'votes' => $db->escape_string($poll['votes']),

						'numoptions' => $poll['numoptions'],
'numvotes' => $poll['numvotes'],
'timeout' => $poll['timeout'],

						'numoptions' => $poll['numoptions'],
'numvotes' => $poll['numvotes'],
'timeout' => $poll['timeout'],

Zeile 1549Zeile 1575

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


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

		$query = $db->simple_select("posts", "pid, uid, visible", "tid='{$tid}'", array('order_by' => 'dateline, pid', '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 1568Zeile 1594
		{
update_first_post($thread['tid']);
}

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

 

// Attach moved posts to the first post
$db->update_query("posts", array('replyto' => $new_firstpost['pid']), "tid='{$tid}' AND replyto = 0 AND pid != '{$new_firstpost['pid']}'");


// Update thread count if thread has a new firstpost and is visible
if($thread['uid'] != $new_firstpost['uid'] && $thread['visible'] == 1 && $forum_cache[$thread['fid']]['usethreadcounts'] == 1)


// Update thread count if thread has a new firstpost and is visible
if($thread['uid'] != $new_firstpost['uid'] && $thread['visible'] == 1 && $forum_cache[$thread['fid']]['usethreadcounts'] == 1)

Zeile 1724Zeile 1753
			if($thread['visible'] == 1)
{
++$mergethread['replies'];

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

			}

			}

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

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

Zeile 1749Zeile 1778
			"replies" => "+{$mergethread['replies']}",
"attachmentcount" => "+{$mergethread['attachmentcount']}",
"unapprovedposts" => "+{$mergethread['unapprovedposts']}",

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

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

 
			"deletedposts" => "+{$mergethread['deletedposts']}"
);
update_thread_counters($tid, $updated_stats);

			"deletedposts" => "+{$mergethread['deletedposts']}"
);
update_thread_counters($tid, $updated_stats);

Zeile 1794Zeile 1822
		}

// Get the first split post

		}

// Get the first split post

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

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


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



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


Zeile 1808Zeile 1836
			'unapprovedposts' => 0,
'deletedposts' => 0
);

			'unapprovedposts' => 0,
'deletedposts' => 0
);

 

$user_counters = array();


if($destination_tid == 0)
{


if($destination_tid == 0)
{

Zeile 1960Zeile 1990
			{
// 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, uid", "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, pid', 'limit' => 1));

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

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

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

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

Zeile 1985Zeile 2015
						}
}
elseif($new_firstpost['visible'] == -1)

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

					{

					{

						--$thread_counters[$post['tid']]['deletedposts'];
}
else

						--$thread_counters[$post['tid']]['deletedposts'];
}
else

Zeile 1999Zeile 2029
					else
{
--$forum_counters[$post['fid']]['deletedposts'];

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

					}

					}


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


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

Zeile 2012Zeile 2042
						}
}
elseif($post['threadvisible'] == -1)

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

					{

					{

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

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

Zeile 2039Zeile 2069
			{
// Update post counters if visibility changes
if($post['visible'] != $newthread['visible'])

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

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

// This is needed to update the forum counters correctly

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

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

				}

				}

				update_first_post($newtid);
}


				update_first_post($newtid);
}


Zeile 2093Zeile 2123
			if($newthread['visible'] == 1 && $post['visible'] == 1)
{
++$forum_counters[$moveto]['posts'];

			if($newthread['visible'] == 1 && $post['visible'] == 1)
{
++$forum_counters[$moveto]['posts'];

			}

			}

			elseif($newthread['visible'] == 0 || ($post['visible'] == 0 && $newthread['visible'] == 1))

			elseif($newthread['visible'] == 0 || ($post['visible'] == 0 && $newthread['visible'] == 1))

			{

			{

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

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

			}

			}

			else
{
++$forum_counters[$moveto]['deletedposts'];
}
}

			else
{
++$forum_counters[$moveto]['deletedposts'];
}
}

 

// Attach moved posts to the first post
$db->update_query("posts", array('replyto' => $post_info['pid']), "tid='{$newtid}' AND replyto = 0 AND pid != '{$post_info['pid']}'");


if($destination_tid == 0 && $newthread['visible'] == 1)
{


if($destination_tid == 0 && $newthread['visible'] == 1)
{

Zeile 2147Zeile 2180
				if($tid == $newtid)
{
// Update the subject of the first post in the new thread

				if($tid == $newtid)
{
// Update the subject of the first post in the new thread

					$query = $db->simple_select("posts", "pid", "tid='$newtid'", array('order_by' => 'dateline', 'limit' => 1));

					$query = $db->simple_select("posts", "pid", "tid='$newtid'", array('order_by' => 'dateline, pid', 'limit' => 1));

					$newthread = $db->fetch_array($query);
$sqlarray = array(
"subject" => $newsubject,

					$newthread = $db->fetch_array($query);
$sqlarray = array(
"subject" => $newsubject,

Zeile 2163Zeile 2196
						FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid)
WHERE p.tid='{$tid}'

						FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid)
WHERE p.tid='{$tid}'

						ORDER BY p.dateline ASC

						ORDER BY p.dateline ASC, p.pid ASC

						LIMIT 1
");
$oldthread = $db->fetch_array($query);

						LIMIT 1
");
$oldthread = $db->fetch_array($query);

Zeile 2199Zeile 2232
					}
}
update_forum_counters($fid, $counters);

					}
}
update_forum_counters($fid, $counters);

				update_forum_lastpost($fid);
}
}


				update_forum_lastpost($fid);
}
}


		return $newtid;
}


		return $newtid;
}


Zeile 2212Zeile 2245
	 * @param array $tids Thread IDs
* @param int $moveto Destination forum
* @return boolean

	 * @param array $tids Thread IDs
* @param int $moveto Destination forum
* @return boolean

 
	 *
* @deprecated Iterate over move_thread instead

	 */
function move_threads($tids, $moveto)
{
global $db, $plugins;

	 */
function move_threads($tids, $moveto)
{
global $db, $plugins;





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

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





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

$moveto = (int)$moveto;

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

$moveto = (int)$moveto;





		$newforum = get_forum($moveto);

if(empty($tids) || !$newforum)

		$newforum = get_forum($moveto);

if(empty($tids) || !$newforum)

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

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

				);
}

				);
}


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


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

Zeile 2277Zeile 2312
				else if($newforum['usethreadcounts'] == 0 && $forum['usethreadcounts'] == 1)
{
--$user_counters[$thread['uid']]['num_threads'];

				else if($newforum['usethreadcounts'] == 0 && $forum['usethreadcounts'] == 1)
{
--$user_counters[$thread['uid']]['num_threads'];

				}

				}


$query1 = $db->query("
SELECT COUNT(p.pid) AS posts, u.uid


$query1 = $db->query("
SELECT COUNT(p.pid) AS posts, u.uid

Zeile 2290Zeile 2325
				while($posters = $db->fetch_array($query1))
{
if(!isset($user_counters[$posters['uid']]))

				while($posters = $db->fetch_array($query1))
{
if(!isset($user_counters[$posters['uid']]))

					{

					{

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

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

Zeile 2310Zeile 2345
			elseif($thread['visible'] == -1)
{
$total_deleted_posts += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1;

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

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

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

Zeile 2329Zeile 2364
			// Remove old redirects
$redirects_query = $db->simple_select('threads', 'tid', "closed='moved|{$thread['tid']}' AND fid='$moveto'");
while($redirect_tid = $db->fetch_field($redirects_query, 'tid'))

			// Remove old redirects
$redirects_query = $db->simple_select('threads', 'tid', "closed='moved|{$thread['tid']}' AND fid='$moveto'");
while($redirect_tid = $db->fetch_field($redirects_query, 'tid'))

			{

			{

				$this->delete_thread($redirect_tid);
}
}

				$this->delete_thread($redirect_tid);
}
}

Zeile 2363Zeile 2398
		}

$arguments = array("tids" => $tids, "moveto" => $moveto);

		}

$arguments = array("tids" => $tids, "moveto" => $moveto);

		$plugins->run_hooks("class_moderation_move_threads", $arguments);


		$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 2374Zeile 2409
					"threadnum" => "+{$counters['num_threads']}",
);
update_user_counters($uid, $update_array);

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

			}
}

			}
}


if(is_array($forum_counters))
{


if(is_array($forum_counters))
{

Zeile 2388Zeile 2423
					'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 2415Zeile 2450

/**
* Approve multiple posts


/**
* Approve multiple posts

	 *
* @param array $pids PIDs
* @return boolean

	 *
* @param array $pids PIDs
* @return boolean

	 */
function approve_posts($pids)
{
global $db, $cache, $plugins;

$num_posts = 0;

	 */
function approve_posts($pids)
{
global $db, $cache, $plugins;

$num_posts = 0;





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

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

Zeile 2457Zeile 2492
		{
// 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))
{
$this->approve_threads($threads_to_update);

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

Zeile 2471Zeile 2506
			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))
{
$pids[] = $post['pid'];

		while($post = $db->fetch_array($query))
{
$pids[] = $post['pid'];





			if(!isset($thread_counters[$post['tid']]))
{
$thread_counters[$post['tid']] = array(
'replies' => 0
);

			if(!isset($thread_counters[$post['tid']]))
{
$thread_counters[$post['tid']] = array(
'replies' => 0
);

			}

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


			}

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

Zeile 2494Zeile 2529
					$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'];

			}

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

			}

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


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


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

Zeile 2508Zeile 2543
					$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))
{
$where = "pid IN (".implode(',', $pids).")";
$db->update_query("posts", $approve, $where);
}

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

if(!empty($thread_counters))
{

			}
}

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

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

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

if(!empty($thread_counters))
{

			foreach($thread_counters as $tid => $counters)
{
$counters_update = array(

			foreach($thread_counters as $tid => $counters)
{
$counters_update = array(

Zeile 2572Zeile 2607
		global $db, $cache, $plugins;

if(empty($pids))

		global $db, $cache, $plugins;

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 2760Zeile 2795
		$tid_list = implode(',', $tids);

// Get original subject

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

// Get original subject

		$query = $db->simple_select("threads", "subject, tid", "tid IN ($tid_list)");





		$query = $db->query("
SELECT u.uid, u.username, t.tid, t.subject FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON t.uid=u.uid
WHERE tid IN ($tid_list)
");

		while($thread = $db->fetch_array($query))
{
// Update threads and first posts with new subject

		while($thread = $db->fetch_array($query))
{
// Update threads and first posts with new subject

			$subject = str_replace('{username}', $mybb->user['username'], $format);
$subject = str_replace('{subject}', $thread['subject'], $subject);
$new_subject = array(
"subject" => $db->escape_string($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,
);

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

$update_subject = array(
"subject" => $db->escape_string($new_subject)

			);

			);

			$db->update_query("threads", $new_subject, "tid='{$thread['tid']}'");
$db->update_query("posts", $new_subject, "tid='{$thread['tid']}' AND replyto='0'");

			$db->update_query("threads", $update_subject, "tid='{$thread['tid']}'");
$db->update_query("posts", $update_subject, "tid='{$thread['tid']}' AND replyto='0'");

		}

$arguments = array("tids" => $tids, "format" => $format);

		}

$arguments = array("tids" => $tids, "format" => $format);

Zeile 2852Zeile 2901
	 * @return boolean true
*/
function toggle_post_softdelete($pids)

	 * @return boolean true
*/
function toggle_post_softdelete($pids)

	{
global $db;

	{
global $db;


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


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

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

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

			}
else

			}
else

			{
$restore[] = $post['pid'];
}
}
if(is_array($delete))

			{
$restore[] = $post['pid'];
}
}
if(is_array($delete))

		{

		{

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

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

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

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

			}
else

			}
else

			{
$approve[] = $thread['tid'];
}

			{
$approve[] = $thread['tid'];
}

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

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

			}

			}

			else
{
$restore[] = $thread['tid'];

			else
{
$restore[] = $thread['tid'];

Zeile 2954Zeile 3003
		if(is_array($restore))
{
$this->restore_threads($restore);

		if(is_array($restore))
{
$this->restore_threads($restore);

		}
return true;
}

/**

		}
return true;
}

/**

	 * Toggle threads open/closed
*
* @param array $tids Thread IDs

	 * Toggle threads open/closed
*
* @param array $tids Thread IDs

Zeile 3170Zeile 3219

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


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





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

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

Zeile 3277Zeile 3326
			$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 3317Zeile 3366
				update_user_counters($uid, array('postnum' => "{$counter}"));
}
}

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





		return true;
}


		return true;
}


Zeile 3334Zeile 3383
		$num_posts = 0;

if(empty($pids))

		$num_posts = 0;

if(empty($pids))

		{
return false;
}


		{
return false;
}


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


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


Zeile 3357Zeile 3406
		// 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 = '-1' AND t.firstpost = p.pid AND t.visible = -1
");
while($post = $db->fetch_array($query))

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

Zeile 3371Zeile 3420
		{
$this->restore_threads($threads_to_update);
}

		{
$this->restore_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 3389Zeile 3438
			{
$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 deleted then we've already taken into account this counter as implied.

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

// If the thread of this post is deleted then we've already taken into account this counter as implied.

Zeile 3405Zeile 3454
					);
}
++$forum_counters[$post['fid']]['num_posts'];

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

			}

			}


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


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

Zeile 3417Zeile 3466
				++$user_counters[$post['uid']];

}

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

}

		}


		}


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

if(!empty($pids))

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

if(!empty($pids))

		{

		{

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

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

Zeile 3442Zeile 3491
				);
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 3455Zeile 3504
				);
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)
{
update_user_counters($uid, array('postnum' => "+{$counter}"));
}

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

		}

		}


return true;
}


return true;
}

Zeile 3482Zeile 3531
		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 3494Zeile 3543

$tid_list = $forum_counters = $user_counters = $posts_to_restore = array();



$tid_list = $forum_counters = $user_counters = $posts_to_restore = array();


		foreach($tids as $tid)




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

while($thread = $db->fetch_array($query))

		{

		{

			$thread = get_thread($tid);
if(!$thread || $thread['visible'] != -1)

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


			{
continue;
}

			{
continue;
}

Zeile 3531Zeile 3582
			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='{$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 3608Zeile 3662
						"threadnum" => "+{$counters['num_threads']}",
);
update_user_counters($uid, $update_array);

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

				}
}
}

				}
}
}

		return true;
}


		return true;
}


Zeile 3648Zeile 3702

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



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


		foreach($tids as $tid)




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

while($thread = $db->fetch_array($query))

		{

		{

			$thread = get_thread($tid);

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

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

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

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

Zeile 3664Zeile 3720
						'num_deleted_posts' => 0,
'unapproved_threads' => 0,
'unapproved_posts' => 0

						'num_deleted_posts' => 0,
'unapproved_threads' => 0,
'unapproved_posts' => 0

					);

					);

				}

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

				}

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

Zeile 3694Zeile 3750
				// 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='{$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 3722Zeile 3781
		$query = $db->simple_select('threads', 'tid', "closed IN ({$tid_moved_list})");

mark_reports($tids, "threads");

		$query = $db->simple_select('threads', 'tid', "closed IN ({$tid_moved_list})");

mark_reports($tids, "threads");

		



		while($redirect_tid = $db->fetch_field($query, 'tid'))
{
$redirect_tids[] = $redirect_tid;

		while($redirect_tid = $db->fetch_field($query, 'tid'))
{
$redirect_tids[] = $redirect_tid;