BxBaseFormLogin.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. protected $_sLoginError = false;
  15. protected $_iRole = BX_DOL_ROLE_MEMBER;
  16. public function __construct($aInfo, $oTemplate) {
  17. parent::__construct($aInfo, $oTemplate);
  18. $sRelocate = bx_process_input(bx_get('relocate'));
  19. $this->aInputs['relocate']['value'] = $sRelocate && 0 == strncmp(BX_DOL_URL_ROOT, $sRelocate, strlen(BX_DOL_URL_ROOT)) ? $sRelocate : BX_DOL_URL_ROOT . 'member.php';
  20. }
  21. function isValid () {
  22. if (!parent::isValid ()) {
  23. $this->_setLoginError (_t('_sys_txt_login_error'));
  24. return false;
  25. }
  26. $sErrorString = bx_check_password($this->getCleanValue('ID'), $this->getCleanValue('Password'), $this->getRole());
  27. $this->_setLoginError ($sErrorString);
  28. return $sErrorString ? false : true;
  29. }
  30. function isSubmittedAndValid () {
  31. $bRet = parent::isSubmittedAndValid ();
  32. if (!$bRet && !$this->getLoginError())
  33. $this->_setLoginError (_t('_sys_txt_login_error'));
  34. return $bRet;
  35. }
  36. protected function genCustomInputSubmitText ($aInput) {
  37. bx_import('BxDolPermalinks');
  38. return '<div class="bx-form-right-line-aligned">
  39. <a href="' . BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password') . '">' . _t("_sys_txt_forgot_pasword") . '</a>
  40. </div>
  41. <div class="clear_both"></div>';
  42. }
  43. public function getRole() {
  44. return $this->_iRole;
  45. }
  46. public function setRole ($iRole) {
  47. $this->_iRole = $iRole == BX_DOL_ROLE_ADMIN ? BX_DOL_ROLE_ADMIN : BX_DOL_ROLE_MEMBER;
  48. }
  49. public function getLoginError() {
  50. return $this->_sLoginError;
  51. }
  52. protected function _setLoginError ($s) {
  53. $this->_sLoginError = $s;
  54. }
  55. }
  56. /** @} */