Vergleich inc/class_moderation.php - 1.2.5 - 1.2.7

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 3
 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

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

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

 *

 *

 * $Id: class_moderation.php 2734 2007-02-08 22:21:16Z CraKteR $

 * $Id: class_moderation.php 3051 2007-05-12 12:07:29Z chris $

 */

class Moderation

 */

class Moderation

Zeile 118Zeile 118
	{
global $db;


	{
global $db;


		// Find the fids that have these redirects
$query = $db->simple_select(TABLE_PREFIX."threads", "fid", "closed='moved|$tid'");
while($forum = $db->fetch_array($query))
{
$fids[] = $forum['fid'];
}






















		// Update forum counters 
$query = $db->simple_select(TABLE_PREFIX."threads", "fid,visible", "closed='moved|$tid'");
while($thread = $db->fetch_array($query))
{
if($thread['visible'] == 1)
{
if($counters[$thread['fid']]['threads'])
{
--$counters[$thread['fid']]['threads'];
}
else
{
$counters[$thread['fid']]['threads'] = -1;
}
}
else if($thread['visible'] == 0)
{
if($counters[$thread['fid']]['unapprovedthreads'])
{
--$counters[$thread['fid']]['unapprovedthreads'];
}
else
{
$counters[$thread['fid']]['unapprovedthreads'] = -1;
}
}
}

		// Delete the redirects
$db->delete_query(TABLE_PREFIX."threads", "closed='moved|$tid'");
// Update the forum stats of the fids found above

		// Delete the redirects
$db->delete_query(TABLE_PREFIX."threads", "closed='moved|$tid'");
// Update the forum stats of the fids found above

		if(is_array($fids))
{
foreach($fids as $fid)
{
update_forum_count($fid);










		if(is_array($counters)) 
{
foreach($counters as $fid => $values)
{
$update_array = array();
if($values['threads'])
{
$update_array['threads'] = $values['threads'];
}
if($values['unapprovedthreads'])
{
$update_array['unapprovedthreads'] = $values['unapprovedthreads'];
}
update_forum_counters($fid, $update_array);

			}
}


			}
}


Zeile 147Zeile 177
	function delete_thread($tid)
{
global $db, $cache, $plugins;

	function delete_thread($tid)
{
global $db, $cache, $plugins;

 
		
$thread = get_thread($tid);


// 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 155Zeile 187
			LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='$tid'
");

			LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='$tid'
");

		$num_unapproved_posts = 0;


		$pids = array();
$num_unapproved_posts = $num_approved_posts = 0;

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

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

			$pids .= $post['pid'].",";

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

			$usepostcounts = $post['usepostcounts'];

// Remove attachments

			$usepostcounts = $post['usepostcounts'];

// Remove attachments

Zeile 169Zeile 202
			{
$num_unapproved_posts++;
continue;

			{
$num_unapproved_posts++;
continue;

			}

// Count the post counts for each user to be subtracted
if($userposts[$post['uid']])
{
$userposts[$post['uid']]--;
}

			}







			else
{

			else
{

				$userposts[$post['uid']] = -1;










				$num_approved_posts++;
// Count the post counts for each user to be subtracted
if($userposts[$post['uid']])
{
$userposts[$post['uid']]--;
}
else
{
$userposts[$post['uid']] = -1;
}

			}
}
// Remove post count from users

			}
}
// Remove post count from users

Zeile 195Zeile 231
		// Delete posts and their attachments
if($pids)
{

		// Delete posts and their attachments
if($pids)
{

			$pids .= "0";

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

			$db->delete_query(TABLE_PREFIX."posts", "pid IN ($pids)");
$db->delete_query(TABLE_PREFIX."attachments", "pid IN ($pids)");
}

			$db->delete_query(TABLE_PREFIX."posts", "pid IN ($pids)");
$db->delete_query(TABLE_PREFIX."attachments", "pid IN ($pids)");
}

Zeile 209Zeile 245
		$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']."'");

		$cache->updatestats();
update_forum_count($thread['fid']);


















		$updated_counters = array( 
"posts" => "-{$num_approved_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);

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

if(substr($thread['closed'], 0, 5) != "moved")
{
// Update forum count
update_forum_counters($thread['fid'], $updated_counters);
}

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

return true;

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

return true;

Zeile 244Zeile 297
	 * @return boolean true
*/
function approve_threads($tids, $fid)

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

	{
global $db, $cache;

if(!is_array($tids))
{
$tids = array($tids);
}
$tid_list = implode(",", $tids);

foreach($tids as $tid)


	{
global $db, $cache;

if(!is_array($tids))
{
$tids = array($tids);
}
$tid_list = implode(",", $tids);

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

		{

		{

 
			$thread = get_thread($tid); 

if($thread['visible'] == 0)
{
$num_approved_threads++;
$num_unapproved_threads--;
}

			$query = $db->query("

			$query = $db->query("

				SELECT p.tid, f.usepostcounts, p.uid

				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'

				FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='$tid' AND p.visible = '0'

Zeile 267Zeile 328
				if($post['usepostcounts'] != "no")
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='".$post['uid']."'");

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

				}






				}

if($post['visible'] == 1)
{
$num_posts++;
}

			}

			}

			update_thread_count($tid);

 
		}

$approve = array(

		}

$approve = array(

Zeile 277Zeile 342
		);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN ($tid_list)", 1);

		);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN ($tid_list)", 1);

		
// Update stats
$cache->updatestats();
update_forum_count($fid);

return true;
}






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


/**
* Unapprove one or more threads


/**
* Unapprove one or more threads

Zeile 297Zeile 367
		global $db, $cache;

if(!is_array($tids))

		global $db, $cache;

if(!is_array($tids))

		{

		{

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


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


 
		$num_threads = $num_posts = 0;

		foreach($tids as $tid)
{

		foreach($tids as $tid)
{

 
			$thread = get_thread($tid); 

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

			$query = $db->query("

			$query = $db->query("

				SELECT p.tid, f.usepostcounts, p.uid

				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 = '1'

				FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='$tid' AND p.visible = '1'

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

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

 
				if($post['visible'] == 1) 
{
$num_posts++;
}

			}

			}

			update_thread_count($tid);

 
		}

$approve = array(

		}

$approve = array(

Zeile 328Zeile 408
		$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN ($tid_list) AND replyto='0'", 1);

// Update stats

		$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN ($tid_list) AND replyto='0'", 1);

// Update stats

		$cache->updatestats();
update_forum_count($fid);






		$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 354Zeile 439
		$post = $db->fetch_array($query);
// If post counts enabled in this forum and it hasn't already been unapproved, remove 1
if($post['usepostcounts'] != "no" && $post['visible'] != 0)

		$post = $db->fetch_array($query);
// If post counts enabled in this forum and it hasn't already been unapproved, remove 1
if($post['usepostcounts'] != "no" && $post['visible'] != 0)

		{

		{

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

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

		}

		}

		// Delete the post
$db->delete_query(TABLE_PREFIX."posts", "pid='$pid'");
// Remove attachments
remove_attachments($pid);


		// Delete the post
$db->delete_query(TABLE_PREFIX."posts", "pid='$pid'");
// Remove attachments
remove_attachments($pid);


 
		$num_unapproved_posts = $num_approved_posts = 0;

		// Update unapproved post count
if($post['visible'] == 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']}'");

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

		}

		}

		$plugins->run_hooks("delete_post", $post['tid']);
$cache->updatestats();
update_thread_count($post['tid']);
update_forum_count($post['fid']);

















		else
{
$num_approved_posts++;
}
$plugins->run_hooks("delete_post", $post['pid']);
// Update stats
$update_array = array(
"replies" => "-{$num_approved_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);
update_thread_counters($post['tid'], $update_array);


// Update stats
$update_array = array(
"posts" => "-{$num_approved_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);

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


return true;
}


return true;
}

Zeile 397Zeile 500
			WHERE p.tid='$tid' AND p.pid IN($pidin)
ORDER BY dateline ASC
");

			WHERE p.tid='$tid' AND p.pid IN($pidin)
ORDER BY dateline ASC
");

		$num_unapproved_posts = 0;

		$num_unapproved_posts = $num_approved_posts = 0;

		$message = '';
while($post = $db->fetch_array($query))
{

		$message = '';
while($post = $db->fetch_array($query))
{

Zeile 405Zeile 508
			{ // all posts will be merged into this one
$masterpid = $post['pid'];
$message = $post['message'];

			{ // all posts will be merged into this one
$masterpid = $post['pid'];
$message = $post['message'];

 
				$fid = $post['fid'];

				$first = 0;
}
else

				$first = 0;
}
else

Zeile 422Zeile 526
				{
// Update post count of the user of the merged posts
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='{$post['uid']}'");

				{
// Update post count of the user of the merged posts
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='{$post['uid']}'");

 
				}
if($post['visible'] == 1)
{
$num_approved_posts++;
}
elseif($post['visible'] == 0)
{
$num_unapproved_posts++;

				}
}
}


				}
}
}


		$fid = $post['fid'];



		// Get lastpost pid to check if we're merging a post that is on the lastpost info
$query = $db->simple_select(TABLE_PREFIX."posts", "pid", "tid = '{$post['tid']}'", array('order_by' => 'dateline', 'order_dir' => 'desc', 'limit' => '1'));
$lastpostpid = $db->fetch_field($query, 'pid');


// Update the message
$mergepost = array(
"message" => $db->escape_string($message),
);


// Update the message
$mergepost = array(
"message" => $db->escape_string($message),
);

		$db->update_query(TABLE_PREFIX."posts", $mergepost, "pid='$masterpid'");

		$db->update_query(TABLE_PREFIX."posts", $mergepost, "pid = '$masterpid'");

		$db->delete_query(TABLE_PREFIX."posts", "pid IN($pidin) AND pid != '$masterpid'");
// Update pid for attachments
$mergepost2 = array(

		$db->delete_query(TABLE_PREFIX."posts", "pid IN($pidin) AND pid != '$masterpid'");
// Update pid for attachments
$mergepost2 = array(

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

// Update stats

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

// Update stats

		update_thread_count($tid);
update_forum_count($fid);











		$update_array = array( 
"replies" => "-{$num_approved_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);
update_thread_counters($tid, $update_array);

// Update stats
$update_array = array(
"posts" => "-{$num_approved_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);
update_forum_counters($fid, $update_array);


return true;
}


return true;
}

Zeile 466Zeile 590
		$newforum = get_forum($new_fid);
$fid = $thread['fid'];
$forum = get_forum($fid);

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

 
		$num_threads = $num_unapproved_threads = $num_posts = $num_unapproved_threads = 0;

		switch($method)
{
case "redirect": // move (and leave redirect) thread
$plugins->run_hooks("moderation_do_move_redirect");

		switch($method)
{
case "redirect": // move (and leave redirect) thread
$plugins->run_hooks("moderation_do_move_redirect");

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

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

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

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

Zeile 521Zeile 658
					"unapprovedposts" => $thread['unapprovedposts'],
"notes" => ''
);

					"unapprovedposts" => $thread['unapprovedposts'],
"notes" => ''
);

 
				
++$num_threads;

				
$plugins->run_hooks("moderation_do_move_copy");
$db->insert_query(TABLE_PREFIX."threads", $threadarray);

				
$plugins->run_hooks("moderation_do_move_copy");
$db->insert_query(TABLE_PREFIX."threads", $threadarray);

Zeile 530Zeile 669
				{
$query = $db->simple_select(TABLE_PREFIX."polls", "*", "tid = '{$thread['tid']}'");
$poll = $db->fetch_array($query);

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

					



					$poll_array = array(
'tid' => $newtid,
'question' => $db->escape_string($poll['question']),

					$poll_array = array(
'tid' => $newtid,
'question' => $db->escape_string($poll['question']),

Zeile 546Zeile 685
					);
$db->insert_query(TABLE_PREFIX."polls", $poll_array);
$new_pid = $db->insert_id();

					);
$db->insert_query(TABLE_PREFIX."polls", $poll_array);
$new_pid = $db->insert_id();

				}

$query = $db->simple_select(TABLE_PREFIX."pollvotes", "*", "tid = '{$thread['tid']}'");
while($pollvote = $db->fetch_array($query))
{
$pollvote_array = array(
'pid' => $new_pid,
'uid' => $pollvote['uid'],
'voteoption' => $pollvote['voteoption'],
'dateline' => $pollvote['dateline'],
);
$db->insert_query(TABLE_PREFIX."pollvotes", $pollvote_array);




$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'],
'voteoption' => $pollvote['voteoption'],
'dateline' => $pollvote['dateline'],
);
$db->insert_query(TABLE_PREFIX."pollvotes", $pollvote_array);
}

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

				}

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

				}

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

Zeile 581Zeile 722
					);
$db->insert_query(TABLE_PREFIX."posts", $post_array);
$pid = $db->insert_id();

					);
$db->insert_query(TABLE_PREFIX."posts", $post_array);
$pid = $db->insert_id();

 
					
if($post['visible'] == 0)
{
$num_unapproved_posts++;
}
else if($post['visible'] == 1)
{
$num_posts++;
}

					
// Insert attachments for this post
$query2 = $db->simple_select(TABLE_PREFIX."attachments", "*", "pid = '{$post['pid']}'");

					
// Insert attachments for this post
$query2 = $db->simple_select(TABLE_PREFIX."attachments", "*", "pid = '{$post['pid']}'");

Zeile 601Zeile 751
						$db->insert_query(TABLE_PREFIX."attachments", $attachment_array);
}
}

						$db->insert_query(TABLE_PREFIX."attachments", $attachment_array);
}
}

				
update_first_post($newtid);
update_thread_count($newtid);



update_thread_data($newtid);



				$the_thread = $newtid;
break;
default:
case "move": // plain move thread
$plugins->run_hooks("moderation_do_move_simple");

				$the_thread = $newtid;
break;
default:
case "move": // plain move thread
$plugins->run_hooks("moderation_do_move_simple");

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

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

	
$sqlarray = array(
"fid" => $new_fid,

	
$sqlarray = array(
"fid" => $new_fid,

Zeile 630Zeile 791
		");
while($posters = $db->fetch_array($query))
{

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

			if($method == "copy" && $newforum['usepostcounts'] != "no")

			if($method == "copy" && $newforum['usepostcounts'] != "no" && $posters['visible'] != "no")

			{
$pcount = "+{$posters['posts']}";
}

			{
$pcount = "+{$posters['posts']}";
}

			elseif($method != "copy" && ($newforum['usepostcounts'] != "no" && $forum['usepostcounts'] == "no"))

			elseif($method != "copy" && ($newforum['usepostcounts'] != "no" && $forum['usepostcounts'] == "no" && $posters['visible'] != "no"))

			{
$pcount = "+{$posters['posts']}";
}

			{
$pcount = "+{$posters['posts']}";
}

			elseif($method != "copy" && ($newforum['usepostcounts'] == "no" && $forum['usepostcounts'] != "no"))
{
$pcount = "-{$posters['posts']}";
}

			elseif($method != "copy" && ($newforum['usepostcounts'] == "no" && $forum['usepostcounts'] != "no" && $posters['visible'] != "no"))
{
$pcount = "-{$posters['posts']}";
}

			if(!empty($pcount))
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$pcount WHERE uid='{$posters['uid']}'");

			if(!empty($pcount))
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$pcount WHERE uid='{$posters['uid']}'");

Zeile 649Zeile 810
		}

// Update forum counts

		}

// Update forum counts

		if($fid != $new_fid)
{
update_forum_count($new_fid);















		$update_array = array( 
"threads" => "+{$num_threads}",
"unapprovedthreads" => "+{$num_unapproved_threads}",
"posts" => "+{$num_posts}",
"unapprovedposts" => "+{$num_unapproved_posts}"
);
update_forum_counters($new_fid, $update_array);

if($method != "copy")
{
$update_array = array(
"threads" => "-{$num_threads}",
"unapprovedthreads" => "-{$num_unapproved_threads}",
"posts" => "-{$num_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);
update_forum_counters($fid, $update_array);

		}

		}

		update_forum_count($fid);

 

if(isset($newtid))
{


if(isset($newtid))
{

Zeile 661Zeile 835
		}
else
{

		}
else
{

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


			return $tid;
}
}

			return $tid;
}
}

Zeile 688Zeile 865
			$tid = intval($tid);
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='".intval($tid)."'");
$thread = $db->fetch_array($query);

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

		}

		}

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

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

Zeile 710Zeile 887
		}

$subject = $db->escape_string($subject);

		}

$subject = $db->escape_string($subject);





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

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

Zeile 721Zeile 898
		$db->query("UPDATE ".TABLE_PREFIX."threads SET subject='$subject' $pollsql WHERE tid='$tid'");
$sqlarray = array(
"closed" => "moved|$tid",

		$db->query("UPDATE ".TABLE_PREFIX."threads SET subject='$subject' $pollsql WHERE tid='$tid'");
$sqlarray = array(
"closed" => "moved|$tid",

		);

		);

		$db->update_query(TABLE_PREFIX."threads", $sqlarray, "closed='moved|$mergetid'");
$sqlarray = array(
"tid" => $tid,

		$db->update_query(TABLE_PREFIX."threads", $sqlarray, "closed='moved|$mergetid'");
$sqlarray = array(
"tid" => $tid,

Zeile 730Zeile 907
		update_first_post($tid);

$this->delete_thread($mergetid);

		update_first_post($tid);

$this->delete_thread($mergetid);

		update_thread_count($tid);
if($thread['fid'] != $mergethread['fid'])
{
update_forum_count($mergethread['fid']);
}
update_forum_count($fid);






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

$updated_stats = array(
"posts" => "+".($mergethread['replies']+1),
"unapprovedposts" => "+{$mergethread['unapprovedposts']}"
);
update_forum_counters($fid, $updated_stats);


return true;
}


return true;
}

Zeile 816Zeile 998
			{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$pcount WHERE uid='{$posters['uid']}'");
}

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

 
		}

$num_visible = $num_unnaproved = 0;
$query = $db->query("SELECT visible FROM ".TABLE_PREFIX."posts WHERE tid='{$newtid}'");
while($post = $db->fetch_array($query))
{
if($post['visible'] == 1)
{
$num_visible++;
}
else if($post['visible'] == 0)
{
$num_unapproved++;
}

		}

// Update the subject of the first post in the new thread

		}

// Update the subject of the first post in the new thread

Zeile 836Zeile 1032
		);
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "pid='{$oldthread['pid']}'");


		);
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "pid='{$oldthread['pid']}'");


 
		// Update old thread stats 
$update_array = array(
"replies" => "-{$num_visible}",
"unapprovedposts" => "-{$num_unapproved}"
);
update_thread_counters($thread['tid'], $update_array);

// Update new thread stats
$update_array = array(
"replies" => $num_visible-1,
"unapprovedposts" => $num_unapproved
);
update_thread_counters($newtid, $update_array);

if($thread['fid'] != $moveto)
{
// Update old forum stats
$update_array = array(
"posts" => "-{$num_visible}",
"unapprovedposts" => "-{$num_unapproved}"
);
update_forum_counters($thread['fid'], $update_array);

// Update new forum stats
$update_array = array(
"posts" => "+{$num_visible}",
"unapprovedposts" => "+{$num_unapproved}"
);
}
else
{
$update_array = array();
}

if($thread['visible'] == 1)
{
$update_array['threads'] = "+1";
}
else if($thread['visible'] == 0)
{
$update_array['unapprovedthreads'] = "+1";
}
update_forum_counters($moveto, $update_array);

// Update first post columns

		update_first_post($tid);
update_first_post($newtid);

		update_first_post($tid);
update_first_post($newtid);

		update_thread_count($tid);
update_thread_count($newtid);
if($moveto != $thread['fid'])
{
update_forum_count($moveto);
}
update_forum_count($thread['fid']);

 

// Merge new thread with destination thread if specified
if($destination_tid)


// Merge new thread with destination thread if specified
if($destination_tid)

		{

		{

			$this->merge_threads($newtid, $destination_tid, $subject);
}

			$this->merge_threads($newtid, $destination_tid, $subject);
}





		return $newtid;
}

/**
* Move multiple threads to new forum

		return $newtid;
}

/**
* Move multiple threads to new forum

	 *

	 *

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

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

Zeile 867Zeile 1101
		global $db;

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

		global $db;

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

 
			
$newforum = get_forum($moveto);

		

		

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


		$total_posts = $total_unapproved_posts = $total_threads = $total_unapproved_threads = 0; 
$query = $db->simple_select(TABLE_PREFIX."threads", "fid, visible, replies, unapprovedposts", "tid IN ($tid_list)");

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

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

			$update_forums[$thread['fid']] = $thread['fid'];
















































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

$total_posts += $thread['replies']+1;
$total_unapproved_posts += $thread['unapproved_posts'];
$forum_counters[$thread['fid']] = array(
"posts" => $forum_counters[$thread['fid']]['posts']+$thread['replies']+1,
"unapprovedposts" => $forum_counters[$thread['fid']]['posts']+$thread['unapprovedposts']
);

if($thread['visible'] == 1)
{
$forum_counters[$thread['fid']]['threads']++;
++$total_threads;
}
else
{
$forum_counters[$thread['fid']]['unapprovedthreads']++;
++$total_unapproved_threads;
}

$query = $db->query("
SELECT COUNT(p.pid) AS posts, u.uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE tid='{$thread['tid']}'
GROUP BY u.uid
ORDER BY posts DESC
");
while($posters = $db->fetch_array($query))
{
if($method == "copy" && $newforum['usepostcounts'] != "no" && $posters['visible'] != "no")
{
$pcount = "+{$posters['posts']}";
}
elseif($method != "copy" && ($newforum['usepostcounts'] != "no" && $forum['usepostcounts'] == "no" && $posters['visible'] != "no"))
{
$pcount = "+{$posters['posts']}";
}
elseif($method != "copy" && ($newforum['usepostcounts'] == "no" && $forum['usepostcounts'] != "no" && $posters['visible'] != "no"))
{
$pcount = "-{$posters['posts']}";
}

if(!empty($pcount))
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$pcount WHERE uid='{$posters['uid']}'");
}
}

		}

$sqlarray = array(

		}

$sqlarray = array(

Zeile 880Zeile 1164
		$db->update_query(TABLE_PREFIX."threads", $sqlarray, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "tid IN ($tid_list)");


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


		update_forum_count($moveto);
foreach($update_forums as $fid)
{
update_forum_count($fid);
}


























		foreach($forum_counters as $fid => $counter) 
{
$updated_count = array(
"posts" => "-{$counter['posts']}",
"unapprovedposts" => "-{$counter['unapproved_posts']}"
);
if($counter['threads'])
{
$updated_count['threads'] = "-{$counter['threads']}";
}
if($counter['unapprovedthreads'])
{
$updated_count['unapprovedthreads'] = "-{$counter['unapprovedthreads']}";
}
update_forum_counters($fid, $updated_count);

// Do post count changes if changing between countable and non-countable forums
}

$updated_count = array(
"threads" => "+{$total_threads}",
"unapprovedthreads" => "+{$total_unapproved_threads}",
"posts" => "+{$total_posts}",
"unapprovedposts" => "+{$total_unapproved_posts}"
);

update_forum_counters($moveto, $updated_count);

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

		return true;
}


		return true;
}


Zeile 897Zeile 1206
	 * @return boolean true
*/
function approve_posts($pids, $tid, $fid)

	 * @return boolean true
*/
function approve_posts($pids, $tid, $fid)

	{

	{

		global $db, $cache;

$thread = get_thread($tid);


		global $db, $cache;

$thread = get_thread($tid);


 
		$num_posts = 0;

		foreach($pids as $pid)
{
$query = $db->query("

		foreach($pids as $pid)
{
$query = $db->query("

				SELECT p.tid, f.usepostcounts, p.uid

				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'

				FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='{$pid}' AND p.visible = '0'

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

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

 
				++$num_posts;

			}
}


			}
}


Zeile 927Zeile 1238
			"visible" => 1,
);
$db->update_query(TABLE_PREFIX."posts", $approve, $where);

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





$is_first = false;

		// If this is the first post of the thread, also approve the thread

		// If this is the first post of the thread, also approve the thread

		$query = $db->simple_select(TABLE_PREFIX."posts", "tid", "pid='{$thread['firstpost']}' AND visible='1'");

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

		$first_post = $db->fetch_array($query);
if($first_post['tid'])
{

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













			if(in_array($first_post['pid'], $pids)) 
{
$is_first = true;
$db->update_query(TABLE_PREFIX."threads", $approve, "tid='{$first_post['tid']}'");
}
}
if($is_first)
{
$updated_thread_stats['replies'] = "+".($num_posts-1);
}
else
{
$updated_thread_stats['replies'] = "+{$num_posts}";

		}

		}

		update_thread_count($tid);
update_forum_count($fid);
$cache->updatestats();












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


return true;
}

Zeile 956Zeile 1291
		
$thread = get_thread($tid);


		
$thread = get_thread($tid);


 
		$num_posts = 0;

		foreach($pids as $pid)
{
$query = $db->query("

		foreach($pids as $pid)
{
$query = $db->query("

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

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

 
				$num_posts++;

			}
}


			}
}


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


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


 
		$is_first = false;

		// If this is the first post of the thread, also approve the thread

		// If this is the first post of the thread, also approve the thread

		$query = $db->simple_select(TABLE_PREFIX."posts", "tid", "pid='{$thread['firstpost']}' AND visible='0'");

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

		$first_post = $db->fetch_array($query);
if($first_post['tid'])
{

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





			if(in_array($first_post['pid'], $pids)) 
{
$is_first = true;
$db->update_query(TABLE_PREFIX."threads", $unapprove, "tid='{$first_post['tid']}'");
}

		}

		}

		update_thread_count($tid);
