Vergleich inc/class_moderation.php - 1.6.0 - 1.6.17

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: class_moderation.php 5145 2010-07-30 21:30:51Z RyanGordon $

 * $Id$

 */

class Moderation

 */

class Moderation

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

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

 
		$db->delete_query("threadratings", "tid='$tid'");


$updated_counters = array(
"posts" => "-{$num_approved_posts}",


$updated_counters = array(
"posts" => "-{$num_approved_posts}",

Zeile 453Zeile 454
	{
global $db, $cache, $plugins;


	{
global $db, $cache, $plugins;


		$plugins->run_hooks_by_ref("class_moderation_delete_post_start", $pid);

		$pid = $plugins->run_hooks("class_moderation_delete_post_start", $pid);

		// Get pid, uid, fid, tid, visibility, forum post count status of post
$pid = intval($pid);
$query = $db->query("

		// Get pid, uid, fid, tid, visibility, forum post count status of post
$pid = intval($pid);
$query = $db->query("

Zeile 545Zeile 546
		");
$num_unapproved_posts = $num_approved_posts = 0;
$message = '';

		");
$num_unapproved_posts = $num_approved_posts = 0;
$message = '';

 
		$threads = array();

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

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

 
			$threads[$post['tid']] = $post['tid'];

			if($first == 1)
{ // all posts will be merged into this one
$masterpid = $post['pid'];

			if($first == 1)
{ // all posts will be merged into this one
$masterpid = $post['pid'];

Zeile 605Zeile 608
				}
}
}

				}
}
}


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

$query2 = $db->simple_select("attachments", "COUNT(aid) as count", "pid IN({$pidin}) AND visible='1'");
$attachment_count = $db->fetch_field($query2, "count");

$db->update_query("threads", array("attachmentcount" => $attachment_count), "tid = '{$mastertid}'");

 

// Update the message
$mergepost = array(


// Update the message
$mergepost = array(

Zeile 645Zeile 639
				--$forum_counters[$thread['fid']]['threads'];
}
else

				--$forum_counters[$thread['fid']]['threads'];
}
else

			{

			{

				if(!isset($forum_counters[$thread['fid']]['unapprovedthreads']))
{
$forum_counters[$thread['fid']]['unapprovedthreads'] = 0;

				if(!isset($forum_counters[$thread['fid']]['unapprovedthreads']))
{
$forum_counters[$thread['fid']]['unapprovedthreads'] = 0;

Zeile 653Zeile 647
				--$forum_counters[$thread['fid']]['unapprovedthreads'];
}
}

				--$forum_counters[$thread['fid']]['unapprovedthreads'];
}
}





		$arguments = array("pids" => $pids, "tid" => $tid);

		$arguments = array("pids" => $pids, "tid" => $tid);

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


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


		if(is_array($thread_counters))
{
foreach($thread_counters as $tid => $counters)

		if(is_array($thread_counters))
{
foreach($thread_counters as $tid => $counters)

Zeile 668Zeile 662
		}

update_thread_data($mastertid);

		}

update_thread_data($mastertid);

		

		

		update_forum_lastpost($fid);

		update_forum_lastpost($fid);

 
		
foreach($threads as $tid)
{
$count = array();
// Attachment count
$query = $db->query("
SELECT COUNT(aid) AS attachment_count
FROM ".TABLE_PREFIX."attachments a
LEFT JOIN ".TABLE_PREFIX."posts p ON (a.pid=p.pid)
WHERE p.tid='$tid'
");
$count['attachmentcount'] = $db->fetch_field($query, "attachment_count");

if(!$count['attachmentcount'])
{
$count['attachmentcount'] = 0;
}

update_thread_counters($tid, $count);
}


if(is_array($forum_counters))
{


if(is_array($forum_counters))
{

Zeile 701Zeile 715
		global $db, $plugins;

// Get thread info

		global $db, $plugins;

// Get thread info

		$tid = intval($tid);

		$tid = intval($tid);

		$new_fid = intval($new_fid);
$redirect_expire = intval($redirect_expire);


		$new_fid = intval($new_fid);
$redirect_expire = intval($redirect_expire);


Zeile 765Zeile 779
					"replies" => 0,
"closed" => "moved|$tid",
"sticky" => $thread['sticky'],

					"replies" => 0,
"closed" => "moved|$tid",
"sticky" => $thread['sticky'],

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

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

					"notes" => ''
);
$redirect_tid = $db->insert_query("threads", $threadarray);

					"notes" => ''
);
$redirect_tid = $db->insert_query("threads", $threadarray);

Zeile 798Zeile 812
					"replies" => $thread['replies'],
"closed" => $thread['closed'],
"sticky" => $thread['sticky'],

					"replies" => $thread['replies'],
"closed" => $thread['closed'],
"sticky" => $thread['sticky'],

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

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

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

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

Zeile 904Zeile 918
					{
$attachment_array = array(
'pid' => $pid,

					{
$attachment_array = array(
'pid' => $pid,

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

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

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

Zeile 972Zeile 985
				while($movedthread = $db->fetch_array($query))
{
$db->delete_query("threads", "tid='".intval($movedthread['tid'])."'", 1);

				while($movedthread = $db->fetch_array($query))
{
$db->delete_query("threads", "tid='".intval($movedthread['tid'])."'", 1);

				}

				}

				break;
}


				break;
}


Zeile 993Zeile 1006
				$pcount = "-{$posters['posts']}";
}
else if($forum['usepostcounts'] == 0 && $newforum['userpostcounts'] == 1 && $posters['visible'] == 1)

				$pcount = "-{$posters['posts']}";
}
else if($forum['usepostcounts'] == 0 && $newforum['userpostcounts'] == 1 && $posters['visible'] == 1)

			{

			{

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


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


Zeile 1026Zeile 1039
		if(isset($newtid))
{
return $newtid;

		if(isset($newtid))
{
return $newtid;

		}

		}

		else
{
// Remove thread subscriptions for the users who no longer have permission to view the thread

		else
{
// Remove thread subscriptions for the users who no longer have permission to view the thread

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

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

		}


		}


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

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

Zeile 1079Zeile 1092
			{
$db->delete_query("polls", "pid='{$mergethread['poll']}'");
$db->delete_query("pollvotes", "pid='{$mergethread['poll']}'");

			{
$db->delete_query("polls", "pid='{$mergethread['poll']}'");
$db->delete_query("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,

			"tid" => $tid,
"fid" => $thread['fid'],
"replyto" => 0,

			"visible" => $mergethread['visible'],

 
		);
$db->update_query("posts", $sqlarray, "tid='{$mergetid}'");


		);
$db->update_query("posts", $sqlarray, "tid='{$mergetid}'");


Zeile 1096Zeile 1108
		$db->update_query("threads", $pollsql, "tid='{$tid}'");
$sqlarray = array(
"closed" => "moved|{$tid}",

		$db->update_query("threads", $pollsql, "tid='{$tid}'");
$sqlarray = array(
"closed" => "moved|{$tid}",

		);

		);

		$db->update_query("threads", $sqlarray, "closed='moved|{$mergetid}'");

		$db->update_query("threads", $sqlarray, "closed='moved|{$mergetid}'");

		$sqlarray = array(

		$sqlarray = array(

			"tid" => $tid,
);

			"tid" => $tid,
);

		$db->update_query("threadsubscriptions", $sqlarray, "tid='{$mergetid}'");




















































// Update the thread ratings
$new_numrating = $thread['numratings'] + $mergethread['numratings'];
$new_threadrating = $thread['totalratings'] + $mergethread['totalratings'];

$sqlarray = array(
"numratings" => $new_numrating,
"totalratings" => $new_threadrating
);

$db->update_query("threads", $sqlarray, "tid = '{$tid}'");

// Check if we have a thread subscription already for our new thread
$subscriptions = array(
$tid => array(),
$mergetid => array()
);

$query = $db->simple_select("threadsubscriptions", "tid, uid", "tid='{$mergetid}' OR tid='{$tid}'");
while($subscription = $db->fetch_array($query))
{
$subscriptions[$subscription['tid']][] = $subscription['uid'];
}

// Update any subscriptions for the merged thread
if(is_array($subscriptions[$mergetid]))
{
$update_users = array();
foreach($subscriptions[$mergetid] as $user)
{
if(!in_array($user, $subscriptions[$tid]))
{
// User doesn't have a $tid subscription
$update_users[] = $user;
}
}

if(!empty($update_users))
{
$update_array = array(
"tid" => $tid
);

$update_users = implode(",", $update_users);
$db->update_query("threadsubscriptions", $update_array, "tid = '{$mergetid}' AND uid IN ({$update_users})");
}
}

// Remove source thread subscriptions
$db->delete_query("threadsubscriptions", "tid = '{$mergetid}'");


		update_first_post($tid);

$arguments = array("mergetid" => $mergetid, "tid" => $tid, "subject" => $subject);

		update_first_post($tid);

$arguments = array("mergetid" => $mergetid, "tid" => $tid, "subject" => $subject);

Zeile 1131Zeile 1193
		{
// If new thread is unapproved, implied counter comes in to effect
if($thread['visible'] == 0 || $mergethread['visible'] == 0)

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

			{

			{

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

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

Zeile 1150Zeile 1212
			{
$updated_stats = array(
"unapprovedposts" => '-'.($mergethread['replies']+1+$mergethread['unapprovedposts'])

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

				);
}
else
{

				);
}
else
{

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

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

Zeile 1202Zeile 1264
		$pids_list = implode(',', $pids);

// Get the icon for the first split post

		$pids_list = implode(',', $pids);

// Get the icon for the first split post

		$query = $db->simple_select("posts", "icon", "pid=".intval($pids[0]));
$icon = $db->fetch_array($query);




		$query = $db->simple_select("posts", "icon, visible", "pid=".intval($pids[0]));
$post_info = $db->fetch_array($query);

$icon = $post_info['icon'];
$visible = $post_info['visible'];


if($destination_tid == 0)
{


if($destination_tid == 0)
{

Zeile 1214Zeile 1279
			$query = array(
"fid" => $moveto,
"subject" => $newsubject,

			$query = array(
"fid" => $moveto,
"subject" => $newsubject,

				"icon" => intval($icon['icon']),

				"icon" => intval($icon),

				"uid" => intval($thread['uid']),
"username" => $db->escape_string($thread['username']),
"dateline" => intval($thread['dateline']),
"lastpost" => intval($thread['lastpost']),
"lastposter" => $db->escape_string($thread['lastposter']),
"replies" => count($pids)-1,

				"uid" => intval($thread['uid']),
"username" => $db->escape_string($thread['username']),
"dateline" => intval($thread['dateline']),
"lastpost" => intval($thread['lastpost']),
"lastposter" => $db->escape_string($thread['lastposter']),
"replies" => count($pids)-1,

				"visible" => 1,

				"visible" => intval($visible),

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

$forum_counters[$moveto]['threads'] = $forum_cache[$moveto]['threads'];

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

$forum_counters[$moveto]['threads'] = $forum_cache[$moveto]['threads'];

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










			$forum_counters[$moveto]['unapprovedthreads'] = $forum_cache[$moveto]['unapprovedthreads'];
if($visible)
{
++$forum_counters[$moveto]['threads'];
}
else
{
// Unapproved thread?
++$forum_counters[$moveto]['unapprovedthreads'];
}

		}

// Get attachment counts for each post

		}

// Get attachment counts for each post

Zeile 1261Zeile 1335
			"replyto" => 0
);
$db->update_query("posts", $sqlarray, "pid IN ($pids_list)");

			"replyto" => 0
);
$db->update_query("posts", $sqlarray, "pid IN ($pids_list)");

 
		$db->update_query("reportedposts", array('tid' => $newtid), "pid IN ($pids_list)");


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


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

Zeile 1336Zeile 1411
					{
$forum_counters[$post['fid']]['unapprovedposts'] = $forum_cache[$post['fid']]['unapprovedposts'];
}

					{
$forum_counters[$post['fid']]['unapprovedposts'] = $forum_cache[$post['fid']]['unapprovedposts'];
}

					--$forum_counters[$post['fid']]['posts'];

					--$forum_counters[$post['fid']]['unapprovedposts'];

					// Add 1 to the new forum's unapproved posts
if(!isset($forum_counters[$moveto]['unapprovedposts']))
{

					// Add 1 to the new forum's unapproved posts
if(!isset($forum_counters[$moveto]['unapprovedposts']))
{

Zeile 1456Zeile 1531
		$newforum = get_forum($moveto);

$total_posts = $total_unapproved_posts = $total_threads = $total_unapproved_threads = 0;

		$newforum = get_forum($moveto);

$total_posts = $total_unapproved_posts = $total_threads = $total_unapproved_threads = 0;

		$query = $db->simple_select("threads", "fid, visible, replies, unapprovedposts, tid", "tid IN ($tid_list)");

		$query = $db->simple_select("threads", "fid, visible, replies, unapprovedposts, tid", "tid IN ($tid_list) AND closed NOT LIKE 'moved|%'");

		while($thread = $db->fetch_array($query))
{
$forum = get_forum($thread['fid']);

		while($thread = $db->fetch_array($query))
{
$forum = get_forum($thread['fid']);

Zeile 1480Zeile 1555
			}

$query1 = $db->query("

			}

$query1 = $db->query("

				SELECT COUNT(p.pid) AS posts, u.uid

				SELECT COUNT(p.pid) AS posts, p.visible, u.uid

				FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.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

				WHERE p.tid = '{$thread['tid']}'
GROUP BY p.visible, u.uid

				ORDER BY posts DESC
");
while($posters = $db->fetch_array($query1))

				ORDER BY posts DESC
");
while($posters = $db->fetch_array($query1))

Zeile 1516Zeile 1591
		$query = $db->simple_select("threads", "tid, prefix", "tid IN ($tid_list) AND prefix != 0");
while($thread = $db->fetch_array($query))
{

		$query = $db->simple_select("threads", "tid, prefix", "tid IN ($tid_list) AND prefix != 0");
while($thread = $db->fetch_array($query))
{

			$query = $db->simple_select("threadprefixes", "COUNT(*) as num_prefixes", "(CONCAT(',',forums,',') LIKE '%,$new_fid,%' OR forums='-1') AND pid='".$thread['prefix']."'");

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

			if($db->fetch_field($query, "num_prefixes") == 0)
{
$sqlarray = array(

			if($db->fetch_field($query, "num_prefixes") == 0)
{
$sqlarray = array(

Zeile 1832Zeile 1907
			$new_subject = array(
"subject" => $db->escape_string($subject)
);

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

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

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

		}

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

		}

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

Zeile 2074Zeile 2149
		$tids = array_map('intval', $tids);
$tids_csv = implode(',', $tids);


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


		$update_thread = array('prefix' => $prefix);

		$update_thread = array('prefix' => intval($prefix));

		$db->update_query('threads', $update_thread, "tid IN ({$tids_csv})");

$arguments = array('tids' => $tids, 'prefix' => $prefix);

		$db->update_query('threads', $update_thread, "tid IN ({$tids_csv})");

$arguments = array('tids' => $tids, 'prefix' => $prefix);