BxBaseServiceLogin.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  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 serviceMemberAuthCode($aAuthTypes)
  23. {
  24. $bCompact = getParam('site_login_social_compact') == 'on';
  25. $aTmplButtons = array();
  26. foreach($aAuthTypes as $iKey => $aItems) {
  27. $sTitle = _t($aItems['Title']);
  28. $aTmplButtons[] = array(
  29. 'class' => $bCompact ? 'sys-auth-compact bx-def-margin-sec-left-auto' : '',
  30. 'href' => !empty($aItems['Link']) ? BX_DOL_URL_ROOT . $aItems['Link'] : 'javascript:void(0)',
  31. 'bx_if:show_onclick' => array(
  32. 'condition' => !empty($aItems['OnClick']),
  33. 'content' => array(
  34. 'onclick' => 'javascript:' . $aItems['OnClick']
  35. )
  36. ),
  37. 'bx_if:show_icon' => array(
  38. 'condition' => !empty($aItems['Icon']),
  39. 'content' => array(
  40. 'icon' => $aItems['Icon']
  41. )
  42. ),
  43. 'bx_if:show_title' => array(
  44. 'condition' => !$bCompact || empty($aItems['Icon']),
  45. 'content' => array(
  46. 'title' => $sTitle
  47. )
  48. )
  49. );
  50. }
  51. BxDolTemplate::getInstance()->addCss(array('auth.css'));
  52. return BxDolTemplate::getInstance()->parseHtmlByName('auth.html', array(
  53. 'bx_repeat:buttons' => $aTmplButtons
  54. ));
  55. }
  56. public function serviceLoginFormOnly ($sParams = '', $sForceRelocate = '')
  57. {
  58. if(strpos($sParams, 'no_join_text') === false)
  59. $sParams = ($sParams != '' ? ' ' : '') . 'no_join_text';
  60. return $this->serviceLoginForm($sParams, $sForceRelocate);
  61. }
  62. public function serviceLoginForm ($sParams = '', $sForceRelocate = '')
  63. {
  64. if (isLogged()) {
  65. return false;
  66. }
  67. // get all auth types
  68. $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`');
  69. $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login');
  70. $sCustomHtmlBefore = '';
  71. $sCustomHtmlAfter = '';
  72. bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes));
  73. if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT))
  74. $oForm->aInputs['relocate']['value'] = $sForceRelocate;
  75. elseif ('homepage' == $sForceRelocate)
  76. $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT;
  77. $sFormCode = $oForm->getCode();
  78. $sJoinText = '';
  79. if (strpos($sParams, 'no_join_text') === false) {
  80. $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>';
  81. }
  82. BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js'));
  83. $sAuth = $this->serviceMemberAuthCode($aAuthTypes);
  84. return $sCustomHtmlBefore . $sAuth . $sFormCode . $sCustomHtmlAfter . $sJoinText;
  85. }
  86. }
  87. /** @} */