Vergleich inc/class_moderation.php - 1.8.3 - 1.8.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 13Zeile 13
	/**
* Close one or more threads
*

	/**
* Close one or more threads
*

	 * @param array Thread IDs

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

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

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

Zeile 43Zeile 43
	/**
* Open one or more threads
*

	/**
* Open one or more threads
*

	 * @param int Thread IDs
* @return boolean true

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

	 */

function open_threads($tids)

	 */

function open_threads($tids)

Zeile 79Zeile 79
	/**
* Stick one or more threads
*

	/**
* Stick one or more threads
*

	 * @param int Thread IDs
* @return boolean true

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

	 */
function stick_threads($tids)
{

	 */
function stick_threads($tids)
{

Zeile 114Zeile 114
	/**
* Unstick one or more thread
*

	/**
* Unstick one or more thread
*

	 * @param int Thread IDs
* @return boolean true

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

	 */
function unstick_threads($tids)

	 */
function unstick_threads($tids)

	{
global $db, $plugins;


	{
global $db, $plugins;


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

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

		}

if(empty($tids))

		}

if(empty($tids))

		{
return false;
}

		{
return false;
}

Zeile 137Zeile 137
		$plugins->run_hooks("class_moderation_unstick_threads", $tids);

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

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

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





		$unstickthread = array(
"sticky" => 0,
);

		$unstickthread = array(
"sticky" => 0,
);

Zeile 149Zeile 149
	/**
* Remove redirects that redirect to the specified thread
*

	/**
* Remove redirects that redirect to the specified thread
*

	 * @param int Thread ID of the thread
* @return boolean true

	 * @param int $tid Thread ID of the thread
* @return boolean

	 */
function remove_redirects($tid)
{
global $db, $plugins;

	 */
function remove_redirects($tid)
{
global $db, $plugins;





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

// Delete the redirects
$tid = (int)$tid;
if(empty($tid))

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

// Delete the redirects
$tid = (int)$tid;
if(empty($tid))

		{
return false;
}

		{
return false;
}


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


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

		}


		}


		return true;
}

/**
* Delete a thread
*

		return true;
}

/**
* Delete a thread
*

	 * @param int Thread ID of the thread
* @return boolean true

	 * @param int $tid Thread ID of the thread
* @return boolean

	 */
function delete_thread($tid)
{

	 */
function delete_thread($tid)
{

Zeile 221Zeile 221
			elseif($post['visible'] == -1 || $thread['visible'] == -1)
{
$num_deleted_posts++;

			elseif($post['visible'] == -1 || $thread['visible'] == -1)
{
$num_deleted_posts++;

			}

			}

			else
{
$num_approved_posts++;

			else
{
$num_approved_posts++;

Zeile 234Zeile 234
						$userposts[$post['uid']]['num_posts'] = 0;
}
++$userposts[$post['uid']]['num_posts'];

						$userposts[$post['uid']]['num_posts'] = 0;
}
++$userposts[$post['uid']]['num_posts'];

				}

				}

			}
}

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

			}
}

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

			{

			{

				$userposts[$thread['uid']]['num_threads'] = 0;
}
++$userposts[$thread['uid']]['num_threads'];

				$userposts[$thread['uid']]['num_threads'] = 0;
}
++$userposts[$thread['uid']]['num_threads'];

Zeile 269Zeile 269
			$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 277Zeile 277
		while($redirect_tid = $db->fetch_field($query, 'tid'))
{
$this->delete_thread($redirect_tid);

		while($redirect_tid = $db->fetch_field($query, 'tid'))
{
$this->delete_thread($redirect_tid);

		}

		}

		$db->delete_query("threadsubscriptions", "tid='$tid'");
$db->delete_query("polls", "tid='$tid'");
$db->delete_query("pollvotes", "pid='".$thread['poll']."'");

		$db->delete_query("threadsubscriptions", "tid='$tid'");
$db->delete_query("polls", "tid='$tid'");
$db->delete_query("pollvotes", "pid='".$thread['poll']."'");

