Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons

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
  #2  
Old 04-10-2006, 01:37 AM
The Chief's Avatar
The Chief The Chief is offline
 
Join Date: Aug 2005
Location: Montreal
Posts: 1,037
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

looks cool, thanks!
Reply With Quote
  #3  
Old 04-10-2006, 01:39 AM
RsX's Avatar
RsX RsX is offline
 
Join Date: Sep 2004
Location: Toronto
Posts: 101
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow! sounds like a great idea!

Installed
Thanks
Reply With Quote
  #4  
Old 04-10-2006, 06:50 AM
sensimilla sensimilla is offline
 
Join Date: Dec 2004
Location: Poland
Posts: 555
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great hack, although its a pity it requires so many file edits.

Thanks alot!
Reply With Quote
  #5  
Old 04-10-2006, 07:15 AM
BoYagoob BoYagoob is offline
 
Join Date: Jan 2005
Location: Doha
Posts: 199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for sharing ..
Reply With Quote
  #6  
Old 04-10-2006, 01:14 PM
antialiasis's Avatar
antialiasis antialiasis is offline
 
Join Date: Jan 2006
Location: Iceland
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the installs, everybody.

I just added instructions for a "lite version" to the first post. The lite version requires only one file edit and one template edit, so it should be much easier to install if you don't care for the option to enable or disable the default BBCode in individual posts.
Reply With Quote
  #7  
Old 04-10-2006, 06:28 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome! Thanks for releasing this hack!
Reply With Quote
  #8  
Old 04-10-2006, 10:02 PM
antialiasis's Avatar
antialiasis antialiasis is offline
 
Join Date: Jan 2006
Location: Iceland
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Upgraded to version 1.01 - one less file edit, one more plugin, and a plugin-only Lite version. I'm going to create another thread for it in vB 3.5 Plugins.
Reply With Quote
  #9  
Old 05-16-2006, 04:19 PM
IrPr IrPr is offline
 
Join Date: Mar 2005
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice Hack
any idea for Plugins instead of code modifications?
Reply With Quote
  #10  
Old 06-16-2006, 06:12 PM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As a user, would this show everyones posts with specific bbcode formatting or would this show everyone else my posts with specific bbcode formatting?
Reply With Quote
Reply

Thread Tools

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:56 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.04830 seconds
  • Memory Usage 2,316KB
  • Queries Executed 23 (?)
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
  • (20)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
  • (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