- Dodano PSR-4 autoloader do wszystkich 6 punktów wejścia - Shared\: CacheHandler, Helpers, Html, ImageManipulator, Tpl - Domain\: LanguagesRepository, SettingsRepository, UserRepository - Stare class.*.php → cienkie wrappery (kompatybilność wsteczna) - Dodano dokumentację: docs/PROJECT_STRUCTURE.md + pozostałe docs/ - Dodano CLAUDE.md z workflow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
84 lines
2.2 KiB
PHP
84 lines
2.2 KiB
PHP
<?php
|
|
namespace admin\factory;
|
|
|
|
/**
|
|
* @deprecated Wrapper — używaj \Domain\User\UserRepository przez DI.
|
|
*/
|
|
class Users
|
|
{
|
|
private static function repo(): \Domain\User\UserRepository
|
|
{
|
|
global $mdb;
|
|
return new \Domain\User\UserRepository( $mdb );
|
|
}
|
|
|
|
public static function user_delete( $user_id ): bool
|
|
{
|
|
return self::repo()->delete( (int)$user_id );
|
|
}
|
|
|
|
public static function user_details( $user_id ): ?array
|
|
{
|
|
return self::repo()->find( (int)$user_id );
|
|
}
|
|
|
|
public static function user_privileges( $user_id ): array
|
|
{
|
|
return self::repo()->privileges( (int)$user_id );
|
|
}
|
|
|
|
public static function user_save(
|
|
$user_id, $login, $status, $active_to, $password, $password_re,
|
|
$admin, $privileges, $twofa_enabled = 0, $twofa_email = ''
|
|
): array {
|
|
return self::repo()->save(
|
|
$user_id, (string)$login, $status, $active_to,
|
|
(string)$password, (string)$password_re,
|
|
$admin, $privileges, $twofa_enabled, (string)$twofa_email
|
|
);
|
|
}
|
|
|
|
public static function check_login( $login, $user_id ): array
|
|
{
|
|
if ( self::repo()->isLoginTaken( (string)$login, (int)$user_id ) )
|
|
return [ 'status' => 'error', 'msg' => 'Podany login jest już zajęty.' ];
|
|
|
|
return [ 'status' => 'ok' ];
|
|
}
|
|
|
|
public static function logon( $login, $password ): int
|
|
{
|
|
return self::repo()->logon( (string)$login, (string)$password );
|
|
}
|
|
|
|
public static function details( $login ): ?array
|
|
{
|
|
return self::repo()->findByLogin( (string)$login );
|
|
}
|
|
|
|
public static function check_privileges( $name, $user_id ): bool
|
|
{
|
|
return self::repo()->hasPrivilege( (string)$name, (int)$user_id );
|
|
}
|
|
|
|
public static function get_by_id( int $userId ): ?array
|
|
{
|
|
return self::repo()->find( $userId );
|
|
}
|
|
|
|
public static function send_twofa_code( int $userId, bool $resend = false ): bool
|
|
{
|
|
return self::repo()->sendTwofaCode( $userId, $resend );
|
|
}
|
|
|
|
public static function update_by_id( int $userId, array $data ): bool
|
|
{
|
|
return self::repo()->update( $userId, $data );
|
|
}
|
|
|
|
public static function verify_twofa_code( int $userId, string $code ): bool
|
|
{
|
|
return self::repo()->verifyTwofaCode( $userId, $code );
|
|
}
|
|
}
|