vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Custom Conditional BB-Codes: Create your own (https://vborg.vbsupport.ru/showthread.php?t=75228)

Marco van Herwaarden 01-26-2005 10:00 PM

Custom Conditional BB-Codes: Create your own
 
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

rin 01-27-2005 01:10 PM

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! :)

roundhost 01-27-2005 05:01 PM

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 ;)

ericgtr 01-27-2005 07:21 PM

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?

rin 01-27-2005 07:27 PM

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.

Marco van Herwaarden 01-27-2005 08:52 PM

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.

ericgtr 01-28-2005 03:40 PM

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?

Marco van Herwaarden 02-04-2005 02:51 PM

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.

ericgtr 02-06-2005 01:11 PM

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) 


Marco van Herwaarden 02-06-2005 03:16 PM

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.


All times are GMT. The time now is 08:39 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.01132 seconds
  • Memory Usage 1,777KB
  • 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
  • (8)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