$where[1] = " AND t4.section_id = '{$filter_identifier}' ";
            break;
        case 'spam':
            $where[0] = " WHERE `spam` = 'yes' ";
            $where[1] = " AND t1.`spam` = 'yes' ";
            break;
    }
}
$comment_count_total = $DB->fetchVar("count", 0, "SELECT count(tbl_comments.id) as `count` FROM `tbl_comments`" . $where[0]);
$comment_count_remaining = $comment_count_total - ($current_page - 1) * $Admin->getConfigVar('pagination_maximum_rows', 'symphony');
$sql = "SELECT t1.* " . "FROM tbl_comments as t1 " . "LEFT JOIN `tbl_entries` AS t3 ON t1.entry_id = t3.id " . "LEFT JOIN `tbl_entries2sections` as t4 ON t3.id = t4.entry_id " . "LEFT JOIN `tbl_sections` AS t5 ON t4.section_id = t5.id " . "LEFT JOIN `tbl_entries2customfields` AS t6 ON t6.field_id = t5.primary_field AND t4.entry_id = t6.entry_id " . "WHERE 1 " . $where[1] . "GROUP BY t1.`id` " . "ORDER BY t1.id DESC " . "LIMIT " . ($current_page - 1) * $Admin->getConfigVar('pagination_maximum_rows', 'symphony') . ", " . $Admin->getConfigVar('pagination_maximum_rows', 'symphony');
$comments = $DB->fetch($sql);
$date = $Admin->getDateObj();
include_once TOOLKIT . "/class.entrymanager.php";
$entryManager = new EntryManager($Admin);
$latest_entries = $entryManager->fetchEntries(5, true);
$sections = $DB->Fetch("SELECT * FROM `tbl_sections`");
if (isset($_GET['_f'])) {
    switch ($_GET['_f']) {
        case "complete-flag":
            $Admin->pageAlert("selected-success", array("Comment(s)", "flagged as spam"));
            break;
        case "complete-unflag":
            $Admin->pageAlert("selected-success", array("Comment(s)", "flagged as not spam"));
            break;
        case "complete-delete":
            $Admin->pageAlert("selected-success", array("Comment(s)", "deleted"));
            break;
    }
}
$config_button = $Admin->authorIsSuper() ? '<a class="configure button" href="' . $Admin->getCurrentPageURL() . 'settings/" title="Configure comment settings">Configure</a>' : "";