vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How do I call up the login required prompt from java (https://vborg.vbsupport.ru/showthread.php?t=282895)

Disco_Stu 05-14-2012 10:50 AM

How do I call up the login required prompt from java
 
Can someone please tell me what function I would execute to display the standard prompt to require the user to login or register? I want to call this from a javascript function in an html forum block.

The display I want to use is the message box with the normal system message:

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

You are not logged in. Fill in the form at the bottom of this page and try again.
You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.




Thanks.

kh99 05-14-2012 10:59 AM

I believe that's the message that you get when you call the php function print_no_permission(); But you can't call it directly from javascript, and there is no php script that will simply call that function (although there are probably a number of them that would display that if the user was logged out). I suppose you could write one, or use a plugin in misc.php, but to be honest I'm having trouble seeing what would happen after that message was displayed (the user would log in obviously, but then where would it take you?).

Disco_Stu 05-14-2012 11:57 AM

Hopefully back to where you were before the message was displayed

kh99 05-14-2012 12:41 PM

OK, I guess that does make sense. And if you call print_no_permission() it should display the message you want, and it then returns to the page it was called from. But I'm not sure how you'd use that because if it was part of the page that you're displaying, you'd never see it without being logged in.

I guess you're trying to make a forum block that lets you log in or something like that?

Disco_Stu 05-14-2012 01:38 PM

I have a forum block with option buttons. If the visitor tries to use one of these buttons without being signed in then I want to display the message.

Just like in these forums when you try to post and you're not logged in. You get a dialog box asking you to log in. After you do it takes you to the posting screen. That is what I'm trying to do.

kh99 05-14-2012 01:49 PM

OK, then I think you could do something like have your javascript call the same page but add a parameter like "&forcelogin=1" or something like that. Then at the top of your script for that page (after global.php is included) put something like:

Code:

if ($_GET['forcelogin'] AND $vbulletin->userinfo['userid'] == 0)
{
    print_no_permission();
}


I guess if you're using a forumblock then you're talking about the forum.php page? Then you can probably put the above code in a plugin using hook forumhome_start.

Disco_Stu 05-14-2012 02:16 PM

Actually I just want to call the routine from java script in my forum block without a page refresh and display the "you need to log in" message, have the user log in then they can try the forum block option buttons again.

Thanks for letting me know the routine name. I should be able to plug that into my code.

kh99 05-14-2012 02:19 PM

Is there a part of the vb code that works like you want (i.e. lets you log in without refreshing the page)? If so we can find it and figure out how it works.

You could have your js target another window and log in in a popup, but than you'd need some way for your js to know if it was successful or not.


All times are GMT. The time now is 05:30 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01078 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete