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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-23-2012, 12:59 AM
Revelence Revelence is offline
 
Join Date: Apr 2011
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Hooks

So I've made a postbit background plugin, which will give certain usergroups a background. It works in my threads, but it's not reading the plugin, or something properly from PM's. I'm guessing it's something with the hook location.

So I'm here to ask what hook location should I use?

My current hook location: postbit_display_start
Reply With Quote
  #2  
Old 10-23-2012, 03:18 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think the problem is that $this->post['usergroupid'] is not set if it's a pm (and so you can't use is_member_of(), if that's what you're doing). I don't think there's anything you can do except do a query for it yourself if you're displaying a PM. Maybe something like:

Code:
if (get_class() == 'vB_Postbit_Pm')
{
   $userinfo = fetch_userinfo($this->post['userid']);
}
else
{
   $userinfo &= $this->post;
}

// then use $userinfo to check group...
Reply With Quote
  #3  
Old 10-23-2012, 03:46 PM
Revelence Revelence is offline
 
Join Date: Apr 2011
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think the problem is that $this->post['usergroupid'] is not set if it's a pm (and so you can't use is_member_of(), if that's what you're doing). I don't think there's anything you can do except do a query for it yourself if you're displaying a PM. Maybe something like:

Code:
if (get_class() == 'vB_Postbit_Pm')
{
   $userinfo = fetch_userinfo($this->post['userid']);
}
else
{
   $userinfo &= $this->post;
}

// then use $userinfo to check group...
Well that's not really the problem. I use an array to store the usergroup ids, and yes I do use the post['usergroupid']. But if it's not set it wouldn't be in the array, which would just default output it the div without a background.

So I'm still having a feeling it's something with the hooks.
Reply With Quote
  #4  
Old 10-23-2012, 03:56 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you using debug mode to view the hooks called on each page and have you verified that the hook you are using is being called on the PM page you are looking at?
Reply With Quote
  #5  
Old 10-23-2012, 04:13 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Revelence View Post
But if it's not set it wouldn't be in the array, which would just default output it the div without a background.
So what does happen? Seems like if it's changing the background then the plugin must be running.
Reply With Quote
  #6  
Old 10-23-2012, 04:23 PM
Revelence Revelence is offline
 
Join Date: Apr 2011
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
So what does happen? Seems like if it's changing the background then the plugin must be running.
Okay so I have a plugin say.

Code:
if (1==2) 
 //<div class="userinfo" style="background: green;">
else 
 //<div class="userinfo">
That's just an example with the if statement, but you should get the picture.

Lynne, that's what I think is wrong. The hook location is wrong and is not being called on the page. How can I turn debug mode on to check which hooks

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

Okay so I enabled debug mode. postbit_display_start, which is the hook I've been using is enabled in both pages. So I'm still a little confused, I'll try making just something that prints out something to test it.

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

Nope, I made it output 'Hello', it works in the threads, but still messes up my PM. Weird..
Reply With Quote
  #7  
Old 10-23-2012, 05:42 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How about you post the exact php code and hook location so we can try it on our own.
Reply With Quote
  #8  
Old 10-23-2012, 06:02 PM
Revelence Revelence is offline
 
Join Date: Apr 2011
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Plugin hook: postbit_display_start

Code:

Code:
ob_start();
	$usergroupid = $post['usergroupid'];
	$has_bg	= array(6);
	if (in_array($usergroupid, $has_bg)) {
		echo '<div class="userinfo" style="background:url(images/ranks/postbit/'.$usergroupid.'.png);min-height: 350px;">';
	} else {
		echo '<div class="userinfo">';
	}
$php_include = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('postbit_legacy',array('postbit_background' => $php_include));
Then in postbit_legacy template, I replace the
Code:
<div class="userinfo">
with
Code:
{vb:raw postbit_background}
Reply With Quote
  #9  
Old 10-23-2012, 06:23 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can look at the query around line 1611 or private.php and see that the usergroupid is never even grabbed, as Kevin had brought up above. You would need to modify the query to add that in.
Reply With Quote
  #10  
Old 10-23-2012, 06:25 PM
Revelence Revelence is offline
 
Join Date: Apr 2011
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
You can look at the query around line 1611 or private.php and see that the usergroupid is never even grabbed, as Kevin had brought up above. You would need to modify the query to add that in.
No, I'm not worried about that postbit backgrounds actually working with the PM's atm, the problem is, the actual plugin is not being called. If it were being called, it would just show <div class="userinfo">, which it's not.
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 04:35 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04254 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
  • (6)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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