mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 08:08:49 +01:00
[MIRROR] Re-adds the admin button to let them exempt players from job exp requirements. (#3282)
* Re-adds the admin button to let them exempt players from job exp requirements. (#56799) * Re-adds the admin button to let them exempt players from job exp requirements. Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
This commit is contained in:
@@ -47,16 +47,6 @@
|
||||
to_chat(usr, "<span class='danger'>ERROR: Mob not found.</span>", confidential = TRUE)
|
||||
return
|
||||
cmd_show_exp_panel(M.client)
|
||||
|
||||
else if(href_list["toggleexempt"])
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
var/client/C = locate(href_list["toggleexempt"]) in GLOB.clients
|
||||
if(!C)
|
||||
to_chat(usr, "<span class='danger'>ERROR: Client not found.</span>", confidential = TRUE)
|
||||
return
|
||||
toggle_exempt_status(C)
|
||||
|
||||
else if(href_list["makeAntag"])
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
@@ -17,6 +17,13 @@
|
||||
ui = new(user, src, "TrackedPlaytime")
|
||||
ui.open()
|
||||
|
||||
/datum/job_report_menu/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
data["exemptStatus"] = (owner.prefs?.db_flags & DB_FLAG_EXEMPT)
|
||||
|
||||
return data
|
||||
|
||||
/datum/job_report_menu/ui_static_data()
|
||||
if (!CONFIG_GET(flag/use_exp_tracking))
|
||||
return list("failReason" = JOB_REPORT_MENU_FAIL_REASON_TRACKING_DISABLED)
|
||||
@@ -43,7 +50,39 @@
|
||||
data["livingTime"] = play_records[EXP_TYPE_LIVING]
|
||||
data["ghostTime"] = play_records[EXP_TYPE_GHOST]
|
||||
|
||||
data["isAdmin"] = check_rights(R_ADMIN)
|
||||
|
||||
return data
|
||||
|
||||
/datum/job_report_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
switch(action)
|
||||
if("toggle_exempt")
|
||||
if(!check_rights(R_ADMIN))
|
||||
message_admins("[ADMIN_LOOKUPFLW(usr)] attempted to toggle job playtime exempt status without admin rights.")
|
||||
log_admin("[ADMIN_LOOKUPFLW(usr)] attempted to toggle job playtime exempt status without admin rights.")
|
||||
to_chat(usr, "<span class='danger'>ERROR: Insufficient admin rights.</span>", confidential = TRUE)
|
||||
return TRUE
|
||||
|
||||
var/datum/admins/viewer_admin_datum = GLOB.admin_datums[usr.ckey]
|
||||
|
||||
if(!viewer_admin_datum)
|
||||
message_admins("[ADMIN_LOOKUPFLW(usr)] attempted to toggle job playtime exempt status without admin datum for their ckey.")
|
||||
log_admin("[ADMIN_LOOKUPFLW(usr)] attempted to toggle job playtime exempt status without admin datum for their ckey.")
|
||||
to_chat(usr, "<span class='danger'>ERROR: Insufficient admin rights.</span>", confidential = TRUE)
|
||||
return TRUE
|
||||
|
||||
var/client/owner_client = locate(owner) in GLOB.clients
|
||||
|
||||
if(!owner_client)
|
||||
to_chat(usr, "<span class='danger'>ERROR: Client not found.</span>", confidential = TRUE)
|
||||
return TRUE
|
||||
|
||||
viewer_admin_datum.toggle_exempt_status(owner_client)
|
||||
return TRUE
|
||||
|
||||
#undef JOB_REPORT_MENU_FAIL_REASON_TRACKING_DISABLED
|
||||
#undef JOB_REPORT_MENU_FAIL_REASON_NO_RECORDS
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { sortBy } from "common/collections";
|
||||
import { useBackend } from "../backend";
|
||||
import { Box, Flex, ProgressBar, Section, Table } from "../components";
|
||||
import { Box, Button, Flex, ProgressBar, Section, Table } from "../components";
|
||||
import { Window } from "../layouts";
|
||||
|
||||
const JOB_REPORT_MENU_FAIL_REASON_TRACKING_DISABLED = 1;
|
||||
@@ -46,11 +46,13 @@ const PlaytimeSection = props => {
|
||||
};
|
||||
|
||||
export const TrackedPlaytime = (props, context) => {
|
||||
const { data } = useBackend(context);
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
failReason,
|
||||
jobPlaytimes,
|
||||
specialPlaytimes,
|
||||
exemptStatus,
|
||||
isAdmin,
|
||||
livingTime,
|
||||
ghostTime,
|
||||
} = data;
|
||||
@@ -75,8 +77,18 @@ export const TrackedPlaytime = (props, context) => {
|
||||
}}
|
||||
/>
|
||||
</Section>
|
||||
<Section title="Jobs">
|
||||
<PlaytimeSection playtimes={jobPlaytimes} />
|
||||
<Section
|
||||
title="Jobs"
|
||||
buttons={!!isAdmin && (
|
||||
<Button.Checkbox
|
||||
checked={!!exemptStatus}
|
||||
onClick={() => act("toggle_exempt")}>
|
||||
Job Playtime Exempt
|
||||
</Button.Checkbox>
|
||||
)}>
|
||||
<PlaytimeSection
|
||||
playtimes={jobPlaytimes}
|
||||
/>
|
||||
</Section>
|
||||
<Section title="Special">
|
||||
<PlaytimeSection playtimes={specialPlaytimes} />
|
||||
|
||||
Reference in New Issue
Block a user