Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project/managementpanel #3852

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@
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_COLOR) . += "[seperator]+COLOR"
if(rights & R_VAREDIT) . += "[seperator]+VAREDIT"
if(rights & R_SOUNDS) . += "[seperator]+SOUND"
Expand Down
1 change: 0 additions & 1 deletion code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ DEFINE_BITFIELD(rights, list(
"POSSESS" = R_POSSESS,
"PERMISSIONS" = R_PERMISSIONS,
"STEALTH" = R_STEALTH,
"REJUVENATE" = R_REJUVINATE,
"COLOR" = R_COLOR,
"VAREDIT" = R_VAREDIT,
"SOUNDS" = R_SOUNDS,
Expand Down
4 changes: 4 additions & 0 deletions code/controllers/configuration/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

/datum/controller/configuration/proc/admin_reload()
if(IsAdminAdvancedProcCall())
alert_proccall("configuration admin_reload")
return
log_admin("[key_name(usr)] has forcefully reloaded the configuration from disk.")
message_admins("[key_name_admin(usr)] has forcefully reloaded the configuration from disk.")
Expand All @@ -33,6 +34,7 @@

/datum/controller/configuration/proc/Load(_directory)
if(IsAdminAdvancedProcCall()) //If admin proccall is detected down the line it will horribly break everything.
alert_proccall("configuration Load")
return
if(_directory)
directory = _directory
Expand Down Expand Up @@ -117,6 +119,7 @@

/datum/controller/configuration/proc/full_wipe()
if(IsAdminAdvancedProcCall())
alert_proccall("configuration full_wipe")
return
entries_by_type.Cut()
QDEL_LIST_ASSOC_VAL(entries)
Expand Down Expand Up @@ -163,6 +166,7 @@

/datum/controller/configuration/proc/LoadEntries(filename, list/stack = list())
if(IsAdminAdvancedProcCall())
alert_proccall("configuration LoadEntries")
return

var/filename_to_test = world.system_type == MS_WINDOWS ? lowertext(filename) : filename
Expand Down
23 changes: 11 additions & 12 deletions code/global.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
#define R_POSSESS (1<<5)
#define R_PERMISSIONS (1<<6)
#define R_STEALTH (1<<7)
#define R_REJUVINATE (1<<8)
#define R_COLOR (1<<9)
#define R_VAREDIT (1<<10)
#define R_SOUNDS (1<<11)
#define R_SPAWN (1<<12)
#define R_MOD (1<<13)
#define R_MENTOR (1<<14)
#define R_HOST (1<<15)
#define R_PROFILER (1<<16)
#define R_NOLOCK (1<<17)
#define R_EVENT (1<<18)
#define R_COLOR (1<<8)
#define R_VAREDIT (1<<9)
#define R_SOUNDS (1<<10)
#define R_SPAWN (1<<11)
#define R_MOD (1<<12)
#define R_MENTOR (1<<13)
#define R_HOST (1<<14)
#define R_PROFILER (1<<15)
#define R_NOLOCK (1<<16)
#define R_EVENT (1<<17)

/// The sum of all other rank permissions.
#define R_EVERYTHING ((1<<19)-1)
#define R_EVERYTHING ((1<<18)-1)

// 512.1430 increases maximum bit flags from 16 to 24, so the following flags should be available for future changes:
//=================================================
Expand Down
23 changes: 14 additions & 9 deletions code/modules/admin/IsBanned.dm
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
#ifndef OVERRIDE_BAN_SYSTEM
//Blocks an attempt to connect before even creating our client datum thing.
/// Blocks an attempt to connect before even creating our client datum thing.
/world/IsBanned(key,address,computer_id, type, real_bans_only=FALSE)
var/ckey = ckey(key)

// This is added siliently. Thanks to MSO for this fix. You will see it when/if we go OS
/// This is added siliently. Thanks to MSO for this fix. You will see it when/if we go OS
if (type == "world")
return ..() //shunt world topic banchecks to purely to byond's internal ban system

var/client/C = GLOB.directory[ckey]
if (C && ckey == C.ckey && computer_id == C.computer_id && address == C.address)
return //don't recheck connected clients.

//Guest Checking
/// Guest Checking
if(IsGuestKey(key))
log_access("Failed Login: [key] - Guests not allowed")
message_admins("Failed Login: [key] - Guests not allowed")
return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.")

WAIT_DB_READY
if(admin_datums[ckey] && (admin_datums[ckey].rights & R_MOD))
return ..()

if(CONFIG_GET(number/limit_players) && CONFIG_GET(number/limit_players) < GLOB.clients.len)
/// Staff can always connect through cap, for safety.
var/staff_player = FALSE
var/player_limit = CONFIG_GET(number/limit_players)
if(admin_datums[ckey])
staff_player = TRUE
if(admin_datums[ckey].rights & R_PERMISSIONS)
return ..()

if(!(staff_player && (player_limit && player_limit < GLOB.clients.len)))
return list("reason"="POP CAPPED", "desc"="\nReason: Server is pop capped at the moment at [CONFIG_GET(number/limit_players)] players. Attempt reconnection in 2-3 minutes.")

var/datum/entity/player/P = get_player_from_key(ckey)

//check if the IP address is a known TOR node
/// check if the IP address is a known TOR node
if(CONFIG_GET(flag/ToRban) && ToRban_isbanned(address))
log_access("Failed Login: [src] - Banned: ToR")
message_admins("Failed Login: [src] - Banned: ToR")
return list("reason"="Using ToR", "desc"="\nReason: The network you are using to connect has been banned.\nIf you believe this is a mistake, please request help at [CONFIG_GET(string/banappeals)]")

// wait for database to be ready
/// wait for database to be ready

. = P.check_ban(computer_id, address)
if(.)
Expand Down
40 changes: 40 additions & 0 deletions code/modules/admin/NewBan.dm
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ var/savefile/Banlist
RemoveBan(A)

/client/proc/cmd_admin_do_ban(mob/M)
if(IsAdminAdvancedProcCall())
alert_proccall("cmd_admin_do_ban")
return

if(!check_rights(R_BAN|R_MOD)) return

if(!ismob(M)) return
Expand All @@ -248,3 +252,39 @@ var/savefile/Banlist
if(P.is_time_banned && alert(usr, "Ban already exists. Proceed?", "Confirmation", "Yes", "No") != "Yes")
return
P.add_timed_ban(reason, mins)



/client/proc/cmd_do_management_ban(mob/M, nameless = TRUE, anti_staff = FALSE)
if(IsAdminAdvancedProcCall())
alert_proccall("cmd_do_management_ban")
return
if(!check_rights(R_PERMISSIONS))
to_chat(src, SPAN_BOLDWARNING("Warning: You do not have access to this command."))
return

if(!ismob(M))
to_chat(src, SPAN_BOLDWARNING("Warning: Mob not found."))
return

if(!anti_staff)
if(M.client && M.client.admin_holder && (M.client.admin_holder.rights & R_MOD))
to_chat(src, SPAN_BOLDWARNING("Warning: This command cannot execute on staff."))
return

if(!M.ckey)
to_chat(usr, SPAN_BOLDWARNING("<B>Warning: Mob ckey for [M.name] not found.</b>"))
return
var/mob_key = M.ckey
var/mins = tgui_input_number(usr,"How long (in minutes)? \n 180 = 3 hours \n 1440 = 1 day \n 4320 = 3 days \n 10080 = 7 days \n 43800 = 1 Month \n 262800 = 6 Months \n Max = 1 Year","Ban time", 1440, 525599, 1)
if(!mins)
return
if(mins >= 525600) mins = 525599
var/reason = input(usr,"Reason? \n\nPress 'OK' to finalize the ban.","reason","Griefer") as message|null
if(!reason)
return
var/datum/entity/player/P = get_player_from_key(mob_key) // you may not be logged in, but I will find you and I will ban you
if(P.is_time_banned && alert(usr, "Ban already exists. Proceed?", "Confirmation", "Yes", "No") != "Yes")
return
///Below proc needs replacing for nameless to function
P.add_timed_ban(reason, mins)
3 changes: 1 addition & 2 deletions code/modules/admin/admin_ranks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ var/list/admin_ranks = list() //list of all ranks with associated rights
if("permissions","rights") rights |= R_PERMISSIONS
if("possess") rights |= R_POSSESS
if("stealth") rights |= R_STEALTH
if("rejuv","rejuvinate") rights |= R_REJUVINATE
if("color") rights |= R_COLOR
if("varedit") rights |= R_VAREDIT
if("event") rights |= R_EVENT
if("everything","host","all") rights |= (R_HOST|R_BUILDMODE|R_ADMIN|R_BAN|R_SERVER|R_DEBUG|R_PERMISSIONS|R_POSSESS|R_STEALTH|R_REJUVINATE|R_COLOR|R_VAREDIT|R_EVENT|R_SOUNDS|R_NOLOCK|R_SPAWN|R_MOD|R_MENTOR)
if("everything","host","all") rights |= (R_HOST|R_BUILDMODE|R_ADMIN|R_BAN|R_SERVER|R_DEBUG|R_PERMISSIONS|R_POSSESS|R_STEALTH|R_COLOR|R_VAREDIT|R_EVENT|R_SOUNDS|R_NOLOCK|R_SPAWN|R_MOD|R_MENTOR)
if("sound","sounds") rights |= R_SOUNDS
if("nolock") rights |= R_NOLOCK
if("spawn","create") rights |= R_SPAWN
Expand Down
6 changes: 6 additions & 0 deletions code/modules/admin/callproc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ GLOBAL_PROTECT(LastAdminCalledProc)
*/
/proc/HandleUserlessProcCall(user, datum/target, procname, list/arguments)
if(IsAdminAdvancedProcCall())
alert_proccall("HandleUserlessProcCall")
return
var/mob/proccall_handler/handler = GLOB.AdminProcCallHandler
handler.add_caller(user)
Expand All @@ -90,6 +91,7 @@ GLOBAL_PROTECT(LastAdminCalledProc)
*/
/proc/HandleUserlessSDQL(user, query_text)
if(IsAdminAdvancedProcCall())
alert_proccall("HandleUserlessSDQL")
return

var/mob/proccall_handler/handler = GLOB.AdminProcCallHandler
Expand Down Expand Up @@ -224,6 +226,10 @@ GLOBAL_PROTECT(LastAdminCalledProc)
/proc/IsAdminAdvancedProcCall()
return (GLOB.AdminProcCaller && GLOB.AdminProcCaller == usr?.client?.ckey) || (GLOB.AdminProcCallHandler && usr == GLOB.AdminProcCallHandler)

/proc/alert_proccall(procname = "Unknown")
to_chat(usr, SPAN_BOLDWARNING("Warning: Force attempt has been logged."))
message_admins("[key_name(usr)] has attempted to execute a restricted proc. ([procname])")

/client/proc/callproc_datum(datum/called_datum as null|area|mob|obj|turf)
set category = "Debug"
set name = "Datum ProcCall"
Expand Down
3 changes: 3 additions & 0 deletions code/modules/admin/holder2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ you will have to do something like if(client.admin_holder.rights & R_ADMIN) your
return 0

/client/proc/deadmin()
if(IsAdminAdvancedProcCall())
alert_proccall("deadmin")
return
if(admin_holder)
admin_holder.disassociate()
QDEL_NULL(admin_holder)
Expand Down
37 changes: 37 additions & 0 deletions code/modules/admin/player_panel/actions/management.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/datum/player_action/nameless_ban
action_tag = "nameless_ban"
name = "Nameless Ban"
permissions_required = R_PERMISSIONS

/datum/player_action/nameless_ban/act(client/user, mob/target, list/params)
user.cmd_admin_do_ban(target)
return TRUE


/datum/player_action/perma_ban
action_tag = "perma_ban"
name = "Permanent Ban"
permissions_required = R_PERMISSIONS

/datum/player_action/perma_ban/act(client/user, mob/target, list/params)
user.cmd_admin_do_ban(target)
return TRUE

/datum/player_action/ban_staff
action_tag = "ban_staff"
name = "Ban Staff"
permissions_required = R_PERMISSIONS

/datum/player_action/ban_staff/act(client/user, mob/target, list/params)
user.cmd_admin_do_ban(target)
return TRUE


/datum/player_action/shadowban
action_tag = "shadow_ban"
name = "Shadow Ban"
permissions_required = R_PERMISSIONS

/datum/player_action/shadowban/act(client/user, mob/target, list/params)
user.cmd_admin_do_ban(target)
return TRUE
1 change: 1 addition & 0 deletions code/modules/admin/player_panel/player_panel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ GLOBAL_LIST_INIT(pp_status_flags, list(

.["is_human"] = ishuman(targetMob)
.["is_xeno"] = isxeno(targetMob)
.["is_manager"] = check_rights(R_PERMISSIONS, FALSE)

.["glob_status_flags"] = GLOB.pp_status_flags
.["glob_limbs"] = GLOB.pp_limbs
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/topic/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@
message_admins("[key_name_admin(usr)] has sent [key_name_admin(M)] to the thunderdome. (Observer.)", 1)

else if(href_list["revive"])
if(!check_rights(R_REJUVINATE)) return
if(!check_rights(R_MOD)) return

var/mob/living/L = locate(href_list["revive"])
if(!istype(L))
Expand Down
1 change: 1 addition & 0 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list(
*/
/client/proc/init_verbs()
if(IsAdminAdvancedProcCall())
alert_proccall("init_verbs")
return
var/list/verblist = list()
var/list/verbstoprocess = verbs.Copy()
Expand Down
1 change: 0 additions & 1 deletion config/example/admin_ranks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# +BAN = the ability to ban, jobban and fullban
# +STEALTH = the ability to stealthmin (make yourself appear with a fake name to everyone but other admins
# +POSSESS = the ability to possess objects
# +REJUV (or +REJUVINATE) = the ability to heal, respawn, modify damage and use godmode
# +COLOR = the ability to use the OOC > "Set OOC Color - Self" verb
# +BUILD (or +BUILDMODE) = the ability to use buildmode
# +SERVER = higher-risk admin verbs and abilities, such as those which affect the server configuration.
Expand Down
68 changes: 68 additions & 0 deletions tgui/packages/tgui/interfaces/PlayerPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ const PAGES = [
color: 'green',
icon: 'tools',
},
{
title: 'Management',
component: () => ManagementActions,
color: 'purple',
icon: 'ban',
canAccess: (data) => {
return !!data.is_manager;
},
},
{
title: 'Punish',
component: () => PunishmentActions,
Expand Down Expand Up @@ -891,3 +900,62 @@ const PhysicalActions = (props, context) => {
</Section>
);
};
const ManagementActions = (props, context) => {
const { act, data } = useBackend(context);
const { glob_mute_bits, client_muted } = data;
return (
<Section fill>
<Section level={2} title="Banishment">
<Stack align="right" grow={1}>
<Button.Confirm
width="100%"
icon="gavel"
color="red"
content="Nameless Ban"
disabled={!hasPermission(data, 'nameless_ban')}
onClick={() => act('nameless_ban')}
/>
<Button.Confirm
width="100%"
icon="ban"
color="red"
content="Permanent Ban"
disabled={!hasPermission(data, 'perma_ban')}
onClick={() => act('perma_ban')}
/>
<Button.Confirm
width="100%"
height="100%"
icon="ban"
color="purple"
content="Shadowban"
disabled={!hasPermission(data, 'shadow_ban')}
onClick={() => act('shadow_ban')}
/>
<Button.Confirm
width="100%"
height="100%"
icon="ban"
color="purple"
content="Ban Staff"
disabled={!hasPermission(data, 'ban_staff')}
onClick={() => act('ban_staff')}
/>
</Stack>
</Section>

<Section level={2} title="Record-keeping">
<Stack align="right" grow={1}>
<Button
width="100%"
icon="clipboard-list"
color="average"
content="Check Notes"
disabled={!hasPermission(data, 'show_notes')}
onClick={() => act('show_notes')}
/>
</Stack>
</Section>
</Section>
);
};