|
178 | 178 | } |
179 | 179 | } |
180 | 180 |
|
| 181 | +// Match-mode defaults differ per filter (#1231): |
| 182 | +// - steam_match defaults to '0' (exact) — typical SteamID |
| 183 | +// queries are "find this one admin by their full ID". |
| 184 | +// - name_match / admemail_match default to '1' (partial) so |
| 185 | +// pre-#1231 URLs (`?name=alice`) keep their substring |
| 186 | +// behaviour. Adding the toggle widens the UI without |
| 187 | +// regressing the default. |
| 188 | +$activeFilterName = is_string($_GET['name'] ?? null) ? (string) $_GET['name'] : ''; |
| 189 | +$activeFilterSteamid = is_string($_GET['steamid'] ?? null) ? (string) $_GET['steamid'] : ''; |
| 190 | +$activeFilterAdmemail = is_string($_GET['admemail'] ?? null) ? (string) $_GET['admemail'] : ''; |
| 191 | +$activeFilterWebgroup = is_scalar($_GET['webgroup'] ?? null) ? (string) $_GET['webgroup'] : ''; |
| 192 | +$activeFilterSrvadmgroup = is_string($_GET['srvadmgroup'] ?? null) ? (string) $_GET['srvadmgroup'] : ''; |
| 193 | +$activeFilterSrvgroup = is_scalar($_GET['srvgroup'] ?? null) ? (string) $_GET['srvgroup'] : ''; |
| 194 | +$activeFilterServer = is_scalar($_GET['server'] ?? null) ? (string) $_GET['server'] : ''; |
| 195 | + |
| 196 | +// #1303 — count populated filter slots so the disclosure can paint a |
| 197 | +// "Filters · N active" badge on the <summary> and auto-expand on |
| 198 | +// post-submit. Match-mode selects (`name_match` / `steam_match` / |
| 199 | +// `admemail_match`) deliberately don't count: they always carry a |
| 200 | +// default ('0' or '1') and only refine the matching filter, they |
| 201 | +// don't filter on their own. Empty multi-select arrays count as zero |
| 202 | +// even though the array itself "exists" — the user hasn't picked a |
| 203 | +// permission. |
| 204 | +$activeFilterCount = |
| 205 | + ($activeFilterName !== '' ? 1 : 0) |
| 206 | + + ($activeFilterSteamid !== '' ? 1 : 0) |
| 207 | + + ($activeFilterAdmemail !== '' ? 1 : 0) |
| 208 | + + ($activeFilterWebgroup !== '' ? 1 : 0) |
| 209 | + + ($activeFilterSrvadmgroup !== '' ? 1 : 0) |
| 210 | + + ($activeFilterSrvgroup !== '' ? 1 : 0) |
| 211 | + + ($activeFilterServer !== '' ? 1 : 0) |
| 212 | + + (count($activeWebFlags) > 0 ? 1 : 0) |
| 213 | + + (count($activeSrvFlags) > 0 ? 1 : 0); |
| 214 | + |
181 | 215 | \Sbpp\View\Renderer::render($theme, new \Sbpp\View\AdminAdminsSearchView( |
182 | 216 | can_editadmin: $userbank->HasAccess(WebPermission::mask(WebPermission::EditAdmins, WebPermission::Owner)), |
183 | 217 | server_list: $servers, |
|
187 | 221 | srvgroup_list: $srvgroups, |
188 | 222 | admwebflag_list: $webflag, |
189 | 223 | admsrvflag_list: $serverflag, |
190 | | - // Match-mode defaults differ per filter (#1231): |
191 | | - // - steam_match defaults to '0' (exact) — typical SteamID |
192 | | - // queries are "find this one admin by their full ID". |
193 | | - // - name_match / admemail_match default to '1' (partial) so |
194 | | - // pre-#1231 URLs (`?name=alice`) keep their substring |
195 | | - // behaviour. Adding the toggle widens the UI without |
196 | | - // regressing the default. |
197 | | - active_filter_name: is_string($_GET['name'] ?? null) ? (string) $_GET['name'] : '', |
| 224 | + active_filter_name: $activeFilterName, |
198 | 225 | active_filter_name_match: is_scalar($_GET['name_match'] ?? null) ? (string) $_GET['name_match'] : '1', |
199 | | - active_filter_steamid: is_string($_GET['steamid'] ?? null) ? (string) $_GET['steamid'] : '', |
| 226 | + active_filter_steamid: $activeFilterSteamid, |
200 | 227 | active_filter_steam_match: is_scalar($_GET['steam_match'] ?? null) ? (string) $_GET['steam_match'] : '0', |
201 | | - active_filter_admemail: is_string($_GET['admemail'] ?? null) ? (string) $_GET['admemail'] : '', |
| 228 | + active_filter_admemail: $activeFilterAdmemail, |
202 | 229 | active_filter_admemail_match: is_scalar($_GET['admemail_match'] ?? null) ? (string) $_GET['admemail_match'] : '1', |
203 | | - active_filter_webgroup: is_scalar($_GET['webgroup'] ?? null) ? (string) $_GET['webgroup'] : '', |
204 | | - active_filter_srvadmgroup: is_string($_GET['srvadmgroup'] ?? null) ? (string) $_GET['srvadmgroup'] : '', |
205 | | - active_filter_srvgroup: is_scalar($_GET['srvgroup'] ?? null) ? (string) $_GET['srvgroup'] : '', |
206 | | - active_filter_server: is_scalar($_GET['server'] ?? null) ? (string) $_GET['server'] : '', |
| 230 | + active_filter_webgroup: $activeFilterWebgroup, |
| 231 | + active_filter_srvadmgroup: $activeFilterSrvadmgroup, |
| 232 | + active_filter_srvgroup: $activeFilterSrvgroup, |
| 233 | + active_filter_server: $activeFilterServer, |
207 | 234 | active_filter_admwebflag: $activeWebFlags, |
208 | 235 | active_filter_admsrvflag: $activeSrvFlags, |
| 236 | + active_filter_count: $activeFilterCount, |
| 237 | + has_active_filters: $activeFilterCount > 0, |
209 | 238 | )); |
0 commit comments