How it Started: Main idea was to have bbcodes that only moderators can use (when editing user posts, for example), ideally with moderator username placed into place automatically. I searched phpBB forums and Internet, and even though many users had similar request/wish, I couldn`t find anything like it
After a while, I found
4S-BB-Control MOD that have BBCode permissions feature, plus so many great other possibilities! (go check it, maybe you`ll like that one instead, it is a great MOD) But, installation looked a bit long and complicated for editing "by-hand", and as our forums have so many custom codes I was afraid to install it automatically - mostly because I didn`t need all the features it offered after all. I wanted something easy to install/use, with features I needed, and without any particularly advanced options.
So, as what I needed wasn`t available at the moment (or at least I couldn`t find it), I decided to try to make it myself... and I did
I need to note here that I`m pretty new to both phpBB and PHP itself, so please forgive me if I made anything in a bit harder way
As I have pretty decent coding experience (C, Pascal, Delphi, C#...), and with help from my friend
_PkZ_ regarding some PHP or phpBB questions, I made it work the way I wanted... well, eventually.
Because of my, already mentioned, humble phpBB knowledge, the MOD lacks some more "user friendly" interface (as ACP module would be), but I tried to make setting it the way you want as easy as possible, editing the core MOD file -
includes/bbcode_group.php
. To make this editing process even easier, I`ll give some examples here.
How to Use the MOD: The easiest thing you can do is install it, either through MODX auto installation, or by editing your files manually, create custom bbcode(s) to use with this MOD, and set MOD options (inside bbcode_group.php file).
Installation: As the original idea was to have an easy to install (manually, "by-hand") MOD, there is only one file to copy to your "includes" folder, and three phpBB files to edit - adding the custom function that will check bbcodes where/when needed. Check
install_mod.xml
for instructions.
Once you installed the MOD, you can create custom bbcodes to use with it.
Custom BBCode(s): I`ll give an example of two working bbcodes that can be used "out of the box", with minimal MOD settings needed.
Go to
Administration Control Panel > Posting > BBCodes, and click
Add a new BBCode. Copy the given text into appropriate fields.
BBCode usage:
HTML replacement:
Code: Select all
<div style="color:#404040; background-color: #FFE6E6; padding: 6px 6px 6px 6px; border: 1px dashed #FFCCCC; border-left: 10px solid #FFCCCC;">{TEXT}</div>
Help line:
Leave "Display on posting page" blank (do not check it). It`s not a problem even if users see the BBCode, but they can`t use it anyway, so no logic to see it.
Click
Submit.
There, we created one BBCode, one more to go. Click
Add a new BBCode again, and copy the text to appropriate fields.
BBCode usage:
Code: Select all
[modname={SIMPLETEXT}]{TEXT}[/modname]
HTML replacement:
Code: Select all
<div style="color:#404040; background-color: #FFE6E6; padding: 6px 6px 6px 6px; border: 1px dashed #FFCCCC; border-left: 10px solid #FFCCCC;">Edited by <strong>{SIMPLETEXT}</strong>: <i>{TEXT}</i></div>
Help line:
Code: Select all
[modname]Moderator text here[/modname]
Notice the help line, where I referred to bbcode as [modname], instead of [modname=USERNAME]. It is not a mistake, don`t worry, wait and see
Leave "Display on posting page" blank again (do not check it), and click
Submit.
Now that we made two custom bbcodes for moderators only, we need to actually make them moderator only
We shall accomplish that by setting the MOD inside "includes/bbcode_group.php" file.
Setting the MOD: Open
includes/bbcode_group.php
file. If you don`t have any PHP programming experience, know that you can open it with Notepad, that simple text editor that comes with Windows
If you are an old PHP wolf, use whatever editor you prefer
What we need to do now is to see what is Global Moderators group id number. Maybe there is another (easier?) way to see this, but I know this one and I`m showing it to you (I saw it here at phpBB forums, but forgot who posted it, sorry
) - go to
Administration Control Panel > Users and Groups > Manage groups.
(click to enlarge)
In the given example, we see that "Global moderators" id number is 4. See what id number is at your forums, and memorize it (or write it down). Back to "bbcode_group.php" now...
Find:
Code: Select all
$modgroups = array( // settings for groups of users, permissions to use bbcodes
// id#
4 => array
Instead of number 4, put the number of "Global moderators" group at your forum. If it is the same, you don`t have to change anything
If you change it, don`t forget to save the edited file.
That`s all! Now only users that have "Global moderators" as their default group can use our custom bbcodes, [mod] and [modname]
Usage examples:
When a user with "Global moderators" group as his default group enters this into his message:
Code: Select all
[mod]This is moderator`s message, please behave.[/mod]
... he should get this:
When a user with "Global moderators" group as his default group enters this into his message:
Code: Select all
[modname]This is moderator`s message, please behave.[/modname]
... he should get this:
... where
BugA is username of the moderator that edited/posted the message.
If moderator
Mike tries to use the bbcode as:
Code: Select all
[modname=BugA]This is moderator`s message, please behave.[/modname]
... he will still get his correct username inside, not the fake one:
If a regular user edits/quotes the post, or tries to use bbcodes we assigned to "Global moderators" group only, the complete bbcode (along with text inside) will be removed, can`t be posted by regular user (nor any user other from "Global moderators" group).
Final notes: And that would conclude this (short? lol) tutorial on using the MOD. I made the MOD for our forums, and wanted to share it here because I saw that many people asked for something like this, but it wasn`t available yet.
For additional options, like using other custom (or even phpBB default) bbcodes, leaving the text inside bbcodes when removing bbcodes for regular users, or turning off fake-username check, examine SETTINGS section inside
includes/bbcode_group.php
file.
Feel free to post here if you encounter any problems, find bugs, or you need help, and please remember that I`m still new to all this (PHP/phpBB)
Cheers,
BugA