PDA

View Full Version : Allow a user to disable smileys (because of epilepsy)


BirdOPrey5
04-14-2011, 12:32 AM
Hello all- I've been working on this all day and can't believe it's not a simple edit- maybe it is and I'm missing something.

I have a new member who says they are epileptic and they have some concerns that some of my larger animated smileys may trigger a seizure. He already browses with images turned off.

I can't find any option to disable smielys per user but I know it's possible. I've been all through class_bbcode.php trying all the hooks and all the options I can think of to disable smileys and none of it seems to work.

I also searched and searched and can't believe this hasn't been asked before. I found a mod for VB 2.x to do this but the code doesn't work on 3.x.

Anyone have any ideas how to do this via a plugin? Once I get how I will work it into a custom user profile field to let people disable them if they want.

What I had been trying was stuff like:

$allowsmilies = false;
$dosmilies = false;
$do_smilies = false;
$forum['allowsmilies'] = false;


In all the BB Code hooks and the showthread_start/complete hooks.

I really only need disable their view in forum posts- they are almost never used elsewhere.
:confused:

kh99
04-14-2011, 01:15 AM
The problem seems to be post caching - I set $dosmilies = false at bbcode_parse_start, but it only changes when the post cache is rebuilt. I tried to set $post_cachable = false at showthread_post_start, but that didn't work. showthread.php is too complicated to for me to figure out tonight :confused:

BirdOPrey5
04-14-2011, 02:36 AM
LOL... at least I'm not crazy... I will keep working on this too, will post up if I find anything.

kh99
04-14-2011, 06:08 PM
OK, if you also put $parsedtext = '' at bbcode_parse_start (as well as $dosmilies = false, both inside some if condition I'd assume), and also put $post_cachable = false (ETA: at showthread_post_start, that is) (probably inside the same if condition), then it seems to work. Well, at least it turns smilies on and off depending on how you set $dosmilies, but I haven't tested to make sure it doesn't affect what other users see.

Another thought was to somehow make a style that has smilies turned off. The caching stuff seems to be separate for different styles, so that might eliminate that problem.

BirdOPrey5
04-14-2011, 11:20 PM
OK, if you also put $parsedtext = '' at bbcode_parse_start (as well as $dosmilies = false, both inside some if condition I'd assume), and also put $post_cachable = false (ETA: at showthread_post_start, that is) (probably inside the same if condition), then it seems to work. Well, at least it turns smilies on and off depending on how you set $dosmilies, but I haven't tested to make sure it doesn't affect what other users see.

Another thought was to somehow make a style that has smilies turned off. The caching stuff seems to be separate for different styles, so that might eliminate that problem.

The style idea is excellent... will look into that... thanks. :up:

Lynne
04-15-2011, 02:57 AM
Mobile styles have smiles (images) disabled by using replacement variables. Just use that code for a new style or write it up as a plugin that gets turned 'on' via a user profile field - Disable Smilies? Yes/No.

BirdOPrey5
04-15-2011, 10:39 PM
Hmmm... the mobile styles I have use the replacement variables to change the HTML of inline images only, they don't work on smilies- I could probably edit it to work on all images but I really don't want to disable all images.

I got a preg_replace going on bbcode_parse_start that removes the colons (:) from a smiley name and replaces it with Italics tags so the name of the smiley displays instead of the smiley... unfortunately I run into the same post cache issue I did last time I tried to modify code at this hook. If the post is cached it doesn't change. Shutting off the post cache for everyone isn't really an option.

What gets me is that anything I run on postbit_display_complete changes all the time regardless of the cache... I'd run my plugin on postbit_display_complete but smileys are already in HTML at this point.

I guess I could just do a str_replace on an array of HTML for the smileys I need to replace- it's a limited number- I don't need to disable all of them, just a handful really.

Surprised this has never come up before.

Is there a "hook" that the replacement variables run on?

Edit- I see- replacement_vars

kh99
04-15-2011, 11:33 PM
I had been thinking maybe you could make a copy of a style and then in a plugin at bbcode_parse_start put something like

if ($styleid == X)
{
$dosmilies = false
}

(But I don't know if $styleid is available there or not. I didn't try this or anything).

BirdOPrey5
04-16-2011, 02:22 AM
That may work, if it was a new style...

I ended up going with basically my own "Replacement Variables" that work on all styles. I put a line of HTML into one box and a replacement text into another...

I use it to disable my biggest/most animated smileys but really it could be used for anything.

Should work for me needs... Needs a little polishing, I'll probably release it if it can be of help to anyone.

Thanks everyone for the help. :)

BirdOPrey5
04-17-2011, 08:45 PM
OK, got this working finally how I wanted it. The key was using the replacement variable hook, Thanks Lynne.

I can now disable all smileys and replace with their names. I also kept the part where I put a whole image tag in and disable that image as well since there are a few popular flashing images my users seem to post and post over again.

I cleaned it up and released it as mod in case anyone in the future finds this in a search, it's here: https://vborg.vbsupport.ru/showthread.php?t=262159