From 9c831a9da4f46a38164a3eec199735d50165940c Mon Sep 17 00:00:00 2001 From: medievalshell Date: Thu, 28 May 2026 22:41:10 +0200 Subject: [PATCH] feat: grant acc_wheeladmin to staff ranks for the wheel prize editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wheel prize editor is gated on acc_wheeladmin (client Settings button + server WheelAdmin{Get,Save}PrizesEvent). Upstream 008_soundboard_fortune_wheel registers the key but only grants rank_7 (its 7-rank hotel). This portable, idempotent migration grants it to the same ranks as acc_ads_background via dynamic SQL over the per-rank columns — no hardcoded rank ids. Apply then :update_permissions or restart. --- .../022_wheel_admin_permission.sql | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Database Updates/Own_Database_RunFirst/022_wheel_admin_permission.sql diff --git a/Database Updates/Own_Database_RunFirst/022_wheel_admin_permission.sql b/Database Updates/Own_Database_RunFirst/022_wheel_admin_permission.sql new file mode 100644 index 00000000..a33b544d --- /dev/null +++ b/Database Updates/Own_Database_RunFirst/022_wheel_admin_permission.sql @@ -0,0 +1,51 @@ +-- Fortune Wheel — admin permission grant (`acc_wheeladmin`) +-- +-- Both the client (FortuneWheelView "Settings" button) and the server handlers +-- (WheelAdminGetPrizesEvent / WheelAdminSavePrizesEvent, PERMISSION_KEY = +-- "acc_wheeladmin") gate the prize editor on `acc_wheeladmin`. +-- +-- The key itself is registered upstream in +-- `Database Updates/008_soundboard_fortune_wheel.sql`, but that file only grants +-- it to `rank_7` (its author's 7-rank hotel) and its ON DUPLICATE clause touches +-- the comment only. So on a hotel with a different rank layout the key would end +-- up granted to nobody useful. This file supplies the portable grant. +-- +-- Idempotent + portable: registers the key as a no-op safety (in case 008 hasn't +-- run yet) and grants it to the same ranks that hold acc_ads_background — the +-- adjacent "manage room-ad furni" permission — with dynamic SQL over the per-rank +-- columns, so no rank ids are hardcoded. If acc_ads_background is absent the JOIN +-- matches nothing and the key stays ungranted (safe; the button just stays +-- hidden until granted by hand). +-- +-- After applying, reload at runtime with `:update_permissions` (rebinds online +-- users to the fresh rank and rebroadcasts the permission map — no relog) or +-- restart the emulator. + +-- 1) Safety no-op registration (008 is the canonical registrar). rank_* default 0. +INSERT IGNORE INTO `permission_definitions` (`permission_key`, `max_value`, `comment`) +VALUES ( + 'acc_wheeladmin', + 1, + 'Allows opening the fortune wheel prize editor (FortuneWheelSettingsView) to add/edit prize slices. Gated server-side by the same key.' +); + +-- 2) Grant to the same ranks as acc_ads_background, portably. +SET @cols := NULL; + +SELECT GROUP_CONCAT(CONCAT('dst.`', `column_name`, '` = src.`', `column_name`, '`') SEPARATOR ', ') + INTO @cols +FROM `information_schema`.`columns` +WHERE `table_schema` = DATABASE() + AND `table_name` = 'permission_definitions' + AND `column_name` REGEXP '^rank_[0-9]+$'; + +SET @sql := CONCAT( + 'UPDATE `permission_definitions` dst ', + 'JOIN `permission_definitions` src ON src.`permission_key` = ''acc_ads_background'' ', + 'SET ', @cols, ' ', + 'WHERE dst.`permission_key` = ''acc_wheeladmin''' +); + +PREPARE stmt FROM @sql; +EXECUTE stmt; +DEALLOCATE PREPARE stmt;