Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: ~Killer~ on February 16, 2009, 06:18:12 AM

Title: Restrictive BBCode
Post by: ~Killer~ on February 16, 2009, 06:18:12 AM
Well I'm using SMF 2.0 BETA 4 (I don't want to upgrade yet, for various reasons), and I have a few BBCodes (ModBreak specificly) that I want to restrict to just Moderators and Administrators to use, but how exactly can I do this, I don't want to let other regular members use it, just Mods...
Title: Re: Restrictive BBCode
Post by: Kermit on February 16, 2009, 07:02:38 AM
You can try that

Sources/Subs-Post.php

Code (find) Select

if (!$previewing && strpos($parts[$i], '[html]') !== false)
{
if (allowedTo('admin_forum'))
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'
\', \'  \' => \'  \')) . \'[/html]\'', $parts[$i]);
// We should edit them out, or else if an admin edits the message they will get shown...
else
{
while (strpos($parts[$i], '[html]') !== false)
$parts[$i] = preg_replace('~\[[/]?html\]~i', '', $parts[$i]);
}
}




Code (replace with) Select

if (!$previewing && strpos($parts[$i], '[html]') !== false)
{
if (allowedTo('admin_forum'))
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'
\', \'  \' => \'  \')) . \'[/html]\'', $parts[$i]);
// We should edit them out, or else if an admin edits the message they will get shown...
else
{
while (strpos($parts[$i], '[html]') !== false)
$parts[$i] = preg_replace('~\[[/]?html\]~i', '', $parts[$i]);
}
}

    if (!$previewing && strpos($parts[$i], '[modbreak]') !== false)
{
if (allowedTo('moderate_board'))
$parts[$i] = preg_replace('~\[modbreak\](.+?)\[/modbreak\]~ise', '\'[modbreak]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'
\', \'  \' => \'  \')) . \'[/modbreak]\'', $parts[$i]);
// We should edit them out, or else if an admin edits the message they will get shown...
else
{
while (strpos($parts[$i], '[modbreak]') !== false)
$parts[$i] = preg_replace('~\[[/]?modbreak\]~i', '', $parts[$i]);
}
}
Title: Re: Restrictive BBCode
Post by: ~Killer~ on February 16, 2009, 10:04:05 AM
Thanks alot, I'll try that later and tell ya if it works ^_^

So I'll just replace "ModBreak" with the name of the BBCode for another one? Great!
Title: Re: Restrictive BBCode
Post by: ~Killer~ on February 17, 2009, 11:59:16 AM
That didn't work :'(
Title: Re: Restrictive BBCode
Post by: ~Killer~ on February 19, 2009, 05:43:03 AM
Bump.
Title: Re: Restrictive BBCode
Post by: Kermit on February 19, 2009, 05:57:28 AM
Quote from: ~Killer~ on February 17, 2009, 11:59:16 AM
That didn't work :'(

But it should work,i've tested it on my test forum,it's worked flawless
Title: Re: Restrictive BBCode
Post by: ~Killer~ on February 20, 2009, 05:06:30 PM
:S Well it's not working... Could you do it for me, I swear it's not working.
Title: Re: Restrictive BBCode
Post by: Mr. Jinx on March 30, 2009, 02:08:32 PM
Thanks Duncan85. This works very nice (SMF 1.1.8!) in combination with the modbreak mod. 8)

Would it also be possible to filter things like [modbreak=test]bla bla[/modbreak] ?
Currently it filters [modbreak]bla bla[/modbreak]
Title: Re: Restrictive BBCode
Post by: buspass on March 31, 2009, 10:35:44 AM
What about disabling a tag like (url)(/url) either by membergroup or for a specific board?
Title: Re: Restrictive BBCode
Post by: Mr. Jinx on April 11, 2009, 04:03:14 AM
Quote from: Mr. Jinx on March 30, 2009, 02:08:32 PM
Thanks Duncan85. This works very nice (SMF 1.1.8!) in combination with the modbreak mod. 8)

Would it also be possible to filter things like [modbreak=test]bla bla[/modbreak] ?
Currently it filters [modbreak]bla bla[/modbreak]

Anyone please?
Title: Re: Restrictive BBCode
Post by: Bulakbol on April 15, 2009, 04:46:54 AM
The best place to ask about modbreak mod is the author in the support/comment topic. Please post your issue here (http://www.simplemachines.org/community/index.php?topic=141374.60).