/** * Execute Inline Post Moderation * * @param array Moderation information * @param mixed Post IDs * @param array Thread IDs (in order of dateline ascending) * @return boolean true */ function execute_post_moderation($post_options, $pids, $tid) { global $db, $mybb, $lang; if (is_array($tid)) { $tid = intval($tid[0]); // There's only 1 thread when doing inline post moderation // The thread chosen is the first thread in the array of tids. // It is recommended that this be the tid of the oldest post } // Get the information about thread $thread = get_thread($tid); // If deleting posts, only do that if ($post_options['deleteposts'] == 1) { foreach ($pids as $pid) { $this->delete_post($pid); } $delete_tids = array(); $imploded_pids = implode(",", array_map("intval", $pids)); $query = $db->simple_select("threads", "tid", "firstpost IN ({$imploded_pids})"); while ($threadid = $db->fetch_field($query, "tid")) { $delete_tids[] = $threadid; } if (!empty($delete_tids)) { foreach ($delete_tids as $delete_tid) { $this->delete_thread($delete_tid); mark_reports($delete_tid, "thread"); } // return 1 here so the code in execute() above knows to redirect to the forum return 1; } } else { if ($post_options['mergeposts'] == 1) { $this->merge_posts($pids); } if ($post_options['approveposts'] == 'approve') { $this->approve_posts($pids); } elseif ($post_options['approveposts'] == 'unapprove') { $this->unapprove_posts($pids); } elseif ($post_options['approveposts'] == 'toggle') { $this->toggle_post_visibility($pids); } if ($post_options['splitposts'] > 0 || $post_options['splitposts'] == -2) { $query = $db->simple_select("posts", "COUNT(*) AS totalposts", "tid='{$tid}'"); $count = $db->fetch_array($query); if ($count['totalposts'] == 1) { error($lang->error_cantsplitonepost); } if ($count['totalposts'] == count($pids)) { error($lang->error_cantsplitall); } if ($post_options['splitposts'] == -2) { $post_options['splitposts'] = $thread['fid']; } if (empty($post_options['splitpostsnewsubject'])) { // Enter in a subject if a predefined one does not exist. $post_options['splitpostsnewsubject'] = "{$lang->split_thread_subject} {$thread['subject']}"; } $new_subject = str_ireplace('{subject}', $thread['subject'], $post_options['splitpostsnewsubject']); $new_tid = $this->split_posts($pids, $tid, $post_options['splitposts'], $new_subject); if ($post_options['splitpostsclose'] == 'close') { $this->close_threads($new_tid); } if ($post_options['splitpostsstick'] == 'stick') { $this->stick_threads($new_tid); } if ($post_options['splitpostsunapprove'] == 'unapprove') { $this->unapprove_threads($new_tid, $thread['fid']); } if (!empty($post_options['splitpostsaddreply'])) { require_once MYBB_ROOT . "inc/datahandlers/post.php"; $posthandler = new PostDataHandler("insert"); if (empty($post_options['splitpostsreplysubject'])) { $post_options['splitpostsreplysubject'] = 'RE: ' . $new_subject; } else { $post_options['splitpostsreplysubject'] = str_ireplace('{username}', $mybb->user['username'], $post_options['splitpostsreplysubject']); $post_options['splitpostsreplysubject'] = str_ireplace('{subject}', $new_subject, $post_options['splitpostsreplysubject']); } // Set the post data that came from the input to the $post array. $post = array("tid" => $new_tid, "fid" => $post_options['splitposts'], "subject" => $post_options['splitpostsreplysubject'], "uid" => $mybb->user['uid'], "username" => $mybb->user['username'], "message" => $post_options['splitpostsaddreply'], "ipaddress" => $db->escape_string(get_ip())); // Set up the post options from the input. $post['options'] = array("signature" => 1, "emailnotify" => 0, "disablesmilies" => 0); $posthandler->set_data($post); if ($posthandler->validate_post($post)) { $posthandler->insert_post($post); } } } } return true; }
$mergepost = $mybb->input['mergepost']; if (count($mergepost) <= 1) { error($lang->error_nomergeposts); } foreach ($mergepost as $pid => $yes) { $postlist[] = intval($pid); } if (!is_moderator_by_pids($postlist, "canmanagethreads")) { error_no_permission(); } foreach ($postlist as $pid) { $pid = intval($pid); $plist[] = $pid; } $masterpid = $moderation->merge_posts($plist, $tid, $mybb->input['sep']); mark_reports($plist, "posts"); log_moderator_action($modlogdata, $lang->merged_selective_posts); moderation_redirect(get_post_link($masterpid) . "#pid{$masterpid}", $lang->redirect_inline_postsmerged); break; // Split posts - Inline moderation // Split posts - Inline moderation case "multisplitposts": add_breadcrumb($lang->nav_multi_splitposts); if ($mybb->input['inlinetype'] == 'search') { $posts = getids($mybb->input['searchid'], 'search'); } else { $posts = getids($tid, 'thread'); } if (count($posts) < 1) { error($lang->error_inline_nopostsselected); }
function m_move_post_func($xmlrpc_params) { global $input, $post, $thread, $forum, $pid, $tid, $fid, $modlogdata, $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $moderation, $parser; $input = Tapatalk_Input::filterXmlInput(array('post_id2' => Tapatalk_Input::STRING, 'topic_id' => Tapatalk_Input::INT, 'topic_title' => Tapatalk_Input::STRING, 'forum_id' => Tapatalk_Input::INT), $xmlrpc_params); mod_setup(); if (!is_moderator($fid, "canmanagethreads")) { return tt_no_permission(); } $pid = $input['post_id2']; $pids = explode(',', $pid); if (empty($pids)) { return xmlrespfalse($lang->error_invalidpost); } foreach ($pids as $pid) { $post = get_post($pid); if (!$post['pid']) { return xmlrespfalse($lang->error_invalidpost); } } $query = $db->simple_select("posts", "COUNT(*) AS totalposts", "tid='{$post['tid']}'"); $count = $db->fetch_array($query); if ($count['totalposts'] == 1) { return xmlrespfalse($lang->error_cantsplitonepost); } if (!empty($input['forum_id'])) { $moveto = $input['forum_id']; } else { $moveto = $thread['fid']; } $query = $db->simple_select("forums", "fid", "fid='{$moveto}'", array('limit' => 1)); if ($db->num_rows($query) == 0) { return xmlrespfalse($lang->error_invalidforum); } mark_reports($pid, "post"); $newtid = $moderation->split_posts($pids, $post['tid'], $moveto, $input['topic_title'], $input['topic_id']); log_moderator_action($modlogdata, $lang->thread_split); $response = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'is_login_mod' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval("", 'base64')), 'struct'); return new xmlrpcresp($response); }
/** * Delete a user in the database * * @param integer $thread Thread ID * @return boolean */ function removeThread($thread) { $tid = intval($thread); $this->lang->load('editpost'); $deleted = delete_thread($tid); mark_reports($tid, "thread"); $modlogdata['tid'] = $tid; $this->logModeratorAction($modlogdata, $this->lang->thread_deleted); return $deleted; }
$modlogdata['fid'] = $fid; $modlogdata['tid'] = $tid; if ($firstpost) { if ($forumpermissions['candeletethreads'] == 1 || is_moderator($fid, "candeletethreads")) { delete_thread($tid); mark_reports($tid, "thread"); log_moderator_action($modlogdata, $lang->thread_deleted); redirect(get_forum_link($fid), $lang->redirect_threaddeleted); } else { error_no_permission(); } } else { if ($forumpermissions['candeleteposts'] == 1 || is_moderator($fid, "candeleteposts")) { // Select the first post before this delete_post($pid, $tid); mark_reports($pid, "post"); log_moderator_action($modlogdata, $lang->post_deleted); $query = $db->simple_select("posts", "pid", "tid='{$tid}' AND dateline <= '{$post['dateline']}'", array("limit" => 1, "order_by" => "dateline", "order_dir" => "desc")); $next_post = $db->fetch_array($query); if ($next_post['pid']) { $redirect = get_post_link($next_post['pid'], $tid) . "#pid{$next_post['pid']}"; } else { $redirect = get_thread_link($tid); } redirect($redirect, $lang->redirect_postdeleted); } else { error_no_permission(); } } } else { error($lang->redirect_nodelete);
/** * Soft delete one or more threads * * @param array|int Thread ID(s) * @return boolean */ function soft_delete_threads($tids) { global $db, $cache, $plugins; if (!is_array($tids)) { $tids = array($tids); } if (empty($tids)) { return false; } // Make sure we only have valid values $tids = array_map('intval', $tids); $tid_list = implode(',', $tids); $tid_moved_list = ""; $comma = ""; foreach ($tids as $tid) { $tid_moved_list .= "{$comma}'moved|{$tid}'"; $comma = ","; } $forum_counters = $user_counters = $posts_to_delete = array(); foreach ($tids as $tid) { $thread = get_thread($tid); $forum = get_forum($thread['fid']); if ($thread['visible'] == 1 || $thread['visible'] == 0) { if (!isset($forum_counters[$forum['fid']])) { $forum_counters[$forum['fid']] = array('num_posts' => 0, 'num_threads' => 0, 'num_deleted_threads' => 0, 'num_deleted_posts' => 0, 'unapproved_threads' => 0, 'unapproved_posts' => 0); } if (!isset($user_counters[$thread['uid']])) { $user_counters[$thread['uid']] = array('num_posts' => 0, 'num_threads' => 0); } ++$forum_counters[$forum['fid']]['num_deleted_threads']; $forum_counters[$forum['fid']]['num_deleted_posts'] += $thread['replies'] + $thread['unapprovedposts'] + 1; if ($thread['visible'] == 1) { ++$forum_counters[$forum['fid']]['num_threads']; $forum_counters[$forum['fid']]['num_posts'] += $thread['replies'] + 1; // Add implied invisible to count $forum_counters[$forum['fid']]['unapproved_posts'] += $thread['unapprovedposts']; } else { ++$forum_counters[$forum['fid']]['unapproved_threads']; $forum_counters[$forum['fid']]['unapproved_posts'] += $thread['replies'] + $thread['deletedposts'] + $thread['unapprovedposts'] + 1; // Add implied invisible to count $forum_counters[$forum['fid']]['num_deleted_posts'] += $thread['deletedposts']; } // 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)) { if (!isset($user_counters[$counter['uid']]['num_posts'])) { $user_counters[$counter['uid']]['num_posts'] = 0; } $user_counters[$counter['uid']]['num_posts'] += $counter['posts']; } } if ($thread['visible'] == 1 && $forum['usethreadcounts'] != 0 && substr($thread['closed'], 0, 6) != 'moved|') { ++$user_counters[$thread['uid']]['num_threads']; } } $posts_to_delete[] = $thread['firstpost']; } $update = array("visible" => -1); $db->update_query("threads", $update, "tid IN ({$tid_list})"); // Soft delete redirects, too $redirect_tids = array(); $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; } if (!empty($redirect_tids)) { $this->soft_delete_threads($redirect_tids); } if (!empty($posts_to_delete)) { $db->update_query("posts", $update, "pid IN (" . implode(',', $posts_to_delete) . ")"); } $plugins->run_hooks("class_moderation_soft_delete_threads", $tids); if (is_array($forum_counters)) { foreach ($forum_counters as $fid => $counters) { // Update stats $update_array = array("threads" => "-{$counters['num_threads']}", "unapprovedthreads" => "-{$counters['unapproved_threads']}", "posts" => "-{$counters['num_posts']}", "unapprovedposts" => "-{$counters['unapproved_posts']}", "deletedposts" => "+{$counters['num_deleted_posts']}", "deletedthreads" => "+{$counters['num_deleted_threads']}"); update_forum_counters($fid, $update_array); update_forum_lastpost($fid); } } 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); } } return true; }