Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 11-04-2012, 03:17 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're extremely helpful. Thank you again.

I did get it working. I did have one more question however.

If I am specifying a lot of different usergroups in my template and plugin and don't want to have to individually go back and change each template anytime I make a change in my usergroups, is there a way I can define an array in place of the usergroups?

Something like: <vb:if condition="in_array($GLOBAL['forumid'], $MyUsergroups)"> ?

How would I create a plugin that would then feed $MyUsergroups to the templates?

Thank you again.
Reply With Quote
  #12  
Old 11-04-2012, 03:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What you could do in that case is set a variable in the plugin to true, then in the template condition just check the variable. In fact you could use the $show[] array that exists already, as long as you choose a name that you're sure would be unique.

For example, in the plugin you could do something like:

Code:
$MyUsergroups = array(1, 3, 5, 57);
if (is_member_of($bbuserinfo, $MyUsergroups))
{
    ...some code..
    $show['some_unique_name'] = true;
    ... more code
}
then in the template

Code:
<vb:if condition="$show['some_unique_name']">
// show something
</vb:if>
Reply With Quote
  #13  
Old 11-04-2012, 03:41 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My Plugin Code:

Code:
//This plugin controls users accepting the rules on each post until they are promoted to Registered Users Plus.
//Template edits for this plugin have been made in SHOWTHREAD, NEWREPLY, and NEWTHREAD
//A custom phrase called spelling_checkbox was added

$SpellingUsergroups = array(2, 3, 4, 6);
if (is_member_of($vbulletin->userinfo, $SpellingUsergroups))
{
   $show['spelling_checker'] = true;

   $vbulletin->input->clean_gpc('p', 'accept_rules', TYPE_BOOL);


   if (!$vbulletin->GPC['accept_rules'])
   {
       $errors[] = "<span style='color: #ba0000; background-color: #FDFD65;'>Please scroll down and accept the highlighted rules before submitting your post.</span>";
   }
}
My Template Code:

Code:
<vb:if condition="$show['spelling_checker']">
<div class="spelling_checkbox">
			<ul class="checkradio">
				<li><label for="rules">
					<input type="checkbox" id="rules" class="bginput" name="accept_rules" value="true"/>
					{vb:rawphrase spelling_checkbox}
				</label></li>
			</ul>
		</div>
</vb:if>
It doesn't show up however on the page.


Am I making a mistake by putting the $SpellingUsergroups = array(2, 3, 4, 6); and $show['spelling_checker'] = true; in the same plugin as the other code? Does it need to be in a different plugin at a different hook location? Right now all of this is at newpost_process...

--------------- Added [DATE]1352047913[/DATE] at [TIME]1352047913[/TIME] ---------------

Ok I added a new plugin, using this example of yours:

Code:
$MyUsergroups = array(1, 3, 5, 57);
if (is_member_of($bbuserinfo, $MyUsergroups))
{
    ...some code..
    $show['some_unique_name'] = true;
    ... more code
}
but used $vbulletin->userinfo instead of $bbuserinfo and put it to work at parse_templates. Seems to be working...going to test some more though
Reply With Quote
  #14  
Old 11-04-2012, 03:54 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You say the plugin is using newpost_process but your template change is in SHOWTHREAD? That's probably the problem because newpost_process isn't called before SHOWTHREAD.
Reply With Quote
  #15  
Old 11-04-2012, 04:00 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks again.

I have 2 plugins now and then 3 template edits (in showthread, newreply, and newthread)

My first plugin which is called at parsetemplates:

Code:
$SpellingUsergroups = array(6, 7);
if (is_member_of($vbulletin->userinfo, $SpellingUsergroups))
{
$show['spelling_checker'] = true;
}

My second plugin which is called at newpost_process

Code:
//This plugin controls users accepting the rules on each post until they are promoted to Registered Users Plus.
//Template edits for this plugin have been made in SHOWTHREAD, NEWREPLY, and NEWTHREAD
//A custom phrase called spelling_checkbox was added

if (is_member_of($vbulletin->userinfo, $SpellingUsergroups))
{
   $vbulletin->input->clean_gpc('p', 'accept_rules', TYPE_BOOL);


   if (!$vbulletin->GPC['accept_rules'])
   {
       $errors[] = "<span style='color: #ba0000; background-color: #FDFD65;'>Please scroll down and accept the highlighted rules before submitting your post.</span>";
   }
}

And my template edit:

Code:
<vb:if condition="$show['spelling_checker']">
<div class="spelling_checkbox">
			<ul class="checkradio">
				<li><label for="rules">
					<input type="checkbox" id="rules" class="bginput" name="accept_rules" value="true"/>
					{vb:rawphrase spelling_checkbox}
				</label></li>
			</ul>
		</div>
</vb:if>

Now the plugin that works at parse_templates is working properly. It will show the template edits to the proper usergroup and the checkbox shows up.

However if I see the checkbox and try to make a post without clicking on the checkbox, it still allows it...making me think the plugin at newpost_process is not correctly getting the $SpellingUsergroups definition that is being defined in the plugin at parsetemplates.

Thanks for sticking with me through this -- I am learning quite a bit but am still hitting a few speed bumps. Thank you.
Reply With Quote
  #16  
Old 11-04-2012, 04:03 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I think the problem is that the newpost_process hook is being called before parse_templates. If that's all the code you have in your parse_templates plugin, try moving it to global_setup_complete (or whatever it's called - I can never remember).
Reply With Quote
  #17  
Old 11-04-2012, 04:06 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Tried it at global_setup_complete and global_bootstrap_init_start and neither seem to work.
Reply With Quote
  #18  
Old 11-04-2012, 04:23 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh yeah...try it again, but add "global $vbulletin, $show;" at the beginning.
Reply With Quote
  #19  
Old 11-04-2012, 04:31 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok it still allows me to post without having the checkbox selected.

Here's how I have it now:
Code:
global $vbulletin, $show;
$SpellingUsergroups = array(6, 67);
if (is_member_of($vbulletin->userinfo, $SpellingUsergroups))
{
$show['spelling_checker'] = true;
}
at global_setup_complete
Reply With Quote
  #20  
Old 11-04-2012, 04:44 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, try changing the newpost_process plugin to:

Code:
global $show;
if ($show['spelling_checker'])
{
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:52 PM.


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.04000 seconds
  • Memory Usage 2,260KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (10)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete