mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-12 15:45:25 +01:00
Improve View Flagged Books admin verb
This changes the "View Flagged Books" admin verb into a datum/browser UI. You can see all the books that have been flagged from here, review them, and remove the flagged status or delete them. Also refactors pencode into some __HELPER procs, and adds a "reverse-pencode" proc. It's not perfect, due to the complexity of HTML and my unwillingness to use BYONDregex, but it's good enough to get the general idea of the formatting across. It's used for the new "view book" panel.
This commit is contained in:
@@ -3019,6 +3019,59 @@
|
||||
else
|
||||
error_viewer.showTo(usr, null, href_list["viewruntime_linear"])
|
||||
|
||||
// Library stuff
|
||||
else if(href_list["library_book_id"])
|
||||
var/isbn = href_list["library_book_id"]
|
||||
|
||||
if(href_list["view_library_book"])
|
||||
var/DBQuery/query_view_book = dbcon.NewQuery("SELECT content, title FROM [format_table_name("library")] WHERE id=[isbn]")
|
||||
if(!query_view_book.Execute())
|
||||
var/err = query_view_book.ErrorMsg()
|
||||
log_game("SQL ERROR viewing book. Error : \[[err]\]\n")
|
||||
return
|
||||
|
||||
var/content = ""
|
||||
var/title = ""
|
||||
while(query_view_book.NextRow())
|
||||
content = query_view_book.item[1]
|
||||
title = html_encode(query_view_book.item[2])
|
||||
|
||||
var/dat = "<pre><code>"
|
||||
dat += "[html_encode(html_to_pencode(content))]"
|
||||
dat += "</code></pre>"
|
||||
|
||||
var/datum/browser/popup = new(usr, "admin_view_book", "[title]", 700, 400)
|
||||
popup.set_content(dat)
|
||||
popup.open(0)
|
||||
|
||||
log_admin("[key_name(usr)] has viewed the book [isbn].")
|
||||
message_admins("[key_name_admin(usr)] has viewed the book [isbn].")
|
||||
return
|
||||
|
||||
else if(href_list["unflag_library_book"])
|
||||
var/DBQuery/query_unflag_book = dbcon.NewQuery("UPDATE [format_table_name("library")] SET flagged = 0 WHERE id=[isbn]")
|
||||
if(!query_unflag_book.Execute())
|
||||
var/err = query_unflag_book.ErrorMsg()
|
||||
log_game("SQL ERROR unflagging book. Error : \[[err]\]\n")
|
||||
return
|
||||
|
||||
log_admin("[key_name(usr)] has unflagged the book [isbn].")
|
||||
message_admins("[key_name_admin(usr)] has unflagged the book [isbn].")
|
||||
|
||||
else if(href_list["delete_library_book"])
|
||||
var/DBQuery/query_delbook = dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[isbn]")
|
||||
if(!query_delbook.Execute())
|
||||
var/err = query_delbook.ErrorMsg()
|
||||
log_game("SQL ERROR deleting book. Error : \[[err]\]\n")
|
||||
return
|
||||
|
||||
log_admin("[key_name(usr)] has deleted the book [isbn].")
|
||||
message_admins("[key_name_admin(usr)] has deleted the book [isbn].")
|
||||
|
||||
// Refresh the page
|
||||
src.view_flagged_books()
|
||||
|
||||
|
||||
/proc/admin_jump_link(var/atom/target)
|
||||
if(!target) return
|
||||
// The way admin jump links handle their src is weirdly inconsistent...
|
||||
|
||||
Reference in New Issue
Block a user