1
0

BxBaseServiceLogin.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 TridentCore Trident 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. $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login');
  46. $sCustomHtmlBefore = '';
  47. $sCustomHtmlAfter = '';
  48. bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes));
  49. if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT))
  50. $oForm->aInputs['relocate']['value'] = $sForceRelocate;
  51. elseif ('homepage' == $sForceRelocate)
  52. $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT;
  53. $sFormCode = $oForm->getCode();
  54. $sJoinText = '';
  55. if (strpos($sParams, 'no_join_text') === false) {
  56. $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>';
  57. }
  58. BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js'));
  59. return $sCustomHtmlBefore . $sFormCode . $sCustomHtmlAfter . $sJoinText;
  60. }
  61. }
  62. /** @} */