Zeile 299Zeile 299
			$updated_counters['deletedthreads'] = -1;
}
else

			$updated_counters['deletedthreads'] = -1;
}
else

		{

		{

			$updated_counters['unapprovedthreads'] = -1;
}


			$updated_counters['unapprovedthreads'] = -1;
}


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

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

			}

			}

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

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

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

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



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


Zeile 332Zeile 333
	/**
* Delete a poll
*

	/**
* Delete a poll
*

	 * @param int Poll id
* @return boolean true

	 * @param int $pid Poll id
* @return boolean

	 */
function delete_poll($pid)

	 */
function delete_poll($pid)

	{

	{

		global $db, $plugins;

$pid = (int)$pid;

		global $db, $plugins;

$pid = (int)$pid;

Zeile 345Zeile 346
		{
return false;
}

		{
return false;
}





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

$db->delete_query("polls", "pid='$pid'");

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

$db->delete_query("polls", "pid='$pid'");

Zeile 354Zeile 355
			'poll' => '0',
);
$db->update_query("threads", $pollarray, "poll='$pid'");

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





		return true;
}

/**
* Approve one or more threads
*

		return true;
}

/**
* Approve one or more threads
*

	 * @param array Thread IDs
* @return boolean true

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

	 */
function approve_threads($tids)
{

	 */
function approve_threads($tids)
{

Zeile 502Zeile 503
	/**
* Unapprove one or more threads
*

	/**
* Unapprove one or more threads
*

	 * @param array Thread IDs
* @return boolean true

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

	 */
function unapprove_threads($tids)

	 */
function unapprove_threads($tids)

	{
global $db, $cache, $plugins;


	{
global $db, $cache, $plugins;


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

if(empty($tids))

		if(!is_array($tids))
{
$tids = array($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 = implode(',', $tids);
$tid_moved_list = "";
$comma = "";

		$tid_list = implode(',', $tids);
$tid_moved_list = "";
$comma = "";

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

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

				{

				{

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

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

Zeile 561Zeile 562
				}

++$forum_counters[$forum['fid']]['num_unapprovedthreads'];

				}

++$forum_counters[$forum['fid']]['num_unapprovedthreads'];

				$forum_counters[$forum['fid']]['num_unapprovedposts'] += $thread['replies']+$thread['deletedposts']+1;

				$forum_counters[$forum['fid']]['num_unapprovedposts'] += $thread['replies']+$thread['deletedposts']+1;


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


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

Zeile 593Zeile 594

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


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

		}

		}


$approve = array(
"visible" => 0


$approve = array(
"visible" => 0

Zeile 613Zeile 614
		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)

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

Zeile 653Zeile 654
	/**
* Delete a specific post
*

	/**
* Delete a specific post
*

	 * @param int Post ID
* @return boolean true

	 * @param int $pid Post ID
* @return boolean

	 */
function delete_post($pid)
{

	 */
function delete_post($pid)
{

Zeile 671Zeile 672
		");
$post = $db->fetch_array($query);
if(!$post)

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

		{
return false;

		{
return false;

		}

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

		}

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

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

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

		}


		}


		// Remove attachments
remove_attachments($pid);


		// Remove attachments
remove_attachments($pid);


Zeile 698Zeile 699

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


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

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

		}
else
{

Zeile 726Zeile 727
		{
$update_array = array(
"unapprovedposts" => "-1"

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

			);
}

			);
}

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

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

Zeile 750Zeile 751
	/**
* Merge posts within thread
*

	/**
* Merge posts within thread
*

	 * @param array Post IDs to be merged
* @param int Thread ID (Set to 0 if posts from multiple threads are
* selected)

	 * @param array $pids Post IDs to be merged
* @param int $tid Thread ID (Set to 0 if posts from multiple threads are selected)


	 * @return int ID of the post into which all other posts are merged
*/
function merge_posts($pids, $tid=0, $sep="new_line")

	 * @return int ID of the post into which all other posts are merged
*/
function merge_posts($pids, $tid=0, $sep="new_line")

Zeile 802Zeile 802
				$fid = $post['fid'];
$mastertid = $post['tid'];
$first = 0;

				$fid = $post['fid'];
$mastertid = $post['tid'];
$first = 0;

 
				$visible = $post['visible'];

			}
else
{

			}
else
{

Zeile 845Zeile 846
					{
--$user_counters[$post['uid']]['num_threads'];
}

					{
--$user_counters[$post['uid']]['num_threads'];
}

 
					$thread_counters[$post['tid']]['attachmentcount'] -= $post['attachmentcount'];

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

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

Zeile 856Zeile 858
					// Subtract 1 deleted post from post's thread
--$thread_counters[$post['tid']]['deletedposts'];
}

					// Subtract 1 deleted post from post's thread
--$thread_counters[$post['tid']]['deletedposts'];
}

				$thread_counters[$post['tid']]['attachmentcount'] -= $post['attachmentcount'];

 

// Subtract 1 post from post's forum
if($post['threadvisible'] == 1 && $post['visible'] == 1)


// Subtract 1 post from post's forum
if($post['threadvisible'] == 1 && $post['visible'] == 1)

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

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

 
				}

