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 09-29-2010, 08:52 PM
countersweet countersweet is offline
 
Join Date: Sep 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default So desperate: writing a plugin for bbcode_parse_start

i spent so much time and can't find the last piece of puzzle

i am writing a plugin which enables on bbcode_parse_start. i'm hiding specific bbtags based on the user permissions, but that doesn't matter

now: for that i need to access user id variable, so i can look for the privileges (privileges of the user who wrote the post, not the viewer). but those vary in every place of the vbulletin. cms, blog, forums, pm, . . . is is a complete mess

for forum posts it's $post['userid'], sometimes it's $postinfo['userid'], inside pms it's $pm['fromuserid'], inside blogposts it's inside $this->parse_userinfo['userid'] (talk about consistency..)

but the only thing that i haven't been able to find is: the cms article comments, i looked into specifications, searched the hell out of google nothing

how do i access user id inside the cms article comments?
Reply With Quote
  #2  
Old 09-29-2010, 09:01 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

According to the template, vbcms_postbit, the $post variable is being used.
Reply With Quote
  #3  
Old 09-29-2010, 09:16 PM
countersweet countersweet is offline
 
Join Date: Sep 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nope..

global $post;
print_r($post);

..empty string

i think that postbit are different than the article comments. i tried erasing the whole vbcms_postbit and the comments stayed
edit: okay, i did print_r($GLOBALS); and there is absolutely no trace about the posts. it must be in some object. but what object? it's not inside $this

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

i found that it is using vbcms_postbit_legacy. it shows a lot of {vb:raw post...} but calling global $post simply does not work

is this a bug? can someone confirm this? calling global $post inside bbcode_parse_start on the article comments page gives you empty $post, while it should provide the post data? can please someone confirm this bug

also, there is "postbit_start" hook on the beginning of the template, but no option for it inside the plugin manager
Reply With Quote
  #4  
Old 09-29-2010, 10:59 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you even sure that function (and thus the hook) is called in the CMS? If you look at package/vbcms/bbcode/html.php, it does call the class_bbcode.php file, however it doesn't ever use the function parse from that file. I looked on a few cms pages (articles, edit articles, create articles) and that hook location never shows up as being called at all.

Quote:
also, there is "postbit_start" hook on the beginning of the template, but no option for it inside the plugin manager
That is a template_hook for html, not a hook location for php.
Reply With Quote
  #5  
Old 09-29-2010, 11:34 PM
countersweet countersweet is offline
 
Join Date: Sep 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yep, the plugin hook is being called

when you create a dummy bbcode_parse_start, and include something like echo('test');, it will appear in the output (you must have some comments on an article first, of course)

you can even do something like this:
write something bold in an article commentary, then paste this into your bbcode_parse_start enabled hook:

Code:
      $this->tag_list['no_option']['b'] = array(
           'html' => "i got called",
           'strip_empty' => true
      );
and it will replace each `something bold` with `i got called`

so, while you can access the bbcode inside the post, you can't seem to access the poster's info like userid

try it
Reply With Quote
  #6  
Old 09-29-2010, 11:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by countersweet View Post
is this a bug? can someone confirm this? calling global $post inside bbcode_parse_start on the article comments page gives you empty $post, while it should provide the post data?
If the $post is inside a function where there's no "global $post", using "global $post" somewhere else won't make it available. But of course if there's a hook inside that function before the bbcode parser is called you could make it available via a global. (And if there's no hook you could always just change the code if you're that desperate).
Reply With Quote
  #7  
Old 09-29-2010, 11:57 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you getting it to do anything with the post username in other areas (not cms comments)? It just doesn't look like the info gets passed there except for the $text itself.
Reply With Quote
  #8  
Old 09-30-2010, 12:17 AM
countersweet countersweet is offline
 
Join Date: Sep 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes, all the other areas work. regular forum posts for example

(btw it's userid that's interesting, not username)

do you think that this bug has to do something with the fact that the user comments are handled as new posts inside hidden forum called "vBCms Comments"?
Reply With Quote
  #9  
Old 09-30-2010, 12:33 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I really don't know as I have not done anything with bbcode parsing before.
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 05:14 PM.


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.03963 seconds
  • Memory Usage 2,240KB
  • 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
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete