Advertisement:

Author Topic: Permissions for BBC, or another way to remove certain BBC buttons?  (Read 436 times)

Offline Dwev

  • Jr. Member
  • **
  • Posts: 212
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?

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 56,495
  • Gender: Male
    • Kindred-999 on GitHub
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #1 on: January 12, 2018, 10:55:22 PM »
No, your bets option would be to remove the option from the bbc button creation array
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Dwev

  • Jr. Member
  • **
  • Posts: 212
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #2 on: January 13, 2018, 06:06:32 AM »
But that means that the code isn't useable anymore, so not really an option...  :(

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,812
    • Arantor on GitHub
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #3 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline Dwev

  • Jr. Member
  • **
  • Posts: 212
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #4 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, so might this be a problem of that mod specifically?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,812
    • Arantor on GitHub
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #5 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline Dwev

  • Jr. Member
  • **
  • Posts: 212
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #6 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..!   ;)

Offline Dwev

  • Jr. Member
  • **
  • Posts: 212
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #7 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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,812
    • Arantor on GitHub
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #8 on: January 13, 2018, 09:17:26 AM »
This is the list from a mostly stock 2.0.14:

Code: [Select]
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
« Last Edit: January 13, 2018, 09:39:00 AM by Illori »
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline Dwev

  • Jr. Member
  • **
  • Posts: 212
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #9 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).

Code: [Select]
//array(
// 'image' => 'center',
// 'code' => 'center',
// 'before' => '[center]',
// 'after' => '[/center]',
// 'description' => $txt['center']
//),

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,812
    • Arantor on GitHub
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #10 on: January 13, 2018, 10:50:55 AM »
Yeah, that works.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline Steve

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 4,302
  • Gender: Male
  • I have not yet begun to procrastinate.
Re: Permissions for BBC, or another way to remove certain BBC buttons?
« Reply #11 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. :)
Online Manual

Please do not PM me for support.