Expand my Community achievements bar.

SOLVED

RTE Source Edit button only for Administrators

Avatar

Level 2

How can I only allow administrators access to the Source Edit button in the RTE? (AEM 6.5) Is there a permission I can use?

I am trying to avoid turning it on and off from the template.
bb47_0-1682129506193.png


1 Accepted Solution

Avatar

Correct answer by
Community Advisor

We can use the dialog submit call.

 

$(document).on("click", ".cq-dialog-submit", function (e) {
            //On submit this is invoked
// Ajax call to servlet here         });

An example here - Call any servlet in touchUI dialog |AEM 6.3+ – AEM Queries & Solutions (wordpress.com)

 

javascript - dialog-ready event does not fire when dialog opens in AEM 6.1? - Stack Overflow

 

Sling Servlet in AEM – AEM CQ5 Tutorials

 

Thanks

 

 

View solution in original post

4 Replies

Avatar

Community Advisor

Hello,

 

We can have a custom servlet that gets invoked on dialog ready and checks the logged in user against user group that should have access to view the source edit. As a response, it can just be a boolean allowed = true or false. Based on that we can show or hide the sourceedit button.

 

Thanks

 

Shubham

Avatar

Level 2

That sounds doable. Do you have any documentation you could send me to set this in place?

Avatar

Correct answer by
Community Advisor

We can use the dialog submit call.

 

$(document).on("click", ".cq-dialog-submit", function (e) {
            //On submit this is invoked
// Ajax call to servlet here         });

An example here - Call any servlet in touchUI dialog |AEM 6.3+ – AEM Queries & Solutions (wordpress.com)

 

javascript - dialog-ready event does not fire when dialog opens in AEM 6.1? - Stack Overflow

 

Sling Servlet in AEM – AEM CQ5 Tutorials

 

Thanks

 

 

Avatar

Community Advisor

Hi! you can make use of ComponentContext here. Create a sling model, check if the current user is a part of administrators group and then set the decoration true. This would make it non-editable for other users and editable for the users which are a part of administrators user group. 

 

thanks,

Bilal