Zeile 254 | Zeile 254 |
---|
{ foreach($userposts as $uid => $subtract) {
|
{ foreach($userposts as $uid => $subtract) {
|
$update_array = array( "postnum" => "-{$subtract['num_posts']}", "threadnum" => "-{$subtract['num_threads']}", );
| $update_array = array();
if(isset($subtract['num_posts'])) { $update_array['postnum'] = "-{$subtract['num_posts']}"; }
if(isset($subtract['num_threads'])) { $update_array['threadnum'] = "-{$subtract['num_threads']}"; }
|
update_user_counters($uid, $update_array); } }
| update_user_counters($uid, $update_array); } }
|
Zeile 269 | Zeile 277 |
---|
$db->delete_query("posts", "pid IN ($pids)"); $db->delete_query("attachments", "pid IN ($pids)"); $db->delete_query("reportedcontent", "id IN ($pids) AND (type = 'post' OR type = '')");
|
$db->delete_query("posts", "pid IN ($pids)"); $db->delete_query("attachments", "pid IN ($pids)"); $db->delete_query("reportedcontent", "id IN ($pids) AND (type = 'post' OR type = '')");
|
}
| }
|
// Delete threads, redirects, subscriptions, polls, and poll votes $db->delete_query("threads", "tid='$tid'");
| // Delete threads, redirects, subscriptions, polls, and poll votes $db->delete_query("threads", "tid='$tid'");
|
Zeile 289 | Zeile 297 |
---|
"unapprovedposts" => "-{$num_unapproved_posts}", "deletedposts" => "-{$num_deleted_posts}" );
|
"unapprovedposts" => "-{$num_unapproved_posts}", "deletedposts" => "-{$num_deleted_posts}" );
|
|
|
if($thread['visible'] == 1) { $updated_counters['threads'] = -1;
| if($thread['visible'] == 1) { $updated_counters['threads'] = -1;
|
Zeile 309 | Zeile 317 |
---|
if($thread['visible'] == 1) { $updated_counters['posts'] = -1;
|
if($thread['visible'] == 1) { $updated_counters['posts'] = -1;
|
}
| }
|
elseif($thread['visible'] == -1) { $updated_counters['deletedposts'] = -1;
| elseif($thread['visible'] == -1) { $updated_counters['deletedposts'] = -1;
|
Zeile 323 | Zeile 331 |
---|
// Update forum count update_forum_counters($thread['fid'], $updated_counters); update_forum_lastpost($thread['fid']);
|
// Update forum count update_forum_counters($thread['fid'], $updated_counters); update_forum_lastpost($thread['fid']);
|
| mark_reports($tid, 'thread');
|
$plugins->run_hooks("class_moderation_delete_thread", $tid);
|
$plugins->run_hooks("class_moderation_delete_thread", $tid);
|
return true; }
| return true; }
|
/** * Delete a poll *
| /** * Delete a poll *
|
Zeile 340 | Zeile 349 |
---|
global $db, $plugins;
$pid = (int)$pid;
|
global $db, $plugins;
$pid = (int)$pid;
|
|
|
if(empty($pid)) { return false; }
|
if(empty($pid)) { return false; }
|
|
|
$plugins->run_hooks("class_moderation_delete_poll", $pid);
|
$plugins->run_hooks("class_moderation_delete_poll", $pid);
|
|
|
$db->delete_query("polls", "pid='$pid'"); $db->delete_query("pollvotes", "pid='$pid'"); $pollarray = array(
| $db->delete_query("polls", "pid='$pid'"); $db->delete_query("pollvotes", "pid='$pid'"); $pollarray = array(
|
Zeile 360 | Zeile 369 |
---|
/** * Approve one or more threads
|
/** * Approve one or more threads
|
* * @param array|int $tids Thread ID(s) * @return boolean
| * * @param array|int $tids Thread ID(s) * @return boolean
|
*/ function approve_threads($tids) {
| */ function approve_threads($tids) {
|
Zeile 371 | Zeile 380 |
---|
if(!is_array($tids)) { $tids = array($tids);
|
if(!is_array($tids)) { $tids = array($tids);
|
}
| }
|
if(empty($tids))
|
if(empty($tids))
|
{
| {
|
return false; }
|
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);
|
|
|
$tid_list = $forum_counters = $user_counters = $posts_to_approve = array();
|
$tid_list = $forum_counters = $user_counters = $posts_to_approve = array();
|
foreach($tids as $tid)
| $tids_list = implode(",", $tids); $query = $db->simple_select("threads", "*", "tid IN ($tids_list)");
while($thread = $db->fetch_array($query))
|
{
|
{
|
$thread = get_thread($tid); if(!$thread || $thread['visible'] == 1 || $thread['visible'] == -1)
| if($thread['visible'] == 1 || $thread['visible'] == -1)
|
{ continue; }
| { continue; }
|
Zeile 420 | Zeile 431 |
---|
if($forum['usepostcounts'] != 0) { // On approving thread restore user post counts
|
if($forum['usepostcounts'] != 0) { // On approving thread restore user post counts
|
$query = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$tid}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid"); while($counter = $db->fetch_array($query))
| $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 472 | Zeile 490 |
---|
foreach($forum_counters as $fid => $counters) { // Update stats
|
foreach($forum_counters as $fid => $counters) { // Update stats
|
$update_array = array(
| $update_array = array(
|
"threads" => "+{$counters['num_threads']}", "unapprovedthreads" => "-{$counters['num_threads']}", "posts" => "+{$counters['num_posts']}",
| "threads" => "+{$counters['num_threads']}", "unapprovedthreads" => "-{$counters['num_threads']}", "posts" => "+{$counters['num_posts']}",
|
Zeile 512 | Zeile 530 |
---|
if(!is_array($tids)) { $tids = array($tids);
|
if(!is_array($tids)) { $tids = array($tids);
|
}
| }
|
if(empty($tids)) { return false;
| if(empty($tids)) { return false;
|
Zeile 526 | Zeile 544 |
---|
$tid_moved_list = ""; $comma = ""; foreach($tids as $tid)
|
$tid_moved_list = ""; $comma = ""; foreach($tids as $tid)
|
{
| {
|
$tid_moved_list .= "{$comma}'moved|{$tid}'"; $comma = ","; }
|
$tid_moved_list .= "{$comma}'moved|{$tid}'"; $comma = ","; }
|
|
|
$forum_counters = $user_counters = $posts_to_unapprove = array();
|
$forum_counters = $user_counters = $posts_to_unapprove = array();
|
foreach($tids as $tid)
| $tids_list = implode(",", $tids); $query = $db->simple_select("threads", "*", "tid IN ($tids_list)");
while($thread = $db->fetch_array($query))
|
{
|
{
|
$thread = get_thread($tid);
| |
$forum = get_forum($thread['fid']);
if($thread['visible'] == 1 || $thread['visible'] == -1)
| $forum = get_forum($thread['fid']);
if($thread['visible'] == 1 || $thread['visible'] == -1)
|
Zeile 579 | Zeile 599 |
---|
// On unapproving thread update user post counts if($thread['visible'] == 1 && $forum['usepostcounts'] != 0) {
|
// On unapproving thread update user post counts if($thread['visible'] == 1 && $forum['usepostcounts'] != 0) {
|
$query = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$tid}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid"); while($counter = $db->fetch_array($query))
| $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 688 | Zeile 715 |
---|
}
// Remove attachments
|
}
// Remove attachments
|
remove_attachments($pid);
| remove_attachments($pid);
|
// Delete the post $db->delete_query("posts", "pid='$pid'");
| // Delete the post $db->delete_query("posts", "pid='$pid'");
|
Zeile 698 | Zeile 725 |
---|
// Update unapproved post count if($post['visible'] == 0)
|
// Update unapproved post count if($post['visible'] == 0)
|
{ $update_array = array(
| { $update_array = array(
|
"unapprovedposts" => "-1" ); }
|
"unapprovedposts" => "-1" ); }
|
elseif($post['visible'] == -1) { $update_array = array( "deletedposts" => "-1" ); } else { $update_array = array( "replies" => "-1"
| elseif($post['visible'] == -1) { $update_array = array( "deletedposts" => "-1" ); } else { $update_array = array( "replies" => "-1"
|
); }
$plugins->run_hooks("class_moderation_delete_post", $post['pid']);
|
); }
$plugins->run_hooks("class_moderation_delete_post", $post['pid']);
|
|
|
update_thread_counters($post['tid'], $update_array); update_last_post($post['tid']);
| update_thread_counters($post['tid'], $update_array); update_last_post($post['tid']);
|
Zeile 732 | Zeile 759 |
---|
{ $update_array = array( "deletedposts" => "-1"
|
{ $update_array = array( "deletedposts" => "-1"
|
); }
| ); }
|
else { $update_array = array(
| else { $update_array = array(
|
Zeile 754 | Zeile 781 |
---|
* @param int $tid Thread ID (Set to 0 if posts from multiple threads are selected) * @return int ID of the post into which all other posts are merged */
|
* @param int $tid Thread ID (Set to 0 if posts from multiple threads are selected) * @return int ID of the post into which all other posts are merged */
|
function merge_posts($pids, $tid=0, $sep="new_line")
| function merge_posts($pids=array(), $tid=0, $sep="new_line")
|
{ global $db, $plugins;
| { global $db, $plugins;
|
Zeile 778 | Zeile 805 |
---|
LEFT JOIN ".TABLE_PREFIX."attachments a ON (a.pid=p.pid AND a.visible=1) WHERE p.pid IN($pidin) GROUP BY p.pid
|
LEFT JOIN ".TABLE_PREFIX."attachments a ON (a.pid=p.pid AND a.visible=1) WHERE p.pid IN($pidin) GROUP BY p.pid
|
ORDER BY p.dateline ASC
| ORDER BY p.dateline ASC, p.pid ASC
|
"); $message = ''; $threads = $forum_counters = $thread_counters = $user_counters = array();
| "); $message = ''; $threads = $forum_counters = $thread_counters = $user_counters = array();
|
Zeile 801 | Zeile 828 |
---|
$fid = $post['fid']; $mastertid = $post['tid']; $first = 0;
|
$fid = $post['fid']; $mastertid = $post['tid']; $first = 0;
|
| $visible = $post['visible'];
|
} else {
| } else {
|
Zeile 844 | Zeile 872 |
---|
{ --$user_counters[$post['uid']]['num_threads']; }
|
{ --$user_counters[$post['uid']]['num_threads']; }
|
| $thread_counters[$post['tid']]['attachmentcount'] -= $post['attachmentcount'];
|
} elseif($post['visible'] == 0) {
| } elseif($post['visible'] == 0) {
|
Zeile 855 | Zeile 884 |
---|
// Subtract 1 deleted post from post's thread --$thread_counters[$post['tid']]['deletedposts']; }
|
// Subtract 1 deleted post from post's thread --$thread_counters[$post['tid']]['deletedposts']; }
|
$thread_counters[$post['tid']]['attachmentcount'] -= $post['attachmentcount'];
| |
// Subtract 1 post from post's forum if($post['threadvisible'] == 1 && $post['visible'] == 1)
| // Subtract 1 post from post's forum if($post['threadvisible'] == 1 && $post['visible'] == 1)
|
Zeile 869 | Zeile 897 |
---|
else { --$forum_counters[$post['fid']]['deletedposts'];
|
else { --$forum_counters[$post['fid']]['deletedposts'];
|
| }
// Add attachment count to thread if($visible == 1) { $thread_counters[$mastertid]['attachmentcount'] += $post['attachmentcount'];
|
} } }
| } } }
|
Zeile 894 | Zeile 928 |
---|
{ // In some cases the first post of a thread changes // Therefore resync the visible field to make sure they're the same if they're not
|
{ // In some cases the first post of a thread changes // Therefore resync the visible field to make sure they're the same if they're not
|
$query = $db->simple_select("posts", "pid, uid, visible", "tid='{$thread['tid']}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));
| $query = $db->simple_select("posts", "pid, uid, visible", "tid='{$thread['tid']}'", array('order_by' => 'dateline, pid', 'limit' => 1));
|
$new_firstpost = $db->fetch_array($query); if($thread['visible'] != $new_firstpost['visible']) {
| $new_firstpost = $db->fetch_array($query); if($thread['visible'] != $new_firstpost['visible']) {
|
Zeile 1163 | Zeile 1197 |
---|
'question' => $db->escape_string($poll['question']), 'dateline' => $poll['dateline'], 'options' => $db->escape_string($poll['options']),
|
'question' => $db->escape_string($poll['question']), 'dateline' => $poll['dateline'], 'options' => $db->escape_string($poll['options']),
|
'votes' => $poll['votes'],
| 'votes' => $db->escape_string($poll['votes']),
|
'numoptions' => $poll['numoptions'], 'numvotes' => $poll['numvotes'], 'timeout' => $poll['timeout'],
| 'numoptions' => $poll['numoptions'], 'numvotes' => $poll['numvotes'], 'timeout' => $poll['timeout'],
|
Zeile 1223 | Zeile 1257 |
---|
'pid' => $pid, 'uid' => $attachment['uid'], 'filename' => $db->escape_string($attachment['filename']),
|
'pid' => $pid, 'uid' => $attachment['uid'], 'filename' => $db->escape_string($attachment['filename']),
|
'filetype' => $attachment['filetype'],
| 'filetype' => $db->escape_string($attachment['filetype']),
|
'filesize' => $attachment['filesize'],
|
'filesize' => $attachment['filesize'],
|
'attachname' => $attachment['attachname'],
| 'attachname' => $db->escape_string($attachment['attachname']),
|
'downloads' => $attachment['downloads'], 'visible' => $attachment['visible'],
|
'downloads' => $attachment['downloads'], 'visible' => $attachment['visible'],
|
'thumbnail' => $attachment['thumbnail']
| 'thumbnail' => $db->escape_string($attachment['thumbnail'])
|
); $new_aid = $db->insert_query("attachments", $attachment_array);
| ); $new_aid = $db->insert_query("attachments", $attachment_array);
|
Zeile 1541 | Zeile 1575 |
---|
// In some cases the thread we may be merging with may cause us to have a new firstpost if it is an older thread // Therefore resync the visible field to make sure they're the same if they're not
|
// In some cases the thread we may be merging with may cause us to have a new firstpost if it is an older thread // Therefore resync the visible field to make sure they're the same if they're not
|
$query = $db->simple_select("posts", "pid, uid, visible", "tid='{$tid}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));
| $query = $db->simple_select("posts", "pid, uid, visible", "tid='{$tid}'", array('order_by' => 'dateline, pid', 'limit' => 1));
|
$new_firstpost = $db->fetch_array($query); if($thread['visible'] != $new_firstpost['visible']) {
| $new_firstpost = $db->fetch_array($query); if($thread['visible'] != $new_firstpost['visible']) {
|
Zeile 1551 | Zeile 1585 |
---|
--$user_posts[$post['uid']]['postnum']; } elseif($thread['visible'] == 1 && $forum_cache[$thread['fid']]['usepostcounts'] == 1)
|
--$user_posts[$post['uid']]['postnum']; } elseif($thread['visible'] == 1 && $forum_cache[$thread['fid']]['usepostcounts'] == 1)
|
{
| {
|
++$user_posts[$post['uid']]['postnum']; } } // Update first post if needed if($new_firstpost['pid'] != $thread['firstpost'])
|
++$user_posts[$post['uid']]['postnum']; } } // Update first post if needed if($new_firstpost['pid'] != $thread['firstpost'])
|
{
| {
|
update_first_post($thread['tid']); }
|
update_first_post($thread['tid']); }
|
// Subtract merged thread from user counter if($mergethread['visible'] == 1 && $forum_cache[$mergethread['fid']]['usethreadcounts'] == 1) { if(!isset($user_posts[$mergethread['uid']]['threadnum'])) { $user_posts[$mergethread['uid']]['threadnum'] = 0; } --$user_posts[$mergethread['uid']]['threadnum']; }
| // 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)
|
// 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;
| if(!isset($user_posts[$thread['uid']]['threadnum'])) { $user_posts[$thread['uid']]['threadnum'] = 0;
|
Zeile 1611 | Zeile 1638 |
---|
); } update_forum_counters($thread['fid'], $updated_stats);
|
); } update_forum_counters($thread['fid'], $updated_stats);
|
// If old thread is unapproved, implied counter comes in to effect
| // If old thread is unapproved, implied counter comes in to effect
|
if($mergethread['visible'] == 0) { $updated_stats = array( "unapprovedposts" => '-'.($mergethread['replies']+$mergethread['unapprovedposts']+$mergethread['deletedposts'])
|
if($mergethread['visible'] == 0) { $updated_stats = array( "unapprovedposts" => '-'.($mergethread['replies']+$mergethread['unapprovedposts']+$mergethread['deletedposts'])
|
); } elseif($mergethread['visible'] == -1)
| ); } elseif($mergethread['visible'] == -1)
|
{ $updated_stats = array( "deletedposts" => '-'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts']) ); } else
|
{ $updated_stats = array( "deletedposts" => '-'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts']) ); } else
|
{
| {
|
$updated_stats = array( "posts" => "-{$mergethread['replies']}", "unapprovedposts" => "-{$mergethread['unapprovedposts']}", "deletedposts" => "-{$mergethread['deletedposts']}" );
|
$updated_stats = array( "posts" => "-{$mergethread['replies']}", "unapprovedposts" => "-{$mergethread['unapprovedposts']}", "deletedposts" => "-{$mergethread['deletedposts']}" );
|
}
| }
|
update_forum_counters($mergethread['fid'], $updated_stats); update_forum_lastpost($mergethread['fid']); }
| update_forum_counters($mergethread['fid'], $updated_stats); update_forum_lastpost($mergethread['fid']); }
|
Zeile 1665 | Zeile 1692 |
---|
$updated_stats['unapprovedposts'] += $mergethread['replies']+$mergethread['deletedposts']; $updated_stats['posts'] -= $mergethread['replies']; $updated_stats['deletedposts'] -= $mergethread['deletedposts'];
|
$updated_stats['unapprovedposts'] += $mergethread['replies']+$mergethread['deletedposts']; $updated_stats['posts'] -= $mergethread['replies']; $updated_stats['deletedposts'] -= $mergethread['deletedposts'];
|
}
| }
|
elseif($thread['visible'] == -1) { $updated_stats['deletedposts'] += $mergethread['replies']+$mergethread['unapprovedposts']; $updated_stats['posts'] -= $mergethread['replies']; $updated_stats['unapprovedposts'] -= $mergethread['unapprovedposts'];
|
elseif($thread['visible'] == -1) { $updated_stats['deletedposts'] += $mergethread['replies']+$mergethread['unapprovedposts']; $updated_stats['posts'] -= $mergethread['replies']; $updated_stats['unapprovedposts'] -= $mergethread['unapprovedposts'];
|
}
| }
|
$new_stats = array(); if($updated_stats['posts'] < 0)
| $new_stats = array(); if($updated_stats['posts'] < 0)
|
Zeile 1684 | Zeile 1711 |
---|
}
if($updated_stats['unapprovedposts'] < 0)
|
}
if($updated_stats['unapprovedposts'] < 0)
|
{
| {
|
$new_stats['unapprovedposts'] = $updated_stats['unapprovedposts'];
|
$new_stats['unapprovedposts'] = $updated_stats['unapprovedposts'];
|
}
| }
|
elseif($updated_stats['unapprovedposts'] > 0) { $new_stats['unapprovedposts'] = "+{$updated_stats['unapprovedposts']}";
|
elseif($updated_stats['unapprovedposts'] > 0) { $new_stats['unapprovedposts'] = "+{$updated_stats['unapprovedposts']}";
|
}
| }
|
if($updated_stats['deletedposts'] < 0) { $new_stats['deletedposts'] = $updated_stats['deletedposts'];
| if($updated_stats['deletedposts'] < 0) { $new_stats['deletedposts'] = $updated_stats['deletedposts'];
|
Zeile 1718 | Zeile 1745 |
---|
elseif($new_firstpost['visible'] == -1) { --$mergethread['deletedposts'];
|
elseif($new_firstpost['visible'] == -1) { --$mergethread['deletedposts'];
|
}
| }
|
else { --$mergethread['unapprovedposts'];
| else { --$mergethread['unapprovedposts'];
|
Zeile 1751 | Zeile 1778 |
---|
"replies" => "+{$mergethread['replies']}", "attachmentcount" => "+{$mergethread['attachmentcount']}", "unapprovedposts" => "+{$mergethread['unapprovedposts']}",
|
"replies" => "+{$mergethread['replies']}", "attachmentcount" => "+{$mergethread['attachmentcount']}", "unapprovedposts" => "+{$mergethread['unapprovedposts']}",
|
"deletedposts" => "+{$mergethread['unapprovedposts']}",
| |
"deletedposts" => "+{$mergethread['deletedposts']}" ); update_thread_counters($tid, $updated_stats);
| "deletedposts" => "+{$mergethread['deletedposts']}" ); update_thread_counters($tid, $updated_stats);
|
Zeile 1796 | Zeile 1822 |
---|
}
// Get the first split post
|
}
// Get the first split post
|
$query = $db->simple_select('posts', 'pid,uid,visible,icon,username,dateline', 'pid IN ('.$pids_list.')', array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));
| $query = $db->simple_select('posts', 'pid,uid,visible,icon,username,dateline', 'pid IN ('.$pids_list.')', array('order_by' => 'dateline, pid', 'limit' => 1));
|
$post_info = $db->fetch_array($query);
| $post_info = $db->fetch_array($query);
|
Zeile 1810 | Zeile 1836 |
---|
'unapprovedposts' => 0, 'deletedposts' => 0 );
|
'unapprovedposts' => 0, 'deletedposts' => 0 );
|
| $user_counters = array();
|
if($destination_tid == 0) {
| if($destination_tid == 0) {
|
Zeile 1841 | Zeile 1869 |
---|
'threadnum' => 0 ); }
|
'threadnum' => 0 ); }
|
// Subtract thread from old thread opener --$user_counters[$newthread['uid']]['threadnum'];
| ++$user_counters[$newthread['uid']]['threadnum'];
|
} elseif($visible == -1) {
| } elseif($visible == -1) {
|
Zeile 1933 | Zeile 1960 |
---|
// Unapproved post // Subtract 1 from the old thread's unapproved posts --$thread_counters[$post['tid']]['unapprovedposts'];
|
// Unapproved post // Subtract 1 from the old thread's unapproved posts --$thread_counters[$post['tid']]['unapprovedposts'];
|
}
| }
|
elseif($post['visible'] == -1) { // Soft deleted post // Subtract 1 from the old thread's deleted posts --$thread_counters[$post['tid']]['deletedposts'];
|
elseif($post['visible'] == -1) { // Soft deleted post // Subtract 1 from the old thread's deleted posts --$thread_counters[$post['tid']]['deletedposts'];
|
}
| }
|
// Subtract 1 from the old forum's posts if($post['threadvisible'] == 1 && $post['visible'] == 1) { --$forum_counters[$post['fid']]['posts']; } elseif($post['threadvisible'] == 0 || ($post['visible'] == 0 && $post['threadvisible'] == 1))
|
// Subtract 1 from the old forum's posts if($post['threadvisible'] == 1 && $post['visible'] == 1) { --$forum_counters[$post['fid']]['posts']; } elseif($post['threadvisible'] == 0 || ($post['visible'] == 0 && $post['threadvisible'] == 1))
|
{
| {
|
--$forum_counters[$post['fid']]['unapprovedposts']; } else
| --$forum_counters[$post['fid']]['unapprovedposts']; } else
|
Zeile 1963 | Zeile 1990 |
---|
{ // In some cases the first post of a thread changes // Therefore resync the visible field to make sure they're the same if they're not
|
{ // In some cases the first post of a thread changes // Therefore resync the visible field to make sure they're the same if they're not
|
$query = $db->simple_select("posts", "pid, visible, uid", "tid='{$post['tid']}'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 1));
| $query = $db->simple_select("posts", "pid, visible, uid", "tid='{$post['tid']}'", array('order_by' => 'dateline, pid', 'limit' => 1));
|
$new_firstpost = $db->fetch_array($query);
if(!isset($user_counters[$new_firstpost['uid']]))
| $new_firstpost = $db->fetch_array($query);
if(!isset($user_counters[$new_firstpost['uid']]))
|
Zeile 1988 | Zeile 2015 |
---|
} } elseif($new_firstpost['visible'] == -1)
|
} } elseif($new_firstpost['visible'] == -1)
|
{
| {
|
--$thread_counters[$post['tid']]['deletedposts']; } else
| --$thread_counters[$post['tid']]['deletedposts']; } else
|
Zeile 2002 | Zeile 2029 |
---|
else { --$forum_counters[$post['fid']]['deletedposts'];
|
else { --$forum_counters[$post['fid']]['deletedposts'];
|
}
| }
|
// Add old first post if($post['threadvisible'] == 1)
| // Add old first post if($post['threadvisible'] == 1)
|
Zeile 2015 | Zeile 2042 |
---|
} } elseif($post['threadvisible'] == -1)
|
} } elseif($post['threadvisible'] == -1)
|
{
| {
|
++$thread_counters[$post['tid']]['deletedposts']; ++$forum_counters[$post['fid']]['deletedposts']; }
| ++$thread_counters[$post['tid']]['deletedposts']; ++$forum_counters[$post['fid']]['deletedposts']; }
|
Zeile 2042 | Zeile 2069 |
---|
{ // Update post counters if visibility changes if($post['visible'] != $newthread['visible'])
|
{ // Update post counters if visibility changes if($post['visible'] != $newthread['visible'])
|
{
| {
|
$db->update_query("posts", array('visible' => $newthread['visible']), "pid='{$post['pid']}'");
// This is needed to update the forum counters correctly
| $db->update_query("posts", array('visible' => $newthread['visible']), "pid='{$post['pid']}'");
// This is needed to update the forum counters correctly
|
Zeile 2106 | Zeile 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 2150 | Zeile 2180 |
---|
if($tid == $newtid) { // Update the subject of the first post in the new thread
|
if($tid == $newtid) { // Update the subject of the first post in the new thread
|
$query = $db->simple_select("posts", "pid", "tid='$newtid'", array('order_by' => 'dateline', 'limit' => 1));
| $query = $db->simple_select("posts", "pid", "tid='$newtid'", array('order_by' => 'dateline, pid', 'limit' => 1));
|
$newthread = $db->fetch_array($query); $sqlarray = array( "subject" => $newsubject,
| $newthread = $db->fetch_array($query); $sqlarray = array( "subject" => $newsubject,
|
Zeile 2166 | Zeile 2196 |
---|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid) WHERE p.tid='{$tid}'
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid) WHERE p.tid='{$tid}'
|
ORDER BY p.dateline ASC
| ORDER BY p.dateline ASC, p.pid ASC
|
LIMIT 1 "); $oldthread = $db->fetch_array($query);
| LIMIT 1 "); $oldthread = $db->fetch_array($query);
|
Zeile 2202 | Zeile 2232 |
---|
} } update_forum_counters($fid, $counters);
|
} } update_forum_counters($fid, $counters);
|
update_forum_lastpost($fid); } }
| update_forum_lastpost($fid); } }
|
return $newtid; }
/** * Move multiple threads to new forum
|
return $newtid; }
/** * Move multiple threads to new forum
|
*
| *
|
* @param array $tids Thread IDs * @param int $moveto Destination forum * @return boolean
|
* @param array $tids Thread IDs * @param int $moveto Destination forum * @return boolean
|
| * * @deprecated Iterate over move_thread instead
|
*/ function move_threads($tids, $moveto) {
| */ function move_threads($tids, $moveto) {
|
Zeile 2224 | Zeile 2256 |
---|
$tids = array_map('intval', $tids);
$tid_list = implode(',', $tids);
|
$tids = array_map('intval', $tids);
$tid_list = implode(',', $tids);
|
|
|
$moveto = (int)$moveto;
$newforum = get_forum($moveto);
| $moveto = (int)$moveto;
$newforum = get_forum($moveto);
|
Zeile 2252 | Zeile 2284 |
---|
'deletedposts' => 0 ); }
|
'deletedposts' => 0 ); }
|
if(!isset($user_counters[$thread['uid']]['num_threads'])) { $user_counters[$thread['uid']]['num_threads'] = 0; }
| if(!isset($user_counters[$thread['uid']])) { $user_counters[$thread['uid']] = array( 'num_posts' => 0, 'num_threads' => 0 ); }
|
if($thread['visible'] == 1)
|
if($thread['visible'] == 1)
|
{
| {
|
$total_posts += $thread['replies']+1; $total_unapproved_posts += $thread['unapprovedposts']; $total_deleted_posts += $thread['deletedposts'];
| $total_posts += $thread['replies']+1; $total_unapproved_posts += $thread['unapprovedposts']; $total_deleted_posts += $thread['deletedposts'];
|
Zeile 2271 | Zeile 2306 |
---|
++$total_threads;
if($newforum['usethreadcounts'] == 1 && $forum['usethreadcounts'] == 0)
|
++$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 2289 | Zeile 2324 |
---|
"); while($posters = $db->fetch_array($query1)) {
|
"); while($posters = $db->fetch_array($query1)) {
|
if(!isset($user_counters[$posters['uid']]['num_posts']))
| if(!isset($user_counters[$posters['uid']]))
|
{
|
{
|
$user_counters[$posters['uid']]['num_posts'] = 0;
| $user_counters[$posters['uid']] = array( 'num_posts' => 0, 'num_threads' => 0 );
|
}
if($newforum['usepostcounts'] != 0 && $forum['usepostcounts'] == 0)
| }
if($newforum['usepostcounts'] != 0 && $forum['usepostcounts'] == 0)
|
Zeile 2417 | Zeile 2455 |
---|
* @return boolean */ function approve_posts($pids)
|
* @return boolean */ function approve_posts($pids)
|
{ global $db, $cache, $plugins;
$num_posts = 0;
| { global $db, $cache, $plugins;
$num_posts = 0;
|
if(empty($pids))
|
if(empty($pids))
|
{
| {
|
return false; }
|
return false; }
|
|
|
// Make sure we only have valid values $pids = array_map('intval', $pids);
|
// Make sure we only have valid values $pids = array_map('intval', $pids);
|
|
|
$pid_list = implode(',', $pids); $pids = $threads_to_update = array();
| $pid_list = implode(',', $pids); $pids = $threads_to_update = array();
|
Zeile 2454 | Zeile 2492 |
---|
{ // This is the first post in the thread so we're approving the whole thread. $threads_to_update[] = $post['tid'];
|
{ // This is the first post in the thread so we're approving the whole thread. $threads_to_update[] = $post['tid'];
|
}
| }
|
if(!empty($threads_to_update)) { $this->approve_threads($threads_to_update);
| if(!empty($threads_to_update)) { $this->approve_threads($threads_to_update);
|
Zeile 2468 | Zeile 2506 |
---|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) WHERE p.pid IN ($pid_list) AND p.visible = '0' AND t.firstpost != p.pid
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) WHERE p.pid IN ($pid_list) AND p.visible = '0' AND t.firstpost != p.pid
|
"); while($post = $db->fetch_array($query)) { $pids[] = $post['pid'];
if(!isset($thread_counters[$post['tid']])) { $thread_counters[$post['tid']] = array(
| "); while($post = $db->fetch_array($query)) { $pids[] = $post['pid'];
if(!isset($thread_counters[$post['tid']])) { $thread_counters[$post['tid']] = array(
|
'replies' => 0 ); }
| 'replies' => 0 ); }
|
Zeile 2493 | Zeile 2531 |
---|
); } ++$forum_counters[$post['fid']]['num_posts'];
|
); } ++$forum_counters[$post['fid']]['num_posts'];
|
}
$forum = get_forum($post['fid']);
| }
$forum = get_forum($post['fid']);
|
// If post counts enabled in this forum and the thread is approved, add 1 if($forum['usepostcounts'] != 0 && $post['threadvisible'] == 1)
| // If post counts enabled in this forum and the thread is approved, add 1 if($forum['usepostcounts'] != 0 && $post['threadvisible'] == 1)
|
Zeile 2509 | Zeile 2547 |
---|
}
if(empty($pids) && empty($threads_to_update))
|
}
if(empty($pids) && empty($threads_to_update))
|
{
| {
|
return false; }
| return false; }
|
Zeile 2528 | Zeile 2566 |
---|
$counters_update = array( "unapprovedposts" => "-".$counters['replies'], "replies" => "+".$counters['replies']
|
$counters_update = array( "unapprovedposts" => "-".$counters['replies'], "replies" => "+".$counters['replies']
|
);
| );
|
update_thread_counters($tid, $counters_update); update_last_post($tid); } }
if(!empty($forum_counters))
|
update_thread_counters($tid, $counters_update); update_last_post($tid); } }
if(!empty($forum_counters))
|
{
| {
|
foreach($forum_counters as $fid => $counters) { $updated_forum_stats = array(
| foreach($forum_counters as $fid => $counters) { $updated_forum_stats = array(
|
Zeile 2582 | Zeile 2620 |
---|
// Make invisible $approve = array( "visible" => 0,
|
// Make invisible $approve = array( "visible" => 0,
|
);
| );
|
// We have three cases we deal with in these code segments: // 1) We're unapproving specific approved posts
| // We have three cases we deal with in these code segments: // 1) We're unapproving specific approved posts
|
Zeile 2593 | Zeile 2631 |
---|
// 3) We're doing both 1 and 2 $query = $db->query(" SELECT p.tid
|
// 3) We're doing both 1 and 2 $query = $db->query(" SELECT p.tid
|
FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
| FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
WHERE p.pid IN ($pid_list) AND p.visible IN (-1,1) AND t.firstpost = p.pid AND t.visible IN (-1,1) "); while($post = $db->fetch_array($query)) { // This is the first post in the thread so we're unapproving the whole thread. $threads_to_update[] = $post['tid'];
|
WHERE p.pid IN ($pid_list) AND p.visible IN (-1,1) AND t.firstpost = p.pid AND t.visible IN (-1,1) "); while($post = $db->fetch_array($query)) { // This is the first post in the thread so we're unapproving the whole thread. $threads_to_update[] = $post['tid'];
|
}
| }
|
if(!empty($threads_to_update)) { $this->unapprove_threads($threads_to_update); }
|
if(!empty($threads_to_update)) { $this->unapprove_threads($threads_to_update); }
|
|
|
$thread_counters = $forum_counters = $user_counters = array();
$query = $db->query("
| $thread_counters = $forum_counters = $user_counters = array();
$query = $db->query("
|
Zeile 2633 | Zeile 2671 |
---|
if($post['visible'] == 1) { ++$thread_counters[$post['tid']]['replies'];
|
if($post['visible'] == 1) { ++$thread_counters[$post['tid']]['replies'];
|
} else {
| } else {
|
++$thread_counters[$post['tid']]['deletedposts']; }
| ++$thread_counters[$post['tid']]['deletedposts']; }
|
Zeile 2658 | Zeile 2696 |
---|
++$forum_counters[$post['fid']]['num_posts']; } else
|
++$forum_counters[$post['fid']]['num_posts']; } else
|
{
| {
|
++$forum_counters[$post['fid']]['num_deleted_posts']; } }
| ++$forum_counters[$post['fid']]['num_deleted_posts']; } }
|
Zeile 2685 | Zeile 2723 |
---|
{ $where = "pid IN (".implode(',', $pids).")"; $db->update_query("posts", $approve, $where);
|
{ $where = "pid IN (".implode(',', $pids).")"; $db->update_query("posts", $approve, $where);
|
}
$plugins->run_hooks("class_moderation_unapprove_posts", $pids);
| }
$plugins->run_hooks("class_moderation_unapprove_posts", $pids);
|
if(!empty($thread_counters)) { foreach($thread_counters as $tid => $counters)
| if(!empty($thread_counters)) { foreach($thread_counters as $tid => $counters)
|
Zeile 2701 | Zeile 2739 |
---|
update_thread_counters($tid, $counters_update); update_last_post($tid);
|
update_thread_counters($tid, $counters_update); update_last_post($tid);
|
} }
| } }
|
if(!empty($forum_counters)) {
| if(!empty($forum_counters)) {
|
Zeile 2715 | Zeile 2753 |
---|
); update_forum_counters($fid, $updated_forum_stats); update_forum_lastpost($fid);
|
); update_forum_counters($fid, $updated_forum_stats); update_forum_lastpost($fid);
|
}
| }
|
}
if(!empty($user_counters))
| }
if(!empty($user_counters))
|
Zeile 2742 | Zeile 2780 |
---|
// Get tids into list if(!is_array($tids))
|
// Get tids into list if(!is_array($tids))
|
{
| {
|
$tids = array($tids); }
| $tids = array($tids); }
|
Zeile 2757 | Zeile 2795 |
---|
$tid_list = implode(',', $tids);
// Get original subject
|
$tid_list = implode(',', $tids);
// Get original subject
|
$query = $db->simple_select("threads", "subject, tid", "tid IN ($tid_list)");
| $query = $db->query(" SELECT u.uid, u.username, t.tid, t.subject FROM ".TABLE_PREFIX."threads t LEFT JOIN ".TABLE_PREFIX."users u ON t.uid=u.uid WHERE tid IN ($tid_list) ");
|
while($thread = $db->fetch_array($query)) { // Update threads and first posts with new subject
|
while($thread = $db->fetch_array($query)) { // Update threads and first posts with new subject
|
$subject = str_replace('{username}', $mybb->user['username'], $format); $subject = str_replace('{subject}', $thread['subject'], $subject); $new_subject = array( "subject" => $db->escape_string($subject) ); $db->update_query("threads", $new_subject, "tid='{$thread['tid']}'"); $db->update_query("posts", $new_subject, "tid='{$thread['tid']}' AND replyto='0'"); }
| $find = array('{username}', 'author', '{subject}'); $replace = array($mybb->user['username'], $thread['username'], $thread['subject']);
$new_subject = str_ireplace($find, $replace, $format);
$args = array( 'thread' => &$thread, 'new_subject' => &$new_subject, );
$plugins->run_hooks("class_moderation_change_thread_subject_newsubject", $args);
$update_subject = array( "subject" => $db->escape_string($new_subject) ); $db->update_query("threads", $update_subject, "tid='{$thread['tid']}'"); $db->update_query("posts", $update_subject, "tid='{$thread['tid']}' AND replyto='0'"); }
|
$arguments = array("tids" => $tids, "format" => $format); $plugins->run_hooks("class_moderation_change_thread_subject", $arguments);
| $arguments = array("tids" => $tids, "format" => $format); $plugins->run_hooks("class_moderation_change_thread_subject", $arguments);
|
Zeile 2801 | Zeile 2853 |
---|
$arguments = array("tid" => $tid, "deletetime" => $deletetime); $plugins->run_hooks("class_moderation_expire_thread", $arguments);
|
$arguments = array("tid" => $tid, "deletetime" => $deletetime); $plugins->run_hooks("class_moderation_expire_thread", $arguments);
|
return true;
| return true;
|
}
/**
| }
/**
|
Zeile 2812 | Zeile 2864 |
---|
* @return boolean true */ function toggle_post_visibility($pids)
|
* @return boolean true */ function toggle_post_visibility($pids)
|
{ global $db;
// Make sure we only have valid values $pids = array_map('intval', $pids);
$pid_list = implode(',', $pids);
| { global $db;
// Make sure we only have valid values $pids = array_map('intval', $pids);
$pid_list = implode(',', $pids);
|
$query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)"); while($post = $db->fetch_array($query)) {
| $query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)"); while($post = $db->fetch_array($query)) {
|
Zeile 2830 | Zeile 2882 |
---|
{ $approve[] = $post['pid']; }
|
{ $approve[] = $post['pid']; }
|
}
| }
|
if(is_array($unapprove)) { $this->unapprove_posts($unapprove);
| if(is_array($unapprove)) { $this->unapprove_posts($unapprove);
|
Zeile 2849 | Zeile 2901 |
---|
* @return boolean true */ function toggle_post_softdelete($pids)
|
* @return boolean true */ function toggle_post_softdelete($pids)
|
{ global $db;
// Make sure we only have valid values $pids = array_map('intval', $pids);
$pid_list = implode(',', $pids);
| { global $db;
// Make sure we only have valid values $pids = array_map('intval', $pids);
$pid_list = implode(',', $pids);
|
$query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)"); while($post = $db->fetch_array($query)) {
| $query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)"); while($post = $db->fetch_array($query)) {
|
Zeile 2866 | Zeile 2918 |
---|
else { $restore[] = $post['pid'];
|
else { $restore[] = $post['pid'];
|
} }
| } }
|
if(is_array($delete)) { $this->soft_delete_posts($delete);
| if(is_array($delete)) { $this->soft_delete_posts($delete);
|
Zeile 2878 | Zeile 2930 |
---|
} return true; }
|
} return true; }
|
|
|
/** * Toggle thread visibility (approved/unapproved) *
| /** * Toggle thread visibility (approved/unapproved) *
|
Zeile 2889 | Zeile 2941 |
---|
function toggle_thread_visibility($tids, $fid) { global $db;
|
function toggle_thread_visibility($tids, $fid) { global $db;
|
|
|
// Make sure we only have valid values $tids = array_map('intval', $tids); $fid = (int)$fid;
| // Make sure we only have valid values $tids = array_map('intval', $tids); $fid = (int)$fid;
|
Zeile 2901 | Zeile 2953 |
---|
if($thread['visible'] != 0) { $unapprove[] = $thread['tid'];
|
if($thread['visible'] != 0) { $unapprove[] = $thread['tid'];
|
} else
| } else
|
{ $approve[] = $thread['tid']; }
| { $approve[] = $thread['tid']; }
|
Zeile 2938 | Zeile 2990 |
---|
if($thread['visible'] != -1) { $delete[] = $thread['tid'];
|
if($thread['visible'] != -1) { $delete[] = $thread['tid'];
|
}
| }
|
else { $restore[] = $thread['tid'];
| else { $restore[] = $thread['tid'];
|
Zeile 2951 | Zeile 3003 |
---|
if(is_array($restore)) { $this->restore_threads($restore);
|
if(is_array($restore)) { $this->restore_threads($restore);
|
} return true; }
/**
| } return true; }
/**
|
* Toggle threads open/closed * * @param array $tids Thread IDs
| * Toggle threads open/closed * * @param array $tids Thread IDs
|
Zeile 3167 | Zeile 3219 |
---|
$pid_list = implode(',', $pids); $pids = $threads_to_update = array();
|
$pid_list = implode(',', $pids); $pids = $threads_to_update = array();
|
|
|
// Make invisible $update = array( "visible" => -1,
| // Make invisible $update = array( "visible" => -1,
|
Zeile 3274 | Zeile 3326 |
---|
$where = "pid IN (".implode(',', $pids).")"; $db->update_query("posts", $update, $where); mark_reports($pids, "posts");
|
$where = "pid IN (".implode(',', $pids).")"; $db->update_query("posts", $update, $where); mark_reports($pids, "posts");
|
}
$plugins->run_hooks("class_moderation_soft_delete_posts", $pids);
if(is_array($thread_counters)) { foreach($thread_counters as $tid => $counters) { $counters_update = array(
| }
$plugins->run_hooks("class_moderation_soft_delete_posts", $pids);
if(is_array($thread_counters)) { foreach($thread_counters as $tid => $counters) { $counters_update = array(
|
"unapprovedposts" => "-".$counters['unapprovedposts'], "replies" => "-".$counters['replies'], "deletedposts" => "+".$counters['deletedposts']
| "unapprovedposts" => "-".$counters['unapprovedposts'], "replies" => "-".$counters['replies'], "deletedposts" => "+".$counters['deletedposts']
|
Zeile 3296 | Zeile 3348 |
---|
if(is_array($forum_counters)) { foreach($forum_counters as $fid => $counters)
|
if(is_array($forum_counters)) { foreach($forum_counters as $fid => $counters)
|
{
| {
|
$updated_forum_stats = array( 'posts' => "-{$counters['num_posts']}", 'unapprovedposts' => "-{$counters['num_unapproved_posts']}",
| $updated_forum_stats = array( 'posts' => "-{$counters['num_posts']}", 'unapprovedposts' => "-{$counters['num_unapproved_posts']}",
|
Zeile 3331 | Zeile 3383 |
---|
$num_posts = 0;
if(empty($pids))
|
$num_posts = 0;
if(empty($pids))
|
{ return false; }
// Make sure we only have valid values $pids = array_map('intval', $pids);
| { return false; }
// Make sure we only have valid values $pids = array_map('intval', $pids);
|
$pid_list = implode(',', $pids); $pids = $threads_to_update = array();
| $pid_list = implode(',', $pids); $pids = $threads_to_update = array();
|
Zeile 3362 | Zeile 3414 |
---|
{ // This is the first post in the thread so we're approving the whole thread. $threads_to_update[] = $post['tid'];
|
{ // This is the first post in the thread so we're approving the whole thread. $threads_to_update[] = $post['tid'];
|
}
| }
|
if(!empty($threads_to_update)) { $this->restore_threads($threads_to_update); }
$thread_counters = $forum_counters = $user_counters = array();
|
if(!empty($threads_to_update)) { $this->restore_threads($threads_to_update); }
$thread_counters = $forum_counters = $user_counters = array();
|
|
|
$query = $db->query(" SELECT p.pid, p.tid, f.fid, f.usepostcounts, p.uid, t.visible AS threadvisible FROM ".TABLE_PREFIX."posts p
| $query = $db->query(" SELECT p.pid, p.tid, f.fid, f.usepostcounts, p.uid, t.visible AS threadvisible FROM ".TABLE_PREFIX."posts p
|
Zeile 3386 | Zeile 3438 |
---|
{ $thread_counters[$post['tid']] = array( 'replies' => 0
|
{ $thread_counters[$post['tid']] = array( 'replies' => 0
|
); }
++$thread_counters[$post['tid']]['replies'];
| ); }
++$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']]))
|
// 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 ); } ++$forum_counters[$post['fid']]['num_posts'];
|
$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) {
| // If post counts enabled in this forum and the thread is approved, add 1 if($post['usepostcounts'] != 0 && $post['threadvisible'] == 1) {
|
Zeile 3443 | Zeile 3495 |
---|
}
if(is_array($forum_counters))
|
}
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 3477 | Zeile 3529 |
---|
global $db, $cache, $plugins;
if(!is_array($tids))
|
global $db, $cache, $plugins;
if(!is_array($tids))
|
{
| {
|
$tids = array($tids); }
| $tids = array($tids); }
|
Zeile 3491 | Zeile 3543 |
---|
$tid_list = $forum_counters = $user_counters = $posts_to_restore = array();
|
$tid_list = $forum_counters = $user_counters = $posts_to_restore = array();
|
foreach($tids as $tid)
| $tids_list = implode(",", $tids); $query = $db->simple_select("threads", "*", "tid IN ($tids_list)");
while($thread = $db->fetch_array($query))
|
{
|
{
|
$thread = get_thread($tid); if(!$thread || $thread['visible'] != -1)
| if($thread['visible'] != -1)
|
{ continue;
|
{ continue;
|
}
| }
|
$tid_list[] = $thread['tid'];
$forum = get_forum($thread['fid']);
|
$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(
|
'num_posts' => 0,
| 'num_posts' => 0,
|
'num_threads' => 0, 'num_deleted_posts' => 0, 'num_unapproved_posts' => 0
|
'num_threads' => 0, 'num_deleted_posts' => 0, 'num_unapproved_posts' => 0
|
);
| );
|
}
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
|
Zeile 3528 | Zeile 3582 |
---|
if($forum['usepostcounts'] != 0) { // On approving thread restore user post counts
|
if($forum['usepostcounts'] != 0) { // On approving thread restore user post counts
|
$query = $db->simple_select("posts", "COUNT(pid) as posts, uid", "tid='{$tid}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid"); while($counter = $db->fetch_array($query))
| $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 3645 | Zeile 3702 |
---|
$forum_counters = $user_counters = $posts_to_delete = array();
|
$forum_counters = $user_counters = $posts_to_delete = array();
|
foreach($tids as $tid)
| $tids_list = implode(",", $tids); $query = $db->simple_select("threads", "*", "tid IN ($tids_list)");
while($thread = $db->fetch_array($query))
|
{
|
{
|
$thread = get_thread($tid);
| |
$forum = get_forum($thread['fid']);
if($thread['visible'] == 1 || $thread['visible'] == 0)
| $forum = get_forum($thread['fid']);
if($thread['visible'] == 1 || $thread['visible'] == 0)
|
Zeile 3661 | Zeile 3720 |
---|
'num_deleted_posts' => 0, 'unapproved_threads' => 0, 'unapproved_posts' => 0
|
'num_deleted_posts' => 0, 'unapproved_threads' => 0, 'unapproved_posts' => 0
|
);
| );
|
}
if(!isset($user_counters[$thread['uid']]))
| }
if(!isset($user_counters[$thread['uid']]))
|
Zeile 3691 | Zeile 3750 |
---|
// On unapproving thread update user post counts if($thread['visible'] == 1 && $forum['usepostcounts'] != 0) {
|
// On unapproving thread update user post counts if($thread['visible'] == 1 && $forum['usepostcounts'] != 0) {
|
$query = $db->simple_select("posts", "COUNT(pid) AS posts, uid", "tid='{$tid}' AND (visible='1' OR pid='{$thread['firstpost']}') AND uid > 0 GROUP BY uid"); while($counter = $db->fetch_array($query))
| $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 3719 | Zeile 3781 |
---|
$query = $db->simple_select('threads', 'tid', "closed IN ({$tid_moved_list})");
mark_reports($tids, "threads");
|
$query = $db->simple_select('threads', 'tid', "closed IN ({$tid_moved_list})");
mark_reports($tids, "threads");
|
|
|
while($redirect_tid = $db->fetch_field($query, 'tid')) { $redirect_tids[] = $redirect_tid;
| while($redirect_tid = $db->fetch_field($query, 'tid')) { $redirect_tids[] = $redirect_tid;
|