Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
ajax.toggle.enhancedquickpick.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2022-2025 Bearsampp
5 * * License: GNU General Public License version 3 or later; see LICENSE.txt
6 * * Website: https://bearsampp.com
7 * * Github: https://github.com/Bearsampp
8 *
9 */
10
22
23// Set appropriate headers for AJAX response
24header('Content-Type: application/json');
25
26// Initialize response array
27$response = array();
28
29// Check if this is a POST request
30if ($_SERVER['REQUEST_METHOD'] === 'POST') {
31 try {
32 global $bearsamppConfig;
33
34 // Get current value
35 $currentValue = $bearsamppConfig->getEnhancedQuickPick();
36
37 // Check if a specific value was provided
38 $newValue = isset($_POST['value']) ? intval($_POST['value']) : null;
39
40 // If no value provided, toggle the current value
41 if ($newValue === null) {
42 $newValue = $currentValue == 1 ? 0 : 1;
43 }
44
45 // Validate the new value (must be 0 or 1)
46 if ($newValue !== 0 && $newValue !== 1) {
47 $response = ['error' => 'Invalid value. Must be 0 or 1.'];
48 } else {
49 // Update the configuration
50 $bearsamppConfig->replace('EnhancedQuickPick', $newValue);
51
52 Util::logInfo('EnhancedQuickPick setting changed from ' . $currentValue . ' to ' . $newValue);
53
54 $response = [
55 'success' => true,
56 'message' => 'EnhancedQuickPick setting updated successfully',
57 'previousValue' => $currentValue,
58 'newValue' => $newValue,
59 'mode' => $newValue == 1 ? 'enhanced' : 'standard'
60 ];
61 }
62
63 } catch (Exception $e) {
64 $response = ['error' => 'Exception: ' . $e->getMessage()];
65 error_log('Exception in toggle EnhancedQuickPick: ' . $e->getMessage());
66 }
67} else {
68 $response = ['error' => 'Invalid request method.'];
69}
70
71// Send the JSON response
72echo json_encode($response);
static logInfo($data, $file=null)
global $bearsamppConfig
Definition homepage.php:41