Vergleich inc/class_moderation.php - 1.2.7 - 1.2.8

  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 3051 2007-05-12 12:07:29Z chris $

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

 */

class Moderation

 */

class Moderation

Zeile 19Zeile 19
	 */
function close_threads($tids)
{

	 */
function close_threads($tids)
{

		global $db;


		global $db, $plugins;


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

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






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


		$openthread = array(
"closed" => "yes",
);
$db->update_query(TABLE_PREFIX."threads", $openthread, "tid IN ($tid_list)");

		$openthread = array(
"closed" => "yes",
);
$db->update_query(TABLE_PREFIX."threads", $openthread, "tid IN ($tid_list)");





		return true;
}


		return true;
}


Zeile 43Zeile 45
	 */

function open_threads($tids)

	 */

function open_threads($tids)

	{
global $db;


	{
global $db, $plugins;


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

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






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


		$closethread = array(
"closed" => "no",

		$closethread = array(
"closed" => "no",

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


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


		return true;
}


		return true;
}


Zeile 67Zeile 71
	 * @return boolean true
*/
function stick_threads($tids)

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

	{
global $db;


	{
global $db, $plugins;


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

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






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


		$stickthread = array(
"sticky" => 1,

		$stickthread = array(
"sticky" => 1,

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

return true;
}

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

return true;
}


/**
* Unstick one or more thread


/**
* Unstick one or more thread

Zeile 92Zeile 98
	 */
function unstick_threads($tids)
{

	 */
function unstick_threads($tids)
{

		global $db;

		global $db, $plugins;


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


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

 

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


$unstickthread = array(
"sticky" => 0,
);
$db->update_query(TABLE_PREFIX."threads", $unstickthread, "tid IN ($tid_list)");


$unstickthread = array(
"sticky" => 0,
);
$db->update_query(TABLE_PREFIX."threads", $unstickthread, "tid IN ($tid_list)");





		return true;
}

		return true;
}





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

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

Zeile 116Zeile 124
	 */
function remove_redirects($tid)
{

	 */
function remove_redirects($tid)
{

		global $db;



		global $db, $plugins;

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





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

		// Delete the redirects
$db->delete_query(TABLE_PREFIX."threads", "closed='moved|$tid'");

		// Update the forum stats of the fids found above
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);
}
}


 
		return true;
}


		return true;
}


Zeile 238Zeile 203
		// Get thread info
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='$tid'");
$thread = $db->fetch_array($query);

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

 

// Implied counters for unapproved thread
if($thread['visible'] == 0)
{
$num_unapproved_posts += $thread['replies'];
}


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


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

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

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

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



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


return true;
}


return true;
}

Zeile 277Zeile 249
	 */
function delete_poll($pid)
{

	 */
function delete_poll($pid)
{

		global $db;



		global $db, $plugins;

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


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


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

Zeile 297Zeile 271
	 * @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);

	{
global $db, $cache, $plugins;

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

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


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


Zeile 313Zeile 287
			
if($thread['visible'] == 0)
{

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

				$num_approved_threads++; 
$num_unapproved_threads--;
}

				$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

			$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid, p.visible
FROM ".TABLE_PREFIX."posts p

Zeile 328Zeile 302
				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++;

 
				}
}

				}
}

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


		}

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

		}

$approve = array(
"visible" => 1,
);
$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."posts", $approve, "tid IN (".implode(",", $posts_to_approve).")");

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

		
// Update stats
$update_array = array(

		
// Update stats
$update_array = array(

Zeile 364Zeile 337
	 */
function unapprove_threads($tids, $fid)
{

	 */
function unapprove_threads($tids, $fid)
{

		global $db, $cache;

		global $db, $cache, $plugins;


if(!is_array($tids))
{


if(!is_array($tids))
{

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

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

 
				$num_posts += $thread['replies']+1; // Add implied invisible to count

			} 
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid, p.visible

			} 
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid, p.visible

Zeile 394Zeile 368
				{
$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++;
}

 
			}

			}

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

		}

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

		}

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

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




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

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


		// Update stats
