vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   BBCode Hide for VB4 (https://vborg.vbsupport.ru/showthread.php?t=269949)

DNCL 09-09-2011 01:28 AM

BBCode Hide for VB4
 
Hello,

i need a full functional mod to hide [CODE] or other bbcode contents for a specific group, i have one but for some odd reason it hides the content for other groups too.

Is there a real working one for VB4? :)

Note: i don't want [ HIDE] [/HIDE ] hack.

kh99 09-09-2011 01:15 PM

Quote:

Originally Posted by DNCL (Post 2243735)
Hello,

i need a full functional mod to hide [CODE] or other bbcode contents for a specific group, i have one but for some odd reason it hides the content for other groups too.

That may be due to post caching. The way things are set up, vb assumes that bbcodes will look the same for everyone viewing a specific style.


Quote:

Note: i don't want [ HIDE] [/HIDE ] hack.

Why not? Is it not what you're asking for, or you don't like it for some other reason?

DNCL 09-09-2011 02:56 PM

i have an already posts coded with [CODE] and i just want to hide them.

kh99 09-09-2011 03:57 PM

OK, well I guess you could do something like this: edit the template bbcode_code (and maybe bbcode_code_printable as well), and add comments like this:

Code:

<!-- code -->
existing template code
<!-- end code -->


Then create a plugin using hook postbit_display_complete and something like this for code:

PHP Code:

global $vbulletin;

if (
is_member_of($vbulletin->userinfo1234))
{
    
$post['message'] = preg_replace('#<!-- code -->.*?<!-- end code -->#s''(Code Removed)'$post['message']);



(of course you can change the usergroup ids and '(Code Removed)' string to whatever you want).

Edit: Actually this doesn't work perfectly. If the code happens to contain <!-- end code --> you'll still see everything after that.

DNCL 09-09-2011 04:34 PM

This worked for me i guess but is this method works 100% and no caching issues for example?

kh99 09-09-2011 04:43 PM

Quote:

Originally Posted by DNCL (Post 2243994)
This worked for me i guess but is this method works 100% and no caching issues for example?

Yes, it happens after the caching so it should be OK (of course now it has to run a preg_replace on every post, but you can't have everything). And like I mentioned above it potentially would mess up if the code included one of those comments, but you change them to something even less likely to appear by accident.

DNCL 09-09-2011 05:03 PM

can i parse bbcode in the message (Code Removed) ?

kh99 09-09-2011 05:25 PM

No, it has to be html. But you could probably render a template, like:

PHP Code:

if (is_member_of($vbulletin->userinfo1234)) 

    static 
$code_replacement '';
    if (empty(
$code_replacement))
    {
        
$templater vB_Template::create('code_replacement');
        
$code_replacement $templater->render();
        unset(
$templater);
    }
    
$post['message'] = preg_replace('#<!-- code -->.*?<!-- end code -->#s'$code_replacement$post['message']); 



That doesn't let you use bbcode, but it's a little more convenient. I suppose you could run the replacement text through the bbcode parser if you wanted, but it really doesn't let you do anything you couldn't do by inserting html.

DNCL 09-09-2011 05:44 PM

the HTML tags works with the first plugin you gave me, anything special wit the second one?

kh99 09-09-2011 05:49 PM

No, it just lets you put the html in a template but you don't need to do that.


All times are GMT. The time now is 11:13 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.01229 seconds
  • Memory Usage 1,744KB
  • 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
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete