mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
- Updated the new admin system to support the database.
git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4994 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -222,4 +222,6 @@ var/fileaccess_timer = 1800 //Cannot access files by ftp until the game is finis
|
||||
#define R_VAREDIT 1024
|
||||
#define R_SOUNDS 2048
|
||||
|
||||
#define R_MAXPERMISSION 2048 //This holds the maximum value for a permission. It is used in iteration, so keep it updated.
|
||||
|
||||
#define R_HOST 65535
|
||||
|
||||
@@ -126,6 +126,7 @@ var/list/admin_verbs_possess = list(
|
||||
/proc/release
|
||||
)
|
||||
var/list/admin_verbs_permissions = list(
|
||||
/client/proc/edit_admin_permissions
|
||||
)
|
||||
var/list/admin_verbs_rejuv = list(
|
||||
/client/proc/cmd_admin_rejuvenate,
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
|
||||
//Before this proc is called, the holder variable must already be set, with the proper rank, level and permissions set.
|
||||
//This proc also DOES NOT CLEAR EXISTING ADMIN VERBS
|
||||
|
||||
/client/proc/handle_permission_verbs()
|
||||
if(!holder || !holder.rank || !holder.sql_permissions)
|
||||
return
|
||||
|
||||
if(holder.sql_permissions & PERMISSIONS)
|
||||
verbs += /client/proc/edit_admin_permissions
|
||||
@@ -11,7 +11,7 @@
|
||||
if(!usr.client)
|
||||
return
|
||||
|
||||
if(!usr.client.holder || !(usr.client.holder.sql_permissions & PERMISSIONS))
|
||||
if(!usr.client.holder || !(usr.client.holder.rights & R_PERMISSIONS))
|
||||
usr << "\red You do not have permission to do this!"
|
||||
return
|
||||
|
||||
@@ -57,10 +57,8 @@
|
||||
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>"
|
||||
var/list/permissionlist = bitfield2list(adm_flags, permissionwords_sql)
|
||||
output += "<td align='center'>"
|
||||
for(var/word in permissionlist)
|
||||
output += "[word]<BR>"
|
||||
output += "<font size='2'>[rights2text(adm_flags)]</font>"
|
||||
output += "</td>"
|
||||
output += "<td align='center'><font size='2'>"
|
||||
|
||||
@@ -76,12 +74,14 @@
|
||||
|
||||
usr << browse(output,"window=editadminpermissions;size=600x500")
|
||||
|
||||
dbcon.Disconnect()
|
||||
|
||||
|
||||
/datum/admins/proc/log_admin_rank_modification(var/adm_ckey, var/new_rank)
|
||||
if(!usr.client)
|
||||
return
|
||||
|
||||
if(!usr.client.holder || !(usr.client.holder.sql_permissions & PERMISSIONS))
|
||||
if(!usr.client.holder || !(usr.client.holder.rights & R_PERMISSIONS))
|
||||
usr << "\red You do not have permission to do this!"
|
||||
return
|
||||
|
||||
@@ -130,3 +130,69 @@
|
||||
var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Edited the rank of [adm_ckey] to [new_rank]');")
|
||||
log_query.Execute()
|
||||
usr << "\blue Admin rank changed."
|
||||
|
||||
dbcon.Disconnect()
|
||||
|
||||
|
||||
|
||||
/datum/admins/proc/log_admin_permission_modification(var/adm_ckey, var/new_permission)
|
||||
|
||||
if(!usr.client)
|
||||
return
|
||||
|
||||
if(!usr.client.holder || !(usr.client.holder.rights & R_PERMISSIONS))
|
||||
usr << "\red You do not have permission to do this!"
|
||||
return
|
||||
|
||||
var/user = sqlfdbklogin
|
||||
var/pass = sqlfdbkpass
|
||||
var/db = sqlfdbkdb
|
||||
var/address = sqladdress
|
||||
var/port = sqlport
|
||||
|
||||
var/DBConnection/dbcon = new()
|
||||
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "\red Failed to establish database connection"
|
||||
return
|
||||
|
||||
if(!adm_ckey || !new_permission)
|
||||
return
|
||||
|
||||
adm_ckey = ckey(adm_ckey)
|
||||
|
||||
if(!adm_ckey)
|
||||
return
|
||||
|
||||
if(istext(new_permission))
|
||||
new_permission = text2num(new_permission)
|
||||
|
||||
if(!istext(adm_ckey) || !isnum(new_permission))
|
||||
return
|
||||
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT id, flags FROM erro_admin WHERE ckey = '[adm_ckey]'")
|
||||
select_query.Execute()
|
||||
|
||||
var/admin_id
|
||||
var/admin_rights
|
||||
while(select_query.NextRow())
|
||||
admin_id = text2num(select_query.item[1])
|
||||
admin_rights = text2num(select_query.item[2])
|
||||
|
||||
if(!admin_id)
|
||||
return
|
||||
|
||||
if(admin_rights & new_permission) //This admin already has this permission, so we are removing it.
|
||||
var/DBQuery/insert_query = dbcon.NewQuery("UPDATE `erro_admin` SET flags = [admin_rights & ~new_permission] WHERE id = [admin_id]")
|
||||
insert_query.Execute()
|
||||
var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Removed permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]');")
|
||||
log_query.Execute()
|
||||
usr << "\blue Permission removed."
|
||||
else //This admin doesn't have this permission, so we are adding it.
|
||||
var/DBQuery/insert_query = dbcon.NewQuery("UPDATE `erro_admin` SET flags = '[admin_rights | new_permission]' WHERE id = [admin_id]")
|
||||
insert_query.Execute()
|
||||
var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Added permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]')")
|
||||
log_query.Execute()
|
||||
usr << "\blue Permission added."
|
||||
|
||||
dbcon.Disconnect()
|
||||
@@ -48,7 +48,6 @@
|
||||
if(!src.makeDeathsquad())
|
||||
usr << "\red Unfortunatly there were no candidates available"
|
||||
|
||||
/* Temporarily commented out
|
||||
if(href_list["editadminpermissions"])
|
||||
if(!usr.client)
|
||||
return
|
||||
@@ -58,7 +57,7 @@
|
||||
usr << "\red no valid ckey"
|
||||
return
|
||||
|
||||
if(!usr.client.holder || !(usr.client.holder.sql_permissions & PERMISSIONS))
|
||||
if(!usr.client.holder || !(usr.client.holder.rights & R_PERMISSIONS))
|
||||
usr << "\red You do not have permission to do this!"
|
||||
message_admins("[key_name_admin(usr)] attempted to edit the admin permissions of [adm_ckey] without authentication!")
|
||||
log_admin("[key_name(usr)] attempted to edit the admin permissions of [adm_ckey] without authentication!")
|
||||
@@ -66,7 +65,18 @@
|
||||
|
||||
switch(href_list["editadminpermissions"])
|
||||
if("permissions")
|
||||
usr << "Currently unavailable since nothing runs off of permissions"
|
||||
var/list/permissionlist = list()
|
||||
for(var/i = 1; i <= R_MAXPERMISSION; i = i << 1)
|
||||
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
|
||||
|
||||
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)
|
||||
@@ -89,7 +99,6 @@
|
||||
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)
|
||||
*/
|
||||
|
||||
|
||||
else if(href_list["call_shuttle"])
|
||||
|
||||
@@ -211,6 +211,7 @@
|
||||
#define FILE_DIR "icons/vending_icons"
|
||||
#define FILE_DIR "interface"
|
||||
#define FILE_DIR "maps"
|
||||
#define FILE_DIR "maps/backup"
|
||||
#define FILE_DIR "maps/RandomZLevels"
|
||||
#define FILE_DIR "sound"
|
||||
#define FILE_DIR "sound/AI"
|
||||
@@ -835,6 +836,7 @@
|
||||
#include "code\modules\admin\topic.dm"
|
||||
#include "code\modules\admin\ToRban.dm"
|
||||
#include "code\modules\admin\DB ban\functions.dm"
|
||||
#include "code\modules\admin\permissionverbs\permissionedit.dm"
|
||||
#include "code\modules\admin\verbs\adminhelp.dm"
|
||||
#include "code\modules\admin\verbs\adminjump.dm"
|
||||
#include "code\modules\admin\verbs\adminpm.dm"
|
||||
|
||||
Reference in New Issue
Block a user