示例#1
0
         $action = $mybb->input['threads'][$thread['tid']];
         if ($action == "approve") {
             $threads_to_approve[] = $thread['tid'];
         } else {
             if ($action == "delete") {
                 $threads_to_delete[] = $thread['tid'];
             }
         }
     }
     if (!empty($threads_to_approve)) {
         $moderation->approve_threads($threads_to_approve);
         log_moderator_action(array('tids' => $threads_to_approve), $lang->multi_approve_threads);
     }
     if (!empty($threads_to_delete)) {
         if ($mybb->settings['soft_delete'] == 1) {
             $moderation->soft_delete_threads($threads_to_delete);
             log_moderator_action(array('tids' => $threads_to_delete), $lang->multi_soft_delete_threads);
         } else {
             foreach ($threads_to_delete as $tid) {
                 $moderation->delete_thread($tid);
             }
             log_moderator_action(array('tids' => $threads_to_delete), $lang->multi_delete_threads);
         }
     }
     $plugins->run_hooks("modcp_do_modqueue_end");
     redirect("modcp.php?action=modqueue", $lang->redirect_threadsmoderated);
 } else {
     if (!empty($mybb->input['posts'])) {
         $posts = array_map("intval", array_keys($mybb->input['posts']));
         // Fetch posts
         $posts_to_approve = $posts_to_delete = array();
示例#2
0
 $query = $db->simple_select("posts", "pid", "tid='{$tid}'", array("limit" => 1, "order_by" => "dateline", "order_dir" => "asc"));
 $firstcheck = $db->fetch_array($query);
 if ($firstcheck['pid'] == $pid) {
     $firstpost = 1;
 } else {
     $firstpost = 0;
 }
 $modlogdata['fid'] = $fid;
 $modlogdata['tid'] = $tid;
 if ($firstpost) {
     if ($forumpermissions['candeletethreads'] == 1 || is_moderator($fid, "candeletethreads") || is_moderator($fid, "cansoftdeletethreads")) {
         require_once MYBB_ROOT . "inc/class_moderation.php";
         $moderation = new Moderation();
         if ($mybb->settings['soft_delete'] == 1 || is_moderator($fid, "cansoftdeletethreads")) {
             $modlogdata['pid'] = $pid;
             $moderation->soft_delete_threads(array($tid));
             log_moderator_action($modlogdata, $lang->thread_soft_deleted);
         } else {
             $moderation->delete_thread($tid);
             mark_reports($tid, "thread");
             log_moderator_action($modlogdata, $lang->thread_deleted);
         }
         if ($mybb->input['ajax'] == 1) {
             header("Content-type: application/json; charset={$lang->settings['charset']}");
             if (is_moderator($fid, "canviewdeleted")) {
                 echo json_encode(array("data" => '1'));
             } else {
                 echo json_encode(array("data" => '3', "url" => get_forum_link($fid)));
             }
         } else {
             redirect(get_forum_link($fid), $lang->redirect_threaddeleted);
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_delayedmoderation($task)
{
    global $db, $lang, $plugins;
    require_once MYBB_ROOT . "inc/class_moderation.php";
    $moderation = new Moderation();
    require_once MYBB_ROOT . "inc/class_custommoderation.php";
    $custommod = new CustomModeration();
    // Iterate through all our delayed moderation actions
    $query = $db->simple_select("delayedmoderation", "*", "delaydateline <= '" . TIME_NOW . "'");
    while ($delayedmoderation = $db->fetch_array($query)) {
        if (is_object($plugins)) {
            $args = array('task' => &$task, 'delayedmoderation' => &$delayedmoderation);
            $plugins->run_hooks('task_delayedmoderation', $args);
        }
        $tids = explode(',', $delayedmoderation['tids']);
        $input = my_unserialize($delayedmoderation['inputs']);
        if (my_strpos($delayedmoderation['type'], "modtool") !== false) {
            list(, $custom_id) = explode('_', $delayedmoderation['type'], 2);
            $custommod->execute($custom_id, $tids);
        } else {
            switch ($delayedmoderation['type']) {
                case "openclosethread":
                    $closed_tids = $open_tids = array();
                    $query2 = $db->simple_select("threads", "tid,closed", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['closed'] == 1) {
                            $closed_tids[] = $thread['tid'];
                        } else {
                            $open_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($closed_tids)) {
                        $moderation->open_threads($closed_tids);
                    }
                    if (!empty($open_tids)) {
                        $moderation->close_threads($open_tids);
                    }
                    break;
                case "deletethread":
                    foreach ($tids as $tid) {
                        $moderation->delete_thread($tid);
                    }
                    break;
                case "move":
                    foreach ($tids as $tid) {
                        $moderation->move_thread($tid, $input['new_forum']);
                    }
                    break;
                case "stick":
                    $unstuck_tids = $stuck_tids = array();
                    $query2 = $db->simple_select("threads", "tid,sticky", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['sticky'] == 1) {
                            $stuck_tids[] = $thread['tid'];
                        } else {
                            $unstuck_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($stuck_tids)) {
                        $moderation->unstick_threads($stuck_tids);
                    }
                    if (!empty($unstuck_tids)) {
                        $moderation->stick_threads($unstuck_tids);
                    }
                    break;
                case "merge":
                    // $delayedmoderation['tids'] should be a single tid
                    if (count($tids) != 1) {
                        continue;
                    }
                    // explode at # sign in a url (indicates a name reference) and reassign to the url
                    $realurl = explode("#", $input['threadurl']);
                    $input['threadurl'] = $realurl[0];
                    // Are we using an SEO URL?
                    if (substr($input['threadurl'], -4) == "html") {
                        // Get thread to merge's tid the SEO way
                        preg_match("#thread-([0-9]+)?#i", $input['threadurl'], $threadmatch);
                        preg_match("#post-([0-9]+)?#i", $input['threadurl'], $postmatch);
                        if ($threadmatch[1]) {
                            $parameters['tid'] = $threadmatch[1];
                        }
                        if ($postmatch[1]) {
                            $parameters['pid'] = $postmatch[1];
                        }
                    } else {
                        // Get thread to merge's tid the normal way
                        $splitloc = explode(".php", $input['threadurl']);
                        $temp = explode("&", my_substr($splitloc[1], 1));
                        if (!empty($temp)) {
                            for ($i = 0; $i < count($temp); $i++) {
                                $temp2 = explode("=", $temp[$i], 2);
                                $parameters[$temp2[0]] = $temp2[1];
                            }
                        } else {
                            $temp2 = explode("=", $splitloc[1], 2);
                            $parameters[$temp2[0]] = $temp2[1];
                        }
                    }
                    if ($parameters['pid'] && !$parameters['tid']) {
                        $post = get_post($parameters['pid']);
                        $mergetid = $post['tid'];
                    } else {
                        if ($parameters['tid']) {
                            $mergetid = $parameters['tid'];
                        }
                    }
                    $mergetid = (int) $mergetid;
                    $mergethread = get_thread($mergetid);
                    if (!$mergethread['tid']) {
                        continue;
                    }
                    if ($mergetid == $delayedmoderation['tids']) {
                        // sanity check
                        continue;
                    }
                    if ($input['subject']) {
                        $subject = $input['subject'];
                    } else {
                        $query = $db->simple_select("threads", "subject", "tid='{$delayedmoderation['tids']}'");
                        $subject = $db->fetch_field($query, "subject");
                    }
                    $moderation->merge_threads($mergetid, $delayedmoderation['tids'], $subject);
                    break;
                case "removeredirects":
                    foreach ($tids as $tid) {
                        $moderation->remove_redirects($tid);
                    }
                    break;
                case "removesubscriptions":
                    $moderation->remove_thread_subscriptions($tids, true);
                    break;
                case "approveunapprovethread":
                    $approved_tids = $unapproved_tids = array();
                    $query2 = $db->simple_select("threads", "tid,visible", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['visible'] == 1) {
                            $approved_tids[] = $thread['tid'];
                        } else {
                            $unapproved_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($approved_tids)) {
                        $moderation->unapprove_threads($approved_tids);
                    }
                    if (!empty($unapproved_tids)) {
                        $moderation->approve_threads($unapproved_tids);
                    }
                    break;
                case "softdeleterestorethread":
                    $delete_tids = $restore_tids = array();
                    $query2 = $db->simple_select("threads", "tid,visible", "tid IN({$delayedmoderation['tids']})");
                    while ($thread = $db->fetch_array($query2)) {
                        if ($thread['visible'] == -1) {
                            $restore_tids[] = $thread['tid'];
                        } else {
                            $delete_tids[] = $thread['tid'];
                        }
                    }
                    if (!empty($restore_tids)) {
                        $moderation->restore_threads($restore_tids);
                    }
                    if (!empty($delete_tids)) {
                        $moderation->soft_delete_threads($delete_tids);
                    }
                    break;
            }
        }
        $db->delete_query("delayedmoderation", "did='{$delayedmoderation['did']}'");
    }
    add_task_log($task, $lang->task_delayedmoderation_ran);
}
示例#4
0
     $moderation->restore_threads($tid);
     moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_threadrestored);
     break;
     // Soft delete a thread
 // Soft delete a thread
 case "softdeletethread":
     // Verify incoming POST request
     verify_post_check($mybb->get_input('my_post_key'));
     if (!is_moderator($fid, "cansoftdeletethreads")) {
         error_no_permission();
     }
     $thread = get_thread($tid);
     $plugins->run_hooks("moderation_softdeletethread");
     $lang->thread_soft_deleted = $lang->sprintf($lang->thread_soft_deleted, $thread['subject']);
     log_moderator_action($modlogdata, $lang->thread_soft_deleted);
     $moderation->soft_delete_threads($tid);
     moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_threadsoftdeleted);
     break;
     // Move a thread
 // Move a thread
 case "move":
     add_breadcrumb($lang->nav_move);
     if (!is_moderator($fid, "canmanagethreads")) {
         error_no_permission();
     }
     $plugins->run_hooks("moderation_move");
     $forumselect = build_forum_jump("", '', 1, '', 0, true, '', "moveto");
     eval("\$movethread = \"" . $templates->get("moderation_move") . "\";");
     output_page($movethread);
     break;
     // Let's get this thing moving!