The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Default BBCode formatting for user's posts - FULL VERSION Details »» | |||||||||||||||||||||||||||
Default BBCode formatting for user's posts - FULL VERSION
Developer Last Online: Nov 2013
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> 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> ------------------------------------------------- In postbit and postbit_legacy FIND Code:
$post[message] 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> ------------------------------------------------- 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]" /> Code:
<input type="hidden" name="defaultbbcode" value="1" /> In newreply.php and newthread.php FIND Code:
if ($vbulletin->userinfo['signature'] != '') { $checked['signature'] = 'checked="checked"'; } else { $checked['signature'] = ''; } [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)); Code:
$show['misc_options'] = ($vbulletin->userinfo['signature'] != '' OR $vbulletin->userinfo['field123'] OR $show['parseurl'] OR !empty($disablesmiliesoption)); ------------------------------------------------- In showthread.php FIND Code:
// set show signature hidden field $showsig = iif($vbulletin->userinfo['signature'], 1, 0); Code:
// set show default bbcode hidden field $showdefaultbbcode = iif($vbulletin->userinfo['field123'], 1, 0); ------------------------------------------------- In includes/class_dm_threadpost.php FIND Code:
case 'pagetext': case 'allowsmilie': case 'showsignature': case 'ipaddress': 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'] = ''; Code:
$this->post['defaultbbcode'] = ''; In includes/functions_newpost.php FIND Code:
// set options $dataman->setr('showsignature', $post['signature']); $dataman->setr('allowsmilie', $post['enablesmilies']); Code:
$dataman->setr('usedefaultbbcode', $post['defaultbbcode']); 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"'), 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
|
Comments |
#12
|
||||
|
||||
This will show everyone else your posts with your specific BBCode formatting.
|
#13
|
||||
|
||||
does this still work with 3.6?
|
#14
|
||||
|
||||
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. |
#15
|
|||
|
|||
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'); |
#16
|
|||
|
|||
hi,
does it work with 3.6.8? |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|