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 "<br>"

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5080 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
elly1989@rocketmail.com
2012-11-15 20:35:37 +00:00
parent 323c527e9d
commit 25b61bae72
12 changed files with 192 additions and 144 deletions

View File

@@ -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)

View File

@@ -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 .

View File

@@ -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!!!"

View File

@@ -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.level<I:stored.level)
current_data.level=I:stored.level
if(current_data.id==TD.stored.id)
if(current_data.level<TD.stored.level)
current_data.level=TD.stored.level
break
I:stored = null
TD.stored = null
U << "\blue Data analyzed and updated. Disk erased."
else
U << "\red <b>ERROR</b>: \black Procedure interrupted. Process terminated."

View File

@@ -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 << "<span class='notice'>You insert [C] into [src].</span>"
cartridge = C
if(C:radio)
C:radio.hostpda = src
user.drop_item()
cartridge.loc = src
user << "<span class='notice'>You insert [cartridge] into [src].</span>"
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

View File

@@ -62,7 +62,7 @@ you will have to do something like if(client.rights & R_ADMIN) yourself.
return 1
else
if(show_msg)
usr << "<font color='red'>Error: You do not have sufficient rights to do that. You require one of the following flags: [rights2text(rights_required)].</font>"
usr << "<font color='red'>Error: You do not have sufficient rights to do that. You require one of the following flags:[rights2text(rights_required," ")].</font>"
else
if(usr.client.holder)
return 1

View File

@@ -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 = {"<!DOCTYPE html>
<html>
<head>
<title>Permissions Panel</title>
<script type='text/javascript' src='search.js'></script>
<link rel='stylesheet' type='text/css' href='panels.css'>
</head>
<body onload='selectTextField();updateSearch();'>
<div id='main'><table id='searchable' cellspacing='0'>
<tr class='title'>
<th style='width:125px;text-align:right;'>CKEY <a class='small' href='?src=\ref[src];editrights=add'>\[+\]</a></th>
<th style='width:125px;'>RANK</th><th style='width:100%;'>PERMISSIONS</th>
</tr>
"}
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 = "<div align='center'><h1>Current admins</h1>"
output += "<a href=\"byond://?src=\ref[src];editadminpermissions=add;editadminckey=none\">Add new admin</a>"
output += "<table width='90%' bgcolor='#e3e3e3' cellpadding='5' cellspacing='0'>"
output += "<tr>"
output += "<th width='125'><b>CKEY</b></th>"
output += "<th width='125'><b>RANK</b></th>"
output += "<th width='25'><b>LEVEL</b></th>"
output += "<th width='75'><b>PERMISSIONS</b></th>"
output += "<th width='150'><b>OPTIONS</b></th>"
output += "</tr>"
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, "+", "<br>+")
if(length(rights_text) > 5)
rights_text = copytext(rights_text, 5) //Removes the first <br>, which replacetextEx() adds.
output += "<tr bgcolor='[(i % 2) ? color1 : color2]'>"
output += "<td align='center'><b>[adm_ckey]</b></td>"
output += "<td align='center'><b>[adm_rank]</b></td>"
output += "<td align='center'>[adm_level]</td>"
output += "<td align='center'>"
output += "<font size='2'>[rights_text]</font>"
output += "</td>"
output += "<td align='center'><font size='2'>"
//Options
output += "<a href=\"byond://?src=\ref[src];editadminpermissions=permissions;editadminckey=[adm_ckey]\">PERMISSIONS</a><br>"
output += "<a href=\"byond://?src=\ref[src];editadminpermissions=rank;editadminckey=[adm_ckey]\">RANK</a><br>"
output += "<a href=\"byond://?src=\ref[src];editadminpermissions=remove;editadminckey=[adm_ckey]\">REMOVE</a>"
output += "</font></td>"
output += "<tr>"
output += "<td style='text-align:right;'>[adm_ckey] <a class='small' href='?src=\ref[src];editrights=remove;ckey=[adm_ckey]'>\[-\]</a></td>"
output += "<td><a href='?src=\ref[src];editrights=rank;ckey=[adm_ckey]'>[rank]</a></td>"
output += "<td><a class='small' href='?src=\ref[src];editrights=permissions;ckey=[adm_ckey]'>[rights]</a></font></td>"
output += "</tr>"
output += "</table></div>"
usr << browse(output,"window=editadminpermissions;size=600x500")
output += {"
</table></div>
<div id='top'><b>Search:</b> <input type='text' id='filter' value='' style='width:70%;' onkeyup='updateSearch();'></div>
</body>
</html>"}
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

View File

@@ -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 << "<font color='red'>Error: Topic 'editrights': [new_ckey] is already an admin</font>"
return
adm_ckey = new_ckey
task = "rank"
else
adm_ckey = ckey(href_list["ckey"])
if(!adm_ckey)
usr << "<font color='red'>Error: Topic 'editrights': No valid ckey</font>"
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 << "<font color='red'>Error: Topic 'editrights': Invalid rank</font>"
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 << "<font color='red'>Error: Topic 'editrights': That ckey has PERMISSIONS rights. We cannot modify.</font>"
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

View File

@@ -116,6 +116,8 @@
log_client_to_db()
getFiles('html/search.js','html/panels.css')
//////////////
//DISCONNECT//

View File

@@ -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',

10
html/panels.css Normal file
View File

@@ -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;}

33
html/search.js Normal file
View File

@@ -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) { }
}
}