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:
Tigercat2000
2017-02-12 08:44:48 -08:00
parent f6ccb2bca7
commit 1cfbeaeddb
4 changed files with 179 additions and 65 deletions
+27 -4
View File
@@ -29,13 +29,36 @@
to_chat(src, "Only administrators may use this command.")
return
holder.view_flagged_books()
/datum/admins/proc/view_flagged_books()
if(!usr.client.holder)
return
var/dat = "<table><tr><th>ISBN</th><th>Title</th><th>Total Flags</th><th>Options</th></tr>"
var/DBQuery/query = dbcon.NewQuery("SELECT id, title, flagged FROM [format_table_name("library")] WHERE flagged > 0 ORDER BY flagged DESC")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR getting flagged books. Error : \[[err]\]\n")
return
var/i
for(i = 0, query.NextRow(), i++)
to_chat(usr, "[add_zero(query.item[1], 4)] ([query.item[2]]) - flagged [query.item[3]] times.")
to_chat(usr, "[i] flagged books total.")
var/books = 0
while(query.NextRow())
books++
var/isbn = query.item[1]
dat += "<tr><td>[add_zero(isbn, 4)]</td><td>[query.item[2]]</td><td>[query.item[3]]</td><td>"
dat += "<a href='?_src_=holder;library_book_id=[isbn];view_library_book=1;'>View Content</a>"
dat += "<a href='?_src_=holder;library_book_id=[isbn];unflag_library_book=1;'>Unflag</a>"
dat += "<a href='?_src_=holder;library_book_id=[isbn];delete_library_book=1;'>Delete</a>"
dat += "</td>"
dat += "</table>"
if(!books)
dat = "<h1>No flagged books! :)</h1>"
var/datum/browser/popup = new(usr, "admin_view_flagged_books", "Flagged Books", 700, 400)
popup.set_content(dat)
popup.open(0)