$update_array = array(
"threads" => "-{$num_threads}",
"unapprovedthreads" => "+{$num_threads}",

		// Update stats
$update_array = array(
"threads" => "-{$num_threads}",
"unapprovedthreads" => "+{$num_threads}",

			"posts" => "-{$num_posts}", 
"unapprovedposts" => "+{$num_posts}"

			"posts" => "-{$num_posts}", 
"unapprovedposts" => "+{$num_posts}"

		); 
update_forum_counters($fid, $update_array);

		); 
update_forum_counters($fid, $update_array);





		return true;
}

		return true;
}





	/**
* Delete a specific post
*

	/**
* Delete a specific post
*

Zeile 435Zeile 408
			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='$pid'

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='$pid'

		");

		");

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

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

		}

		}

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

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

Zeile 450Zeile 423
		$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 458Zeile 431
		else
{
$num_approved_posts++;

		else
{
$num_approved_posts++;

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


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


		// Update stats 
$update_array = array(
"replies" => "-{$num_approved_posts}",

		// Update stats 
$update_array = array(
"replies" => "-{$num_approved_posts}",

Zeile 488Zeile 462
	 */
function merge_posts($pids, $tid, $sep="new_line")
{

	 */
function merge_posts($pids, $tid, $sep="new_line")
{

		global $db;

		global $db, $plugins;


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


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

Zeile 554Zeile 528
		);
$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
$update_array = array(


// Update stats
$update_array = array(

Zeile 594Zeile 570
		switch($method)
{
case "redirect": // move (and leave redirect) thread

		switch($method)
{
case "redirect": // move (and leave redirect) thread

				$plugins->run_hooks("moderation_do_move_redirect");

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

				$plugins->run_hooks("class_moderation_move_thread_redirect", array("tid" => $tid, "new_fid" => $new_fid));

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

					$num_threads++; 

					$num_threads++; 

				} 

				} 

				else 
{

				else 
{

					$num_unapproved_threads++; 



					$num_unapproved_threads++;
// Implied forum unapproved count for unapproved threads
$num_unapproved_posts = $thread['replies']+1;

				} 

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

				} 

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

				$num_unapproved_posts = $thread['unapprovedposts'];

				$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 616Zeile 594
				$db->update_query(TABLE_PREFIX."posts", $changefid, "tid='$tid'");
$threadarray = array(
"fid" => $thread['fid'],

				$db->update_query(TABLE_PREFIX."posts", $changefid, "tid='$tid'");
$threadarray = array(
"fid" => $thread['fid'],

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

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

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

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

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

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

 

if($thread['visible'] == 1)
{
++$num_threads;
}
else
{
$num_unapproved_threads++;
// Implied forum unapproved count for unapproved threads
$num_unapproved_posts = $thread['replies']+1;
}

				

				

				++$num_threads;

$plugins->run_hooks("moderation_do_move_copy");

				$plugins->run_hooks("class_moderation_copy_thread", array("tid" => $tid, "new_fid" => $new_fid));



				$db->insert_query(TABLE_PREFIX."threads", $threadarray);
$newtid = $db->insert_id();


				$db->insert_query(TABLE_PREFIX."threads", $threadarray);
$newtid = $db->insert_id();


Zeile 722Zeile 709
					);
$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']}'");
while($attachment = $db->fetch_array($query2))

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

Zeile 758Zeile 736
				break;
default:
case "move": // plain move thread

				break;
default:
case "move": // plain move thread

				$plugins->run_hooks("moderation_do_move_simple");

				$plugins->run_hooks("class_moderation_move_simple", array("tid" => $tid, "new_fid" => $new_fid));

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

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

Zeile 767Zeile 745
				else 
{
$num_unapproved_threads++;

				else 
{
$num_unapproved_threads++;

 
					// Implied forum unapproved count for unapproved threads
$num_unapproved_posts = $thread['replies']+1;

				} 

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

				} 

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

Zeile 792Zeile 772
		while($posters = $db->fetch_array($query))
{
if($method == "copy" && $newforum['usepostcounts'] != "no" && $posters['visible'] != "no")

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

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

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

		global $db, $mybb, $mergethread, $thread;




		global $db, $mybb, $mergethread, $thread, $plugins;

$mergetid = intval($mergetid);
$tid = intval($tid);


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


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

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

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


			$mergethread = $db->fetch_array($query);
}

			$mergethread = $db->fetch_array($query);
}

		if(!isset($thread['tid']) || $thread['tid'] != $tid)
{
$tid = intval($tid);
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='".intval($tid)."'");
$thread = $db->fetch_array($query);
}

		if(!isset($thread['tid']) || $thread['tid'] != $tid)
{
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='{$tid}'");
$thread = $db->fetch_array($query);
}


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

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

			$pollsql = ", poll='{$mergethread['poll']}'";

			$pollsql['poll'] = $mergethread['poll'];

			$sqlarray = array(
"tid" => $tid,
);
$db->update_query(TABLE_PREFIX."polls", $sqlarray, "tid='".intval($mergethread['tid'])."'");

			$sqlarray = array(
"tid" => $tid,
);
$db->update_query(TABLE_PREFIX."polls", $sqlarray, "tid='".intval($mergethread['tid'])."'");

		}

		}

		else
{

		else
{

			$query = $db->simple_select(TABLE_PREFIX."threads", "*", "poll='{$mergethread['poll']}' AND tid != '".intval($mergetid)."'");

			$query = $db->simple_select(TABLE_PREFIX."threads", "*", "poll='{$mergethread['poll']}' AND tid != '{$mergetid}'");

			$pollcheck = $db->fetch_array($query);
if(!$pollcheck['poll'])
{
$db->delete_query(TABLE_PREFIX."polls", "pid='{$mergethread['poll']}'");
$db->delete_query(TABLE_PREFIX."pollvotes", "pid='{$mergethread['poll']}'");

			$pollcheck = $db->fetch_array($query);
if(!$pollcheck['poll'])
{
$db->delete_query(TABLE_PREFIX."polls", "pid='{$mergethread['poll']}'");
$db->delete_query(TABLE_PREFIX."pollvotes", "pid='{$mergethread['poll']}'");

			}
}

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

$sqlarray = array(

			}
}

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

$sqlarray = array(

			"tid" => $tid,
"fid" => $thread['fid'],
"replyto" => 0
);
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "tid='$mergetid'");

			"tid" => $tid,
"fid" => $thread['fid'],
"replyto" => 0
);
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "tid='$mergetid'");

		
$db->query("UPDATE ".TABLE_PREFIX."threads SET subject='$subject' $pollsql WHERE tid='$tid'");



