Handle errors on search query + Make search work better
This commit is contained in:
parent
725f2ab476
commit
5b00931878
7
base.php
7
base.php
|
@ -453,14 +453,19 @@ function matches_comparing_expression($expr, $text) {
|
|||
} else if (strpos($t, 'contains ') === 0) {
|
||||
$w = substr($t, strlen('contains')+1);
|
||||
$w = trim(trim($w, '"'));
|
||||
$contains = strpos($text, normalize_for_search($w)) !== false;
|
||||
$contains = strpos(' '.$text.' ',
|
||||
' '.normalize_for_search($w).' ') !== false;
|
||||
$result = str_replace($t, $contains ? 'true' : 'false', $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = str_replace('OR', '|', $result);
|
||||
$result = str_replace('AND', '&', $result);
|
||||
try {
|
||||
eval('$result = '.$result.';');
|
||||
} catch (\Throwable $e) {
|
||||
return apiresult(['error' => 'Query contains errors, please correct it and try again.']);
|
||||
}
|
||||
return in_array($result, [0,false]) ? false : true;
|
||||
}
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ window.view.instance = {
|
|||
http.get(`api/v1/database/${hargs.software}/accounts/search?${payload}&paging=${page},${items_per_page}`, data, function(js) {
|
||||
if (js === undefined) return toast.error('Could not process the query result');
|
||||
if (js.ok !== undefined) return toast.info(js.ok);
|
||||
if (js.error !== undefined) return toast.error(js.error);
|
||||
E.template('users-all', function(TPL) {
|
||||
var html = '';
|
||||
for (var i = 0; i < js['data'].length; i++) {
|
||||
|
|
Loading…
Reference in New Issue