Vergleich inc/class_moderation.php - 1.8.32 - 1.8.38

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 434Zeile 434
				$query2 = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))
{

				$query2 = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))
{

 
					if(!isset($user_counters[$counter['uid']]))
{
$user_counters[$counter['uid']] = array(
'num_posts' => 0,
'num_threads' => 0
);
}

					$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}

					$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}

			}

			}


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


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

			{

			{

				++$user_counters[$thread['uid']]['num_threads'];
}


				++$user_counters[$thread['uid']]['num_threads'];
}


Zeile 454Zeile 461
			{
$tid_moved_list .= "{$comma}'moved|{$tid}'";
$comma = ",";

			{
$tid_moved_list .= "{$comma}'moved|{$tid}'";
$comma = ",";

			}

			}

			$tid_list = implode(',', $tid_list);
$approve = array(
"visible" => 1

			$tid_list = implode(',', $tid_list);
$approve = array(
"visible" => 1

Zeile 464Zeile 471
			$redirect_tids = array();
$query = $db->simple_select('threads', 'tid', "closed IN ({$tid_moved_list})");
while($redirect_tid = $db->fetch_field($query, 'tid'))

			$redirect_tids = array();
$query = $db->simple_select('threads', 'tid', "closed IN ({$tid_moved_list})");
while($redirect_tid = $db->fetch_field($query, 'tid'))

			{

			{

				$redirect_tids[] = $redirect_tid;
}
if(!empty($redirect_tids))

				$redirect_tids[] = $redirect_tid;
}
if(!empty($redirect_tids))

Zeile 474Zeile 481
			if(!empty($posts_to_approve))
{
$db->update_query("posts", $approve, "pid IN (".implode(',', $posts_to_approve).")");

			if(!empty($posts_to_approve))
{
$db->update_query("posts", $approve, "pid IN (".implode(',', $posts_to_approve).")");

			}

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

			}

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


if(!empty($forum_counters))
{


if(!empty($forum_counters))
{

Zeile 492Zeile 499
					);
update_forum_counters($fid, $update_array);
update_forum_lastpost($fid);

					);
update_forum_counters($fid, $update_array);
update_forum_lastpost($fid);

				}
}


				}
}


			if(!empty($user_counters))
{
foreach($user_counters as $uid => $counters)

			if(!empty($user_counters))
{
foreach($user_counters as $uid => $counters)

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

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

				{

				{

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

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

Zeile 595Zeile 602
					$query2 = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))
{

					$query2 = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))
{

 
						if(!isset($user_counters[$counter['uid']]))
{
$user_counters[$counter['uid']] = array(
'num_posts' => 0,
'num_threads' => 0
);
}

						$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}
}

						$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}
}

Zeile 1580Zeile 1594
		{
update_first_post($thread['tid']);
}

		{
update_first_post($thread['tid']);
}

 

// Attach moved posts to the first post
$db->update_query("posts", array('replyto' => $new_firstpost['pid']), "tid='{$tid}' AND replyto = 0 AND pid != '{$new_firstpost['pid']}'");


// Update thread count if thread has a new firstpost and is visible
if($thread['uid'] != $new_firstpost['uid'] && $thread['visible'] == 1 && $forum_cache[$thread['fid']]['usethreadcounts'] == 1)
{
if(!isset($user_posts[$thread['uid']]['threadnum']))


// Update thread count if thread has a new firstpost and is visible
if($thread['uid'] != $new_firstpost['uid'] && $thread['visible'] == 1 && $forum_cache[$thread['fid']]['usethreadcounts'] == 1)
{
if(!isset($user_posts[$thread['uid']]['threadnum']))

			{

			{

				$user_posts[$thread['uid']]['threadnum'] = 0;
}
--$user_posts[$thread['uid']]['threadnum'];

				$user_posts[$thread['uid']]['threadnum'] = 0;
}
--$user_posts[$thread['uid']]['threadnum'];

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

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

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

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

					"deletedposts" => '+'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts'])
);
}

					"deletedposts" => '+'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts'])
);
}

Zeile 2116Zeile 2133
				++$forum_counters[$moveto]['deletedposts'];
}
}

				++$forum_counters[$moveto]['deletedposts'];
}
}

 

// Attach moved posts to the first post
$db->update_query("posts", array('replyto' => $post_info['pid']), "tid='{$newtid}' AND replyto = 0 AND pid != '{$post_info['pid']}'");


if($destination_tid == 0 && $newthread['visible'] == 1)
{


if($destination_tid == 0 && $newthread['visible'] == 1)
{

Zeile 2123Zeile 2143
			--$thread_counters[$newtid]['replies'];
}
elseif($destination_tid == 0 && $newthread['visible'] == 0)

			--$thread_counters[$newtid]['replies'];
}
elseif($destination_tid == 0 && $newthread['visible'] == 0)

		{
// If splitting into a new thread, subtract one from the thread's reply count to compensate for the original post

		{
// If splitting into a new thread, subtract one from the thread's reply count to compensate for the original post

			--$thread_counters[$newtid]['unapprovedposts'];
}
elseif($destination_tid == 0 && $newthread['visible'] == -1)

			--$thread_counters[$newtid]['unapprovedposts'];
}
elseif($destination_tid == 0 && $newthread['visible'] == -1)

		{

		{

			// If splitting into a new thread, subtract one from the thread's reply count to compensate for the original post
--$thread_counters[$newtid]['deletedposts'];

			// If splitting into a new thread, subtract one from the thread's reply count to compensate for the original post
--$thread_counters[$newtid]['deletedposts'];

		}


		}


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


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