$pollsql['subject'] = $subject;
$db->update_query(TABLE_PREFIX."threads", $pollsql, "tid='$tid'");

		$sqlarray = array(
"closed" => "moved|$tid",
);

		$sqlarray = array(
"closed" => "moved|$tid",
);

Zeile 905Zeile 887
		);
$db->update_query(TABLE_PREFIX."favorites", $sqlarray, "tid='$mergetid'");
update_first_post($tid);

		);
$db->update_query(TABLE_PREFIX."favorites", $sqlarray, "tid='$mergetid'");
update_first_post($tid);






$plugins->run_hooks("class_moderation_merge_threads", array("mergetid" => $tid, "tid" => $tid, "subject" => $subject));


		$this->delete_thread($mergetid);

		$this->delete_thread($mergetid);

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

 




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

// 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)
{
$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"
);
}
update_forum_counters($thread['fid'], $updated_stats);
}

		return true;
}


		return true;
}


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

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

		global $db, $thread;

		global $db, $thread, $plugins;


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


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

Zeile 946Zeile 977
		// Create the new thread
$newsubject = $db->escape_string($newsubject);
$query = array(

		// Create the new thread
$newsubject = $db->escape_string($newsubject);
$query = array(

			"fid" => $moveto,
"subject" => $newsubject,
"icon" => $thread['icon'],
"uid" => $thread['uid'],
"username" => $thread['username'],
"dateline" => $thread['dateline'],
"lastpost" => $thread['lastpost'],
"lastposter" => $thread['lastposter'],

			"fid" => intval($moveto),
"subject" => $db->escape_string($newsubject),
"icon" => $db->escape_string($thread['icon']),
"uid" => $db->escape_string($thread['uid']),
"username" => $db->escape_string($thread['username']),
"dateline" => $db->escape_string($thread['dateline']),
"lastpost" => $db->escape_string($thread['lastpost']),
"lastposter" => $db->escape_string($thread['lastposter']),

			"replies" => count($pids)-1,
"visible" => "1",
"notes" => ''

			"replies" => count($pids)-1,
"visible" => "1",
"notes" => ''

Zeile 995Zeile 1026
			}

if(!empty($pcount))

			}