update_forum_count($fid);
$cache->updatestats();






















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


return true;
}


return true;
}

Zeile 1026Zeile 1389
			$db->update_query(TABLE_PREFIX."posts", $new_subject, "tid='{$thread['tid']}' AND replyto='0'", 1);
}


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


		return true;
}

		return true;
}


/**
* Add thread expiry


/**
* Add thread expiry

Zeile 1057Zeile 1420
	 * @return boolean true
*/
function toggle_post_visibility($pids, $tid, $fid)

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

	{

	{

		global $db;
$pid_list = implode(',', $pids);
$query = $db->simple_select(TABLE_PREFIX."posts", 'pid, visible', "pid IN ($pid_list)");

		global $db;
$pid_list = implode(',', $pids);
$query = $db->simple_select(TABLE_PREFIX."posts", 'pid, visible', "pid IN ($pid_list)");

Zeile 1066Zeile 1429
			if($post['visible'] == 1)
{
$unapprove[] = $post['pid'];

			if($post['visible'] == 1)
{
$unapprove[] = $post['pid'];

			}

			}

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

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

			}
}
if(is_array($unapprove))

			}
}
if(is_array($unapprove))

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

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

Zeile 1100Zeile 1463
			if($thread['visible'] == 1)
{
$unapprove[] = $thread['tid'];

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

			}
