Vergleich inc/class_moderation.php - 1.2.8 - 1.2.11

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html
*

 * $Id: class_moderation.php 3171 2007-06-29 04:57:39Z chris $

 * $Id: class_moderation.php 3548 2007-12-14 04:08:59Z dennis $

 */

class Moderation

 */

class Moderation

Zeile 144Zeile 144
		global $db, $cache, $plugins;

$thread = get_thread($tid);

		global $db, $cache, $plugins;

$thread = get_thread($tid);

 

$userposts = array();


// Find the pid, uid, visibility, and forum post count status
$query = $db->query("


// Find the pid, uid, visibility, and forum post count status
$query = $db->query("

Zeile 186Zeile 188
		if($usepostcounts != "no")
{
if(is_array($userposts))

		if($usepostcounts != "no")
{
if(is_array($userposts))

			{

			{

				foreach($userposts as $uid => $subtract)
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$subtract WHERE uid='$uid'");

				foreach($userposts as $uid => $subtract)
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$subtract WHERE uid='$uid'");

Zeile 216Zeile 218
		$db->delete_query(TABLE_PREFIX."favorites", "tid='$tid'");
$db->delete_query(TABLE_PREFIX."polls", "tid='$tid'");
$db->delete_query(TABLE_PREFIX."pollvotes", "pid='".$thread['poll']."'");

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

		$updated_counters = array( 

		$updated_counters = array(

			"posts" => "-{$num_approved_posts}", 
"unapprovedposts" => "-{$num_unapproved_posts}"

			"posts" => "-{$num_approved_posts}", 
"unapprovedposts" => "-{$num_unapproved_posts}"

		); 

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

		);

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

		
if(substr($thread['closed'], 0, 5) != "moved")

		
if(substr($thread['closed'], 0, 5) != "moved")

		{ 

		{

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

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

		} 

		}


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



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


Zeile 256Zeile 258
		$db->delete_query(TABLE_PREFIX."polls", "pid='$pid'");
$db->delete_query(TABLE_PREFIX."pollvotes", "pid='$pid'");
$pollarray = array(

		$db->delete_query(TABLE_PREFIX."polls", "pid='$pid'");
$db->delete_query(TABLE_PREFIX."pollvotes", "pid='$pid'");
$pollarray = array(

			"poll" => '',

			'poll' => '0',

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


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


Zeile 275Zeile 277
		global $db, $cache, $plugins;

if(!is_array($tids))

		global $db, $cache, $plugins;

if(!is_array($tids))

		{

		{

			$tids = array($tids);
}

			$tids = array($tids);
}

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

 
		
$num_threads = $num_posts = 0;
foreach($tids as $tid)
{

		
$num_threads = $num_posts = 0;
foreach($tids as $tid)
{

			$thread = get_thread($tid); 








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

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

			

			

			if($thread['visible'] == 0) 
{
$num_threads++;
$num_posts += $thread['replies']+1; // Remove implied visible from count
}
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid, p.visible
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='$tid' AND p.visible = '0'
");
while($post = $db->fetch_array($query))

			$num_threads++; 
$num_posts += $thread['replies']+1; // Remove implied visible from count

if($forum['usepostcounts'] != "no")









			{

			{

				// If post counts enabled in this forum and the post hasn't already been approved, remove 1
if($post['usepostcounts'] != "no")


				// On approving thread restore user post counts
$query = $db->simple_select(TABLE_PREFIX."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))

				{

				{

					$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='".$post['uid']."'");

					$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+{$counter['posts']} WHERE uid='".$counter['uid']."'");

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

}


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

}


		$approve = array(
"visible" => 1,
);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN (".implode(",", $posts_to_approve).")");

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

// Update stats
$update_array = array(
"threads" => "+{$num_threads}",
"unapprovedthreads" => "-{$num_threads}",
"posts" => "+{$num_posts}",
"unapprovedposts" => "-{$num_posts}"
);
update_forum_counters($fid, $update_array);






		if(is_array($tid_list))
{
$tid_list = implode(",", $tid_list);

$approve = array(
"visible" => 1,
);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $approve, "pid IN (".implode(",", $posts_to_approve).")");

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

// Update stats
$update_array = array(
"threads" => "+{$num_threads}",
"unapprovedthreads" => "-{$num_threads}",
"posts" => "+{$num_posts}",
"unapprovedposts" => "-{$num_posts}"
);
update_forum_counters($fid, $update_array);
}

		return true;
}


		return true;
}


Zeile 336Zeile 341
	 * @return boolean true
*/
function unapprove_threads($tids, $fid)

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

	{
global $db, $cache, $plugins;


	{
global $db, $cache, $plugins;


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

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

Zeile 376Zeile 381
			"visible" => 0,
);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");

			"visible" => 0,
);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");

		$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN (".implode(",", $posts_to_unapprove).")");

		$db->update_query(TABLE_PREFIX."posts", $approve, "pid IN (".implode(",", $posts_to_unapprove).")");


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

// Update stats


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

// Update stats

		$update_array = array( 

		$update_array = array( 

			"threads" => "-{$num_threads}", 
"unapprovedthreads" => "+{$num_threads}",
"posts" => "-{$num_posts}",

			"threads" => "-{$num_threads}", 
"unapprovedthreads" => "+{$num_threads}",
"posts" => "-{$num_posts}",

Zeile 423Zeile 428
		$num_unapproved_posts = $num_approved_posts = 0;
// Update unapproved post count
if($post['visible'] == 0)

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

		{

		{

			$db->query("UPDATE ".TABLE_PREFIX."forums SET unapprovedposts=unapprovedposts-1 WHERE fid='{$post['fid']}'");
$db->query("UPDATE ".TABLE_PREFIX."threads SET unapprovedposts=unapprovedposts-1 WHERE tid='{$post['tid']}'");
$num_unaproved_posts--;

			$db->query("UPDATE ".TABLE_PREFIX."forums SET unapprovedposts=unapprovedposts-1 WHERE fid='{$post['fid']}'");
$db->query("UPDATE ".TABLE_PREFIX."threads SET unapprovedposts=unapprovedposts-1 WHERE tid='{$post['tid']}'");
$num_unaproved_posts--;

Zeile 464Zeile 469
	{
global $db, $plugins;


	{
global $db, $plugins;


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

		$pidin = implode(",", array_map("intval", $pids));

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

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

Zeile 508Zeile 513
				elseif($post['visible'] == 0) 
{
$num_unapproved_posts++;

				elseif($post['visible'] == 0) 
{
$num_unapproved_posts++;

				}

				}

			}
}


			}
}


Zeile 528Zeile 533
		);
$db->update_query(TABLE_PREFIX."posts", $mergepost2, "pid IN($pidin)");
$db->update_query(TABLE_PREFIX."attachments", $mergepost2, "pid IN($pidin)");

		);
$db->update_query(TABLE_PREFIX."posts", $mergepost2, "pid IN($pidin)");
$db->update_query(TABLE_PREFIX."attachments", $mergepost2, "pid IN($pidin)");





		$plugins->run_hooks("class_moderation_merge_posts", array("pids" => $pids, "tid" => $tid));

// Update stats

		$plugins->run_hooks("class_moderation_merge_posts", array("pids" => $pids, "tid" => $tid));

// Update stats

Zeile 586Zeile 591
				$num_posts = $thread['replies']+1; 
$num_unapproved_posts += $thread['unapprovedposts'];


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


				$db->delete_query(TABLE_PREFIX."threads", "closed='moved|$tid' AND fid='$moveto'");

				$db->delete_query(TABLE_PREFIX."threads", "closed='moved|$tid' AND fid='{$new_fid}'");

				$changefid = array(
"fid" => $new_fid,
);

				$changefid = array(
"fid" => $new_fid,
);

Zeile 634Zeile 639
					"sticky" => $thread['sticky'],
"visible" => $thread['visible'],
"unapprovedposts" => $thread['unapprovedposts'],

					"sticky" => $thread['sticky'],
"visible" => $thread['visible'],
"unapprovedposts" => $thread['unapprovedposts'],

 
					"attachmentcount" => $thread['attachmentcount'],

					"notes" => ''
);

					"notes" => ''
);

 



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


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

				{

				{

					++$num_threads;

					++$num_threads;

 
					$num_posts = $thread['replies']+1;

// Fetch count of unapproved posts in this thread
$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(pid) AS unapproved", "tid='{$thread['tid']}' AND visible=0");
$num_unapproved_posts = $db->fetch_field($query, "unapproved");


				}
else
{
$num_unapproved_threads++;

				}
else
{
$num_unapproved_threads++;

					// Implied forum unapproved count for unapproved threads

 
					$num_unapproved_posts = $thread['replies']+1;
}


					$num_unapproved_posts = $thread['replies']+1;
}


Zeile 675Zeile 687

$query = $db->simple_select(TABLE_PREFIX."pollvotes", "*", "pid = '{$poll['pid']}'");
while($pollvote = $db->fetch_array($query))


$query = $db->simple_select(TABLE_PREFIX."pollvotes", "*", "pid = '{$poll['pid']}'");
while($pollvote = $db->fetch_array($query))

					{

					{

						$pollvote_array = array(
'pid' => $new_pid,
'uid' => $pollvote['uid'],

						$pollvote_array = array(
'pid' => $new_pid,
'uid' => $pollvote['uid'],

Zeile 737Zeile 749
			default:
case "move": // plain move thread
$plugins->run_hooks("class_moderation_move_simple", array("tid" => $tid, "new_fid" => $new_fid));

			default:
case "move": // plain move thread
$plugins->run_hooks("class_moderation_move_simple", array("tid" => $tid, "new_fid" => $new_fid));

	

	

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

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

				{ 

				{ 

					$num_threads++; 
}
else

					$num_threads++; 
}
else

Zeile 758Zeile 770
				$db->update_query(TABLE_PREFIX."threads", $sqlarray, "tid='$tid'");
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "tid='$tid'");
break;

				$db->update_query(TABLE_PREFIX."threads", $sqlarray, "tid='$tid'");
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "tid='$tid'");
break;

		}

		}


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


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

Zeile 838Zeile 850
		$tid = intval($tid);

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

		$tid = intval($tid);

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

		{			
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='{$mergetid}'");
$mergethread = $db->fetch_array($query);

		{	
$mergethread = get_thread($mergetid);


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

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

			$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='{$tid}'");
$thread = $db->fetch_array($query);

			$thread = get_thread($tid);


		}
$pollsql = '';
if($mergethread['poll'])

		}
$pollsql = '';
if($mergethread['poll'])

Zeile 893Zeile 903
		$this->delete_thread($mergetid);

$updated_stats = array(

		$this->delete_thread($mergetid);

$updated_stats = array(

			"replies" => '+'.$mergethread['replies']+1, 

			"replies" => '+'.($mergethread['replies']+1), 

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

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



		

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

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

		{
// If old thread was unapproved, implied counter for old forum needs updating
if($mergethread['visible'] == 0)
{
$updated_stats = array(
"unapprovedposts" => '-'.($mergethread['replies']+$mergethread['unapprovedposts'])
);
}
else
{
$updated_stats = array(
"posts" => '-'.($mergethread['replies']+1),
"unapprovedposts" => "-{$mergethread['unapprovedposts']}"
);
}
update_forum_counters($mergethread['fid'], $updated_stats);


		{			

















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

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

			{
$updated_stats = array(

			{
$updated_stats = array(

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

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

					"posts" => '+'.($mergethread['replies']+1),
"unapprovedposts" => "+{$mergethread['unapprovedposts']}"
);
}
update_forum_counters($thread['fid'], $updated_stats);
}
// Merged thread and new thread are in the same forum
else
{
if($mergethread['visible'] == 0)
{
$updated_stats = array(
"unapprovedthreads" => "-1"
);
}
else
{
$updated_stats = array(
"threads" => "-1"

					"posts" => '+'.($mergethread['replies']+1),
"unapprovedposts" => "+{$mergethread['unapprovedposts']}"


















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

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

		}

		}

		return true;
}


		return true;
}


Zeile 978Zeile 955
		$newsubject = $db->escape_string($newsubject);
$query = array(
"fid" => intval($moveto),

		$newsubject = $db->escape_string($newsubject);
$query = array(
"fid" => intval($moveto),

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

			"subject" => $newsubject,
"icon" => intval($thread['icon']),
"uid" => intval($thread['uid']),

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

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

			"dateline" => $db->escape_string($thread['dateline']),
"lastpost" => $db->escape_string($thread['lastpost']),

			"dateline" => intval($thread['dateline']),
"lastpost" => intval($thread['lastpost']),

			"lastposter" => $db->escape_string($thread['lastposter']),
"replies" => count($pids)-1,

			"lastposter" => $db->escape_string($thread['lastposter']),
"replies" => count($pids)-1,

			"visible" => "1",

			"visible" => 1,

			"notes" => ''
);
$db->insert_query(TABLE_PREFIX."threads", $query);

			"notes" => ''
);
$db->insert_query(TABLE_PREFIX."threads", $query);

Zeile 1247Zeile 1224
	 * Approve multiple posts
*
* @param array PIDs

	 * Approve multiple posts
*
* @param array PIDs

	 * @param int Thread ID
* @param int Forum ID
* @return boolean true
*/
function approve_posts($pids, $tid, $fid)
{
global $db, $cache, $plugins;

	 * @return boolean true
*/
function approve_posts($pids)
{
global $db, $cache;







		$thread = get_thread($tid);


 
		$num_posts = 0;

		$num_posts = 0;

		foreach($pids as $pid)
{
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid, p.visible
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='{$pid}' AND p.visible = '0'
");
while($post = $db->fetch_array($query))
{
// If post counts enabled in this forum and the post hasn't already been approved, add 1
if($post['usepostcounts'] != "no")
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='".$post['uid']."'");
}
++$num_posts;
}
}

$where = "pid IN (".implode(",", $pids).")";


		$pid_list = implode(",", $pids);
$pids = array();




















		// Make visible
$approve = array(
"visible" => 1,
);

		// Make visible
$approve = array(
"visible" => 1,
);

		$db->update_query(TABLE_PREFIX."posts", $approve, $where);

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

$is_first = false;
// If this is the first post of the thread, also approve the thread
$query = $db->simple_select(TABLE_PREFIX."posts", "tid, pid", "pid='{$thread['firstpost']}' AND visible='1'");
$first_post = $db->fetch_array($query);
if($first_post['tid'])
{
if(in_array($first_post['pid'], $pids))
{
$is_first = true;
// Thread is invisible, update impled counters
if($thread['visible'] == 0)
{
$num_posts += $thread['replies'];
}
$db->update_query(TABLE_PREFIX."threads", $approve, "tid='{$first_post['tid']}'");
}
}
if($is_first)

		
$query = $db->query("
SELECT p.pid, p.tid, f.fid, f.usepostcounts, p.uid, p.visible, t.visible AS threadvisible, t.replies AS threadreplies, t.firstpost AS threadfirstpost, t.unapprovedposts AS threadunapprovedposts
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid IN ($pid_list) AND p.visible = '0'
");
while($post = $db->fetch_array($query))














		{

		{

			$updated_thread_stats['replies'] = "+".($num_posts-1); 
}
else
{
$updated_thread_stats['replies'] = "+{$num_posts}";
}
$updated_thread_stats['unapprovedposts'] = "-".$num_posts;
update_thread_counters($tid, $updated_thread_stats);

$updated_forum_stats = array(
"posts" => "+{$num_posts}",
"unapprovedposts" => "-{$num_posts}"
);

if($is_first)
{
$updated_forum_stats['threads'] = "+1";
$updated_forum_stats['unapprovedthreads'] = "-1";
}
update_forum_counters($fid, $updated_forum_stats);

return true;
}

/**
* Unapprove multiple posts
*
* @param array PIDs
* @param int Thread ID
* @param int Forum ID
* @return boolean true
*/
function unapprove_posts($pids, $tid, $fid)
{
global $db, $cache, $plugins;

$thread = get_thread($tid);

$num_posts = 0;
foreach($pids as $pid)
{
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='{$pid}' AND p.visible = '1'
");
while($post = $db->fetch_array($query))
{
// If post counts enabled in this forum and the post hasn't already been unapproved, remove 1
if($post['usepostcounts'] != "no")

			// If post counts enabled in this forum and the post hasn't already been approved, add 1
if($post['usepostcounts'] != "no" && $thread['visible'] == 1)
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='".$post['uid']."'");
}

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

if(!$thread_counters[$post['tid']]['unapprovedposts'])
{
$thread_counters[$post['tid']]['unapprovedposts'] = $post['threadunapprovedposts'];
}
--$thread_counters[$post['tid']]['unapprovedposts'];

if($post['threadfirstpost'] != $post['pid'])
{
if(!$thread_counters[$post['tid']]['replies'])



































				{

				{

					$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='".$post['uid']."'");

					$thread_counters[$post['tid']]['replies'] = $post['threadreplies'];

				}

				}

				$num_posts++;
















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

// Only add to the forum count if the thread is invisible
if($post['threadvisible'] == 0)
{
++$forum_counters[$post['fid']]['num_posts'];
}

// If the first post here matches and thread is invisible, we approve the thread too
if($post['threadfirstpost'] == $post['pid'] && $post['threadvisible'] == 0)
{
$thread_counters[$post['tid']]['visible'] = 1;
$thread_counters[$post['tid']]['unapprovedposts'] += 1;
$forum_counters[$post['fid']]['num_posts'] += $post['threadreplies'];
$forum_counters[$post['fid']]['num_threads']++;

			}

			}

		}

$where = "pid IN (".implode(",", $pids).")";





























		}

if(!count($pids)) return false;

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

if(is_array($thread_counters))
{
foreach($thread_counters as $tid => $counters)
{
$db->update_query(TABLE_PREFIX."threads", $counters, "tid='{$tid}'");
}
}

if(is_array($forum_counters))
{
foreach($forum_counters as $fid => $counters)
{
$updated_forum_stats = array(
"posts" => "+{$counters['num_posts']}",
"unapprovedposts" => "-{$counters['num_posts']}",
"threads" => "+{$counters['num_threads']}",
"unapprovedthreads" => "-{$counters['num_threads']}"
);

update_forum_counters($fid, $updated_forum_stats);
}
}
return true;
}





		// Make visible
$unapprove = array(














	/**
* Unapprove multiple posts
*
* @param array PIDs
* @return boolean true
*/
function unapprove_posts($pids)
{
global $db, $cache;

$pid_list = implode(",", $pids);
$pids = array();

// Make invisible
$approve = array(

			"visible" => 0,
);

			"visible" => 0,
);

		$db->update_query(TABLE_PREFIX."posts", $unapprove, $where);

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

$is_first = false;
// If this is the first post of the thread, also approve the thread
$query = $db->simple_select(TABLE_PREFIX."posts", "tid,pid", "pid='{$thread['firstpost']}' AND visible='0'");
$first_post = $db->fetch_array($query);
if($first_post['tid'])

		
$query = $db->query("
SELECT p.pid, p.tid, f.fid, f.usepostcounts, p.uid, p.visible, t.visible AS threadvisible, t.replies AS threadreplies, t.firstpost AS threadfirstpost, t.unapprovedposts AS threadunapprovedposts
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid IN ($pid_list) AND p.visible = '1'
");
while($post = $db->fetch_array($query))

		{

		{

			if(in_array($first_post['pid'], $pids)) 
{
$is_first = true;
// Thread is visible, update impled counters
if($thread['visible'] == 1)












			// If post counts enabled in this forum and the post hasn't already been unapproved, subtract 1
if($post['usepostcounts'] != "no" && $thread['visible'] == 1)
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='".$post['uid']."'");
}

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

if(!$thread_counters[$post['tid']]['unapprovedposts'])
{
$thread_counters[$post['tid']]['unapprovedposts'] = $post['threadunapprovedposts'];
}
++$thread_counters[$post['tid']]['unapprovedposts'];
if($post['threadfirstpost'] != $post['pid'])
{
if(!$thread_counters[$post['tid']]['replies'])

				{

				{

					$num_posts += $thread['replies'];

					$thread_counters[$post['tid']]['replies'] = $post['threadreplies'];

				}

				}

				$db->update_query(TABLE_PREFIX."threads", $unapprove, "tid='{$first_post['tid']}'");

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

			}

			}

		}
$updated_thread_stats = array(
"unapprovedposts" => "+{$num_posts}"
);
if($is_first)
{
$updated_thread_stats['replies'] = "-".($num_posts-1);
}
else
{
$updated_thread_stats['replies'] = "-{$num_posts}";
}
update_thread_counters($tid, $updated_thread_stats);

$updated_forum_stats = array(
"posts" => "-{$num_posts}",
"unapprovedposts" => "+{$num_posts}"
);

if($is_first)
{
$updated_forum_stats['threads'] = "-1";
$updated_forum_stats['unapprovedthreads'] = "+1";
}
update_forum_counters($fid, $updated_forum_stats);




















if($post['threadvisible'] == 1)
{
++$forum_counters[$post['fid']]['num_posts'];
}

// If the first post here matches and thread is visible, we unapprove the thread too
if($post['threadfirstpost'] == $post['pid'] && $post['threadvisible'] == 1)
{
$thread_counters[$post['tid']]['visible'] = 0;
$thread_counters[$post['tid']]['unapprovedposts'] -= 1;
$forum_counters[$post['fid']]['num_posts'] += $post['threadreplies'];
$forum_counters[$post['fid']]['num_threads']++;
}
}

if(!count($pids)) return false;

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

if(is_array($thread_counters))
{
foreach($thread_counters as $tid => $counters)
{
$db->update_query(TABLE_PREFIX."threads", $counters, "tid='{$tid}'");
}
}

if(is_array($forum_counters))
{
foreach($forum_counters as $fid => $counters)
{
$updated_forum_stats = array(
"posts" => "-{$counters['num_posts']}",
"unapprovedposts" => "+{$counters['num_posts']}",
"threads" => "-{$counters['num_threads']}",
"unapprovedthreads" => "+{$counters['num_threads']}"
);

update_forum_counters($fid, $updated_forum_stats);
}
}

		return true;
}


		return true;
}


Zeile 1451Zeile 1443
			$lastpost_subject = array(				
"lastpostsubject" => $new_subject['subject']
);

			$lastpost_subject = array(				
"lastpostsubject" => $new_subject['subject']
);





			$db->update_query(TABLE_PREFIX."forums", $lastpost_subject, "lastposttid='{$thread['tid']}'");
}


			$db->update_query(TABLE_PREFIX."forums", $lastpost_subject, "lastposttid='{$thread['tid']}'");
}


Zeile 1485Zeile 1477
	 * Toggle post visibility (approved/unapproved)
*
* @param array Post IDs

	 * Toggle post visibility (approved/unapproved)
*
* @param array Post IDs

	 * @param int Thread ID
* @param int Forum ID

 
	 * @return boolean true
*/

	 * @return boolean true
*/

	function toggle_post_visibility($pids, $tid, $fid)

	function toggle_post_visibility($pids)

	{
global $db;
$pid_list = implode(',', $pids);

	{
global $db;
$pid_list = implode(',', $pids);

Zeile 1507Zeile 1497
		}
if(is_array($unapprove))
{

		}
if(is_array($unapprove))
{

			$this->unapprove_posts($unapprove, $tid, $fid);

			$this->unapprove_posts($unapprove);

		}
if(is_array($approve))
{

		}
if(is_array($approve))
{

			$this->approve_posts($approve, $tid, $fid);

			$this->approve_posts($approve);

		}
return true;
}

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

		}
return true;
}

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

	 *
* @param array Thread IDs

	 *
* @param array Thread IDs

	 * @param int Forum ID
* @return boolean true
*/

	 * @param int Forum ID
* @return boolean true
*/

Zeile 1535Zeile 1525
				$unapprove[] = $thread['tid'];
}
else

				$unapprove[] = $thread['tid'];
}
else

			{
$approve[] = $thread['tid'];
}
}
if(is_array($unapprove))
{

			{
$approve[] = $thread['tid'];
}
}
if(is_array($unapprove))
{

			$this->unapprove_threads($unapprove, $fid);
}
if(is_array($approve))

			$this->unapprove_threads($unapprove, $fid);
}
if(is_array($approve))

Zeile 1623Zeile 1613
			if(count($groups) > 0)
{
$groups_csv = implode(',', $groups);

			if(count($groups) > 0)
{
$groups_csv = implode(',', $groups);

				$db->query("DELETE s FROM (".TABLE_PREFIX."favorites s, ".TABLE_PREFIX."users u) WHERE s.type='s' AND s.tid IN ({$tids_csv}) AND s.uid=u.uid AND (u.usergroup IN ({$groups_csv}){$additional_groups})");











				$query = $db->query("
SELECT s.tid, u.uid
FROM ".TABLE_PREFIX."favorites s
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=s.uid)
WHERE s.type='s' AND s.tid IN ({$tids_csv})
AND (u.usergroup IN ({$groups_csv}){$additional_groups})
");
while($favorites = $db->fetch_array($query))
{
$db->query("DELETE FROM ".TABLE_PREFIX."favorites WHERE uid='{$favorites['uid']}' AND tid='{$favorites['tid']}'");
}

			}
}
// Delete all subscriptions of this thread

			}
}
// Delete all subscriptions of this thread