Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Default BBCode formatting for user's posts - FULL VERSION Details »»
Default BBCode formatting for user's posts - FULL VERSION
Version: 1.03, by antialiasis antialiasis is offline
Developer Last Online: Nov 2013 Show Printable Version Email this Page

Version: 3.5.4 Rating:
Released: 04-09-2006 Last Update: 04-21-2006 Installs: 14
DB Changes Uses Plugins Template Edits
Code Changes Is in Beta Stage  
No support by the author.

This hack in a nutshell: All users on your forum will be able to add optional BBCode to format all of their posts with.

This was inspired by DarthCow's user setable default BB code formatting for each post hack for vBulletin 3.0, borrows a couple of regular expressions from it and used it for reference in one spot. Everything else is my own.

Version 1.03: Regular expression bug with colors and fonts fixed. SQL query added to install code.

Version 1.02: Regular expression for "Default BBCode" field edited to support fonts with spaces in them.

Version 1.01: One file edit was moved to a plugin, which allows the Lite version to be pure plugins. No functionality was changed, so if you already installed version 1.0, there is no particular reason to upgrade; however, if you do want to, simply install the new product and undo the file edit by finding and removing this from includes/class_postbit.php:

Code:
$this->post['defaultbbcodes'] = $this->bbcode_parser->parse($this->post['defaultbbcodes'], $this->forum['forumid'], $this->post['allowsmilie']);

		$dbbctags = explode("MESSAGE", $this->post['defaultbbcodes']);
		$this->post['dbbcopen'] = $dbbctags[0];
		$this->post['dbbcclose'] = $dbbctags[1];


ADDITIONAL FEATURES

-enable or disable default BBCode for individual posts you make
-choose in your user CP whether to see any default BBCode at all