// Add attachment count to thread
if($visible == 1)
{
$thread_counters[$mastertid]['attachmentcount'] += $post['attachmentcount'];

				}
}
}

				}
}
}

Zeile 953Zeile 960
					'unapprovedposts' => signed($counters['unapprovedposts']),
'deletedposts' => signed($counters['deletedposts']),
'attachmentcount' => signed($counters['attachmentcount'])

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

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

if(!empty($forum_counters))
{

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

if(!empty($forum_counters))
{

			foreach($forum_counters as $fid => $counters)
{
$updated_forum_stats = array(
'posts' => signed($counters['num_posts']),
'unapprovedposts' => signed($counters['unapprovedposts']),
'deletedposts' => signed($counters['deletedposts'])

			foreach($forum_counters as $fid => $counters)
{
$updated_forum_stats = array(
'posts' => signed($counters['num_posts']),
'unapprovedposts' => signed($counters['unapprovedposts']),
'deletedposts' => signed($counters['deletedposts'])

				);

				);

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

if(!empty($user_counters))

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

if(!empty($user_counters))

		{

		{

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

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

Zeile 987Zeile 994

return $masterpid;
}


return $masterpid;
}





	/**
* Move/copy thread
*

	/**
* Move/copy thread
*

	 * @param int Thread to be moved
* @param int Destination forum
* @param string Method of movement (redirect, copy, move)
* @param int Expiry timestamp for redirect

	 * @param int $tid Thread to be moved
* @param int $new_fid Destination forum
* @param string $method Method of movement (redirect, copy, move)
* @param int $redirect_expire Expiry timestamp for redirect

	 * @return int Thread ID
*/
function move_thread($tid, $new_fid, $method="redirect", $redirect_expire=0)

	 * @return int Thread ID
*/
function move_thread($tid, $new_fid, $method="redirect", $redirect_expire=0)

Zeile 1017Zeile 1024
		$forum = get_forum($fid);

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

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

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

Zeile 1026Zeile 1033
			$num_deleted_posts = $thread['deletedposts'];
}
elseif($thread['visible'] == -1)

			$num_deleted_posts = $thread['deletedposts'];
}
elseif($thread['visible'] == -1)

		{

		{

			$num_deleted_threads++;
// Implied forum deleted count for deleted threads
$num_deleted_posts = $thread['replies']+$thread['deletedposts']+$thread['unapprovedposts']+1;

			$num_deleted_threads++;
// Implied forum deleted count for deleted threads
$num_deleted_posts = $thread['replies']+$thread['deletedposts']+$thread['unapprovedposts']+1;

		}

		}

		else
{
$num_unapproved_threads++;

		else
{
$num_unapproved_threads++;

Zeile 1054Zeile 1061
				);
$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(


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

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

Zeile 1224Zeile 1231
							'pid' => $pid,
'uid' => $attachment['uid'],
'filename' => $db->escape_string($attachment['filename']),

							'pid' => $pid,
'uid' => $attachment['uid'],
'filename' => $db->escape_string($attachment['filename']),

							'filetype' => $attachment['filetype'],

							'filetype' => $db->escape_string($attachment['filetype']),

							'filesize' => $attachment['filesize'],

							'filesize' => $attachment['filesize'],

							'attachname' => $attachment['attachname'],

							'attachname' => $db->escape_string($attachment['attachname']),

							'downloads' => $attachment['downloads'],
'visible' => $attachment['visible'],

							'downloads' => $attachment['downloads'],
'visible' => $attachment['visible'],

							'thumbnail' => $attachment['thumbnail']
);

							'thumbnail' => $db->escape_string($attachment['thumbnail'])
);

						$new_aid = $db->insert_query("attachments", $attachment_array);

$post['message'] = str_replace("[attachment={$attachment['aid']}]", "[attachment={$new_aid}]", $post['message']);

						$new_aid = $db->insert_query("attachments", $attachment_array);

$post['message'] = str_replace("[attachment={$attachment['aid']}]", "[attachment={$new_aid}]", $post['message']);

Zeile 1388Zeile 1395
	/**
* Merge one thread into another
*

	/**
* Merge one thread into another
*

	 * @param int Thread that will be merged into destination
* @param int Destination thread
* @param string New thread subject
* @return boolean true

	 * @param int $mergetid Thread that will be merged into destination
* @param int $tid Destination thread
* @param string $subject New thread subject
* @return boolean

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

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

Zeile 1560Zeile 1567
		if($new_firstpost['pid'] != $thread['firstpost'])
{
update_first_post($thread['tid']);

		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
if($thread['uid'] != $new_firstpost['uid'] && $thread['visible'] == 1 && $forum_cache[$thread['fid']]['usethreadcounts'] == 1)
{
if(!isset($user_posts[$thread['uid']]['threadnum']))

		}

// 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)
{
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[$thread['uid']]['threadnum'] = 0;
}
--$user_posts[$thread['uid']]['threadnum'];
if(!isset($user_posts[$new_firstpost['uid']]['threadnum']))

			{

			{

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

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

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

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

				);
}

				);
}

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

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

Zeile 1609Zeile 1606
					"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);

// If old thread is unapproved, implied counter comes in to effect

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

// If old thread is unapproved, implied counter comes in to effect

Zeile 1687Zeile 1684
			if($updated_stats['unapprovedposts'] < 0)
{
$new_stats['unapprovedposts'] = $updated_stats['unapprovedposts'];

			if($updated_stats['unapprovedposts'] < 0)
{
$new_stats['unapprovedposts'] = $updated_stats['unapprovedposts'];

			}

			}

			elseif($updated_stats['unapprovedposts'] > 0)
{
$new_stats['unapprovedposts'] = "+{$updated_stats['unapprovedposts']}";

			elseif($updated_stats['unapprovedposts'] > 0)
{
$new_stats['unapprovedposts'] = "+{$updated_stats['unapprovedposts']}";

Zeile 1766Zeile 1763
	/**
* Split posts into a new/existing thread
*

	/**
* Split posts into a new/existing thread
*

	 * @param array PIDs of posts to split
* @param int Original thread ID (this is only used as a base for the new

	 * @param array $pids PIDs of posts to split
* @param int $tid Original thread ID (this is only used as a base for the new

	 * thread; it can be set to 0 when the posts specified are coming from more
* than 1 thread)

	 * thread; it can be set to 0 when the posts specified are coming from more
* than 1 thread)

	 * @param int Destination forum
* @param string New thread subject
* @param int TID if moving into existing thread
* @return int New thread ID

	 * @param int $moveto Destination forum
* @param string $newsubject New thread subject
* @param int $destination_tid TID if moving into existing thread
* @return int|bool New thread ID or false on failure

	 */
function split_posts($pids, $tid, $moveto, $newsubject, $destination_tid=0)
{

	 */
function split_posts($pids, $tid, $moveto, $newsubject, $destination_tid=0)
{

Zeile 1842Zeile 1839
						'threadnum' => 0
);
}

						'threadnum' => 0
);
}

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

				++$user_counters[$newthread['uid']]['threadnum'];


			}