else
{

			}
else
{

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

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

Zeile 1117Zeile 1480
		return true;
}


		return true;
}


	/**

	/**

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

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

Zeile 1147Zeile 1510
		{
$this->close_threads($close);
}

		{
$this->close_threads($close);
}

 
		return true;
}
/**
* 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 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 (if 0, will query database)
* @return boolean true
*/
function remove_thread_subscriptions($tids,$all = true, $fid = 0)
{
global $db;

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

// Delete only subscriptions from users who no longer have permission to read the thread.
if(!$all)
{
// Get forum ID
if(!$fid)
{
$query = $db->simple_select(TABLE_PREFIX."threads", "fid", "tid='{$tid[0]}'");
}

// Get groups that cannot view the forum or its threads
$forum_parentlist = get_parent_list($fid);
$query = $db->simple_select(TABLE_PREFIX."forumpermissions", "gid", "fid IN ({$forum_parentlist}) AND (canview='no' OR canviewthreads='no')");
$groups = array();
while($group = $db->fetch_array($query))
{
$groups[] = $group['gid'];
$additional_groups .= " OR CONCAT(',',u.additionalgroups,',') LIKE ',{$group['gid']},'";
}
// If there are groups found, delete subscriptions from users in these 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})");
}
}
// Delete all subscriptions of this thread
else
{
$db->delete_query(TABLE_PREFIX."favorites", "tid IN ({$tids_csv}) AND type='s'");
}


		return true;
}
}

		return true;
}
}