mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-27 06:54:18 +01:00
Syndicate Contracts - Initial Implementation
Adds SQL database based syndicate contracts to be viewed from any uplink. These can be used as IC traitor objectives, but hopefully with more RP and stuff.
This commit is contained in:
@@ -257,6 +257,16 @@ datum/nano_item_lists
|
||||
if(href_list["menu"])
|
||||
nanoui_menu = text2num(href_list["menu"])
|
||||
update_nano_data(href_list["id"])
|
||||
if(href_list["contract_interact"])
|
||||
var/list/params = list("location" = "contract_details", "contract" = href_list["contract_interact"])
|
||||
usr.client.process_webint_link("interface/login/sso_server", list2params(params))
|
||||
if(href_list["contract_page"])
|
||||
nanoui_data["contracts_current_page"] = text2num(href_list["contract_page"])
|
||||
update_nano_data()
|
||||
if(href_list["contract_view"])
|
||||
nanoui_data["contracts_view"] = text2num(href_list["contract_view"])
|
||||
nanoui_data["contracts_current_page"] = 1
|
||||
update_nano_data()
|
||||
|
||||
interact(usr)
|
||||
return 1
|
||||
@@ -292,6 +302,111 @@ datum/nano_item_lists
|
||||
nanoui_data["exploit_exists"] = 1
|
||||
break
|
||||
|
||||
if(nanoui_menu == 2)
|
||||
nanoui_data["contracts_found"] = 0
|
||||
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if (dbcon.IsConnected())
|
||||
nanoui_data["contracts"] = list()
|
||||
|
||||
if (!nanoui_data["contracts_current_page"])
|
||||
nanoui_data["contracts_current_page"] = 1
|
||||
|
||||
if (!nanoui_data["contracts_view"])
|
||||
nanoui_data["contracts_view"] = 1
|
||||
|
||||
var/query_details[0]
|
||||
|
||||
switch (nanoui_data["contracts_view"])
|
||||
if (1)
|
||||
query_details[":status"] = "open"
|
||||
if (2)
|
||||
query_details[":status"] = "closed"
|
||||
else
|
||||
nanoui_data["contracts_view"] = 1
|
||||
query_details[":status"] = "open"
|
||||
|
||||
var/DBQuery/index_query = dbcon.NewQuery("SELECT count(*) as Total_Contracts FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status")
|
||||
index_query.Execute(query_details)
|
||||
|
||||
var/pages = 0
|
||||
|
||||
if (index_query.NextRow())
|
||||
var/total_contracts = text2num(index_query.item[1])
|
||||
|
||||
pages = total_contracts / 10
|
||||
|
||||
if (total_contracts % 10)
|
||||
pages++
|
||||
|
||||
pages = round(pages)
|
||||
|
||||
var/list/contracts_pages = list()
|
||||
|
||||
for (var/i = 1, i <= pages, i++)
|
||||
contracts_pages.Add(i)
|
||||
|
||||
for (var/a in contracts_pages)
|
||||
|
||||
nanoui_data["contracts_pages"] = contracts_pages
|
||||
|
||||
if (nanoui_data["contracts_current_page"] > pages)
|
||||
return
|
||||
|
||||
query_details[":offset"] = (nanoui_data["contracts_current_page"] - 1) * 10
|
||||
|
||||
var/DBQuery/list_query = dbcon.NewQuery("SELECT contract_id, contractee_name, title FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status LIMIT 10 OFFSET :offset")
|
||||
list_query.Execute(query_details)
|
||||
|
||||
var/list/contracts = list()
|
||||
while (list_query.NextRow())
|
||||
contracts.Add(list(list("id" = list_query.item[1],
|
||||
"contractee" = list_query.item[2],
|
||||
"title" = list_query.item[3])))
|
||||
|
||||
nanoui_data["contracts"] = contracts
|
||||
|
||||
nanoui_data["contracts_found"] = 1
|
||||
|
||||
if(nanoui_menu == 21)
|
||||
nanoui_data["contracts_found"] = 0
|
||||
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if (dbcon.IsConnected())
|
||||
var/query_details[0]
|
||||
query_details[":contract_id"] = text2num(id)
|
||||
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT contract_id, contractee_name, status, title, description, reward_other FROM ss13_syndie_contracts WHERE contract_id = :contract_id")
|
||||
select_query.Execute(query_details)
|
||||
|
||||
if (select_query.NextRow())
|
||||
nanoui_data["contracts_found"] = 1
|
||||
|
||||
var/contract[0]
|
||||
contract["id"] = select_query.item[1]
|
||||
contract["contractee"] = select_query.item[2]
|
||||
|
||||
switch (select_query.item[3])
|
||||
if ("open")
|
||||
contract["status"] = "1"
|
||||
else
|
||||
contract["status"] = "0"
|
||||
|
||||
contract["title"] = html_encode(select_query.item[4])
|
||||
contract["description"] = select_query.item[5]
|
||||
|
||||
var/list/nano_blacklist = list("/" = " ", "_" = " ", "\n" = "<br>")
|
||||
|
||||
for (var/a in nano_blacklist)
|
||||
contract["description"] = replacetext(contract["description"], a, nano_blacklist[a])
|
||||
|
||||
contract["description"] = html_encode(contract["description"])
|
||||
contract["reward_other"] = select_query.item[6]
|
||||
|
||||
nanoui_data["contract"] = contract
|
||||
|
||||
// I placed this here because of how relevant it is.
|
||||
// You place this in your uplinkable item to check if an uplink is active or not.
|
||||
// If it is, it will display the uplink menu and return 1, else it'll return false.
|
||||
|
||||
Reference in New Issue
Block a user