// actually remove old warnings file
This commit is contained in:
parent
73d3552dcb
commit
a165f9cffd
2 changed files with 0 additions and 33 deletions
|
@ -82,7 +82,6 @@ require_once 'src/Users/avatar.php';
|
|||
require_once 'src/Users/background.php';
|
||||
require_once 'src/Users/role.php';
|
||||
require_once 'src/Users/user_legacy.php';
|
||||
require_once 'src/Users/warning.php';
|
||||
|
||||
$dbConfig = parse_ini_file(MSZ_ROOT . '/config/config.ini', true, INI_SCANNER_TYPED);
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
define('MSZ_WARN_SILENCE', 2);
|
||||
define('MSZ_WARN_BAN', 3);
|
||||
|
||||
define('MSZ_WARN_TYPES_HAS_DURATION', [MSZ_WARN_SILENCE, MSZ_WARN_BAN]);
|
||||
|
||||
function user_warning_check_expiration(int $userId, int $type): int {
|
||||
if($userId < 1 || !in_array($type, MSZ_WARN_TYPES_HAS_DURATION, true))
|
||||
return 0;
|
||||
|
||||
static $memo = [];
|
||||
$memoId = "{$userId}-{$type}";
|
||||
|
||||
if(array_key_exists($memoId, $memo))
|
||||
return $memo[$memoId];
|
||||
|
||||
$getExpiration = \Misuzu\DB::prepare('
|
||||
SELECT `warning_duration`
|
||||
FROM `msz_user_warnings`
|
||||
WHERE `warning_type` = :type
|
||||
AND `user_id` = :user
|
||||
AND `warning_duration` IS NOT NULL
|
||||
AND `warning_duration` >= NOW()
|
||||
ORDER BY `warning_duration` DESC
|
||||
LIMIT 1
|
||||
');
|
||||
$getExpiration->bind('type', $type);
|
||||
$getExpiration->bind('user', $userId);
|
||||
$expiration = $getExpiration->fetchColumn(0, '');
|
||||
|
||||
return $memo[$memoId] = (empty($expiration) ? 0 : strtotime($expiration));
|
||||
}
|
Loading…
Reference in a new issue