Example #1
0
function lockposts_moderation()
{
    global $mybb, $lang, $db;
    if ($mybb->input['modtype'] != 'inlinepost') {
        return;
    }
    $lang->load('lockposts');
    $tid = intval($mybb->input['tid']);
    $fid = intval($mybb->input['fid']);
    $posts = getids($tid, 'thread');
    if (count($posts) < 1) {
        $mybb->input['action'] = 'multiunapprovethreads';
        // Display correct error
        return;
    }
    $lockpost = 0;
    if ($mybb->input['action'] == 'lockposts') {
        $lockpost = 1;
    } else {
        if ($mybb->input['action'] != 'unlockposts') {
            return;
        }
    }
    foreach ($posts as $pid) {
        $post = get_post($pid);
        if ($post['pid'] > 0) {
            $locked = array("locked" => intval($lockpost));
            $db->update_query("posts", $locked, "pid='{$post['pid']}'");
        }
    }
    clearinline($tid, 'thread');
    if ($lockpost) {
        moderation_redirect(get_post_link($posts[0]) . "#pid{$posts[0]}", $lang->redirect_inline_postslocked);
    } else {
        moderation_redirect(get_post_link($posts[0]) . "#pid{$posts[0]}", $lang->redirect_inline_postsunlocked);
    }
}
                $tids = array();
                $options = array('order_by' => 'dateline', 'order_dir' => 'asc');
                $query = $db->simple_select("posts", "DISTINCT tid", "pid IN (" . implode(',', $pids) . ")", $options);
                while ($row = $db->fetch_array($query)) {
                    $tids[] = $row['tid'];
                }
                $ret = $custommod->execute(intval($mybb->input['action']), $tids, $pids);
                $lang->custom_tool = $lang->sprintf($lang->custom_tool, $tool['name']);
                log_moderator_action($modlogdata, $lang->custom_tool);
                if ($mybb->input['inlinetype'] == 'search') {
                    clearinline($mybb->input['searchid'], 'search');
                    $lang->redirect_customtool_search = $lang->sprintf($lang->redirect_customtool_search, $tool['name']);
                    $return_url = htmlspecialchars_uni($mybb->input['url']);
                    redirect($return_url, $lang->redirect_customtool_search);
                } else {
                    clearinline($tid, 'thread');
                    if ($ret == 'forum') {
                        $lang->redirect_customtool_forum = $lang->sprintf($lang->redirect_customtool_forum, $tool['name']);
                        moderation_redirect(get_forum_link($fid), $lang->redirect_customtool_forum);
                    } else {
                        $lang->redirect_customtool_thread = $lang->sprintf($lang->redirect_customtool_thread, $tool['name']);
                        moderation_redirect(get_thread_link($tid), $lang->redirect_customtool_thread);
                    }
                }
                break;
            }
        }
        error_no_permission();
        break;
}
// Some little handy functions for our inline moderation
Example #3
0
function mysupport_do_inline_thread_moderation()
{
    global $mybb;
    // we're hooking into the start of moderation.php, so if we're not submitting a MySupport action, exit now
    if (strpos($mybb->input['action'], "mysupport") === false) {
        return false;
    }
    verify_post_check($mybb->input['my_post_key']);
    global $db, $cache, $lang, $mod_log_action, $redirect;
    $lang->load("mysupport");
    $fid = intval($mybb->input['fid']);
    if (!is_moderator($fid, 'canmanagethreads')) {
        error_no_permission();
    }
    if ($mybb->input['inlinetype'] == "search") {
        $type = "search";
        $id = $mybb->input['searchid'];
        $redirect_url = "search.php?action=results&sid=" . rawurlencode($id);
    } else {
        $type = "forum";
        $id = $fid;
        $redirect_url = get_forum_link($fid);
    }
    $threads = getids($id, $type);
    if (count($threads) < 1) {
        mysupport_error($lang->error_inline_nothreadsselected);
        exit;
    }
    clearinline($id, $type);
    $tids = implode(",", array_map("intval", $threads));
    $mysupport_threads = array();
    // in a list of search results, you could see threads that aren't from a MySupport forum, but the MySupport options will always show in the inline moderation options regardless of this
    // this is a way of determining which of the selected threads from a list of search results are in a MySupport forum
    // this isn't necessary for inline moderation via the forum display, as the options only show in MySupport forums to begin with
    if ($type == "search") {
        // list of MySupport forums
        $mysupport_forums = implode(",", array_map("intval", mysupport_forums()));
        // query all the threads that are in the list of TIDs and where the FID is also in the list of MySupport forums and where the thread is set to be a support thread
        // this will knock out the non-MySupport threads
        $query = $db->simple_select("threads", "tid", "fid IN (" . $db->escape_string($mysupport_forums) . ") AND tid IN (" . $db->escape_string($tids) . ") AND issupportthread = '1'");
        while ($tid = $db->fetch_field($query, "tid")) {
            $mysupport_threads[] = intval($tid);
        }
        $threads = $mysupport_threads;
        // if the new list of threads is empty, no MySupport threads have been selected
        if (count($threads) < 1) {
            mysupport_error($lang->no_mysupport_threads_selected);
            exit;
        }
    } elseif ($type == "forum") {
        $query = $db->simple_select("threads", "tid", "tid IN (" . $db->escape_string($tids) . ") AND issupportthread = '1'");
        while ($tid = $db->fetch_field($query, "tid")) {
            $mysupport_threads[] = intval($tid);
        }
        $threads = $mysupport_threads;
        // if the new list of threads is empty, no MySupport threads have been selected
        if (count($threads) < 1) {
            mysupport_error($lang->no_mysupport_threads_selected);
            exit;
        }
    }
    $mod_log_action = "";
    $redirect = "";
    if (strpos($mybb->input['action'], "status") !== false) {
        $status = str_replace("mysupport_status_", "", $mybb->input['action']);
        if ($status == 2 || $status == 4) {
            $perm = "canmarktechnical";
        } else {
            $perm = "canmarksolved";
        }
        // they don't have permission to perform this action, so go through the different statuses and show an error for the right one
        if (!mysupport_usergroup($perm)) {
            switch ($status) {
                case 1:
                    mysupport_error($lang->no_permission_mark_solved_multi);
                    break;
                case 2:
                    mysupport_error($lang->no_permission_mark_technical_multi);
                    break;
                case 3:
                    mysupport_error($lang->no_permission_mark_solved_close_multi);
                    break;
                case 4:
                    mysupport_error($lang->no_permission_mark_nottechnical_multi);
                    break;
                default:
                    mysupport_error($lang->no_permission_mark_notsolved_multi);
            }
        }
        mysupport_change_status($threads, $status, true);
    }
    if (strpos($mybb->input['action'], "onhold") !== false) {
        $hold = str_replace("mysupport_onhold_", "", $mybb->input['action']);
        if (!mysupport_usergroup("canmarksolved")) {
            mysupport_error($lang->no_permission_thread_hold_multi);
            exit;
        }
        mysupport_change_hold($threads, $hold, true);
    } elseif (strpos($mybb->input['action'], "assign") !== false) {
        if (!mysupport_usergroup("canassign")) {
            mysupport_error($lang->assign_no_perms);
            exit;
        }
        $assign = str_replace("mysupport_assign_", "", $mybb->input['action']);
        if ($assign == 0) {
            // in the function to change the assigned user, -1 means removing; 0 is easier to put into the form than -1, so change it back here
            $assign = -1;
        } else {
            $assign_users = mysupport_get_assign_users();
            // -1 is what's used to unassign a thread so we need to exclude that
            if (!array_key_exists($assign, $assign_users)) {
                mysupport_error($lang->assign_invalid);
                exit;
            }
        }
        mysupport_change_assign($threads, $assign, true);
    } elseif (strpos($mybb->input['action'], "priority") !== false) {
        if (!mysupport_usergroup("cansetpriorities")) {
            mysupport_error($lang->priority_no_perms);
            exit;
        }
        $priority = str_replace("mysupport_priority_", "", $mybb->input['action']);
        if ($priority == 0) {
            // in the function to change the priority, -1 means removing; 0 is easier to put into the form than -1, so change it back here
            $priority = -1;
        } else {
            $mysupport_cache = $cache->read("mysupport");
            $mids = array();
            if (!empty($mysupport_cache['priorities'])) {
                foreach ($mysupport_cache['priorities'] as $priority_info) {
                    $mids[] = intval($priority_info['mid']);
                }
            }
            if (!in_array($priority, $mids)) {
                mysupport_error($lang->priority_invalid);
                exit;
            }
        }
        mysupport_change_priority($threads, $priority, true);
    } elseif (strpos($mybb->input['action'], "category") !== false) {
        $category = str_replace("mysupport_category_", "", $mybb->input['action']);
        if ($category == 0) {
            // in the function to change the category, -1 means removing; 0 is easier to put into the form than -1, so change it back here
            $category = -1;
        } else {
            $categories = mysupport_get_categories($forum);
            if (!array_key_exists($category, $categories) && $category != "-1") {
                mysupport_error($lang->category_invalid);
                exit;
            }
        }
        mysupport_change_category($threads, $category, true);
    }
    $mod_log_data = array("fid" => intval($fid));
    log_moderator_action($mod_log_data, $mod_log_action);
    redirect($redirect_url, $redirect);
}