Fix older/newer than filter on accounts search API method

This commit is contained in:
Bofh 2022-12-08 21:50:47 +01:00
parent fac4cca53a
commit ebe97d05f7
1 changed files with 8 additions and 6 deletions

View File

@ -90,13 +90,15 @@ switch ($user_filter) {
break;
}
if (isset($_GET['older_than_days']))
$sql_all = str_replace('{olderThanNDays}', "(acs.updated_at IS NULL OR acs.updated_at <= (NOW() - INTERVAL '".intval($_GET['older_than_days'])." days')) AND", $sql_all);
else $sql_all = str_replace('{olderThanNDays}', '', $sql_all);
if (isset($_GET['older_than_days'])) {
$_str_interval = "(NOW() - INTERVAL '".intval($_GET['older_than_days'])." days')";
$sql_all = str_replace('{olderThanNDays}', "a.created_at <= $_str_interval AND (acs.updated_at IS NULL OR acs.updated_at <= $_str_interval) AND", $sql_all);
} else $sql_all = str_replace('{olderThanNDays}', '', $sql_all);
if (isset($_GET['newer_than_days']))
$sql_all = str_replace('{newerThanNDays}', "(NOT acs.updated_at IS NULL AND acs.updated_at >= (NOW() - INTERVAL '".intval($_GET['newer_than_days'])." days')) AND", $sql_all);
else $sql_all = str_replace('{newerThanNDays}', '', $sql_all);
if (isset($_GET['newer_than_days'])) {
$_str_interval = "(NOW() - INTERVAL '".intval($_GET['newer_than_days'])." days')";
$sql_all = str_replace('{newerThanNDays}', "a.created_at >= $_str_interval AND (acs.updated_at IS NULL OR acs.updated_at >= $_str_interval) AND", $sql_all);
} else $sql_all = str_replace('{newerThanNDays}', '', $sql_all);
if (isset($_GET['no_avatar']))
$sql_all = str_replace('{noAvatarWhere}', 'a.avatar_file_name IS NULL AND', $sql_all);