ikibooru/reports.html.l
2024-06-01 17:40:11 +03:00

63 lines
2.8 KiB
Plaintext

{%
local queryStatus = tonumber(request.querystring.status) or BigGlobe.REPORT_STATUS_OPEN
local offset = tonumber(request.querystring.o)
if verified and verified.privs >= DB.USER_PRIVS_MOD then
if request:post() and request:post().csrf and DB.csrfverify(verified.id, Escapes.urlunescape(request:post().csrf)) and request:post().rid and tonumber(request:post().rid) then
local rid = tonumber(request:post().rid)
local selected = tonumber(request:post().newsta)
DB.setreportstatus(rid, selected)
end
title = "Reports"
else
title = "Not authorized"
end
%}
{% function content() %}
{% if verified and verified.privs >= DB.USER_PRIVS_MOD then %}
<p>View: <a href="/reports?status=0">Open</a> | <a href="/reports?status=2">Fixed</a> | <a href="/reports?status=1">Wontfix</a></p>
{% local reports = DB.getreports(queryStatus, offset) %}
{% local csrfval = DB.csrf(verified.id) %}
<table class="report">
{% if #reports == 0 then %}
<p>No results.</p>
{% end %}
{% for _, report in pairs(reports) do %}
<tr>
<td>
<p>
On <span class="dt">{{ report.createtime }}</span>,
<a href="/user/{{report.reportee}}">{{ Escapes.htmlescape(DB.getuserbyid(report.reportee).displayname) }}</a>
was reported by
<a href="/user/{{report.reporter}}">{{ Escapes.htmlescape(DB.getuserbyid(report.reporter).displayname) }}</a>
</p>
<p>Status: {{ ({[BigGlobe.REPORT_STATUS_OPEN] = "Open", [BigGlobe.REPORT_STATUS_CLOSED_WONTFIX] = "Wont Fix", [BigGlobe.REPORT_STATUS_CLOSED_FIXED] = "Fixed"})[report.status] }}</p>
<div class="content"><p>{{ Escapes.htmlescape(report.content):gsub("\n\n", "</p><p>") }}</p></div>
</td>
<td>
<p>Change Status?</p>
<form action="#" method="POST">
<input type="hidden" name="csrf" value="{{ csrfval }}" />
<input type="hidden" name="rid" value="{{ report.id }}" />
<div><input type="radio" name="newsta" value="{{ BigGlobe.REPORT_STATUS_OPEN }}" id="setopen{{ report.id }}" checked /><label for="setopenparam{{ report.id }}">Set to "Open"</label></div>
<div><input type="radio" name="newsta" value="{{ BigGlobe.REPORT_STATUS_CLOSED_FIXED }}" id="setfixedparam{{ report.id }}" /><label for="setfixedparam{{ report.id }}">Set to "Fixed"</label></div>
<div><input type="radio" name="newsta" value="{{ BigGlobe.REPORT_STATUS_CLOSED_WONTFIX }}" id="setwontfixparam{{ report.id }}" /><label for="setwontfixparam{{ report.id }}">Set to "Wont Fix"</label></div>
<button>Submit</button>
</form>
</td>
</tr>
{% end %}
</table>
{% if #reports == 50 then %}
<p><a href="/reports?status={{ queryStatus }}&o={{ reports[#reports].id }}">Next</a></p>
{% end %}
{% else %}
<p>Not authorized.</p>
{% end %}
{% end %}
{# base.inc