diff --git a/~dev_rating/application/classes/Account.php b/~dev_rating/application/classes/Account.php index 985c5c0f77fdfff56c737ec8ff27f4703267deaa..0b87b7728aa13cf3ebecdb3545e6cb61ae0b6af1 100644 --- a/~dev_rating/application/classes/Account.php +++ b/~dev_rating/application/classes/Account.php @@ -100,13 +100,11 @@ class Account } public static function doesLoginExist($login) { - $login_count = Model_Account::checkAccountExistence($login, 'login'); - return $login_count > 0; + return Model_Account::checkAccountExistenceBy('login', $login); } - public static function isMailValid($email) { - $email_count = Model_Account::checkAccountExistence($email, 'email'); - return $email_count > 0; + public static function doesEmailExist($email) { + return Model_Account::checkAccountExistenceBy('email', $email); } diff --git a/~dev_rating/application/classes/Controller/Handler/Sign.php b/~dev_rating/application/classes/Controller/Handler/Sign.php index 4f40f4bde0575c85c91621121de2f7e1af7a2a68..28ed3721b40384bb9cd2c5497d01117555add7db 100644 --- a/~dev_rating/application/classes/Controller/Handler/Sign.php +++ b/~dev_rating/application/classes/Controller/Handler/Sign.php @@ -65,7 +65,7 @@ class Controller_Handler_Sign extends Controller_Handler $this->post->rule('email', 'not_empty')->rule('email', 'email'); if ($this->post->check()) { - if (Account::isMailValid($_POST['email'])) { + if (Account::doesEmailExist($_POST['email'])) { Account::createRecoveryRequest($_POST['email']); $res['success'] = true; } else { diff --git a/~dev_rating/application/classes/Model/Account.php b/~dev_rating/application/classes/Model/Account.php index c33d73f5d13d1d0e10c10c94e76fe407a8ccd37e..3ba2085ff21ee7ba10f411eb69e89e391cdb52ee 100644 --- a/~dev_rating/application/classes/Model/Account.php +++ b/~dev_rating/application/classes/Model/Account.php @@ -95,14 +95,14 @@ class Model_Account extends Model } /** - * @param string $data * @param string $type 'login','email' or 'code' - * @return int + * @param string $value + * @return bool */ - public static function checkAccountExistence($data, $type) { - $sql = "SELECT `CheckAccountExistence`(:data, :type) AS Num;"; - return DB::query(Database::SELECT, $sql) - ->param(':data', $data) + public static function checkAccountExistenceBy($type, $value) { + $sql = "SELECT `CheckAccountExistence`(:value, :type) AS Num;"; + return (bool) DB::query(Database::SELECT, $sql) + ->param(':value', $value) ->param(':type', $type) ->execute()->get('Num'); }