Back to vBulletin 3.0 Add-Ons

User setable default BB code formatting for each post
Mod Version: 1.00, by Darth Cow

This modification is in the archives.
vB Version: 3.0.5 Rating: (1 vote - 5.00 average) Installs: 9
Released: 11 Jan 2005 Last Update: Never Downloads: 2
Not Supported  

Allow your users to set default formatting for each of their newpostswith the familiar BB code via the options page in their controlpanel.

This requires one file edit and adding a custom profile field.

There is also the option to allow users to choose not to seeautomaticbb code. This requires another file edit and custom profilefield. (Theaddition of this option is the only change between versions1.0 and1.1.)

First, open up your admincp and find the "User Profile Fields" section in the sidebar and click "Add New User Profile Field".

Click "Continue" with the default Single-Line Text Field option selected. Set the following options:

Title: Automatic BB Code
Description: Enter the opening portion of BB code tags that youwouldlike format all of your posts (e.g. [color=red]). Multiple tagsarefine, but no text outside of the tags. Only single quotation marks(nodouble quotation marks) can be used in this field.
Private Field: Yes
Field Searchable on Members List: No
Show on Members List: No
Regular Expression:
Code:
^(\[(b|i|u|color|font|size|left|center|right)(\=\'?(\#\w+\s*)+\'?)?\])*$
Display Page: Options: Other

You can change the BB codes in the regular expression to any othersyouhave added on your forum or customize them in any way you choose.Justkeep the same formatting with the | character dividing each tag.

Once you've customized this page to your satisfaction (every other option can be left as the default), click Add.

Now, note the "Name" field for your new field in the User Profile Field Manager. It should be of the format "field123".

You'll need to edit includes/functions_newpost.php. Find the following line:

PHP Code:
          // ### PREPARE OPTIONS AND CHECK VALID INPUT ###
          
$post['parseurl'] = intval($post['parseurl']);
          
$post['email'] = intval($post['email']);
          
$post['signature'] = intval($post['signature']);
          
$post['preview'] = iif($post['preview'], 10);
          
$post['disablesmilies'] = intval($post['disablesmilies']);
          
$post['enablesmilies'] = iif($post['disablesmilies'], 01);
          
$post['rating'] = intval($post['rating']);
          
$post['iconid'] = intval($post['iconid']);
          
$post['message'] = trim($post['message']);
          
$post['title'] = trim(preg_replace('/&#0*32;/'' '$post['title']));
          
$post['emailupdate'] = intval($post['emailupdate']);
          
$post['folderid'] = intval($post['folderid']);
          
$post['username'] = trim($post['username']);
          
$post['posthash'] = trim($post['posthash']);
          
$post['poststarttime'] = trim($post['poststarttime']); 
AFTER it add,

PHP Code:
      // Darth Cow's auto BB code hack
          
$auto_bb_opentag $bbuserinfo['field123'];
      
    
preg_match_all("/\[(\w+)(\=\"?\'?(\w+\s*)+\"?\'?)?\]/",$auto_bb_opentag$auto_bb_tagsPREG_SET_ORDER);
          
$auto_bb_closetags array_reverse($auto_bb_tags);
          
$auto_bb_closetag "";
          foreach (
$auto_bb_closetags as $auto_bb_tag)
          {
              
$auto_bb_closetag .= "[/" $auto_bb_tag[1] . "]";
          }
      
          
$post['message'] = $auto_bb_opentag $post['message'] . $auto_bb_closetag;
      
// End hack 
Be sure to edit field123 in the first line to the name of the field you noted above.

Save and upload the file. That's it!

-------------------------------

You can also choice to allow users the option of seeing no automatic bb code. Keep in mind this part will not work if you have enabled caching of posts(vBulletinOptions > Server Settings and Optimization Options >Cached PostsLifespan should equal 0). If you need to cache posts forperformancereasons, then you're out of luck. (There's no technical wayaround this,without saving this information elsewhere in the database,since cachedposts saved parsed BB code for all users--it can't bechanged on anindividual basis as this hack does.)

To do so, add a "Single-Selection Menu" custom profile field with the following options:

Title: Show Automatic BB Code
Description: Set this to "No" to view the forums without anyone else's automatic BB code.
Options:
Yes
No
Private Field: Yes
Field Searchable on Members List: No
Show on Members List: No
Display Page: Options: Thread Viewing

Do not change the options from Yes and No (exactly) or the removalofautomatic BB code will not work. You can customize the rest oftheoptions as you choice. Once you're done, hit add it and again notethename of the profile field (it's in the form field123).

Open up /includes/functions_bbcodeparse.php. Find the following line:

PHP Code:
    // ********************* PARSE BBCODE TAGS *************************** 
ABOVE it add:

PHP Code:
// Darth Cow's auto BB code hack
        
$show_auto_bbcode $bbuserinfo['field123'];
    
        global 
$stopsaveparsed$parsed_postcache;
    
        if ((
$stopsaveparsed OR $parsed_postcache['skip'] == true) AND $show_auto_bbcode == "No")
        {
            
$outer_bbcode_stripped2 $bbcode;
            while (
true)
            {
        
$outer_bbcode_stripped=preg_replace("/^\[(\w+)(\=\'?(\w+\s*)+\'?)?\](?!.*\[\/\\1\].+)(.+)\[\/\\1\]$/si","\\4",$outer_bbcode_stripped2);
    
             if (
$outer_bbcode_stripped2 == $outer_bbcode_stripped)
                {
                
$bbcode$outer_bbcode_stripped;
                    break;
                }
                else
                {
                
$outer_bbcode_stripped2=$outer_bbcode_stripped;
                }
            }
        }
    
// End hack 
Once again, be sure to edit field123 in the first line to the nameofthe field you noted for the "Show Automatic BB Code" option.

Save and upload the file.

Version 1.2: RegExp fix should allow hex values for colors.

Download

No files for download.

Similar Mods

Default BBCode formatting for user's posts (LITE VERSION) vBulletin 3.5 Add-ons
Default BBCode formatting for user's posts - FULL VERSION vBulletin 3.5 Add-ons

vblts.ru supports vBulletin®, 2022-2024