Fixed Dropdown button in editor

kick

Well-known member
Affected version
2.1.7
If you add a drop-down menu in the bb code editor and assign bbcodes there, assign viewing rights. And if the user does not have rights for these bb codes, then the drop-down button will still hang. It would be correct if the list for the user is empty, then do not display this drop-down menu in the editor.
 
We already have code to handle this in the cases where we remove buttons.

For example, if you consider the rich text editor when used to edit signatures, we do remove some buttons based on permissions there.

My attempted reproduction case was to set all permissions to never except "Allow images" and "Allow links".

1584115478273.webp

I then modified the editor button configuration so that "Insert image" and "Insert link" were in a drop down, and I included only that drop down in the editor.

1584115413549.webp

1584115432136.webp

With the permissions as configured above:

1584115509694.webp

With the permissions denying access to links and images:

1584115559340.webp

It seems as though we correctly remove a dropdown that is empty.

So with that in mind, you need to adjust your code so the same thing happens.
 
@Chris D, This works for Custom BB codes. I will give an example of reproduction in the Media Gallery.
1) Create dropdown
1584116569449.png
2) check event listener on gallery:
PHP:
public static function templaterTemplatePreRenderPublicEditor(\XF\Template\Templater $templater, &$type, &$template, array &$params)
    {
        if (isset($params['customIcons']['gallery']))
        {
            if (!self::visitor()->canViewMedia())
            {
                unset($params['customIcons']['gallery']);
            }
        }
    }
Well going in permission
1584116638723.png
3) Add in editor:
1584116672263.png
4) going in public part:
1584116720576.png
5) Trying give permission to view media
1584116779167.png
6) Check in public part
1584116839863.png
And it's work correctly and we can use dropdown menu. And the dropdown is not hiding
 
In that case, it is what I said, but it's actually XFMG that's wrong.

The code in XFMG (and presumably your own) should be similar to:

PHP:
public static function templaterTemplatePreRenderPublicEditor(\XF\Template\Templater $templater, &$type, &$template, array &$params)
{
   if (!self::visitor()->canViewMedia())
   {
      $params['removeButtons'][] = 'xfCustom_gallery';
   }
}
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XFMG release (2.1.8).

Change log:
When there is no permission to view media, ensure the custom BB code gallery button is removed appropriately.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom