BxBaseFormLogin.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. bx_import('BxTemplFormView');
  10. /**
  11. * Login Form.
  12. */
  13. class BxBaseFormLogin extends BxTemplFormView
  14. {
  15. protected $_iRole = BX_DOL_ROLE_MEMBER;
  16. public function __construct($aInfo, $oTemplate)
  17. {
  18. parent::__construct($aInfo, $oTemplate);
  19. $sRelocate = bx_process_input(bx_get('relocate'));
  20. $this->aInputs['relocate']['value'] = $sRelocate && 0 == strncmp(BX_DOL_URL_ROOT, $sRelocate, strlen(BX_DOL_URL_ROOT)) ? $sRelocate : BX_DOL_URL_ROOT . 'member.php';
  21. }
  22. function isValid ()
  23. {
  24. if (!parent::isValid ())
  25. return false;
  26. $sErrorString = bx_check_password($this->getCleanValue('ID'), $this->getCleanValue('Password'), $this->getRole());
  27. $this->_setCustomError ($sErrorString);
  28. return $sErrorString ? false : true;
  29. }
  30. protected function genCustomInputSubmitText ($aInput)
  31. {
  32. bx_import('BxDolPermalinks');
  33. return '<div class="bx-form-right-line-aligned">
  34. <a href="' . BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password') . '">' . _t("_sys_txt_forgot_pasword") . '</a>
  35. </div>
  36. <div class="clear_both"></div>';
  37. }
  38. public function getRole()
  39. {
  40. return $this->_iRole;
  41. }
  42. public function setRole ($iRole)
  43. {
  44. $this->_iRole = $iRole == BX_DOL_ROLE_ADMIN ? BX_DOL_ROLE_ADMIN : BX_DOL_ROLE_MEMBER;
  45. }
  46. public function getLoginError ()
  47. {
  48. return isset($this->aInputs['ID']['error']) ? $this->aInputs['ID']['error'] : '';
  49. }
  50. protected function _setCustomError ($s)
  51. {
  52. $this->aInputs['ID']['error'] = $s;
  53. }
  54. }
  55. /** @} */