BxBaseServiceLogin.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /**
  10. * System service for login form functionality.
  11. */
  12. class BxBaseServiceLogin extends BxDol
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function serviceTest ($n = 1)
  19. {
  20. return $n*2;
  21. }
  22. public function serviceLoginForm ($sParams = '', $sForceRelocate = '')
  23. {
  24. if (isLogged()) {
  25. return false;
  26. }
  27. // get all auth types
  28. $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`');
  29. // define additional auth types
  30. if ($aAuthTypes) {
  31. $aAddInputEl[''] = _t('_Basic');
  32. // procces all additional menu's items
  33. foreach($aAuthTypes as $iKey => $aItems)
  34. $aAddInputEl[$aItems['Link']] = _t($aItems['Title']);
  35. $aAuthTypes = array(
  36. 'type' => 'select',
  37. 'caption' => _t('_Auth type'),
  38. 'values' => $aAddInputEl,
  39. 'value' => '',
  40. 'attrs' => array ('onchange' => 'if (this.value) { location.href = "' . BX_DOL_URL_ROOT . '" + this.value }'),
  41. );
  42. } else {
  43. $aAuthTypes = array('type' => 'hidden');
  44. }
  45. bx_import ('BxDolForm');
  46. $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login');
  47. $sCustomHtmlBefore = '';
  48. $sCustomHtmlAfter = '';
  49. bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes));
  50. if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT))
  51. $oForm->aInputs['relocate']['value'] = $sForceRelocate;
  52. elseif ('homepage' == $sForceRelocate)
  53. $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT;
  54. $sFormCode = $oForm->getCode();
  55. $sJoinText = '';
  56. if (strpos($sParams, 'no_join_text') === false) {
  57. bx_import('BxDolPermalinks');
  58. $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div>' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>';
  59. }
  60. BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js'));
  61. return $sCustomHtmlBefore . $sFormCode . $sCustomHtmlAfter . $sJoinText;
  62. }
  63. }
  64. /** @} */