-if (!IS_MEMBER()) {
- // Redirect
- // @TODO Display quick login form here or redirect as configured
- redirectToUrl('modules.php?module=index');
+if (!isMember()) {
+ // Should we display login window or redirect to main page?
+ if ((isSurfbarGuestLoginFormEnabled()) && (isExtensionActive('user'))) {
+ // Is the form sent?
+ if ((isFormSent('login')) && (isPostRequestElementSet('id')) && (isPostRequestElementSet('password'))) {
+ // Do the login procedure
+ $url = doUserLogin(postRequestElement('id'), postRequestElement('password'), basename(__FILE__), basename(__FILE__) . '?code=');
+
+ // And redirect to the URL
+ redirectToUrl($url);
+ } else {
+ // Load header
+ loadPageHeader();
+
+ // Is there a 'code' provided?
+ if (isGetRequestElementSet('code')) {
+ // Then generate an error message
+ displayMessage(getMessageFromErrorCode(getRequestElement('code')));
+ } // END - if
+
+ // Display login form
+ loadTemplate('surfbar_login_form');
+
+ // Allow footer here
+ $GLOBALS['__header_sent'] = 2;
+
+ // Load footer
+ loadPageFooter();
+ }
+ } else {
+ // Redirect
+ redirectToUrl('modules.php?module=index');
+ }