==README for Signatures Solution==
Release date: July 10, 2005.
Latest update: June 7, 2023.
miniBB version: 3.6+
Author: Paul Puzyrev (minibb.com).

With this solution (the principles of it are built-in miniBB) you may allow your visitors to add Signatures to their messages. Every time user changes his signature, it is changed automatically in his every message. 

==INSTALLATION==

By default, signature solution uses 'user_custom2' field of default miniBB database. If you're installing this add-on in default mode, DO NOT apply any extra changes to database.


However, depending on the customizations made, you can easily change the name of the signature field, specifying it in setup_options.php' "$dbUserSheme" array, and changing it in all HTML templates and PHP code snippets attached.

For example, if you would like to add a new field in database (let's say when integrating with WordPress blog), the command would be:

alter table wp_users add user_customsig varchar(2000) not null default '';

for $dbUserShema then paste the following (before the closing bracket and after the array's comma):

'user_customsig'=>array(17,'user_customsig','user_custom2')

and add 'user_customsig' (with apostrophes) to $userInfoInPosts array.

In bb_plugins.php code, you will need to change 'parseUserInfo_user_custom2' to 'parseUserInfo_user_customsig', for templates/main_posts_cell.html you should have {$userInfo_user_customsig[$poster_id]}. bb_plugins_user.php code should contain $sig_field='user_customsig';

==================================

Edit lang/eng.php of whatever default language pack you have on your forum, and paste/translate before the closing ?> tag the code located in lang/eng.code.txt of this package (or from another language pack).

==================================

Copy from this package to the same folder of your forum:

templates/addon_signatures_userform.html
templates/addon_signatures_userform.js

==================================

Edit templates/user_dataform.html, add paste the following:

{$signaturesJs} - in the JavaScript section, between the top <script></script> tags;

{$signaturesForm} - in the form body, preferrably before the <tr> starting the `{$l_userInterest}` field.

==================================

Edit bb_plugins.php and paste the code provided in bb_plugins.code. Here you're able to change a HOW a user's signatue will look in the thread message. Feel free to apply any kind of HTML/CSS styling.

==================================

Edit templates/main_posts_cell.html and paste the variable {$userInfo_user_custom2[$poster_id]} which will be substituted as user's signature, most preferrably before closing </div>, like here:

<div class="postedText">{$posterText}{$userInfo_user_custom2[$poster_id]}</div>

==================================

Edit setup_options.php and in "$userInfoInPosts" array, specify signatures field:

$userInfoInPosts=array($dbUserSheme['user_custom2'][1]);

If you are using additional user info in post, just ADD new array element listing it by comma, do not paste this code exactly. Example:

$userInfoInPosts=array($dbUserSheme['user_custom2'][1], $dbUserSheme['num_posts'][1]);

==================================




BY THIS TIME, signatures already should be enabled. Please check them now. However, they will saved only as plain text, with no breakes, BB codes allowed or any other special attributes. That way you will just set up "plain signatures". If you would like to make them "rich", with special attributes, proceed to the next steps.



==================================

Only if you'd like some BB-codes and linebreaks enabled in Signatures, copy bb_codes_sig.php to your forums folder (if file is not present, this function will be disabled). This is the file containing functions similar to the forum BB-functions from bb_codes.php. You can set up your own BB codes here or cut off/mofify some existing code. Basically, it is not the best practice to allow using of rich BB codes in the signatures as for forum messages. For example, most preferrably all URLs should have "nofollow" attribute, images should be allowed to display without additional linkage etc. At the same time it's nice to allow color-making text codes.

==================================

Edit bb_plugins_user.php and paste the code provided in bb_plugins_user.code.txt (preferrably at the top of this file, right after the opening <?php tag).

==================================

It is recommended to change the length of the text field in database, which holds the signature; for example:

alter table minibbtable_users modify column user_custom2 varchar(2000);

==================================



Signatures should be available to edit in user's Preferences after successful installation.


==CONFIGURATION==

Signatures are (and should be) limited in length. They should look like a short piece of text or graphics, not an essay.

The first 128 characters of Unicode/ASCII symbols, which include regular latin-based symbols, digits and some specific symbos like backslash, take 1 byte of space. In a foreign encoding, a "char" could stand for a symbol taking 2-4 bytes. You should count on it while setting up the signature limitations - both on the browser side and in the database.

The Limitation which is *entered in a browser*, is set under templates/addon_signatures_userform.js - check the line of code which looks like: `var fMax=150;`. You could adjust the entered value of chars here. It's not about the length reserved in the database - and it should not be equal to database field's length! All BB codes are also included in this limitation. Users should think about their priorities - either to post a long URL, either to post a simple text. This all counts for your traffic and pages load, in general.

JavaScript, surely, doesn't suppose a safe method of limitation, so in PHP code, in bb_plugins_user.php - `//trimming to a certain length` `textFilter` function - the limit to trim a signature is defined, and if it's length exceeds some value, the submitted value is being cut-off. By default, the submitted signature is trimmed to 600 chars (Limitation of 150 in the browser's form multiplied to 4 max.bytes per symbol).

Despite of it, the database field still could have a reserve for a bigger value, like mentioned above (look up for `varchar(2000)`). In the database configuration, the final limitation is set. As mentioned in the SQL statement above, 2000 chars should cover the most issues, however you could make it a bigger value, adjusting all limitations mentioned above.

So, depending on your forum's subject and encoding, you could set up different limitations:

- for a browser form
- in the submitted value's code workout
- in the database.


==FINALLY==
Enjoy using miniBB! Our forums will help you more:
http://www.minibb.com/forums/11_4311_0.html