elseif($visible == -1)
{
++$forum_counters[$moveto]['deletedthreads'];
}
else

			}
elseif($visible == -1)
{
++$forum_counters[$moveto]['deletedthreads'];
}
else

			{

			{

				// Unapproved thread?
++$forum_counters[$moveto]['unapprovedthreads'];

				// Unapproved thread?
++$forum_counters[$moveto]['unapprovedthreads'];

			}
}

			}
}

		else
{
$newthread = get_thread($newtid);

		else
{
$newthread = get_thread($newtid);

Zeile 1864Zeile 1860
			}
$moveto = $newthread['fid'];
}

			}
$moveto = $newthread['fid'];
}





		// 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, p.dateline, t.visible as threadvisible, t.firstpost, COUNT(a.aid) as postattachmentcount

		// 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, p.dateline, t.visible as threadvisible, t.firstpost, COUNT(a.aid) as postattachmentcount

Zeile 1888Zeile 1884
			'unapprovedposts' => 0,
'deletedposts' => 0,
'attachmentcount' => 0

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

		);

		);


// Get posts being merged
while($post = $db->fetch_array($original_posts_query))


// Get posts being merged
while($post = $db->fetch_array($original_posts_query))

Zeile 2109Zeile 2105
		}

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

Zeile 2213Zeile 2209
	/**
* Move multiple threads to new forum
*

	/**
* Move multiple threads to new forum
*

	 * @param array Thread IDs
* @param int Destination forum
* @return boolean true

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

	 */
