Fix library shit for reals

This commit is contained in:
D3athrow
2015-04-30 02:14:25 -05:00
parent e59e09522b
commit 6323c84f2b
3 changed files with 38 additions and 11 deletions

View File

@@ -29,22 +29,23 @@
if(query)
var/where = 0
if(query.title)
searchquery += " WHERE title LIKE [query.title]"
searchquery += " WHERE title LIKE '%[query.title]%'"
where = 1
if(query.author)
searchquery += " [where ? "WHERE" : "AND"] author LIKE [query.author]"
searchquery += " [where ? "WHERE" : "AND"] author LIKE '%[query.author]%'"
where = 1
if(query.category)
searchquery += " [where ? "WHERE" : "AND"] category LIKE [query.category]"
searchquery += " [where ? "WHERE" : "AND"] category LIKE '%[query.category]%'"
where = 1
var/sql = "SELECT id, author, title, category, ckey FROM library [searchquery] LIMIT [page_num * LIBRARY_BOOKS_PER_PAGE], [LIBRARY_BOOKS_PER_PAGE]"
//if(query)
//sql += " [query.toSQL()]"
// Pagination
var/DBQuery/_query = dbcon_old.NewQuery(sql)
_query.Execute()
if(_query.ErrorMsg())
world.log << _query.ErrorMsg()
var/list/results = list()
while(_query.NextRow())

View File

@@ -179,7 +179,7 @@
if(!emagged)
forbidden |= /obj/item/weapon/book/manual/nuclear
var/manualcount = 0
var/manualcount = 1
var/obj/item/weapon/book/manual/M = null
for(var/manual_type in (typesof(/obj/item/weapon/book/manual) - forbidden))
@@ -372,6 +372,9 @@
return
var/datum/cachedbook/newbook = getBookByID(href_list["id"]) // Sanitized in getBookByID
if(!newbook)
alert("No book found")
return
if((newbook.forbidden == 2 && !emagged) || newbook.forbidden == 1)
alert("This book is forbidden and cannot be printed.")
return
@@ -384,7 +387,30 @@
spawn(60)
bibledelay = 0
make_external_book(newbook)
if(href_list["manual"])
if(!href_list["manual"]) return
var/bookid = href_list["manual"]
if(!dbcon_old.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
var/datum/cachedbook/newbook = getBookByID("M[bookid]")
if(!newbook)
alert("No book found")
return
if((newbook.forbidden == 2 && !emagged) || newbook.forbidden == 1)
alert("This book is forbidden and cannot be printed.")
return
if(bibledelay)
for (var/mob/V in hearers(src))
V.show_message("<b>[src]</b>'s monitor flashes, \"Printer unavailable. Please allow a short time before attempting to print.\"")
else
bibledelay = 1
spawn(60)
bibledelay = 0
make_external_book(newbook)
src.add_fingerprint(usr)
src.updateUsrDialog()