コード例 #1
0
ファイル: mysupport.php プロジェクト: myWebDev/MySupport
     $query = $db->write_query("\r\n\t\t\tSELECT t.tid, t.subject, t.fid, f.name, t.uid, t.username, t.status\r\n\t\t\tFROM " . TABLE_PREFIX . "threads t\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "forums f\r\n\t\t\tON (t.fid = f.fid)\r\n\t\t\tWHERE t.priority = '{$pid}'\r\n\t\t");
     $query2 = $db->simple_select("mysupport", "name", "mid = '{$pid}' AND type = 'priority'");
     $priority_name = $db->fetch_field($query2, "name");
     if ($db->num_rows($query) > 0) {
         $table->construct_header($lang->thread);
         $table->construct_header($lang->forum);
         $table->construct_header($lang->started_by);
         $table->construct_header($lang->status);
         while ($thread = $db->fetch_array($query)) {
             $thread_link = get_thread_link($thread['tid']);
             $forum_link = get_forum_link($thread['fid']);
             $profile_link = build_profile_link($thread['username'], $thread['uid'], "_blank");
             $table->construct_cell("<a href=\"{$mybb->settings['bburl']}/{$thread_link}\" target=\"_blank\">" . htmlspecialchars_uni($thread['subject']) . "</a>", array('width' => '30%'));
             $table->construct_cell("<a href=\"{$mybb->settings['bburl']}/{$forum_link}\" target=\"_blank\">" . htmlspecialchars_uni($thread['name']) . "</a>", array('width' => '30%'));
             $table->construct_cell($profile_link, array('class' => 'align_center', 'width' => '20%'));
             $table->construct_cell(mysupport_get_friendly_status($thread['status']), array('class' => 'align_center', 'width' => '20%'));
             $table->construct_row();
         }
     } else {
         $table->construct_cell($lang->sprintf($lang->priorities_thread_list_none, $priority_name), array('class' => 'align_center'));
         $table->construct_row();
     }
     $table->output($lang->sprintf($lang->priorities_thread_list_header, $priority_name));
 } else {
     $page->output_header($lang->mysupport);
     generate_mysupport_tabs("priorities");
     $table = new Table();
     $query = $db->simple_select("mysupport", "*", "type = 'priority'");
     if ($db->num_rows($query) > 0) {
         $table->construct_header($lang->mysupport_name);
         $table->construct_header($lang->mysupport_description);
コード例 #2
0
ファイル: mysupport.php プロジェクト: myWebDev/MySupport
/**
 * Change the status of a thread.
 *
 * @param array Information about the thread.
 * @param int The new status.
 * @param bool If this is changing the status of multiple threads.
**/
function mysupport_change_status($thread_info, $status = 0, $multiple = false)
{
    global $mybb, $db, $lang, $cache;
    $status = intval($status);
    if ($status == 3) {
        // if it's 3, we're solving and closing, but we'll just check for regular solving in the list of things to log
        // saves needing to have a 3, for the solving and closing option, in the setting of what to log
        // then below it'll check if 1 is in the list of things to log; 1 is normal solving, so if that's in the list, it'll log this too
        $log_status = 1;
    } else {
        $log_status = $status;
    }
    if ($multiple) {
        $tid = -1;
        $old_status = -1;
    } else {
        $tid = intval($thread_info['tid']);
        $old_status = intval($thread_info['status']);
    }
    $move_fid = "";
    $forums = $cache->read("forums");
    foreach ($forums as $forum) {
        if (!empty($forum['mysupportmove']) && $forum['mysupportmove'] != 0) {
            $move_fid = intval($forum['fid']);
            break;
        }
    }
    // are we marking it as solved and is it being moved??
    if (!empty($move_fid) && ($status == 1 || $status == 3)) {
        if ($mybb->settings['mysupportmoveredirect'] == "none") {
            $move_type = "move";
            $redirect_time = 0;
        } else {
            $move_type = "redirect";
            if ($mybb->settings['mysupportmoveredirect'] == "forever") {
                $redirect_time = 0;
            } else {
                $redirect_time = intval($mybb->settings['mysupportmoveredirect']);
            }
        }
        if ($multiple) {
            $move_tids = $thread_info;
        } else {
            $move_tids = array($thread_info['tid']);
        }
        require_once MYBB_ROOT . "inc/class_moderation.php";
        $moderation = new Moderation();
        // the reason it loops through using move_thread is because move_threads doesn't give the option for a redirect
        // if it's not a multiple thread it will just loop through once as there'd only be one value in the array
        foreach ($move_tids as $move_tid) {
            $moderation->move_thread($move_tid, $move_fid, $move_type, $redirect_time);
        }
    }
    if ($multiple) {
        $tids = implode(",", array_map("intval", $thread_info));
        $where_sql = "tid IN (" . $db->escape_string($tids) . ")";
    } else {
        $where_sql = "tid = '" . intval($tid) . "'";
    }
    // we need to build an array of users who have been assigned threads before the assignment is removed
    if ($status == 1 || $status == 3) {
        $query = $db->simple_select("threads", "DISTINCT assign", $where_sql . " AND assign != '0'");
        $assign_users = array();
        while ($user = $db->fetch_field($query, "assign")) {
            $assign_users[] = $user;
        }
    }
    if ($status == 3 || $status == 1 && $mybb->settings['mysupportclosewhensolved'] == "always") {
        // the bit after || here is for if we're marking as solved via marking a post as the best answer, it will close if it's set to always close
        // the incoming status would be 1 but we need to close it if necessary
        $status_update = array("closed" => 1, "status" => 1, "statusuid" => intval($mybb->user['uid']), "statustime" => TIME_NOW, "assign" => 0, "assignuid" => 0, "priority" => 0, "closedbymysupport" => 1, "onhold" => 0);
    } elseif ($status == 0) {
        // if we're marking it as unsolved, a post may have been marked as the best answer when it was originally solved, best remove it, as well as rest everything else
        $status_update = array("status" => 0, "statusuid" => 0, "statustime" => 0, "bestanswer" => 0);
    } elseif ($status == 4) {
        /** if it's 4, it's because it was marked as being not technical after being marked technical
         ** basically put back to the original status of not solved (0)
         ** however it needs to be 4 so we can differentiate between this action (technical => not technical), and a user marking it as not solved
         ** because both of these options eventually set it back to 0
         ** so the mod log entry will say the correct action as the status was 4 and it used that
         ** now that the log has been inserted we can set it to 0 again for the thread update query so it's marked as unsolved **/
        $status_update = array("status" => 0, "statusuid" => 0, "statustime" => 0);
    } elseif ($status == 2) {
        $status_update = array("status" => 2, "statusuid" => intval($mybb->user['uid']), "statustime" => TIME_NOW);
    } else {
        $status_update = array("status" => 1, "statusuid" => intval($mybb->user['uid']), "statustime" => TIME_NOW, "assign" => 0, "assignuid" => 0, "priority" => 0, "onhold" => 0);
    }
    $db->update_query("threads", $status_update, $where_sql);
    // if the thread is being marked as technical, being marked as something else after being marked technical, or we're changing the status of multiple threads, recount the number of technical threads
    if ($status == 2 || $old_status == 2 || $multiple) {
        mysupport_recount_technical_threads();
    }
    // if the thread is being marked as solved, recount the number of assigned threads for any users who were assigned threads that are now being marked as solved
    if ($status == 1 || $status == 3) {
        foreach ($assign_users as $user) {
            mysupport_recount_assigned_threads($user);
        }
    }
    if ($status == 0) {
        // if we're marking a thread(s) as unsolved, re-open any threads that were closed when they were marked as solved, but not any that were closed by denying support
        $update = array("closed" => 0, "closedbymysupport" => 0);
        $db->update_query("threads", $update, $where_sql . " AND closed = '1' AND closedbymysupport = '1'");
    }
    // get the friendly version of the status for the redirect message and mod log
    $friendly_old_status = "'" . mysupport_get_friendly_status($old_status) . "'";
    $friendly_new_status = "'" . mysupport_get_friendly_status($status) . "'";
    if ($multiple) {
        mysupport_mod_log_action($log_status, $lang->sprintf($lang->status_change_mod_log_multi, count($thread_info), $friendly_new_status));
        mysupport_redirect_message($lang->sprintf($lang->status_change_success_multi, count($thread_info), htmlspecialchars_uni($friendly_new_status)));
    } else {
        mysupport_mod_log_action($log_status, $lang->sprintf($lang->status_change_mod_log, $friendly_new_status));
        mysupport_redirect_message($lang->sprintf($lang->status_change_success, htmlspecialchars_uni($friendly_old_status), htmlspecialchars_uni($friendly_new_status)));
    }
}