Fix filters not working as intended and add onlyShow filter
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.vscode/sftp.json
|
.vscode/sftp.json
|
||||||
|
.DS_STORE
|
||||||
@@ -5,12 +5,15 @@ checkClientDatabaseVersion();
|
|||||||
$conn = newConnection();
|
$conn = newConnection();
|
||||||
|
|
||||||
$post = getPostData();
|
$post = getPostData();
|
||||||
|
$userId = (int)$post['userId'] ?? 0;
|
||||||
$sortBy = (int)$post['sortBy'] ?? 2;
|
$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;
|
$priceRangeMin = (int)$post['priceRangeMin'] ?? 10;
|
||||||
$priceRangeMax = (int)$post['priceRangeMax'] ?? 250;
|
$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'] ?? '';
|
$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)"];
|
$where = ["u.banned = 0", "(c.state = 1 OR c.state = 2)"];
|
||||||
$params = [];
|
$params = [];
|
||||||
@@ -35,6 +38,18 @@ if ($searchForEnabled && $searchForValue !== '') {
|
|||||||
$types .= "s";
|
$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 = "
|
$sql = "
|
||||||
SELECT c.data, u.username, u.id, c.price, c.name, c.uuid, c.state
|
SELECT c.data, u.username, u.id, c.price, c.name, c.uuid, c.state
|
||||||
FROM marketplaceicons c
|
FROM marketplaceicons c
|
||||||
|
|||||||
Reference in New Issue
Block a user