1
0

BxBaseServiceLogin.php 2.4 KB

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