* Get role ('1' admin, '0' user) or null. */
($username)
| 974 | * Get role ('1' admin, '0' user) or null. |
| 975 | */ |
| 976 | public static function getUserRole($username) |
| 977 | { |
| 978 | self::ensureUserCaseMigration(); |
| 979 | $usersFile = USERS_DIR . USERS_FILE; |
| 980 | if (!file_exists($usersFile)) { |
| 981 | return null; |
| 982 | } |
| 983 | foreach (file($usersFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) { |
| 984 | $parts = explode(':', trim($line)); |
| 985 | if (count($parts) >= 3 && strcasecmp($parts[0], $username) === 0) { |
| 986 | return trim($parts[2]); |
| 987 | } |
| 988 | } |
| 989 | return null; |
| 990 | } |
| 991 | |
| 992 | /** |
| 993 | * Get a single user’s info (admin flag, TOTP status, profile picture). |
nothing calls this directly
no test coverage detected