if(!empty($pcount))

			{

			{

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










		}

$num_visible = $num_unnaproved = $num_attachments = 0;
$query = $db->query("
SELECT p.visible, a.aid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."attachments a ON (a.pid=p.pid AND a.visible=1)
WHERE p.tid='{$newtid}'
");
while($post = $db->fetch_array($query))
{
if($post['visible'] == 1)
{
$num_visible++;
if($post['aid'])
{
$num_attachments++;
}
}
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 1022Zeile 1062
			"replyto" => 0
);
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "pid='{$newthread['pid']}'");

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





		// Update the subject of the first post in the old thread
$query = $db->simple_select(TABLE_PREFIX."posts", "pid", "tid='$tid'", array('order_by' => 'dateline', 'limit' => 1));
$oldthread = $db->fetch_array($query);

		// Update the subject of the first post in the old thread
$query = $db->simple_select(TABLE_PREFIX."posts", "pid", "tid='$tid'", array('order_by' => 'dateline', 'limit' => 1));
$oldthread = $db->fetch_array($query);

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

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

 

$plugins->run_hooks("class_moderation_split_posts", array("pids" => $pids, "tid" => $tid, "moveto" => $moveto, "newsubject" => $newsubject, "destination_tid" => $destination_tid));


// Update old thread stats
$update_array = array(
"replies" => "-{$num_visible}",


// Update old thread stats
$update_array = array(
"replies" => "-{$num_visible}",

			"unapprovedposts" => "-{$num_unapproved}" 


			"unapprovedposts" => "-{$num_unapproved}",
"attachmentcount" => "-{$num_attachments}"

		); 
update_thread_counters($thread['tid'], $update_array);

// Update new thread stats
$update_array = array(
"replies" => $num_visible-1,

		); 
update_thread_counters($thread['tid'], $update_array);

// Update new thread stats
$update_array = array(
"replies" => $num_visible-1,

			"unapprovedposts" => $num_unapproved 


			"unapprovedposts" => $num_unapproved,
"attachmentcount" => $num_attachments

		); 
update_thread_counters($newtid, $update_array);


		); 
update_thread_counters($newtid, $update_array);


Zeile 1062Zeile 1106
			); 
}
else

			); 
}
else

		{ 

		{ 

			$update_array = array(); 
}


			$update_array = array(); 
}


Zeile 1098Zeile 1142
	 */
function move_threads($tids, $moveto)
{

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

		global $db;

		global $db, $plugins;


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



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


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

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

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

			$total_unapproved_posts += $thread['unapprovedposts']; 

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


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

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

Zeile 1125Zeile 1168
			else 
{
$forum_counters[$thread['fid']]['unapprovedthreads']++;

			else 
{
$forum_counters[$thread['fid']]['unapprovedthreads']++;

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

				++$total_unapproved_threads; 
}


				++$total_unapproved_threads; 
}


			$query = $db->query("

			$query1 = $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)

				SELECT COUNT(p.pid) AS posts, u.uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

Zeile 1136Zeile 1180
				GROUP BY u.uid
ORDER BY posts DESC
");

				GROUP BY u.uid
ORDER BY posts DESC
");

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

			while($posters = $db->fetch_array($query1))

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

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

Zeile 1157Zeile 1201
				}
}
}

				}
}
}



		

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

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

 

$plugins->run_hooks("class_moderation_move_threads", array("tids" => $tids, "moveto" => $moveto));


