solved Custom Banning

TiG
TiG
@tig
6 years ago
184 posts
We have a need to censor select words but only on the more public face of the site. The censoring would not be done everywhere. Sounds like a perfect application for jrBanned with a little customization. :)

The docs suggest in various spots the following:

Quote:
The Banned Items module allows you to "ban" specific items from your site:

...

It also includes functionality for other modules to register additional ban "types" for use in the system.

I looked but could not find any examples of this in the code or in the documentation. Admittedly I may have missed it but I just do not see it.

So my question is how would I, for example, register a new type in jrBanned? I presume that I can do so in a module and that would add a new type ( e.g. 'censored' ) so that we could use jrBanned to create a list of censored words and then use jrBanned functions to test them in the specific contexts where we wish to apply them.

I just do not know how to register the new type. FIgured this would be a decent start (this is in the ntCensor module init):

    jrCore_register_module_feature('jrBanned','banned_type', 'ntCensor','censored');

But apparently not.




--
TiG

updated by @tig: 05/02/18 09:50:11AM
michael
@michael
6 years ago
7,746 posts
looks close, but appears to be wanting to receive an array (screenshot).

Try
$_opt = array(
'title' => "NT Censor",
'function' => 'ntCensor_banned_words'
);
    jrCore_register_module_feature('jrBanned','banned_type', 'ntCensor', $_opt);
banned.jpg
banned.jpg  •  199KB

TiG
TiG
@tig
6 years ago
184 posts
@michael

That helped quite a bit. The signature is slightly different but I have it working. The fourth parameter has to be a string (seems any string will suffice) so I passed 'censoring'. The key is the optional fifth parameter. This is where we pass the array to populate the type structure. So the working code is below:

$_opt = array('title' => 'Censored Word',
                  'function' => 'ntCensor_something' );
    jrCore_register_module_feature('jrBanned','banned_type', 'ntCensor', 'censoring', $_opt);

Apparently the only requirement for the function (ntCensor_something) is that it exist. Do you off hand know the purpose of this function? I will experiment, but if you already know .... :)

Thanks again for your help!


--
TiG
michael
@michael
6 years ago
7,746 posts
its got 2 parameters passed to the function, and wants a string back. so take $value, run it through your censor function and return the output string.
$value = "The cult of croft cost one cent to cast";

return $value;  // "the c$%t of c$%t c$%t one c$%t to c$%t "
censor.jpg
censor.jpg  •  181KB

TiG
TiG
@tig
6 years ago
184 posts
@michael

Yup I found it. Thanks for your help.


--
TiG
TiG
TiG
@tig
6 years ago
184 posts
@michael

We now have a context-specific censoring module to help the site maintain a 'nice' public face while allowing members to still express themselves (in the appropriate spots). A very good addition to the (substantially) more encompassing admin censoring control functionality we are adding.

It is great to be able to re-purpose JR functionality without having to reinvent the wheel!


--
TiG
michael
@michael
6 years ago
7,746 posts
:)

Tags