From 295eca8f8a59ce1bf6c1e2fcb1adb574e4c72243 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Wed, 22 Jun 2022 17:14:26 +0300 Subject: [PATCH] =?UTF-8?q?[*]=20phpcmd=20=D0=B8=20=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/lib/Core/Models/User.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/lib/Core/Models/User.class.php b/core/lib/Core/Models/User.class.php index feba4e4..7f65b5e 100644 --- a/core/lib/Core/Models/User.class.php +++ b/core/lib/Core/Models/User.class.php @@ -50,7 +50,7 @@ if (empty($id)) { throw new CoreException('Передан некорректный идентификатор пользователя', CoreException::ERROR_INCORRECT_USER_ID); } - if (!(DB::getInstance())->getItem(self::USERS_TABLE, ['id' => $id])) { + if (!self::isUserExistsByParams(['id' => $id])) { throw new CoreException('Пользователь с идентификатором ' . $id . ' отсутствует в базе', CoreException::ERROR_USER_NOT_FOUND); } @@ -234,6 +234,23 @@ } } + /** + * Проверка пользователя на существование по параметрам + * + * @param array $where Массив параметров фильтра + * + * @return bool + */ + public static function isUserExistsByParams(array $where): bool + { + $result = (DB::getInstance())->getItem(self::USERS_TABLE, $where); + if (!empty($result)) { + return true; + } else { + return false; + } + } + /** * Проверка пользователя на онлайн *