Fix filters not working as intended and add onlyShow filter

This commit is contained in:
2025-09-04 18:00:52 -07:00
parent d2a7ad1f78
commit b82b8842bc
2 changed files with 19 additions and 3 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
.vscode/sftp.json
.DS_STORE

View File

@@ -5,12 +5,15 @@ checkClientDatabaseVersion();
$conn = newConnection();
$post = getPostData();
$userId = (int)$post['userId'] ?? 0;
$sortBy = (int)$post['sortBy'] ?? 2;
$priceRangeEnabled = (bool)$post['priceRangeEnabled'] ?? false;
$priceRangeEnabled = isset($post['priceRangeEnabled']) ? (string)$post['priceRangeEnabled'] == 'False' ? false : true : false;
$priceRangeMin = (int)$post['priceRangeMin'] ?? 10;
$priceRangeMax = (int)$post['priceRangeMax'] ?? 250;
$searchForEnabled = (bool)$post['searchForEnabled'] ?? false;
$searchForEnabled = isset($post['searchForEnabled']) ? (string)$post['searchForEnabled'] == 'False' ? false : true : false;
$searchForValue = (string)$post['searchForValue'] ?? '';
$onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string)$post['onlyShowEnabled'] == 'False' ? false : true : false;
$onlyShowValue = (string)$post['onlyShowValue'] ?? '';
$where = ["u.banned = 0", "(c.state = 1 OR c.state = 2)"];
$params = [];
@@ -35,6 +38,18 @@ if ($searchForEnabled && $searchForValue !== '') {
$types .= "s";
}
if ($onlyShowEnabled) {
if ($onlyShowValue === '0') {
$where[] = "c.userId = ?";
$params[] = $userId;
$types .= "i";
} elseif ($onlyShowValue === '1') {
$where[] = "c.userId != ?";
$params[] = $userId;
$types .= "i";
}
}
$sql = "
SELECT c.data, u.username, u.id, c.price, c.name, c.uuid, c.state
FROM marketplaceicons c