Zeile 384 | Zeile 384 |
---|
$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 423 |
---|
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");
| $query = $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($query)) { $user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
| while($counter = $db->fetch_array($query)) { $user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
|
Zeile 488 | Zeile 490 |
---|
if(!empty($user_counters)) { foreach($user_counters as $uid => $counters)
|
if(!empty($user_counters)) { foreach($user_counters as $uid => $counters)
|
{
| {
|
$update_array = array( "postnum" => "+{$counters['num_posts']}", "threadnum" => "+{$counters['num_threads']}",
| $update_array = array( "postnum" => "+{$counters['num_posts']}", "threadnum" => "+{$counters['num_threads']}",
|
Zeile 513 | Zeile 515 |
---|
if(!is_array($tids)) { $tids = array($tids);
|
if(!is_array($tids)) { $tids = array($tids);
|
}
| }
|
if(empty($tids)) {
| if(empty($tids)) {
|
Zeile 533 | Zeile 535 |
---|
}
$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)
|
{
| {
|
if(!isset($forum_counters[$forum['fid']])) { $forum_counters[$forum['fid']] = array(
| if(!isset($forum_counters[$forum['fid']])) { $forum_counters[$forum['fid']] = array(
|
Zeile 550 | Zeile 554 |
---|
'num_unapprovedposts' => 0, 'num_deletedthreads' => 0, 'num_deletedposts' => 0
|
'num_unapprovedposts' => 0, 'num_deletedthreads' => 0, 'num_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 571 | Zeile 575 |
---|
$forum_counters[$forum['fid']]['num_deletedposts'] += $thread['deletedposts']; } else
|
$forum_counters[$forum['fid']]['num_deletedposts'] += $thread['deletedposts']; } else
|
{
| {
|
++$forum_counters[$forum['fid']]['num_deletedthreads']; $forum_counters[$forum['fid']]['num_deletedposts'] += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1; // Add implied invisible to count $forum_counters[$forum['fid']]['num_unapprovedposts'] += $thread['unapprovedposts'];
| ++$forum_counters[$forum['fid']]['num_deletedthreads']; $forum_counters[$forum['fid']]['num_deletedposts'] += $thread['replies']+$thread['unapprovedposts']+$thread['deletedposts']+1; // Add implied invisible to count $forum_counters[$forum['fid']]['num_unapprovedposts'] += $thread['unapprovedposts'];
|
Zeile 580 | Zeile 584 |
---|
// 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");
| $query = $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($query)) { $user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
| while($counter = $db->fetch_array($query)) { $user_counters[$counter['uid']]['num_posts'] += $counter['posts'];
|
Zeile 591 | Zeile 595 |
---|
{ ++$user_counters[$thread['uid']]['num_threads']; }
|
{ ++$user_counters[$thread['uid']]['num_threads']; }
|
}
| }
|
$posts_to_unapprove[] = $thread['firstpost']; }
| $posts_to_unapprove[] = $thread['firstpost']; }
|
Zeile 696 | Zeile 700 |
---|
// Remove any reports attached to this post $db->delete_query("reportedcontent", "id='{$pid}' AND (type = 'post' OR type = '')");
|
// Remove any reports attached to this post $db->delete_query("reportedcontent", "id='{$pid}' AND (type = 'post' OR type = '')");
|
|
|
// Update unapproved post count if($post['visible'] == 0) {
| // Update unapproved post count if($post['visible'] == 0) {
|
Zeile 755 | Zeile 759 |
---|
* @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 779 | Zeile 783 |
---|
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 802 | Zeile 806 |
---|
$fid = $post['fid']; $mastertid = $post['tid']; $first = 0;
|
$fid = $post['fid']; $mastertid = $post['tid']; $first = 0;
|
$visible = $post['visible']; }
| $visible = $post['visible']; }
|
else { // these are the selected posts
| else { // these are the selected posts
|
Zeile 902 | Zeile 906 |
---|
{ // 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 960 | Zeile 964 |
---|
'unapprovedposts' => signed($counters['unapprovedposts']), 'deletedposts' => signed($counters['deletedposts']), 'attachmentcount' => signed($counters['attachmentcount'])
|
'unapprovedposts' => signed($counters['unapprovedposts']), 'deletedposts' => signed($counters['deletedposts']), 'attachmentcount' => signed($counters['attachmentcount'])
|
);
| );
|
update_thread_counters($tid, $counters); update_last_post($tid); }
| update_thread_counters($tid, $counters); update_last_post($tid); }
|
Zeile 1167 | Zeile 1171 |
---|
$poll = $db->fetch_array($query);
$poll_array = array(
|
$poll = $db->fetch_array($query);
$poll_array = array(
|
'tid' => $newtid,
| 'tid' => $newtid,
|
'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 1219 | Zeile 1223 |
---|
// Properly set our new firstpost in our new thread if($thread['firstpost'] == $post['pid'])
|
// Properly set our new firstpost in our new thread if($thread['firstpost'] == $post['pid'])
|
{
| {
|
$db->update_query("threads", array('firstpost' => $pid), "tid='{$newtid}'"); }
| $db->update_query("threads", array('firstpost' => $pid), "tid='{$newtid}'"); }
|
Zeile 1549 | Zeile 1553 |
---|
// 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 1749 | Zeile 1753 |
---|
"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 1794 | Zeile 1797 |
---|
}
// 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 1808 | Zeile 1811 |
---|
'unapprovedposts' => 0, 'deletedposts' => 0 );
|
'unapprovedposts' => 0, 'deletedposts' => 0 );
|
| $user_counters = array();
|
if($destination_tid == 0) {
| if($destination_tid == 0) {
|
Zeile 1930 | Zeile 1935 |
---|
// 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
| elseif($post['visible'] == -1) { // Soft deleted post
|
Zeile 1960 | Zeile 1965 |
---|
{ // 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 2021 | Zeile 2026 |
---|
++$thread_counters[$post['tid']]['unapprovedposts']; ++$forum_counters[$post['fid']]['unapprovedposts']; }
|
++$thread_counters[$post['tid']]['unapprovedposts']; ++$forum_counters[$post['fid']]['unapprovedposts']; }
|
}
| }
|
// Update user thread counter if thread opener changes if($post['threadvisible'] == 1 && $forum_cache[$post['fid']]['usethreadcounts'] == 1 && $post['uid'] != $new_firstpost['uid']) {
| // Update user thread counter if thread opener changes if($post['threadvisible'] == 1 && $forum_cache[$post['fid']]['usethreadcounts'] == 1 && $post['uid'] != $new_firstpost['uid']) {
|
Zeile 2030 | Zeile 2035 |
---|
--$user_counters[$post['uid']]['threadnum']; // Add thread to new thread opener ++$user_counters[$new_firstpost['uid']]['threadnum'];
|
--$user_counters[$post['uid']]['threadnum']; // Add thread to new thread opener ++$user_counters[$new_firstpost['uid']]['threadnum'];
|
}
| }
|
update_first_post($post['tid']); }
| update_first_post($post['tid']); }
|
Zeile 2041 | Zeile 2046 |
---|
if($post['visible'] != $newthread['visible']) { $db->update_query("posts", array('visible' => $newthread['visible']), "pid='{$post['pid']}'");
|
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 $post['visible'] = $newthread['visible']; }
| // This is needed to update the forum counters correctly $post['visible'] = $newthread['visible']; }
|
Zeile 2052 | Zeile 2057 |
---|
// Add thread to new thread opener ++$user_counters[$post['uid']]['threadnum']; if(!isset($user_counters[$newthread['uid']]))
|
// Add thread to new thread opener ++$user_counters[$post['uid']]['threadnum']; if(!isset($user_counters[$newthread['uid']]))
|
{
| {
|
$user_counters[$newthread['uid']] = array( 'postnum' => 0, 'threadnum' => 0
| $user_counters[$newthread['uid']] = array( 'postnum' => 0, 'threadnum' => 0
|
Zeile 2147 | Zeile 2152 |
---|
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 2163 | Zeile 2168 |
---|
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 2212 | Zeile 2217 |
---|
* @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 2468 | Zeile 2475 |
---|
$query = $db->query(" SELECT p.pid, p.tid, p.fid, p.uid, t.visible AS threadvisible
|
$query = $db->query(" SELECT p.pid, p.tid, p.fid, p.uid, t.visible AS threadvisible
|
FROM ".TABLE_PREFIX."posts p
| 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 ");
| 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 ");
|
Zeile 2477 | Zeile 2484 |
---|
$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 );
|
$thread_counters[$post['tid']] = array( 'replies' => 0 );
|
}
| }
|
++$thread_counters[$post['tid']]['replies'];
// If the thread of this post is unapproved then we've already taken into account this counter as implied.
| ++$thread_counters[$post['tid']]['replies'];
// If the thread of this post is unapproved then we've already taken into account this counter as implied.
|
Zeile 2496 | Zeile 2503 |
---|
); } ++$forum_counters[$post['fid']]['num_posts'];
|
); } ++$forum_counters[$post['fid']]['num_posts'];
|
}
| }
|
$forum = get_forum($post['fid']);
// If post counts enabled in this forum and the thread is approved, add 1
| $forum = get_forum($post['fid']);
// If post counts enabled in this forum and the thread is approved, add 1
|
Zeile 2508 | Zeile 2515 |
---|
$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); }
| } }
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)
|
$plugins->run_hooks("class_moderation_approve_posts", $pids);
if(!empty($thread_counters)) { foreach($thread_counters as $tid => $counters)
|
{
| {
|
$counters_update = array( "unapprovedposts" => "-".$counters['replies'], "replies" => "+".$counters['replies']
| $counters_update = array( "unapprovedposts" => "-".$counters['replies'], "replies" => "+".$counters['replies']
|
Zeile 2540 | Zeile 2547 |
---|
if(!empty($forum_counters)) { foreach($forum_counters as $fid => $counters)
|
if(!empty($forum_counters)) { foreach($forum_counters as $fid => $counters)
|
{
| {
|
$updated_forum_stats = array( 'posts' => "+{$counters['num_posts']}", 'unapprovedposts' => "-{$counters['num_posts']}",
| $updated_forum_stats = array( 'posts' => "+{$counters['num_posts']}", 'unapprovedposts' => "-{$counters['num_posts']}",
|
Zeile 2572 | Zeile 2579 |
---|
global $db, $cache, $plugins;
if(empty($pids))
|
global $db, $cache, $plugins;
if(empty($pids))
|
{
| {
|
return false; }
| return false; }
|
Zeile 2604 | Zeile 2611 |
---|
{ // This is the first post in the thread so we're unapproving the whole thread. $threads_to_update[] = $post['tid'];
|
{ // 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);
|
Zeile 2624 | Zeile 2631 |
---|
$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']]['unapprovedposts']; if($post['visible'] == 1) {
| ++$thread_counters[$post['tid']]['unapprovedposts']; if($post['visible'] == 1) {
|
Zeile 2649 | Zeile 2656 |
---|
'num_unapproved_posts' => 0, 'num_deleted_posts' => 0 );
|
'num_unapproved_posts' => 0, 'num_deleted_posts' => 0 );
|
}
| }
|
// 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'] != 0) { ++$forum_counters[$post['fid']]['num_unapproved_posts']; if($post['visible'] == 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'] != 0) { ++$forum_counters[$post['fid']]['num_unapproved_posts']; if($post['visible'] == 1)
|
{
| {
|
++$forum_counters[$post['fid']]['num_posts']; } else { ++$forum_counters[$post['fid']]['num_deleted_posts'];
|
++$forum_counters[$post['fid']]['num_posts']; } else { ++$forum_counters[$post['fid']]['num_deleted_posts'];
|
}
| }
|
}
$forum = get_forum($post['fid']);
| }
$forum = get_forum($post['fid']);
|
Zeile 2676 | Zeile 2683 |
---|
$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) && empty($threads_to_update)) { return false;
|
}
| }
|
if(!empty($pids)) { $where = "pid IN (".implode(',', $pids).")"; $db->update_query("posts", $approve, $where);
|
if(!empty($pids)) { $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);
|
Zeile 2700 | Zeile 2707 |
---|
"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);
|
Zeile 2718 | Zeile 2725 |
---|
); 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)) { foreach($user_counters as $uid => $counter) { update_user_counters($uid, array('postnum' => "{$counter}"));
|
if(!empty($user_counters)) { foreach($user_counters as $uid => $counter) { update_user_counters($uid, array('postnum' => "{$counter}"));
|
} }
| } }
|
return true; }
| return true; }
|
Zeile 2747 | Zeile 2754 |
---|
if(!is_array($tids)) { $tids = array($tids);
|
if(!is_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 2760 | Zeile 2767 |
---|
$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 2787 | Zeile 2808 |
---|
* @return boolean */ function expire_thread($tid, $deletetime)
|
* @return boolean */ function expire_thread($tid, $deletetime)
|
{
| {
|
global $db, $plugins;
|
global $db, $plugins;
|
|
|
$tid = (int)$tid;
if(empty($tid))
|
$tid = (int)$tid;
if(empty($tid))
|
{
| {
|
return false; }
| return false; }
|
Zeile 2824 | Zeile 2845 |
---|
$pid_list = implode(',', $pids); $query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)"); while($post = $db->fetch_array($query))
|
$pid_list = implode(',', $pids); $query = $db->simple_select("posts", 'pid, visible', "pid IN ($pid_list)"); while($post = $db->fetch_array($query))
|
{
| {
|
if($post['visible'] != 0) { $unapprove[] = $post['pid'];
| if($post['visible'] != 0) { $unapprove[] = $post['pid'];
|
Zeile 2837 | Zeile 2858 |
---|
if(is_array($unapprove)) { $this->unapprove_posts($unapprove);
|
if(is_array($unapprove)) { $this->unapprove_posts($unapprove);
|
} if(is_array($approve)) {
| } if(is_array($approve)) {
|
$this->approve_posts($approve); } return true;
| $this->approve_posts($approve); } return true;
|
Zeile 2865 | Zeile 2886 |
---|
if($post['visible'] != -1) { $delete[] = $post['pid'];
|
if($post['visible'] != -1) { $delete[] = $post['pid'];
|
}
| }
|
else { $restore[] = $post['pid'];
| else { $restore[] = $post['pid'];
|
Zeile 2890 | Zeile 2911 |
---|
* @return boolean true */ function toggle_thread_visibility($tids, $fid)
|
* @return boolean true */ function toggle_thread_visibility($tids, $fid)
|
{
| {
|
global $db;
|
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;
|
|
|
$tid_list = implode(',', $tids); $query = $db->simple_select("threads", 'tid, visible', "tid IN ($tid_list)"); while($thread = $db->fetch_array($query)) { if($thread['visible'] != 0)
|
$tid_list = implode(',', $tids); $query = $db->simple_select("threads", 'tid, visible', "tid IN ($tid_list)"); while($thread = $db->fetch_array($query)) { if($thread['visible'] != 0)
|
{
| {
|
$unapprove[] = $thread['tid'];
|
$unapprove[] = $thread['tid'];
|
}
| }
|
else { $approve[] = $thread['tid']; }
|
else { $approve[] = $thread['tid']; }
|
}
| }
|
if(is_array($unapprove))
|
if(is_array($unapprove))
|
{
| {
|
$this->unapprove_threads($unapprove, $fid); } if(is_array($approve))
|
$this->unapprove_threads($unapprove, $fid); } if(is_array($approve))
|
{
| {
|
$this->approve_threads($approve, $fid); } return true;
| $this->approve_threads($approve, $fid); } return true;
|
Zeile 2941 | Zeile 2962 |
---|
if($thread['visible'] != -1) { $delete[] = $thread['tid'];
|
if($thread['visible'] != -1) { $delete[] = $thread['tid'];
|
} else
| } else
|
{ $restore[] = $thread['tid']; }
| { $restore[] = $thread['tid']; }
|
Zeile 2978 | Zeile 2999 |
---|
if($thread['closed'] == 1) { $open[] = $thread['tid'];
|
if($thread['closed'] == 1) { $open[] = $thread['tid'];
|
}
| }
|
elseif($thread['closed'] == 0) { $close[] = $thread['tid'];
| elseif($thread['closed'] == 0) { $close[] = $thread['tid'];
|
Zeile 2991 | Zeile 3012 |
---|
if(is_array($close)) { $this->close_threads($close);
|
if(is_array($close)) { $this->close_threads($close);
|
} return true; }
| } return true; }
|
/** * Toggle threads stick/unstick *
| /** * Toggle threads stick/unstick *
|
Zeile 3007 | Zeile 3028 |
---|
// Make sure we only have valid values $tids = array_map('intval', $tids);
|
// Make sure we only have valid values $tids = array_map('intval', $tids);
|
|
|
$stick = array(); $unstick = array();
$tid_list = implode(',', $tids); $query = $db->simple_select("threads", 'tid, sticky', "tid IN ($tid_list)"); while($thread = $db->fetch_array($query))
|
$stick = array(); $unstick = array();
$tid_list = implode(',', $tids); $query = $db->simple_select("threads", 'tid, sticky', "tid IN ($tid_list)"); while($thread = $db->fetch_array($query))
|
{
| {
|
if($thread['sticky'] == 0) { $stick[] = $thread['tid'];
| if($thread['sticky'] == 0) { $stick[] = $thread['tid'];
|
Zeile 3027 | Zeile 3048 |
---|
if(!empty($stick)) { $this->stick_threads($stick);
|
if(!empty($stick)) { $this->stick_threads($stick);
|
}
| }
|
if(!empty($unstick)) { $this->unstick_threads($unstick);
| if(!empty($unstick)) { $this->unstick_threads($unstick);
|
Zeile 3044 | Zeile 3065 |
---|
* @return boolean */ function remove_thread_subscriptions($tids, $all = true, $fid = 0)
|
* @return boolean */ function remove_thread_subscriptions($tids, $all = true, $fid = 0)
|
{ global $db, $plugins;
| { global $db, $plugins;
|
// Format thread IDs if(!is_array($tids)) {
| // Format thread IDs if(!is_array($tids)) {
|
Zeile 3097 | Zeile 3118 |
---|
AND (u.usergroup IN ({$groups_csv}){$additional_groups}) "); while($subscription = $db->fetch_array($query))
|
AND (u.usergroup IN ({$groups_csv}){$additional_groups}) "); while($subscription = $db->fetch_array($query))
|
{
| {
|
$db->delete_query("threadsubscriptions", "uid='{$subscription['uid']}' AND tid='{$subscription['tid']}'"); } } } // Delete all subscriptions of this thread else
|
$db->delete_query("threadsubscriptions", "uid='{$subscription['uid']}' AND tid='{$subscription['tid']}'"); } } } // Delete all subscriptions of this thread else
|
{
| {
|
$db->delete_query("threadsubscriptions", "tid IN ({$tids_csv})"); }
$arguments = array("tids" => $tids, "all" => $all, "fid" => $fid); $plugins->run_hooks("class_moderation_remove_thread_subscriptions", $arguments);
|
$db->delete_query("threadsubscriptions", "tid IN ({$tids_csv})"); }
$arguments = array("tids" => $tids, "all" => $all, "fid" => $fid); $plugins->run_hooks("class_moderation_remove_thread_subscriptions", $arguments);
|
|
|
return true; }
| return true; }
|
Zeile 3129 | Zeile 3150 |
---|
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 3149 | Zeile 3170 |
---|
return true; }
|
return true; }
|
|
|
/** * Soft delete multiple posts *
| /** * Soft delete multiple posts *
|
Zeile 3161 | Zeile 3182 |
---|
global $db, $cache, $plugins;
if(empty($pids))
|
global $db, $cache, $plugins;
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 3198 | Zeile 3219 |
---|
if(!empty($threads_to_update)) { $this->soft_delete_threads($threads_to_update);
|
if(!empty($threads_to_update)) { $this->soft_delete_threads($threads_to_update);
|
}
$thread_counters = $forum_counters = $user_counters = array();
| }
$thread_counters = $forum_counters = $user_counters = array();
|
$query = $db->query(" SELECT p.pid, p.tid, p.visible, f.fid, f.usepostcounts, p.uid, t.visible AS threadvisible FROM ".TABLE_PREFIX."posts p
| $query = $db->query(" SELECT p.pid, p.tid, p.visible, f.fid, f.usepostcounts, p.uid, t.visible AS threadvisible FROM ".TABLE_PREFIX."posts p
|
Zeile 3214 | Zeile 3235 |
---|
$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']]['deletedposts']; if($post['visible'] == 1) {
|
Zeile 3247 | Zeile 3268 |
---|
{ ++$forum_counters[$post['fid']]['num_deleted_posts']; if($post['visible'] == 1)
|
{ ++$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_posts']; } else { ++$forum_counters[$post['fid']]['num_unapproved_posts'];
|
}
| }
|
}
// If post counts enabled in this forum and the thread is approved, subtract 1
| }
// If post counts enabled in this forum and the thread is approved, subtract 1
|
Zeile 3264 | Zeile 3285 |
---|
$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))
|
if(empty($pids) && empty($threads_to_update)) { return false; }
if(!empty($pids))
|
{
| {
|
$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);
| }
$plugins->run_hooks("class_moderation_soft_delete_posts", $pids);
|
if(is_array($thread_counters)) {
| if(is_array($thread_counters)) {
|
Zeile 3304 | Zeile 3325 |
---|
'posts' => "-{$counters['num_posts']}", 'unapprovedposts' => "-{$counters['num_unapproved_posts']}", 'deletedposts' => "+{$counters['num_deleted_posts']}"
|
'posts' => "-{$counters['num_posts']}", 'unapprovedposts' => "-{$counters['num_unapproved_posts']}", 'deletedposts' => "+{$counters['num_deleted_posts']}"
|
);
| );
|
update_forum_counters($fid, $updated_forum_stats); update_forum_lastpost($fid); }
| update_forum_counters($fid, $updated_forum_stats); update_forum_lastpost($fid); }
|
Zeile 3494 | Zeile 3515 |
---|
$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; }
|
Zeile 3512 | Zeile 3535 |
---|
'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']]))
|
Zeile 3531 | Zeile 3554 |
---|
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");
| $query = $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($query)) { if(!isset($user_counters[$counter['uid']]['num_posts']))
| while($counter = $db->fetch_array($query)) { if(!isset($user_counters[$counter['uid']]['num_posts']))
|
Zeile 3648 | Zeile 3671 |
---|
$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 3694 | Zeile 3719 |
---|
// 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");
| $query = $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($query)) { if(!isset($user_counters[$counter['uid']]['num_posts']))
| while($counter = $db->fetch_array($query)) { if(!isset($user_counters[$counter['uid']]['num_posts']))
|
Zeile 3722 | Zeile 3747 |
---|
$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;
|