From 25b61bae72420ce6f6357c3df1dd67e181fc9aac Mon Sep 17 00:00:00 2001 From: "elly1989@rocketmail.com" Date: Thu, 15 Nov 2012 20:35:37 +0000 Subject: [PATCH] Removed the infra_sensor define for noddie. Integrated the sql and standard admin_rank stuff a little. Still needs some work. Permissions Panel has a sexy floating search bar. The scripts and stylesheets are external files which will be sent to every client at connect, so they can be used in any panel you wish with no additional overheads. If there are any bugs with the permissions panel (particularly the search bar) please let me know. thanks. rights2text now has a seperator argument. It defaults to "", but can be any string, for instance "
" git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5080 316c924e-a436-60f5-8080-3fe189b3f50e --- code/__HELPERS/files.dm | 2 +- code/__HELPERS/type2type.dm | 28 ++-- code/defines/obj.dm | 19 --- code/game/gamemodes/events/ninja_equipment.dm | 11 +- code/game/objects/items/devices/PDA/PDA.dm | 11 +- code/modules/admin/holder2.dm | 2 +- .../admin/permissionverbs/permissionedit.dm | 94 +++++--------- code/modules/admin/topic.dm | 122 ++++++++++++------ code/modules/client/client procs.dm | 2 + code/modules/mob/mob.dm | 2 +- html/panels.css | 10 ++ html/search.js | 33 +++++ 12 files changed, 192 insertions(+), 144 deletions(-) create mode 100644 html/panels.css create mode 100644 html/search.js diff --git a/code/__HELPERS/files.dm b/code/__HELPERS/files.dm index 955c5ba300..9d9a3140d2 100644 --- a/code/__HELPERS/files.dm +++ b/code/__HELPERS/files.dm @@ -13,6 +13,6 @@ return text //Sends resource files to client cache -/mob/proc/getFiles() +/client/proc/getFiles() for(var/file in args) src << browse_rsc(file) \ No newline at end of file diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 50774abc3b..2215e0d52f 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -240,18 +240,18 @@ proc/tg_list2text(list/list, glue=",") //Converts a rights bitfield into a string -/proc/rights2text(rights) - if(rights & R_BUILDMODE) . += "+BUILDMODE" - if(rights & R_ADMIN) . += "+ADMIN" - if(rights & R_BAN) . += "+BAN" - if(rights & R_FUN) . += "+FUN" - if(rights & R_SERVER) . += "+SERVER" - if(rights & R_DEBUG) . += "+DEBUG" - if(rights & R_POSSESS) . += "+POSSESS" - if(rights & R_PERMISSIONS) . += "+PERMISSIONS" - if(rights & R_STEALTH) . += "+STEALTH" - if(rights & R_REJUVINATE) . += "+REJUVINATE" - if(rights & R_VAREDIT) . += "+VAREDIT" - if(rights & R_SOUNDS) . += "+SOUND" - if(rights & R_SPAWN) . += "+SPAWN" +/proc/rights2text(rights,seperator="") + if(rights & R_BUILDMODE) . += "[seperator]+BUILDMODE" + if(rights & R_ADMIN) . += "[seperator]+ADMIN" + if(rights & R_BAN) . += "[seperator]+BAN" + if(rights & R_FUN) . += "[seperator]+FUN" + if(rights & R_SERVER) . += "[seperator]+SERVER" + if(rights & R_DEBUG) . += "[seperator]+DEBUG" + if(rights & R_POSSESS) . += "[seperator]+POSSESS" + if(rights & R_PERMISSIONS) . += "[seperator]+PERMISSIONS" + if(rights & R_STEALTH) . += "[seperator]+STEALTH" + if(rights & R_REJUVINATE) . += "[seperator]+REJUVINATE" + if(rights & R_VAREDIT) . += "[seperator]+VAREDIT" + if(rights & R_SOUNDS) . += "[seperator]+SOUND" + if(rights & R_SPAWN) . += "[seperator]+SPAWN" return . \ No newline at end of file diff --git a/code/defines/obj.dm b/code/defines/obj.dm index 4d0f402620..d12cc3e704 100644 --- a/code/defines/obj.dm +++ b/code/defines/obj.dm @@ -48,25 +48,6 @@ var/locked[] = list() - -/* - * This item is completely unused, but removing it will break something in R&D and Radio code causing PDA and Ninja code to fail on compile - */ -/obj/item/device/infra_sensor - name = "Infrared Sensor" - desc = "Scans for infrared beams in the vicinity." - icon_state = "infra_sensor" - var/passive = 1.0 - flags = FPRINT | TABLEPASS| CONDUCT - item_state = "electronic" - m_amt = 150 - origin_tech = "magnets=2" -/* - * - */ - - - /obj/effect/laser name = "laser" desc = "IT BURNS!!!" diff --git a/code/game/gamemodes/events/ninja_equipment.dm b/code/game/gamemodes/events/ninja_equipment.dm index dd77de486b..e7f64d6e30 100644 --- a/code/game/gamemodes/events/ninja_equipment.dm +++ b/code/game/gamemodes/events/ninja_equipment.dm @@ -844,15 +844,16 @@ ________________________________________________________________________________ U << "\red Procedure interrupted. Protocol terminated." return else if(istype(I, /obj/item/weapon/disk/tech_disk))//If it's a data disk, we want to copy the research on to the suit. - if(I:stored)//If it has something on it. + var/obj/item/weapon/disk/tech_disk/TD = I + if(TD.stored)//If it has something on it. U << "Research information detected, processing..." if(do_after(U,s_delay)) for(var/datum/tech/current_data in stored_research) - if(current_data.id==I:stored.id) - if(current_data.levelERROR: \black Procedure interrupted. Process terminated." diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index dae947c43c..6fd584cd30 100644 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -838,12 +838,13 @@ var/global/list/obj/item/device/pda/PDAs = list() /obj/item/device/pda/attackby(obj/item/C as obj, mob/user as mob) ..() if(istype(C, /obj/item/weapon/cartridge) && !cartridge) - user.drop_item() - C.loc = src - user << "You insert [C] into [src]." cartridge = C - if(C:radio) - C:radio.hostpda = src + user.drop_item() + cartridge.loc = src + user << "You insert [cartridge] into [src]." + cartridge = C + if(cartridge.radio) + cartridge.radio.hostpda = src else if(istype(C, /obj/item/weapon/card/id)) var/obj/item/weapon/card/id/idcard = C diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm index 0c112464ee..853558d4c7 100644 --- a/code/modules/admin/holder2.dm +++ b/code/modules/admin/holder2.dm @@ -62,7 +62,7 @@ you will have to do something like if(client.rights & R_ADMIN) yourself. return 1 else if(show_msg) - usr << "Error: You do not have sufficient rights to do that. You require one of the following flags: [rights2text(rights_required)]." + usr << "Error: You do not have sufficient rights to do that. You require one of the following flags:[rights2text(rights_required," ")]." else if(usr.client.holder) return 1 diff --git a/code/modules/admin/permissionverbs/permissionedit.dm b/code/modules/admin/permissionverbs/permissionedit.dm index a86329fc6c..3bd563aaf5 100644 --- a/code/modules/admin/permissionverbs/permissionedit.dm +++ b/code/modules/admin/permissionverbs/permissionedit.dm @@ -2,74 +2,51 @@ set category = "Admin" set name = "Permissions Panel" set desc = "Edit admin permissions" - - if(!holder) - return - holder.edit_admin_permissions() + if(!check_rights(R_PERMISSIONS)) return + usr.client.holder.edit_admin_permissions() /datum/admins/proc/edit_admin_permissions() if(!check_rights(R_PERMISSIONS)) return - establish_db_connection() - if(!dbcon.IsConnected()) - usr << "\red Failed to establish database connection" - return + var/output = {" + + +Permissions Panel + + + + +
+ + + + +"} - var/DBQuery/select_query = dbcon.NewQuery("SELECT ckey, rank, level, flags FROM erro_admin ORDER BY rank, ckey") - select_query.Execute() + for(var/adm_ckey in admin_datums) + var/datum/admins/D = admin_datums[adm_ckey] + if(!D) continue + var/rank = D.rank ? D.rank : "*none*" + var/rights = rights2text(D.rights," ") + if(!rights) rights = "*none*" - var/output = "

Current admins

" - - output += "Add new admin" - - output += "
CKEY \[+\]RANKPERMISSIONS
" - output += "" - output += "" - output += "" - output += "" - output += "" - output += "" - output += "" - - var/color1 = "#f4f4f4" - var/color2 = "#e7e7e7" - var/i = 1 //Used to determine the color of each row - - while(select_query.NextRow()) - i = !i - var/adm_ckey = select_query.item[1] - var/adm_rank = select_query.item[2] - var/adm_level = select_query.item[3] - var/adm_flags = text2num(select_query.item[4]) - - var/rights_text = rights2text(adm_flags) - rights_text = replacetextEx(rights_text, "+", "
+") - if(length(rights_text) > 5) - rights_text = copytext(rights_text, 5) //Removes the first
, which replacetextEx() adds. - - output += "" - output += "" - output += "" - output += "" - output += "" - output += "" + output += "" + output += "" + output += "" + output += "" output += "" - output += "
CKEYRANKLEVELPERMISSIONSOPTIONS
[adm_ckey][adm_rank][adm_level]" - output += "[rights_text]" - output += "" - - //Options - output += "PERMISSIONS
" - output += "RANK
" - output += "REMOVE" - - output += "
[adm_ckey] \[-\][rank][rights]
" - - usr << browse(output,"window=editadminpermissions;size=600x500") + output += {" + +
Search:
+ +"} + usr << browse(output,"window=editrights;size=600x500") /datum/admins/proc/log_admin_rank_modification(var/adm_ckey, var/new_rank) + if(config.admin_legacy_system) return + if(!usr.client) return @@ -117,9 +94,8 @@ log_query.Execute() usr << "\blue Admin rank changed." - - /datum/admins/proc/log_admin_permission_modification(var/adm_ckey, var/new_permission) + if(config.admin_legacy_system) return if(!usr.client) return diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 52e077f5ee..3b17732a51 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -100,52 +100,96 @@ DB_ban_record(bantype, playermob, banduration, banreason, banjob, null, banckey) - else if(href_list["editadminpermissions"]) - var/adm_ckey = href_list["editadminckey"] - if(!adm_ckey) - usr << "\red no valid ckey" - return - + else if(href_list["editrights"]) if(!check_rights(R_PERMISSIONS)) - message_admins("[key_name_admin(usr)] attempted to edit the admin permissions of [adm_ckey] without sufficient rights.") - log_admin("[key_name(usr)] attempted to edit the admin permissions of [adm_ckey] without sufficient rights.") + message_admins("[key_name_admin(usr)] attempted to edit the admin permissions without sufficient rights.") + log_admin("[key_name(usr)] attempted to edit the admin permissions without sufficient rights.") return - switch(href_list["editadminpermissions"]) - if("permissions") - var/list/permissionlist = list() - for(var/i=1, i<=R_MAXPERMISSION, i<<=1) //that <<= is shorthand for i = i << 1. Which is a left bitshift - permissionlist[rights2text(i)] = i - var/new_permission - spawn(0) //Safety - new_permission = input("Select a permission to turn on/off", "Permission toggle", null, null) as null|anything in permissionlist - if(!new_permission) return + var/adm_ckey - message_admins("[key_name_admin(usr)] toggled the [new_permission] permission of [adm_ckey]") - log_admin("[key_name(usr)] toggled the [new_permission] permission of [adm_ckey]") - log_admin_permission_modification(adm_ckey, permissionlist[new_permission]) - if("rank") - var/new_rank = input("Please, select a rank", "New rank for player", null, null) as null|anything in list("Game Master","Game Admin", "Trial Admin", "Admin Observer") - if(!new_rank) return + var/task = href_list["editrights"] + if(task == "add") + var/new_ckey = ckey(input(usr,"New admin's ckey","Admin ckey", null) as text|null) + if(!new_ckey) return + if(new_ckey in admin_datums) + usr << "Error: Topic 'editrights': [new_ckey] is already an admin" + return + adm_ckey = new_ckey + task = "rank" + else + adm_ckey = ckey(href_list["ckey"]) + if(!adm_ckey) + usr << "Error: Topic 'editrights': No valid ckey" + return - message_admins("[key_name_admin(usr)] edited the admin rank of [adm_ckey] to [new_rank]") - log_admin("[key_name(usr)] edited the admin rank of [adm_ckey] to [new_rank]") - log_admin_rank_modification(adm_ckey, new_rank) - if("remove") - if(alert("Are you sure you want to remove [adm_ckey]?","Message","Yes","Cancel") == "Yes") - message_admins("[key_name_admin(usr)] removed [adm_ckey] from the admins list") - log_admin("[key_name(usr)] removed [adm_ckey] from the admins list") - log_admin_rank_modification(adm_ckey, "Removed") - if("add") - var/new_ckey = input(usr,"New admin's ckey","Admin ckey", null) as text|null - if(!new_ckey) return - var/new_rank = input("Please, select a rank", "New rank for player", null, null) as null|anything in list("Game Master","Game Admin", "Trial Admin", "Admin Observer") - if(!new_rank) return + var/datum/admins/D = admin_datums[adm_ckey] - message_admins("[key_name_admin(usr)] added [new_ckey] as a new admin to the rank [new_rank]") - log_admin("[key_name(usr)] added [new_ckey] as a new admin to the rank [new_rank]") - log_admin_rank_modification(new_ckey, new_rank) + if(task == "remove") + if(alert("Are you sure you want to remove [adm_ckey]?","Message","Yes","Cancel") == "Yes") + if(!D) return + admin_datums -= adm_ckey + D.disassociate() + message_admins("[key_name_admin(usr)] removed [adm_ckey] from the admins list") + log_admin("[key_name(usr)] removed [adm_ckey] from the admins list") + log_admin_rank_modification(adm_ckey, "Removed") + + else if(task == "rank") + var/new_rank + if(admin_ranks.len) + new_rank = input("Please select a rank", "New rank", null, null) as null|anything in (admin_ranks|"*New Rank*") + else + new_rank = input("Please select a rank", "New rank", null, null) as null|anything in list("Game Master","Game Admin", "Trial Admin", "Admin Observer","*New Rank*") + + var/rights = 0 + switch(new_rank) + if(null,"") return + if("*New Rank*") + new_rank = ckeyEx(input("Please input a new rank", "New custom rank", null, null) as null|text) + if(!new_rank) + usr << "Error: Topic 'editrights': Invalid rank" + return + if(admin_ranks.len) + if(new_rank in admin_ranks) + rights |= admin_ranks[new_rank] //we typed a rank which already exists, use its rights + else + admin_ranks[new_rank] = 0 //add the new rank to admin_ranks + else + new_rank = ckeyEx(new_rank) + rights |= admin_ranks[new_rank] //we input an existing rank, use its rights + + if(D) + if((D != usr.client.holder) && (D.rights & R_PERMISSIONS)) //we can't edit another admin with PERMISSIONS rights + usr << "Error: Topic 'editrights': That ckey has PERMISSIONS rights. We cannot modify." + return + D.disassociate() //remove adminverbs and unlink from client + D.rank = new_rank //update the rank + D.rights = rights //update the rights based on admin_ranks (default: 0) + else + D = new /datum/admins(new_rank, rights, adm_ckey) + + var/client/C = directory[adm_ckey] //find the client with the specified ckey (if they are logged in) + D.associate(C) //link up with the client and add verbs + + message_admins("[key_name_admin(usr)] edited the admin rank of [adm_ckey] to [new_rank]") + log_admin("[key_name(usr)] edited the admin rank of [adm_ckey] to [new_rank]") + log_admin_rank_modification(adm_ckey, new_rank) + + else if(task == "permissions") + if(!D) return + var/list/permissionlist = list() + for(var/i=1, i<=R_MAXPERMISSION, i<<=1) //that <<= is shorthand for i = i << 1. Which is a left bitshift + permissionlist[rights2text(i)] = i + var/new_permission = input("Select a permission to turn on/off", "Permission toggle", null, null) as null|anything in permissionlist + if(!new_permission) return + D.rights ^= permissionlist[new_permission] + + message_admins("[key_name_admin(usr)] toggled the [new_permission] permission of [adm_ckey]") + log_admin("[key_name(usr)] toggled the [new_permission] permission of [adm_ckey]") + log_admin_permission_modification(adm_ckey, permissionlist[new_permission]) + + edit_admin_permissions() else if(href_list["call_shuttle"]) if(!check_rights(R_ADMIN)) return diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 3d0085baf9..5256c106b6 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -116,6 +116,8 @@ log_client_to_db() + getFiles('html/search.js','html/panels.css') + ////////////// //DISCONNECT// diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 851166c5e4..8e9cb799e3 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -376,7 +376,7 @@ var/list/slot_equipment_priority = list( \ set name = "Changelog" set category = "OOC" if (client) - src.getFiles('html/postcardsmall.jpg', + client.getFiles('html/postcardsmall.jpg', 'html/somerights20.png', 'html/88x31.png', 'html/bug-minus.png', diff --git a/html/panels.css b/html/panels.css new file mode 100644 index 0000000000..0d1cb0cb9f --- /dev/null +++ b/html/panels.css @@ -0,0 +1,10 @@ +body {padding:0px;margin:0px;} +#top {position:fixed;top:5px;left:10%;width:80%;text-align:center;background-color:#fff;border:2px solid #ccc;} +#main {position:relative;top:50px;left:3%;width:96%;text-align:center;z-index:0;} +#searchable {table-layout:fixed;width:100%;text-align:center;"#f4f4f4";} +tr.norm {background-color:#f4f4f4;} +tr.title {background-color:#ccc;} +tr.alt {background-color:#e7e7e7;} +.small {font-size:80%;} +a {text-decoration:none;color:#a0a;} +a:hover {color:#d3d;} diff --git a/html/search.js b/html/search.js new file mode 100644 index 0000000000..abc47a9757 --- /dev/null +++ b/html/search.js @@ -0,0 +1,33 @@ +function selectTextField(){ + var filter_text = document.getElementById('filter'); + filter_text.focus(); + filter_text.select(); +} +function updateSearch(){ + var input_form = document.getElementById('filter'); + var filter = input_form.value.toLowerCase(); + input_form.value = filter; + var table = document.getElementById('searchable'); + var alt_style = 'norm'; + for(var i = 0; i < table.rows.length; i++){ + try{ + var row = table.rows[i]; + if(row.className == 'title') continue; + var found=0; + for(var j = 0; j < row.cells.length; j++){ + var cell = row.cells[j]; + if(cell.innerText.toLowerCase().indexOf(filter) != -1){ + found=1; + break; + } + } + if(found == 0) row.style.display='none'; + else{ + row.style.display='block'; + row.className = alt_style; + if(alt_style == 'alt') alt_style = 'norm'; + else alt_style = 'alt'; + } + }catch(err) { } + } +} \ No newline at end of file