function move_threads($tids, $moveto)
{

	 */
function move_threads($tids, $moveto)
{

Zeile 2254Zeile 2250
				);
}


				);
}


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

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

			{

			{

				$user_counters[$thread['uid']]['num_threads'] = 0;




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

			}

			}





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

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

Zeile 2267Zeile 2266
				$forum_counters[$thread['fid']]['posts'] += $thread['replies']+1;
$forum_counters[$thread['fid']]['unapprovedposts'] += $thread['unapprovedposts'];
$forum_counters[$thread['fid']]['deletedposts'] += $thread['deletedposts'];

				$forum_counters[$thread['fid']]['posts'] += $thread['replies']+1;
$forum_counters[$thread['fid']]['unapprovedposts'] += $thread['unapprovedposts'];
$forum_counters[$thread['fid']]['deletedposts'] += $thread['deletedposts'];





				$forum_counters[$thread['fid']]['threads']++;
++$total_threads;


				$forum_counters[$thread['fid']]['threads']++;
++$total_threads;


Zeile 2278Zeile 2277
				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
FROM ".TABLE_PREFIX."posts p

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

Zeile 2290Zeile 2289
				");
while($posters = $db->fetch_array($query1))
{

				");
while($posters = $db->fetch_array($query1))
{

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

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

					{

					{

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




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

					}

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

					}

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

Zeile 2322Zeile 2324

$forum_counters[$thread['fid']]['unapprovedthreads']++;
++$total_unapproved_threads;


$forum_counters[$thread['fid']]['unapprovedthreads']++;
++$total_unapproved_threads;

			}


			}


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

Zeile 2337Zeile 2339
		);
$db->update_query("threads", $sqlarray, "tid IN ($tid_list)");
$db->update_query("posts", $sqlarray, "tid IN ($tid_list)");

		);
$db->update_query("threads", $sqlarray, "tid IN ($tid_list)");
$db->update_query("posts", $sqlarray, "tid IN ($tid_list)");





		// If any of the thread has a prefix and the destination forum doesn't accept that prefix, remove the prefix
