BxBaseServiceLogin.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. public function __construct() {
  14. parent::__construct();
  15. }
  16. public function serviceLoginForm ($sParams = '') {
  17. if (isLogged()) {
  18. return false;
  19. }
  20. // get all auth types
  21. $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`');
  22. // define additional auth types
  23. if ($aAuthTypes) {
  24. $aAddInputEl[''] = _t('_Basic');
  25. // procces all additional menu's items
  26. foreach($aAuthTypes as $iKey => $aItems)
  27. $aAddInputEl[$aItems['Link']] = _t($aItems['Title']);
  28. $aAuthTypes = array(
  29. 'type' => 'select',
  30. 'caption' => _t('_Auth type'),
  31. 'values' => $aAddInputEl,
  32. 'value' => '',
  33. 'attrs' => array ('onchange' => 'if (this.value) { location.href = "' . BX_DOL_URL_ROOT . '" + this.value }'),
  34. );
  35. } else {
  36. $aAuthTypes = array('type' => 'hidden');
  37. }
  38. bx_import ('BxDolForm');
  39. $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login');
  40. $sCustomHtmlBefore = '';
  41. $sCustomHtmlAfter = '';
  42. bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes));
  43. $sFormCode = $oForm->getCode();
  44. $sJoinText = '';
  45. if (strpos($sParams, 'no_join_text') === false) {
  46. bx_import('BxDolPermalinks');
  47. $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>';
  48. }
  49. BxDolTemplate::getInstance()->addJs(array('jquery.form.js'));
  50. return $sCustomHtmlBefore . $sFormCode . $sCustomHtmlAfter . $sJoinText;
  51. }
  52. }
  53. /** @} */