foreach($forum_counters as $fid => $counter)
{
$updated_count = array(
"posts" => "-{$counter['posts']}",


foreach($forum_counters as $fid => $counter)
{
$updated_count = array(
"posts" => "-{$counter['posts']}",

				"unapprovedposts" => "-{$counter['unapproved_posts']}" 

				"unapprovedposts" => "-{$counter['unapprovedposts']}" 

			); 
if($counter['threads'])
{

			); 
if($counter['threads'])
{

Zeile 1207Zeile 1253
	 */
function approve_posts($pids, $tid, $fid)
{

	 */
function approve_posts($pids, $tid, $fid)
{

		global $db, $cache;

		global $db, $cache, $plugins;


$thread = get_thread($tid);



$thread = get_thread($tid);


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

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


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






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

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

		}

		}

		if($is_first) 
{
$updated_thread_stats['replies'] = "+".($num_posts-1);

		if($is_first) 
{
$updated_thread_stats['replies'] = "+".($num_posts-1);

Zeile 1267Zeile 1320
			"unapprovedposts" => "-{$num_posts}" 
);


			"unapprovedposts" => "-{$num_posts}" 
);


		if($is_first) 

		if($is_first) 

		{ 
$updated_forum_stats['threads'] = "+1";
$updated_forum_stats['unapprovedthreads'] = "-1";

		{ 
$updated_forum_stats['threads'] = "+1";
$updated_forum_stats['unapprovedthreads'] = "-1";

Zeile 1286Zeile 1339
	 * @return boolean true
*/
function unapprove_posts($pids, $tid, $fid)

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

	{
global $db, $cache;


	{
global $db, $cache, $plugins;


		$thread = get_thread($tid);

$num_posts = 0;

		$thread = get_thread($tid);

$num_posts = 0;

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

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

			}

			}

		}

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

		}

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

Zeile 1318Zeile 1371
			"visible" => 0,
);
$db->update_query(TABLE_PREFIX."posts", $unapprove, $where);

			"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


$is_first = false;
// If this is the first post of the thread, also approve the thread

Zeile 1328Zeile 1383
			if(in_array($first_post['pid'], $pids)) 
{
$is_first = true;

			if(in_array($first_post['pid'], $pids)) 
{
$is_first = true;

 
				// Thread is visible, update impled counters
if($thread['visible'] == 1)
{
$num_posts += $thread['replies'];
}

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

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

Zeile 1348Zeile 1408
			"posts" => "-{$num_posts}", 
"unapprovedposts" => "+{$num_posts}"
);

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





		if($is_first) 
{
$updated_forum_stats['threads'] = "-1";

		if($is_first) 
{
$updated_forum_stats['threads'] = "-1";

Zeile 1368Zeile 1428
	 */
function change_thread_subject($tids, $format)
{

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

		global $db;

		global $db, $plugins;


// Get tids into list
if(!is_array($tids))


// Get tids into list
if(!is_array($tids))

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

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

 

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

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

		}

		}

	




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


		return true;
}


		return true;
}


Zeile 1401Zeile 1469
	 */
function expire_thread($tid, $deletetime)
{

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

		global $db;

		global $db, $plugins;


$update_thread = array(
"deletetime" => intval($deletetime)
);
$db->update_query(TABLE_PREFIX."threads", $update_thread, "tid='{$tid}'");


$update_thread = array(
"deletetime" => intval($deletetime)
);
$db->update_query(TABLE_PREFIX."threads", $update_thread, "tid='{$tid}'");


return true;




$plugins->run_hooks("class_moderation_expire_thread", array("tid" => $tid, "deletetime" => $deletetime));

return true;

	}

/**

	}

/**

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

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

			}
else

			}
else

			{
$approve[] = $post['pid'];
}
}
if(is_array($unapprove))

			{
$approve[] = $post['pid'];
}
}
if(is_array($unapprove))

		{

		{

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

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

		}

		}

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

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

Zeile 1451Zeile 1521
	 *
* @param array Thread IDs
* @param int Forum ID

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

	 * @return boolean true

	 * @return boolean true

	 */
function toggle_thread_visibility($tids, $fid)
{

	 */
function toggle_thread_visibility($tids, $fid)
{

Zeile 1520Zeile 1590
	 * @param int $fid (Only applies if $all is false) The forum ID of the thread (if 0, will query database)
* @return boolean true
*/

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

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

	{

	{

		global $db;

		global $db, $plugins;

		
// Format thread IDs
if(!is_array($tids))

		
// Format thread IDs
if(!is_array($tids))

Zeile 1561Zeile 1631
		{
$db->delete_query(TABLE_PREFIX."favorites", "tid IN ({$tids_csv}) AND type='s'");
}

		{
$db->delete_query(TABLE_PREFIX."favorites", "tid IN ({$tids_csv}) AND type='s'");
}

 

$plugins->run_hooks("class_moderation_remove_thread_subscriptions", array("tids" => $tids, "all" => $all, "fid" => $fid));

		
return true;
}

		
return true;
}