$query = $db->simple_select("threads", "tid, prefix", "tid IN ($tid_list) AND prefix != 0");
while($thread = $db->fetch_array($query))
{
switch($db->type)

		// If any of the thread has a prefix and the destination forum doesn't accept that prefix, remove the prefix
$query = $db->simple_select("threads", "tid, prefix", "tid IN ($tid_list) AND prefix != 0");
while($thread = $db->fetch_array($query))
{
switch($db->type)

			{

			{

				case "pgsql":
case "sqlite":
$query = $db->simple_select("threadprefixes", "COUNT(*) as num_prefixes", "(','||forums||',' LIKE '%,$moveto,%' OR forums='-1') AND pid='".$thread['prefix']."'");

				case "pgsql":
case "sqlite":
$query = $db->simple_select("threadprefixes", "COUNT(*) as num_prefixes", "(','||forums||',' LIKE '%,$moveto,%' OR forums='-1') AND pid='".$thread['prefix']."'");

Zeile 2361Zeile 2363
		}

$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 2389Zeile 2391

);
update_forum_counters($fid, $updated_count);


);
update_forum_counters($fid, $updated_count);

				update_forum_lastpost($fid);
}
}


				update_forum_lastpost($fid);
}
}


		$updated_count = array(
"threads" => "+{$total_threads}",
"unapprovedthreads" => "+{$total_unapproved_threads}",

		$updated_count = array(
"threads" => "+{$total_threads}",
"unapprovedthreads" => "+{$total_unapproved_threads}",

Zeile 2414Zeile 2416
	/**
* Approve multiple posts
*

	/**
* Approve multiple posts
*

	 * @param array PIDs
* @return boolean true

	 * @param array $pids PIDs
* @return boolean

	 */
function approve_posts($pids)
{

	 */
function approve_posts($pids)
{

Zeile 2430Zeile 2432

// 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 2444Zeile 2446
		// 1.1) if the thread is approved
// 1.2) if the thread is unapproved
// 2) We're approving the firstpost of the thread, therefore approving the thread itself

		// 1.1) if the thread is approved
// 1.2) if the thread is unapproved
// 2) We're approving the firstpost of the thread, therefore approving the thread itself

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

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

			WHERE p.pid IN ($pid_list) AND p.visible = '0' AND t.firstpost = p.pid AND t.visible = 0
");
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'];

			WHERE p.pid IN ($pid_list) AND p.visible = '0' AND t.firstpost = p.pid AND t.visible = 0
");
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))
{


if(!empty($threads_to_update))
{

Zeile 2500Zeile 2502

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

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

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

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

				}
++$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_approve_posts", $pids);

if(!empty($thread_counters))

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

if(!empty($thread_counters))

Zeile 2532Zeile 2534
				);
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 2545Zeile 2547
				);
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;
}


/**
* Unapprove multiple posts
*


/**
* Unapprove multiple posts
*

	 * @param array PIDs
* @return boolean true

	 * @param array $pids PIDs
* @return boolean

	 */