I should note that I have very little previous experience of PHP (although I'm not new to general website scripting) and this is my first real hack. It was a challenge to make, perhaps more challenging than I assumed it would when I started it. But as I'm new to this, the code is most likely not the neatest you've ever seen, and there may be unnecessary file edits that could be made into plugins, etc. although I did my best to fit everything I could into the plugin system. All I know is that it works like a dream for me.

There are almost certainly bugs or something, so I'm releasing this as a beta and any pointers to make the installation less of a hassle would be greatly appreciated. Please excuse if there is anything I've done dreadfully wrong in the format of this, too. I will do my best to provide support, although I can't promise I'll be able to solve all your problems.

1 Product install
2 Custom profile fields
3 Template edits (in 6 templates)
7 File edits (in 6 files)
2 Plugin edits

There is a "lite version" too: if all those file edits are scaring you away, they are only present because of the feature to enable or disable default BBCode in a particular post. I can imagine quite a lot of situations where members would really not want their default BBCode on one particular post of theirs so the hack is definitely better with it, but if you would rather be using a plugin version with one template edit, go to this thread


INSTALLATION INSTRUCTIONS

1. Download the product and import it.
2. Add two custom profile fields:

Profile field type: Single-line textbox
Title: Default BBCode
Description: You may choose to make a default BBCode formatting for each post. Allowed tags: [b] [i] [u] [left] [right] [center] [font] [color] [size] Please type in only the opening tags.
Max length of allowed user input: Doesn't really matter, but make sure it's enough
Display size: 25
Field Required: No
Field Editable by User: Yes
Private Field: Yes
Field Searchable on Members List: No
Show on Members List: No
Regular expression: ^(\[(b|i|u|left|right|center|font|color|size)(\=(\'|") ?(#[0-9a-fA-F]+)?[\w\s]+)?('|")?\])*$
Display Page: Options: Other

(Here you can edit the description and regular expression to allow or disallow BBCode - in the regular expression, just make sure to separate all of them with |.)

Profile field type: Single-selection radio buttons
Title: Show Default BBCode?
Description: Selecting no will cause all posts to be displayed without users' automatic BBCode formatting.
Options: Yes
No
Set Default: Yes
Field Required: No
Field Editable by User: Yes
Private Field: Yes
Field Searchable on Members List: No
Show on Members List: No
Allow user to input their own value for this option: No
Display Page: Options: Thread Viewing

3. Make the following edits:



############## TEMPLATE EDITS ###################

In newreply, newthread and editpost

FIND

Code:
						<if condition="$bbuserinfo['signature'] != ''"><div><label for="cb_signature"><input type="checkbox" name="signature" value="1" id="cb_signature" tabindex="1" $checked[signature] />$vbphrase[show_your_signature]</label></div></if>
BELOW it add

Code:
						<if condition="$bbuserinfo['field123'] != ''"><div><label for="cb_defaultbbcode"><input type="checkbox" name="defaultbbcode" value="1" id="cb_defaultbbcode" tabindex="1" $checked[defaultbbcode] />$vbphrase[use_default_bbcode]</label></div></if>
Replace "field123" with your "Default BBCode" field.

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

In postbit and postbit_legacy

FIND

Code:
$post[message]
REPLACE with

Code:
                   <if condition="$post['dbbcopen'] AND $post['usedefaultbbcode'] AND ($bbuserinfo['field234'] == 'Yes')">$post[dbbcopen]</if>
                   $post[message]
                   <if condition="$post['dbbcclose'] AND $post['usedefaultbbcode'] AND ($bbuserinfo['field234'] == 'Yes')">$post[dbbcclose]</if>
Replace "field234" with your "Show Default BBCode?" field.

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

In SHOWTHREAD

FIND

Code:
			<input type="hidden" name="fromquickreply" value="1" />
			<input type="hidden" name="s" value="$session[sessionhash]" />
			<input type="hidden" name="do" value="postreply" />
			<input type="hidden" name="t" value="$threadid" id="qr_threadid" />
			<input type="hidden" name="p" value="$qrpostid" id="qr_postid" />
			<input type="hidden" name="parseurl" value="1" />
			<input type="hidden" name="loggedinuser" value="$bbuserinfo[userid]" />
BELOW it add

Code:
                        <input type="hidden" name="defaultbbcode" value="1" />
################## FILE EDITS ###################

In newreply.php and newthread.php

FIND

Code:
		if ($vbulletin->userinfo['signature'] != '')
		{
			$checked['signature'] = 'checked="checked"';
		}
		else
		{
			$checked['signature'] = '';
		}
BELOW it add

[code] // default bbcode
if ($vbulletin->userinfo['field123'] != '')
{
$checked['defaultbbcode'] = 'checked="checked"';
}
else
{
$checked['defaultbbcode'] = '';
}[code]

Replace "field123" with your default BBCode field.

Also FIND

Code:
	$show['misc_options'] = ($vbulletin->userinfo['signature'] != '' OR $show['parseurl'] OR !empty($disablesmiliesoption));
REPLACE with

Code:
	$show['misc_options'] = ($vbulletin->userinfo['signature'] != '' OR $vbulletin->userinfo['field123'] OR $show['parseurl'] OR !empty($disablesmiliesoption));
Again, replace "field123" with your default BBCode field.

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

In showthread.php

FIND

Code:
	// set show signature hidden field
	$showsig = iif($vbulletin->userinfo['signature'], 1, 0);
BELOW it add

Code:
	// set show default bbcode hidden field
	$showdefaultbbcode = iif($vbulletin->userinfo['field123'], 1, 0);
Replace "field123" with your field again.

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

In includes/class_dm_threadpost.php

FIND

Code:
			case 'pagetext':
			case 'allowsmilie':
			case 'showsignature':
			case 'ipaddress':
BELOW it add

Code:
			case 'usedefaultbbcode':
-------------------------------------------------

In includes/class_postbit.php

FIND

Code:
	/**
	* Process this post's user info assuming its a guest.
	*/
	function process_unregistered_user()
	{
		global $show, $vbphrase, $vbulletin;

		$this->post['rank'] = '';
		$this->post['postsperday'] = 0;
		$this->post['displaygroupid'] = 1;
		$this->post['musername'] = $this->post['username'] = $this->post['postusername'];
		$this->post['musername'] = fetch_musername($this->post, 'displaygroupid', 'musername');
		//$this->post['usertitle'] = $vbphrase['guest'];
		$this->post['usertitle'] =& $this->registry->usergroupcache["0"]['usertitle'];
		$this->post['joindate'] = '';
		$this->post['posts'] = 'n/a';
		$this->post['avatar'] = '';
		$this->post['profile'] = '';
		$this->post['email'] = '';
		$this->post['useremail'] = '';
		$this->post['icqicon'] = '';
		$this->post['aimicon'] = '';
		$this->post['yahooicon'] = '';
		$this->post['msnicon'] = '';
		$this->post['skypeicon'] = '';
		$this->post['homepage'] = '';
		$this->post['findposts'] = '';
		$this->post['signature'] = '';
		$this->post['reputationdisplay'] = '';
		$this->post['onlinestatus'] = '';
BELOW it add

Code:
		$this->post['defaultbbcode'] = '';
--------------------------------------------------

In includes/functions_newpost.php

FIND

Code:
	// set options
	$dataman->setr('showsignature', $post['signature']);
	$dataman->setr('allowsmilie', $post['enablesmilies']);
BELOW it add

Code:
	$dataman->setr('usedefaultbbcode', $post['defaultbbcode']);
Also FIND

Code:
// ###################### Start processcheckboxes #######################
function construct_checkboxes($post)
{
	global $checked;

	$checked = array(
		'parseurl' => iif($post['parseurl'], 'checked="checked"'),
		'disablesmilies' => iif($post['disablesmilies'], 'checked="checked"'),
		'signature' => iif($post['signature'], 'checked="checked"'),
BELOW it add
Code:
		'defaultbbcode' => iif($post['defaultbbcode'], 'checked="checked"'),



################## PLUGIN EDITS ##################

After installing the product, you will have to edit the following plugins:

Set default BBCode for post preview
Default BBCode setup

Find "field6" in both of them and replace it with your default BBCode field.



At this point the installation should be complete. Enjoy!

Show Your Support

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

Comments
  #12  
Old 06-19-2006, 01:06 AM
antialiasis's Avatar
antialiasis antialiasis is offline
 
Join Date: Jan 2006
Location: Iceland
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This will show everyone else your posts with your specific BBCode formatting.
Reply With Quote
  #13  
Old 10-03-2006, 07:50 PM
Zelos's Avatar
Zelos Zelos is offline
 
Join Date: Jun 2006
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

does this still work with 3.6?
Reply With Quote
  #14  
Old 12-31-2006, 04:21 PM
Saskia's Avatar
Saskia Saskia is offline
 
Join Date: Oct 2005
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This no longer works with the Quick Reply or New Post option anymore after I upgraded to 3.6.4, yet it remains working with the Edit Post option.

Could this be ported? It's been of immense use to my members and the board in general. I'd appreciate it a lot! Cheers.
Reply With Quote
  #15  
Old 07-01-2007, 07:12 AM
cmwg cmwg is offline
 
Join Date: Apr 2006
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Works fine with 3.6.7

just the last part is a bit tricky since this has changed. Just add defaultbbcode to the listing of variables in the array.

like so:

Code:
// default array keys
	$default_keys = array('parseurl', 'disablesmilies', 'signature', 'postpoll', 'receipt', 'savecopy', 'stickunstick', 'openclose', 'sendanyway','defaultbbcode');
Reply With Quote
  #16  
Old 08-02-2007, 10:38 PM
Hannah_HH Hannah_HH is offline
 
Join Date: Jul 2007
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hi,

does it work with 3.6.8?
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 06:51 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.03982 seconds
  • Memory Usage 2,279KB
  • Queries Executed 20 (?)
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
  • (21)bbcode_code
  • (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
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)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