Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Dwev on January 12, 2018, 10:52:20 PM

Title: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Dwev on January 12, 2018, 10:52:20 PM
As far as I can see/find it used to be possible (with a Mod) to set permissions for BBC codes, but they aren't compatible with 2.0.xx.

I would like to be able to use most codes, but I want to show the users only a selection.
Turning certain codes off doesn't work, because it means that the codes can't be used anymore.

Making the button the color of the background seems to be the 'best' option so far (not exactly great), but maybe there is another solution?
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Kindred on January 12, 2018, 10:55:22 PM
No, your bets option would be to remove the option from the bbc button creation array
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Dwev on January 13, 2018, 06:06:32 AM
But that means that the code isn't useable anymore, so not really an option...  :(
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Arantor on January 13, 2018, 06:51:12 AM
No, if you remove it from the array in the editor, it just means the button doesn't get shown.
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Dwev on January 13, 2018, 07:55:55 AM
@ Arantor: if that were true I wouldn't ask.

Just tried switching off the float BBC-code and images are immediately not floated to the left or right anymore.
The code came from this mod (https://custom.simplemachines.org/mods/index.php?mod=2305), so might this be a problem of that mod specifically?
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Arantor on January 13, 2018, 08:00:40 AM
You're misunderstanding what we're saying.

There are two places bbcode are listed. One is in Subs.php, where the master bbc itself is defined. The other is in Subs-Editor.php which contains the list of buttons. You can remove them from Subs-Editor.php and they will be removed from the editor without them removed from functioning as bbcode.

There are plenty of bbcode that aren't given editor buttons, like tables - they're just not present in the Subs-Editor.php list.
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Dwev on January 13, 2018, 08:04:08 AM
@ Arantor: you're right, I understood that completely wrong.

But now I got it, so thanks a lot, I'm off to the Subs-Editor.php..!   ;)
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Dwev on January 13, 2018, 08:51:05 AM
Hmm, can someone give me a pointer to what to edit exactly in Subs-Editor.php to stop a button from showing?
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Arantor on January 13, 2018, 09:17:26 AM
This is the list from a mostly stock 2.0.14:


if (empty($context['bbc_tags']))
{
// The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you!
$context['bbc_tags'] = array();
$context['bbc_tags'][] = array(
array(
'image' => 'bold',
'code' => 'b',
'before' => '[b]',
'after' => '[/b]',
'description' => $txt['bold'],
),
array(
'image' => 'italicize',
'code' => 'i',
'before' => '[i]',
'after' => '[/i]',
'description' => $txt['italic'],
),
array(
'image' => 'underline',
'code' => 'u',
'before' => '[u]',
'after' => '[/u]',
'description' => $txt['underline']
),
array(
'image' => 'strike',
'code' => 's',
'before' => '[s]',
'after' => '[/s]',
'description' => $txt['strike']
),
array(),
array(
'image' => 'pre',
'code' => 'pre',
'before' => '[pre]',
'after' => '[/pre]',
'description' => $txt['preformatted']
),
array(
'image' => 'left',
'code' => 'left',
'before' => '[left]',
'after' => '[/left]',
'description' => $txt['left_align']
),
array(
'image' => 'center',
'code' => 'center',
'before' => '[center]',
'after' => '[/center]',
'description' => $txt['center']
),
array(
'image' => 'right',
'code' => 'right',
'before' => '[right]',
'after' => '[/right]',
'description' => $txt['right_align']
),
);
$context['bbc_tags'][] = array(
array(
'image' => 'flash',
'code' => 'flash',
'before' => '[flash=200,200]',
'after' => '[/flash]',
'description' => $txt['flash']
),
array(
'image' => 'img',
'code' => 'img',
'before' => '[img]',
'after' => '[/img]',
'description' => $txt['image']
),
array(
'image' => 'url',
'code' => 'url',
'before' => '[url]',
'after' => '[/url]',
'description' => $txt['hyperlink']
),
array(
'image' => 'email',
'code' => 'email',
'before' => '[email]',
'after' => '[/email]',
'description' => $txt['insert_email']
),
array(
'image' => 'ftp',
'code' => 'ftp',
'before' => '[ftp]',
'after' => '[/ftp]',
'description' => $txt['ftp']
),
array(),
array(
'image' => 'glow',
'code' => 'glow',
'before' => '[glow=red,2,300]',
'after' => '[/glow]',
'description' => $txt['glow']
),
array(
'image' => 'shadow',
'code' => 'shadow',
'before' => '[shadow=red,left]',
'after' => '[/shadow]',
'description' => $txt['shadow']
),
array(
'image' => 'move',
'code' => 'move',
'before' => '[move]',
'after' => '[/move]',
'description' => $txt['marquee']
),
array(),
array(
'image' => 'sup',
'code' => 'sup',
'before' => '[sup]',
'after' => '[/sup]',
'description' => $txt['superscript']
),
array(
'image' => 'sub',
'code' => 'sub',
'before' => '[sub]',
'after' => '[/sub]',
'description' => $txt['subscript']
),
array(
'image' => 'tele',
'code' => 'tt',
'before' => '[tt]',
'after' => '[/tt]',
'description' => $txt['teletype']
),
array(),
array(
'image' => 'table',
'code' => 'table',
'before' => '[table]\n[tr]\n[td]',
'after' => '[/td]\n[/tr]\n[/table]',
'description' => $txt['table']
),
array(
'image' => 'code',
'code' => 'code',
'before' => '[c ode]',
'after' => '[/co de]',
'description' => $txt['bbc_code']
),
array(
'image' => 'quote',
'code' => 'quote',
'before' => '[quote]',
'after' => '[/quote]',
'description' => $txt['bbc_quote']
),
array(),
array(
'image' => 'list',
'code' => 'list',
'before' => '[list]\n[li]',
'after' => '[/li]\n[li][/li]\n[/list]',
'description' => $txt['list_unordered']
),
array(
'image' => 'orderlist',
'code' => 'orderlist',
'before' => '[list type=decimal]\n[li]',
'after' => '[/li]\n[li][/li]\n[/list]',
'description' => $txt['list_ordered']
),
array(
'image' => 'hr',
'code' => 'hr',
'before' => '[hr]',
'description' => $txt['horizontal_rule']
),
);


If you want to remove a button, remove the array(...) that lists it.

[edit] added spaces in code tag to not parse -Illori
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Dwev on January 13, 2018, 10:12:43 AM
I was looking for a "true" that could be changed into "false", thanks guys, busy removing unneeded buttons right now.

I didn't remove the code though, just edited it out with double slahes (so if I ever would want to bring its back I don't have to look for the code).


//array(
// 'image' => 'center',
// 'code' => 'center',
// 'before' => '[center]',
// 'after' => '[/center]',
// 'description' => $txt['center']
//),
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Arantor on January 13, 2018, 10:50:55 AM
Yeah, that works.
Title: Re: Permissions for BBC, or another way to remove certain BBC buttons?
Post by: Steve on January 13, 2018, 04:52:34 PM
Marking solved then. If you have any other questions regarding this topic, by all means, mark this unsolved and let us know. :)