1
0

BxBaseFormForgotPassword.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. bx_import('BxTemplFormView');
  10. class BxFormForgotPasswordCheckerHelper extends BxDolFormCheckerHelper
  11. {
  12. /**
  13. * Check if email is exists.
  14. */
  15. function checkEmailExist ($s)
  16. {
  17. if (!$this->checkEmail($s))
  18. return false;
  19. return BxDolAccountQuery::getInstance()->getIdByEmail($s) ? true : _t('_sys_form_forgot_password_email_not_recognized');
  20. }
  21. function checkEmailExistOrEmpty ($s)
  22. {
  23. if (trim($s) == '')
  24. return true;
  25. if (!$this->checkEmail($s))
  26. return false;
  27. return BxDolAccountQuery::getInstance()->getIdByEmail($s) ? true : _t('_sys_form_forgot_password_email_not_recognized');
  28. }
  29. /**
  30. * Check if phone is exists.
  31. */
  32. function checkPhoneExist ($s)
  33. {
  34. $s = trim($s);
  35. if(!preg_match("/^\+[0-9\s]*$/", $s)) {
  36. return _t('_sys_form_forgot_password_phone_error_format');
  37. }
  38. return BxDolAccountQuery::getInstance()->getIdByPhone($s) ? true : _t('_sys_form_forgot_password_phone_not_recognized');
  39. }
  40. function checkPhoneExistOrEmpty ($s)
  41. {
  42. if (trim($s) == '')
  43. return true;
  44. $s = trim($s);
  45. if(!preg_match("/^\+[0-9\s]*$/", $s)) {
  46. return _t('_sys_form_forgot_password_phone_error_format');
  47. }
  48. return BxDolAccountQuery::getInstance()->getIdByPhone($s) ? true : _t('_sys_form_forgot_password_phone_not_recognized');
  49. }
  50. }
  51. /**
  52. * Forgot Password Form.
  53. */
  54. class BxBaseFormForgotPassword extends BxTemplFormView
  55. {
  56. public function __construct($aInfo, $oTemplate)
  57. {
  58. parent::__construct($aInfo, $oTemplate);
  59. $this->aParams['checker_errors']['summary']['disabled'] = true;
  60. }
  61. }
  62. /** @} */