Zeile 2149Zeile 2169
					}
}
update_user_counters($uid, $counters);

					}
}
update_user_counters($uid, $counters);

			}
}

			}
}


// Update thread counters
if(is_array($thread_counters))


// Update thread counters
if(is_array($thread_counters))

Zeile 2217Zeile 2237
		}

return $newtid;

		}

return $newtid;

	}


	}


	/**
* Move multiple threads to new forum
*

	/**
* Move multiple threads to new forum
*

Zeile 2231Zeile 2251
	function move_threads($tids, $moveto)
{
global $db, $plugins;

	function move_threads($tids, $moveto)
{
global $db, $plugins;





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


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


Zeile 2240Zeile 2260
		$moveto = (int)$moveto;

$newforum = get_forum($moveto);

		$moveto = (int)$moveto;

$newforum = get_forum($moveto);





		if(empty($tids) || !$newforum)
{
return false;

		if(empty($tids) || !$newforum)
{
return false;

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

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





			if(!isset($forum_counters[$thread['fid']]))
{
$forum_counters[$thread['fid']] = array(

			if(!isset($forum_counters[$thread['fid']]))
{
$forum_counters[$thread['fid']] = array(

Zeile 2262Zeile 2282
					'unapprovedthreads' => 0,
'deletedthreads' => 0,
'deletedposts' => 0

					'unapprovedthreads' => 0,
'deletedthreads' => 0,
'deletedposts' => 0

				);
}


				);
}


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

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

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

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





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

if($newforum['usethreadcounts'] == 1 && $forum['usethreadcounts'] == 0)

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

if($newforum['usethreadcounts'] == 1 && $forum['usethreadcounts'] == 0)

				{

				{

					++$user_counters[$thread['uid']]['num_threads'];
}
else if($newforum['usethreadcounts'] == 0 && $forum['usethreadcounts'] == 1)

					++$user_counters[$thread['uid']]['num_threads'];
}
else if($newforum['usethreadcounts'] == 0 && $forum['usethreadcounts'] == 1)

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

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





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

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

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

					break;
default:
$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(
"prefix" => 0,
);
$db->update_query("threads", $sqlarray, "tid = '{$thread['tid']}'");

			if($db->fetch_field($query, "num_prefixes") == 0)
{
$sqlarray = array(
"prefix" => 0,
);
$db->update_query("threads", $sqlarray, "tid = '{$thread['tid']}'");

			}
}


			}
}


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


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


Zeile 2389Zeile 2409
					"threadnum" => "+{$counters['num_threads']}",
);
update_user_counters($uid, $update_array);

					"threadnum" => "+{$counters['num_threads']}",
);
update_user_counters($uid, $update_array);

			}
}


			}
}


		if(is_array($forum_counters))
{
foreach($forum_counters as $fid => $counter)

		if(is_array($forum_counters))
{
foreach($forum_counters as $fid => $counter)

Zeile 3174Zeile 3194

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



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


		$plugins->run_hooks('class_moderation_apply_thread_prefix', $arguments);


		$plugins->run_hooks('class_moderation_apply_thread_prefix', $arguments);


		return true;
}


		return true;
}


Zeile 3221Zeile 3241
		while($post = $db->fetch_array($query))
{
// This is the first post in the thread so we're deleting the whole thread.

		while($post = $db->fetch_array($query))
{
// This is the first post in the thread so we're deleting the whole thread.

			$threads_to_update[] = $post['tid'];
}

if(!empty($threads_to_update))

			$threads_to_update[] = $post['tid'];
}

if(!empty($threads_to_update))

		{
$this->soft_delete_threads($threads_to_update);
}

		{
$this->soft_delete_threads($threads_to_update);
}

Zeile 3243Zeile 3263
			$pids[] = $post['pid'];

if(!isset($thread_counters[$post['tid']]))

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

if(!isset($thread_counters[$post['tid']]))

			{

			{

				$thread_counters[$post['tid']] = array(
'replies' => 0,
'unapprovedposts' => 0,
'deletedposts' => 0

				$thread_counters[$post['tid']] = array(
'replies' => 0,
'unapprovedposts' => 0,
'deletedposts' => 0

				);
}

				);
}


++$thread_counters[$post['tid']]['deletedposts'];
if($post['visible'] == 1)
{
++$thread_counters[$post['tid']]['replies'];


++$thread_counters[$post['tid']]['deletedposts'];
if($post['visible'] == 1)
{
++$thread_counters[$post['tid']]['replies'];

			}

			}

			else
{
++$thread_counters[$post['tid']]['unapprovedposts'];

			else
{
++$thread_counters[$post['tid']]['unapprovedposts'];

Zeile 3267Zeile 3287
					'num_posts' => 0,
'num_unapproved_posts' => 0,
'num_deleted_posts' => 0

					'num_posts' => 0,
'num_unapproved_posts' => 0,
'num_deleted_posts' => 0

				);
}

// If the thread of this post is deleted then we've already taken into account this counter as implied.
// Updating it again would cause it to double count
if($post['threadvisible'] == 1)
{

				);
}

// If the thread of this post is deleted then we've already taken into account this counter as implied.
// Updating it again would cause it to double count
if($post['threadvisible'] == 1)
{

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

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

				{

				{

					++$forum_counters[$post['fid']]['num_unapproved_posts'];
}
}

					++$forum_counters[$post['fid']]['num_unapproved_posts'];
}
}

Zeile 3318Zeile 3338
					"unapprovedposts" => "-".$counters['unapprovedposts'],
"replies" => "-".$counters['replies'],
"deletedposts" => "+".$counters['deletedposts']

					"unapprovedposts" => "-".$counters['unapprovedposts'],
"replies" => "-".$counters['replies'],
"deletedposts" => "+".$counters['deletedposts']

				);

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

				);

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

		}

if(is_array($forum_counters))

		}

if(is_array($forum_counters))

Zeile 3418Zeile 3438
			{
$thread_counters[$post['tid']] = array(
'replies' => 0

			{
$thread_counters[$post['tid']] = array(
'replies' => 0

				);
}


				);
}


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

// If the thread of this post is deleted then we've already taken into account this counter as implied.
// Updating it again would cause it to double count
if($post['threadvisible'] == 1)

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

// If the thread of this post is deleted then we've already taken into account this counter as implied.
// Updating it again would cause it to double count
if($post['threadvisible'] == 1)

			{

			{

				if(!isset($forum_counters[$post['fid']]))
{
$forum_counters[$post['fid']] = array(
'num_posts' => 0
);

				if(!isset($forum_counters[$post['fid']]))
{
$forum_counters[$post['fid']] = array(
'num_posts' => 0
);

				}

				}

				++$forum_counters[$post['fid']]['num_posts'];
}

// If post counts enabled in this forum and the thread is approved, add 1
if($post['usepostcounts'] != 0 && $post['threadvisible'] == 1)

				++$forum_counters[$post['fid']]['num_posts'];
}

// If post counts enabled in this forum and the thread is approved, add 1
if($post['usepostcounts'] != 0 && $post['threadvisible'] == 1)

			{

			{

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

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





			}
}


			}
}


Zeile 3468Zeile 3488
				$counters_update = array(
"deletedposts" => "-".$counters['replies'],
"replies" => "+".$counters['replies']

				$counters_update = array(
"deletedposts" => "-".$counters['replies'],
"replies" => "+".$counters['replies']

				);

				);

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

if(is_array($forum_counters))

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

if(is_array($forum_counters))

		{

		{

			foreach($forum_counters as $fid => $counters)
{
$updated_forum_stats = array(

			foreach($forum_counters as $fid => $counters)
{
$updated_forum_stats = array(

Zeile 3493Zeile 3513
			{
update_user_counters($uid, array('postnum' => "+{$counter}"));
}

			{
update_user_counters($uid, array('postnum' => "+{$counter}"));
}

		}

		}


return true;
}


return true;
}

Zeile 3511Zeile 3531
		if(!is_array($tids))
{
$tids = array($tids);

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

		}

		}


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


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





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


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


Zeile 3529Zeile 3549
		while($thread = $db->fetch_array($query))
{
if($thread['visible'] != -1)

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

			{

			{

				continue;
}
$tid_list[] = $thread['tid'];

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

				continue;
}
$tid_list[] = $thread['tid'];

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





			if(!isset($forum_counters[$forum['fid']]))
{
$forum_counters[$forum['fid']] = array(

			if(!isset($forum_counters[$forum['fid']]))
{
$forum_counters[$forum['fid']] = array(

Zeile 3547Zeile 3567
			}

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

			}

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

			{

			{

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

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





			++$forum_counters[$forum['fid']]['num_threads'];
$forum_counters[$forum['fid']]['num_posts'] += $thread['replies']+1; // Remove implied visible from count
$forum_counters[$forum['fid']]['num_deleted_posts'] += $thread['replies']+$thread['unapprovedposts']+1;

			++$forum_counters[$forum['fid']]['num_threads'];
$forum_counters[$forum['fid']]['num_posts'] += $thread['replies']+1; // Remove implied visible from count
$forum_counters[$forum['fid']]['num_deleted_posts'] += $thread['replies']+$thread['unapprovedposts']+1;

Zeile 3565Zeile 3585
				$query2 = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))
{

				$query2 = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))
{

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

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

					{

					{

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




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

					}
$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}

					}
$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}

Zeile 3730Zeile 3753
					$query2 = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))
{

					$query2 = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$thread['tid']}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid");
while($counter = $db->fetch_array($query2))
{

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

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

						{

						{

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




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

						}
$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}

						}
$user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
}