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 384 | Zeile 392 |
---|
$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 421 | 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))
|
{ $user_counters[$counter['uid']]['num_posts'] += $counter['posts']; }
| { $user_counters[$counter['uid']]['num_posts'] += $counter['posts']; }
|
Zeile 431 | Zeile 441 |
---|
if($forum['usethreadcounts'] != 0 && substr($thread['closed'], 0, 6) != 'moved|') { ++$user_counters[$thread['uid']]['num_threads'];
|
if($forum['usethreadcounts'] != 0 && substr($thread['closed'], 0, 6) != 'moved|') { ++$user_counters[$thread['uid']]['num_threads'];
|
}
| }
|
$posts_to_approve[] = $thread['firstpost']; }
|
$posts_to_approve[] = $thread['firstpost']; }
|
|
|
if(!empty($tid_list)) { $tid_moved_list = "";
| if(!empty($tid_list)) { $tid_moved_list = "";
|
Zeile 464 | Zeile 474 |
---|
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)) { foreach($forum_counters as $fid => $counters)
| if(!empty($forum_counters)) { foreach($forum_counters as $fid => $counters)
|
Zeile 534 | Zeile 544 |
---|
$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 580 | Zeile 592 |
---|
// 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))
|
{ $user_counters[$counter['uid']]['num_posts'] += $counter['posts']; }
| { $user_counters[$counter['uid']]['num_posts'] += $counter['posts']; }
|
Zeile 779 | Zeile 791 |
---|
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 902 | Zeile 914 |
---|
{ // 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 1549 | Zeile 1561 |
---|
// 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']) { $db->update_query("posts", array('visible' => $thread['visible']), "pid='{$new_firstpost['pid']}'"); if($new_firstpost['visible'] == 1 && $forum_cache[$thread['fid']]['usepostcounts'] == 1)
|
$new_firstpost = $db->fetch_array($query); if($thread['visible'] != $new_firstpost['visible']) { $db->update_query("posts", array('visible' => $thread['visible']), "pid='{$new_firstpost['pid']}'"); if($new_firstpost['visible'] == 1 && $forum_cache[$thread['fid']]['usepostcounts'] == 1)
|
{
| {
|
--$user_posts[$post['uid']]['postnum'];
|
--$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']) {
| // Update first post if needed if($new_firstpost['pid'] != $thread['firstpost']) {
|
Zeile 1589 | Zeile 1601 |
---|
{ // If new thread is unapproved, implied counter comes in to effect if($thread['visible'] == 0)
|
{ // If new thread is unapproved, implied counter comes in to effect if($thread['visible'] == 0)
|
{ $updated_stats = array(
| { $updated_stats = array(
|
"unapprovedposts" => '+'.($mergethread['replies']+$mergethread['unapprovedposts']+$mergethread['deletedposts']) ); } elseif($thread['visible'] == -1)
|
"unapprovedposts" => '+'.($mergethread['replies']+$mergethread['unapprovedposts']+$mergethread['deletedposts']) ); } elseif($thread['visible'] == -1)
|
{ $updated_stats = array(
| { $updated_stats = array(
|
"deletedposts" => '+'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts']) ); }
| "deletedposts" => '+'.($mergethread['replies']+$mergethread['deletedposts']+$mergethread['unapprovedposts']) ); }
|
Zeile 1609 | Zeile 1621 |
---|
); } 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($mergethread['visible'] == 0) { $updated_stats = array( "unapprovedposts" => '-'.($mergethread['replies']+$mergethread['unapprovedposts']+$mergethread['deletedposts'])
|
// 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'])
|
); }
| ); }
|
elseif($mergethread['visible'] == -1) { $updated_stats = array(
| elseif($mergethread['visible'] == -1) { $updated_stats = array(
|
Zeile 1630 | Zeile 1642 |
---|
"unapprovedposts" => "-{$mergethread['unapprovedposts']}", "deletedposts" => "-{$mergethread['deletedposts']}" );
|
"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 1663 | Zeile 1675 |
---|
$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 1682 | Zeile 1694 |
---|
}
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 1716 | Zeile 1728 |
---|
elseif($new_firstpost['visible'] == -1) { --$mergethread['deletedposts'];
|
elseif($new_firstpost['visible'] == -1) { --$mergethread['deletedposts'];
|
} else
| } else
|
{ --$mergethread['unapprovedposts']; }
| { --$mergethread['unapprovedposts']; }
|
Zeile 1793 | Zeile 1805 |
---|
}
// 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 1807 | Zeile 1819 |
---|
'unapprovedposts' => 0, 'deletedposts' => 0 );
|
'unapprovedposts' => 0, 'deletedposts' => 0 );
|
| $user_counters = array();
|
if($destination_tid == 0) {
| if($destination_tid == 0) {
|
Zeile 1959 | Zeile 1973 |
---|
{ // 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 1986 | Zeile 2000 |
---|
elseif($new_firstpost['visible'] == -1) { --$thread_counters[$post['tid']]['deletedposts'];
|
elseif($new_firstpost['visible'] == -1) { --$thread_counters[$post['tid']]['deletedposts'];
|
} else
| } else
|
{ --$thread_counters[$post['tid']]['unapprovedposts']; }
| { --$thread_counters[$post['tid']]['unapprovedposts']; }
|
Zeile 2092 | Zeile 2106 |
---|
if($newthread['visible'] == 1 && $post['visible'] == 1) { ++$forum_counters[$moveto]['posts'];
|
if($newthread['visible'] == 1 && $post['visible'] == 1) { ++$forum_counters[$moveto]['posts'];
|
}
| }
|
elseif($newthread['visible'] == 0 || ($post['visible'] == 0 && $newthread['visible'] == 1)) { ++$forum_counters[$moveto]['unapprovedposts'];
| elseif($newthread['visible'] == 0 || ($post['visible'] == 0 && $newthread['visible'] == 1)) { ++$forum_counters[$moveto]['unapprovedposts'];
|
Zeile 2146 | Zeile 2160 |
---|
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 2162 | Zeile 2176 |
---|
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 2198 | Zeile 2212 |
---|
} } update_forum_counters($fid, $counters);
|
} } update_forum_counters($fid, $counters);
|
update_forum_lastpost($fid); } }
| update_forum_lastpost($fid); } }
|
return $newtid; }
| return $newtid; }
|
Zeile 2360 | Zeile 2374 |
---|
"prefix" => 0, ); $db->update_query("threads", $sqlarray, "tid = '{$thread['tid']}'");
|
"prefix" => 0, ); $db->update_query("threads", $sqlarray, "tid = '{$thread['tid']}'");
|
} }
| } }
|
$arguments = array("tids" => $tids, "moveto" => $moveto); $plugins->run_hooks("class_moderation_move_threads", $arguments);
if(!empty($user_counters)) { foreach($user_counters as $uid => $counters)
|
$arguments = array("tids" => $tids, "moveto" => $moveto); $plugins->run_hooks("class_moderation_move_threads", $arguments);
if(!empty($user_counters)) { foreach($user_counters as $uid => $counters)
|
{
| {
|
$update_array = array( "postnum" => "+{$counters['num_posts']}", "threadnum" => "+{$counters['num_threads']}", ); update_user_counters($uid, $update_array);
|
$update_array = array( "postnum" => "+{$counters['num_posts']}", "threadnum" => "+{$counters['num_threads']}", ); update_user_counters($uid, $update_array);
|
} }
| } }
|
if(is_array($forum_counters)) {
| if(is_array($forum_counters)) {
|
Zeile 2389 | Zeile 2403 |
---|
'unapprovedthreads' => "-{$counter['unapprovedthreads']}", 'deletedposts' => "-{$counter['deletedposts']}", 'deletedthreads' => "-{$counter['deletedthreads']}"
|
'unapprovedthreads' => "-{$counter['unapprovedthreads']}", 'deletedposts' => "-{$counter['deletedposts']}", 'deletedthreads' => "-{$counter['deletedthreads']}"
|
|
|
); update_forum_counters($fid, $updated_count); update_forum_lastpost($fid);
| ); update_forum_counters($fid, $updated_count); update_forum_lastpost($fid);
|
Zeile 2416 | Zeile 2430 |
---|
/** * Approve multiple posts
|
/** * Approve multiple posts
|
* * @param array $pids PIDs * @return boolean */
| * * @param array $pids PIDs * @return boolean */
|
function approve_posts($pids) { global $db, $cache, $plugins;
| function approve_posts($pids) { global $db, $cache, $plugins;
|
Zeile 2433 | Zeile 2447 |
---|
// 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 2472 | Zeile 2486 |
---|
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))
| "); while($post = $db->fetch_array($query))
|
{ $pids[] = $post['pid'];
|
{ $pids[] = $post['pid'];
|
|
|
if(!isset($thread_counters[$post['tid']])) { $thread_counters[$post['tid']] = array( 'replies' => 0 );
|
if(!isset($thread_counters[$post['tid']])) { $thread_counters[$post['tid']] = array( 'replies' => 0 );
|
}
++$thread_counters[$post['tid']]['replies'];
| }
++$thread_counters[$post['tid']]['replies'];
|
// If the thread of this post is unapproved 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 unapproved then we've already taken into account this counter as implied. // Updating it again would cause it to double count if($post['threadvisible'] == 1)
|
Zeile 2495 | Zeile 2509 |
---|
$forum_counters[$post['fid']] = array( 'num_posts' => 0 );
|
$forum_counters[$post['fid']] = array( 'num_posts' => 0 );
|
}
| }
|
++$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 2523 |
---|
$user_counters[$post['uid']] = 0; } ++$user_counters[$post['uid']];
|
$user_counters[$post['uid']] = 0; } ++$user_counters[$post['uid']];
|
} }
if(empty($pids) && empty($threads_to_update)) { return false; }
if(!empty($pids)) { $where = "pid IN (".implode(',', $pids).")"; $db->update_query("posts", $approve, $where); }
$plugins->run_hooks("class_moderation_approve_posts", $pids);
if(!empty($thread_counters)) { foreach($thread_counters as $tid => $counters)
| } }
if(empty($pids) && empty($threads_to_update)) { return false; }
if(!empty($pids)) { $where = "pid IN (".implode(',', $pids).")"; $db->update_query("posts", $approve, $where); }
$plugins->run_hooks("class_moderation_approve_posts", $pids);
if(!empty($thread_counters)) { foreach($thread_counters as $tid => $counters)
|
{ $counters_update = array( "unapprovedposts" => "-".$counters['replies'],
| { $counters_update = array( "unapprovedposts" => "-".$counters['replies'],
|
Zeile 2635 | Zeile 2649 |
---|
++$thread_counters[$post['tid']]['unapprovedposts']; if($post['visible'] == 1)
|
++$thread_counters[$post['tid']]['unapprovedposts']; if($post['visible'] == 1)
|
{
| {
|
++$thread_counters[$post['tid']]['replies'];
|
++$thread_counters[$post['tid']]['replies'];
|
}
| }
|
else { ++$thread_counters[$post['tid']]['deletedposts'];
|
else { ++$thread_counters[$post['tid']]['deletedposts'];
|
}
| }
|
if(!isset($forum_counters[$post['fid']])) { $forum_counters[$post['fid']] = array(
| if(!isset($forum_counters[$post['fid']])) { $forum_counters[$post['fid']] = array(
|
Zeile 2662 | Zeile 2676 |
---|
++$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 2689 | Zeile 2703 |
---|
{ $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);
if(!empty($thread_counters)) { foreach($thread_counters as $tid => $counters)
|
$plugins->run_hooks("class_moderation_unapprove_posts", $pids);
if(!empty($thread_counters)) { foreach($thread_counters as $tid => $counters)
|
{
| {
|
$counters_update = array( "unapprovedposts" => "+".$counters['unapprovedposts'], "replies" => "-".$counters['replies'],
| $counters_update = array( "unapprovedposts" => "+".$counters['unapprovedposts'], "replies" => "-".$counters['replies'],
|
Zeile 2743 | Zeile 2757 |
---|
function change_thread_subject($tids, $format) { global $db, $mybb, $plugins;
|
function change_thread_subject($tids, $format) { global $db, $mybb, $plugins;
|
|
|
// Get tids into list if(!is_array($tids))
|
// Get tids into list if(!is_array($tids))
|
{
| {
|
$tids = array($tids);
|
$tids = array($tids);
|
}
| }
|
// 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 2761 | Zeile 2775 |
---|
$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)
| $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", $new_subject, "tid='{$thread['tid']}'"); $db->update_query("posts", $new_subject, "tid='{$thread['tid']}' AND replyto='0'");
| $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);
| }
$arguments = array("tids" => $tids, "format" => $format);
|
Zeile 2853 | Zeile 2881 |
---|
* @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);
| { 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)");
| $pid_list = implode(',', $pids); $query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)");
|
Zeile 3495 | Zeile 3523 |
---|
$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'];
|
$tid_list[] = $thread['tid'];
|
|
|
$forum = get_forum($thread['fid']);
|
$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 3513 | Zeile 3543 |
---|
'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']])) { $user_counters[$thread['uid']] = array( 'num_posts' => 0, 'num_threads' => 0 );
|
if(!isset($user_counters[$thread['uid']])) { $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 3532 | Zeile 3562 |
---|
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']]['num_posts'])) {
|
Zeile 3579 | Zeile 3609 |
---|
if(!empty($posts_to_restore)) { $db->update_query("posts", $update, "pid IN (".implode(',', $posts_to_restore).")");
|
if(!empty($posts_to_restore)) { $db->update_query("posts", $update, "pid IN (".implode(',', $posts_to_restore).")");
|
}
$plugins->run_hooks("class_moderation_restore_threads", $tids);
| }
$plugins->run_hooks("class_moderation_restore_threads", $tids);
|
if(is_array($forum_counters)) { foreach($forum_counters as $fid => $counters) { // Update stats
|
if(is_array($forum_counters)) { foreach($forum_counters as $fid => $counters) { // Update stats
|
$update_array = array(
| $update_array = array(
|
"threads" => "+{$counters['num_threads']}", "posts" => "+{$counters['num_posts']}", "unapprovedposts" => "+{$counters['num_unapproved_posts']}",
| "threads" => "+{$counters['num_threads']}", "posts" => "+{$counters['num_posts']}", "unapprovedposts" => "+{$counters['num_unapproved_posts']}",
|
Zeile 3609 | Zeile 3639 |
---|
"threadnum" => "+{$counters['num_threads']}", ); update_user_counters($uid, $update_array);
|
"threadnum" => "+{$counters['num_threads']}", ); update_user_counters($uid, $update_array);
|
}
| }
|
} } return true;
| } } return true;
|
Zeile 3637 | Zeile 3667 |
---|
// 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 = implode(',', $tids); $tid_moved_list = ""; $comma = "";
| $tid_list = implode(',', $tids); $tid_moved_list = ""; $comma = "";
|
Zeile 3648 | Zeile 3678 |
---|
}
$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 3665 | Zeile 3697 |
---|
'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 3695 | Zeile 3727 |
---|
// 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']]['num_posts'])) {
|
Zeile 3723 | Zeile 3755 |
---|
$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;
|