Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools
Custom Conditional BB-Codes: Create your own Details »»
Custom Conditional BB-Codes: Create your own
Version: 1.00, by Marco van Herwaarden Marco van Herwaarden is offline
Developer Last Online: Dec 2010 Show Printable Version Email this Page

Version: 3.0.6 Rating:
Released: 01-26-2005 Last Update: Never Installs: 17
 
No support by the author.

Custom Conditional BB-Codes: Create your own - Version 1.00

Description
This Hack will give you all building blocks to create your own BB-Codes that eveluate different based on a condition. You can create almost any condition you want.

As an example full instructions are given to install a "[noguest]text[/noguest]" BB-Code that will only show "text" to logged in users.

This hack is a result of the following 2 threads:
- https://vborg.vbsupport.ru/showthrea...threadid=75162 (now withdrawn)
- https://vborg.vbsupport.ru/showthread.php?t=74940

WARNING:
With exception of the provided example, does this hack need some basic PH-coding skills.


Tested on
- vB 3.0.6

Install Information
Install time: from 2 minute till ...... hours
File edits: 1 - 5 (depending on configuration)
Template edits: 0

IT IS EXTREME IMPORTANT THAT YOU READ ALL INSTRUCTIONS CAREFULLY.

Features
- Included example will give you a [noguest]Text[/noguest] BB-Code
- You can write your own conditional BB-Codes
- Post caching is modified not to include posts that contain user dependent conditionals.
- Post preview on forumdisplay.php is modified not to show text that contain user dependent conditionals.


Support
Support will be given in this thread.

I will not charge for this hack. But if you like it and are looking for a way to spend your money, paypal donations are always welcome (marcoh64@msn.com)

Please click Install if you are using this hack

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 01-27-2005, 01:10 PM
rin rin is offline
 
Join Date: Aug 2004
Location: Mainland of China
Posts: 109
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hi marco,

can you tell me why this does not work?
Code:
function handle_bbcode_noguest($code)
{
        global $bbuserinfo;

        // remove empty codes
        if (trim($code) == '')
        {
                return '';
        }

        // Prevent caching if a BB-code is used that is userdependent
        // Uncomment the following 2 lines if the parsing of the bb-code is user dependent.
        // So:
        // - If user permissions are checked
        // - If usergroup is checked
        // - if userid is checked
        // - .....
        // Leave commented if:
        // - No checking is done
        // - Checking is done based on forumid
        // - ....
        global $bbcodeparse_nopostcache;
        $bbcodeparse_nopostcache = 1;
        if ($bbuserinfo['userid'] == 0 OR $bbuserinfo['usergroupid'] == 2)                         // Guest
        {
                $code = "no guest!";
        }

        return $code;
}
usergroup 2 are those with 0 posts. i dont know why they still can see what lies beneath the tag. it still works for guests with this code but not for registered users with 0 posts. (usergroup id 2)

haha, i solved the "problem" myself. i just added usergroupid instead of userid.
thanks a lot for this great hack. everything works fine now!
Reply With Quote
  #3  
Old 01-27-2005, 05:01 PM
roundhost roundhost is offline
 
Join Date: Jul 2004
Location: UK
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am going to have a play with this, as i have recently been developing an admin notes system where admins can leave notes in posts stating if somebody has done somethign wrong, rather than just editing the post
Reply With Quote
  #4  
Old 01-27-2005, 07:21 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by roundhost
I am going to have a play with this, as i have recently been developing an admin notes system where admins can leave notes in posts stating if somebody has done somethign wrong, rather than just editing the post
Marco, I wonder if this mod isn't exactly what I am looking for. Have a look at this mod I created for an embedded media player https://vborg.vbsupport.ru/showthrea...threadid=72162 I have left in beta because I have been unable to add contitionals to the custom bbcode to keep certain groups from being able to see it. If I am not mistaken this looks like it will do exactly that?
Reply With Quote
  #5  
Old 01-27-2005, 07:27 PM
rin rin is offline
 
Join Date: Aug 2004
Location: Mainland of China
Posts: 109
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this will exactly display something different to different groups.
for example the media to the paying customers and an error notice to the guests.
i am just not too sure about the built-in archive of vb3.
Reply With Quote
  #6  
Old 01-27-2005, 08:52 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rin
this will exactly display something different to different groups.
for example the media to the paying customers and an error notice to the guests.
i am just not too sure about the built-in archive of vb3.
Hmm archive...