function unapprove_posts($pids)
{

	 */
function unapprove_posts($pids)
{

Zeile 2668Zeile 2670

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

			{

			{

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

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

Zeile 2733Zeile 2735
	/**
* Change thread subject
*

	/**
* Change thread subject
*

	 * @param mixed Thread ID(s)
* @param string Format of new subject (with {subject})
* @return boolean true

	 * @param int|array $tids Thread ID(s)
* @param string $format Format of new subject (with {subject})
* @return boolean

	 */
function change_thread_subject($tids, $format)
{

	 */
function change_thread_subject($tids, $format)
{

Zeile 2745Zeile 2747
		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);


Zeile 2780Zeile 2782
	/**
* Add thread expiry
*

	/**
* Add thread expiry
*

	 * @param int Thread ID
* @param int Timestamp when the thread is deleted
* @return boolean true

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

	 */
function expire_thread($tid, $deletetime)
{

	 */
function expire_thread($tid, $deletetime)
{

Zeile 2809Zeile 2811
	/**
* Toggle post visibility (approved/unapproved)
*

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

	 * @param array Post IDs

	 * @param array $pids Post IDs

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

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

Zeile 2846Zeile 2848
	/**
* Toggle post visibility (deleted/restored)
*

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

	 * @param array Post IDs

	 * @param array $pids Post IDs

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

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

Zeile 2883Zeile 2885
	/**
* Toggle thread visibility (approved/unapproved)
*

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

	 * @param array Thread IDs
* @param int Forum ID

	 * @param array $tids Thread IDs
* @param int $fid Forum ID

	 * @return boolean true
*/
function toggle_thread_visibility($tids, $fid)

	 * @return boolean true
*/
function toggle_thread_visibility($tids, $fid)

Zeile 2922Zeile 2924
	/**
* Toggle thread visibility (deleted/restored)
*

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

	 * @param array Thread IDs
* @param int Forum ID

	 * @param array $tids Thread IDs


	 * @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)");

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

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

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

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

			}
else

			}
else

			{
$restore[] = $thread['tid'];
}
}
if(is_array($delete))
{

			{
$restore[] = $thread['tid'];
}
}
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 2961Zeile 2961
	/**
* Toggle threads open/closed
*

	/**
* Toggle threads open/closed
*

	 * @param array Thread IDs

	 * @param array $tids Thread IDs

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

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

Zeile 2976Zeile 2976
		while($thread = $db->fetch_array($query))
{
if($thread['closed'] == 1)

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

			{

			{

				$open[] = $thread['tid'];
}
elseif($thread['closed'] == 0)

				$open[] = $thread['tid'];
}
elseif($thread['closed'] == 0)

Zeile 2998Zeile 2998
	/**
* Toggle threads stick/unstick
*

	/**
* Toggle threads stick/unstick
*

	 * @param array Thread IDs

	 * @param array $tids Thread IDs

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

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

Zeile 3038Zeile 3038
	/**
* Remove thread subscriptions (from one or multiple threads in the same forum)
*

	/**
* Remove thread subscriptions (from one or multiple threads in the same forum)
*

	 * @param int $tids Thread ID, or an array of thread IDs from the same forum.

	 * @param int|array $tids Thread ID, or an array of thread IDs from the same forum.

	 * @param boolean $all True (default) to delete all subscriptions, false to only delete subscriptions from users with no permission to read the thread
* @param int $fid (Only applies if $all is false) The forum ID of the thread

	 * @param boolean $all True (default) to delete all subscriptions, false to only delete subscriptions from users with no permission to read the thread
* @param int $fid (Only applies if $all is false) The forum ID of the thread

	 * @return boolean true

	 * @return boolean

	 */
function remove_thread_subscriptions($tids, $all = true, $fid = 0)

	 */
function remove_thread_subscriptions($tids, $all = true, $fid = 0)

	{
global $db, $plugins;

// Format thread IDs
if(!is_array($tids))
{
$tids = array($tids);
}

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

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

	{
global $db, $plugins;

// Format thread IDs
if(!is_array($tids))
{
$tids = array($tids);
}

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

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

		$fid = (int)$fid;

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

		$fid = (int)$fid;

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

Zeile 3071Zeile 3071
			$forum_parentlist = get_parent_list($fid);
$query = $db->simple_select("forumpermissions", "gid", "fid IN ({$forum_parentlist}) AND (canview=0 OR canviewthreads=0)");
$groups = array();

			$forum_parentlist = get_parent_list($fid);
$query = $db->simple_select("forumpermissions", "gid", "fid IN ({$forum_parentlist}) AND (canview=0 OR canviewthreads=0)");
$groups = array();

 
			$additional_groups = '';

			while($group = $db->fetch_array($query))
{
$groups[] = $group['gid'];

			while($group = $db->fetch_array($query))
{
$groups[] = $group['gid'];

Zeile 3098Zeile 3099
				while($subscription = $db->fetch_array($query))
{
$db->delete_query("threadsubscriptions", "uid='{$subscription['uid']}' AND tid='{$subscription['tid']}'");

				while($subscription = $db->fetch_array($query))
{
$db->delete_query("threadsubscriptions", "uid='{$subscription['uid']}' AND tid='{$subscription['tid']}'");

				}
}

				}
}

		}
// Delete all subscriptions of this thread
else

		}
// Delete all subscriptions of this thread
else

Zeile 3116Zeile 3117
	/**
* Apply a thread prefix (to one or multiple threads in the same forum)
*

	/**
* Apply a thread prefix (to one or multiple threads in the same forum)
*

	 * @param int $tids Thread ID, or an array of thread IDs from the same forum.

	 * @param int|array $tids Thread ID, or an array of thread IDs from the same forum.

	 * @param int $prefix Prefix ID to apply to the threads

	 * @param int $prefix Prefix ID to apply to the threads

 
	 * @return bool

	 */
function apply_thread_prefix($tids, $prefix = 0)
{

	 */
function apply_thread_prefix($tids, $prefix = 0)
{

Zeile 3151Zeile 3153
	/**
* Soft delete multiple posts
*

	/**
* Soft delete multiple posts
*

	 * @param array PIDs
* @return boolean true

	 * @param array $pids PIDs
* @return boolean

	 */
function soft_delete_posts($pids)
{

	 */
function soft_delete_posts($pids)
{

Zeile 3183Zeile 3185
		// 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

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

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

Zeile 3262Zeile 3264
					$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))

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

 
			mark_reports($pids, "posts");

		}

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

		}

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

Zeile 3290Zeile 3293

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 3304Zeile 3307
				);
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 3320Zeile 3323

/**
* Restore multiple posts


/**
* Restore multiple posts

	 *
* @param array PIDs
* @return boolean true

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

	 */
function restore_posts($pids)
{

	 */
function restore_posts($pids)
{

Zeile 3469Zeile 3472
	/**
* Restore one or more threads
*

	/**
* Restore one or more threads
*

	 * @param array Thread IDs

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

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

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

	{
global $db, $cache, $plugins;

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

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

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

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

foreach($tids as $tid)

	{
global $db, $cache, $plugins;

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

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

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

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

foreach($tids as $tid)

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

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

Zeile 3603Zeile 3606
					$update_array = array(
"postnum" => "+{$counters['num_posts']}",
"threadnum" => "+{$counters['num_threads']}",

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

					);

					);

					update_user_counters($uid, $update_array);
}
}
}
return true;
}

					update_user_counters($uid, $update_array);
}
}
}
return true;
}





	/**
* Soft delete one or more threads
*

	/**
* Soft delete one or more threads
*

	 * @param array Thread IDs
* @return boolean true

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

	 */
function soft_delete_threads($tids)
{

	 */
function soft_delete_threads($tids)
{

Zeile 3633Zeile 3636

// 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);
$tid_moved_list = "";
$comma = "";

		$tid_list = implode(',', $tids);
$tid_moved_list = "";
$comma = "";

Zeile 3661Zeile 3664
						'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 3674Zeile 3677

++$forum_counters[$forum['fid']]['num_deleted_threads'];
$forum_counters[$forum['fid']]['num_deleted_posts'] += $thread['replies']+$thread['unapprovedposts']+1;


++$forum_counters[$forum['fid']]['num_deleted_threads'];
$forum_counters[$forum['fid']]['num_deleted_posts'] += $thread['replies']+$thread['unapprovedposts']+1;





				if($thread['visible'] == 1)
{
++$forum_counters[$forum['fid']]['num_threads'];

				if($thread['visible'] == 1)
{
++$forum_counters[$forum['fid']]['num_threads'];

Zeile 3709Zeile 3712
			}
$posts_to_delete[] = $thread['firstpost'];
}

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





		$update = array(
"visible" => -1
);

		$update = array(
"visible" => -1
);

Zeile 3717Zeile 3720
		// Soft delete redirects, too
$redirect_tids = array();
$query = $db->simple_select('threads', 'tid', "closed IN ({$tid_moved_list})");

		// Soft delete redirects, too
$redirect_tids = array();
$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;