Not check for that one yet. I know it will work ok for:
- Normal post/thread viewing
- In all view modes (linear/threaded)
- Using cached posts
- Preview on forum index

Will try to check put the archive tomorrow.

@roundhost/eric
Yes i think it will work fine for what you want to do.
Reply With Quote
  #7  
Old 01-28-2005, 03:40 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, here is what I have and it's not working for me i.e. nothing happens and it does not send the permissions error allowing anyone to view. Let's say I want to send a no permissions error code to my custom [media] BBcode.

I change all instances of mycustombbcode to media according to the instructions in Install Conditional Custom BB-Codes.txt and applied the instructed changes to functions_bbcodeparse.php

Then I make the proper additions to the functions_forumdisplay.php and it still does not block the group. Here is the function_bbcodeparse.php that I am using.

PHP Code:
// Start Hack Conditional BB-Codes (MarcoH64)
// ###################### Start bbcodehandler_media #######################
function handle_bbcode_media($code)
{
    
// Define Global Variables if needed:
    // global $neededglobalvarnames;

    // remove empty codes
    
if (trim($code) == '')
    {
        return 
'';
    }
    
    
// Prevent caching if a BB-code is used that is userdependent
    // Uncomment the following 2 lines if the parsing of the bb-code is user dependent.
    // So:
    // - If user permissions are checked
    // - If usergroup is checked
    // - if userid is checked
    // - .....
    // Leave commented if:
    // - No checking is done
    // - Checking is done based on forumid
    // - ....
    // global $bbcodeparse_nopostcache;
    // $bbcodeparse_nopostcache = 1;
    
if ($bbuserinfo['usergroupid'] == 6)             
    {
        
// You can change the following to whatever suits you, text and/or html
        
$code "<b>You must be registered to view the embedded media player</b>";
    }
    return 
$code;
}
// End Hack Conditional BB-Codes (MarcoH64) 
Any ideas on what i am doing wrong?
Reply With Quote
  #8  
Old 02-04-2005, 02:51 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes 2 things are wrong:
1. Since this condition is user dependant, you will need to uncomment the line:
PHP Code:
// $bbcodeparse_nopostcache = 1; 
2. You will need to change the line:
PHP Code:
    // global $neededglobalvarnames; 
to:
PHP Code:
global $bbuserinfo
in top of the function i think. See also the provided [noguest] example.
Reply With Quote
  #9  
Old 02-06-2005, 01:11 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarcoH64
Yes 2 things are wrong:
1. Since this condition is user dependant, you will need to uncomment the line:
PHP Code:
// $bbcodeparse_nopostcache = 1; 
2. You will need to change the line:
PHP Code:
    // global $neededglobalvarnames; 
to:
PHP Code:
global $bbuserinfo
in top of the function i think. See also the provided [noguest] example.
It's still not working, here is what I have now. I log in as guest and can still see the custom bbcode (I am using 'media' as my bbcode' it's been changed in all instances).

PHP Code:
// Start Hack Conditional BB-Codes (MarcoH64)
// ###################### Start bbcodehandler_noguest #######################
function handle_bbcode_media($code)
{
    global 
$bbuserinfo;

    
// remove empty codes
    
if (trim($code) == '')
    {
        return 
'';
    }
    
    
// Prevent caching if a BB-code is used that is userdependent
    // Uncomment the following 2 lines if the parsing of the bb-code is user dependent.
    // So:
    // - If user permissions are checked
    // - If usergroup is checked
    // - if userid is checked
    // - .....
    // Leave commented if:
    // - No checking is done
    // - Checking is done based on forumid
    // - ....
    
global $bbcodeparse_nopostcache;
    
$bbcodeparse_nopostcache 1;
    if (
$bbuserinfo['userid'] == 0)             // Guest
    
{
        
// You can change the following to whatever suits you, text and/or html
        
$code "Sorry this text is not viewable by guests.";
    }
    return 
$code;
}
// End Hack Conditional BB-Codes (MarcoH64) 
Reply With Quote
  #10  
Old 02-06-2005, 03:16 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you made the file edits as instructed in "Install with user based conditionals.txt" and optionally in "Install with use of post cache.txt"?

PS You could try the "noguest" example. It is almost the same as what you want, and tested.
Reply With Quote
 


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:23 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.04862 seconds
  • Memory Usage 2,320KB
  • Queries Executed 25 (?)
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)bbcode_code
  • (8)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)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
  • (9)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