Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

How to hide/disable "Add Comment" section in Asset Timeline

Avatar

Level 3

I have a required to hide/disable comment section in the asset timeline for a particular user group? Any advice on how can this be achieved?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

One of the ways to customise this would be to :

1. Get the current userGroups and check if they fall in the group for which commenting should not be allowed. Lets, assume the variable as isUnallowedUg.

function getLoggedInUserID() {
    var currentUserId = "";
    var currentUserInfo;
    var CURRENT_USER_JSON_PATH = Granite.HTTP.externalize('/libs/granite/security/currentuser.json');
    var result = Granite.$.ajax({
        type: "GET",
        async: false,
        url: CURRENT_USER_JSON_PATH
    });

    if (result.status === 200) {
        currentUserInfo = JSON.parse(result.responseText);
        currentUserId = currentUserInfo.authorizableId;
    }
    return currentUserId;
}





function getUserGroups(userID)
    var isMemberOfGroupEveryOne=false;

    $.ajax({
        url: "/bin/security/authorizables.json?filter=" + userID +'&_charset_=utf-8',
        async: false,
        success: function(result) {
            if (result) {
                $.each(result.authorizables,function(index,authObj){
                    if( (authObj.id !== userID)){
                        return;
                    }else {

                        $.each(authObj.memberOf,function(index,memberOf){
                            if(memberOf.id === 'everyone'){
                                isMemberOfGroupEveryOne=true;
                            }
                        });
                    }
                });
            }
        }
    });
    return isMemberOfGroupEveryOne;
}

I have used everyone for demo, you could use your custom group.

2. if isUnallowedUg is true, you would be hiding the class cq-common-admin-timeline-toolbar using display: none in CSS.

Hope this helps, thanks!

View solution in original post

3 Replies

Avatar

Community Advisor

You can add a Deny Access Control Policy rule with jcr:read privilege on this node

 

/libs/wcm/core/content/sites/jcr:content/rails/timeline/items/timeline/items/toolbar/actions/createcomment

Avatar

Correct answer by
Employee Advisor

One of the ways to customise this would be to :

1. Get the current userGroups and check if they fall in the group for which commenting should not be allowed. Lets, assume the variable as isUnallowedUg.

function getLoggedInUserID() {
    var currentUserId = "";
    var currentUserInfo;
    var CURRENT_USER_JSON_PATH = Granite.HTTP.externalize('/libs/granite/security/currentuser.json');
    var result = Granite.$.ajax({
        type: "GET",
        async: false,
        url: CURRENT_USER_JSON_PATH
    });

    if (result.status === 200) {
        currentUserInfo = JSON.parse(result.responseText);
        currentUserId = currentUserInfo.authorizableId;
    }
    return currentUserId;
}





function getUserGroups(userID)
    var isMemberOfGroupEveryOne=false;

    $.ajax({
        url: "/bin/security/authorizables.json?filter=" + userID +'&_charset_=utf-8',
        async: false,
        success: function(result) {
            if (result) {
                $.each(result.authorizables,function(index,authObj){
                    if( (authObj.id !== userID)){
                        return;
                    }else {

                        $.each(authObj.memberOf,function(index,memberOf){
                            if(memberOf.id === 'everyone'){
                                isMemberOfGroupEveryOne=true;
                            }
                        });
                    }
                });
            }
        }
    });
    return isMemberOfGroupEveryOne;
}

I have used everyone for demo, you could use your custom group.

2. if isUnallowedUg is true, you would be hiding the class cq-common-admin-timeline-toolbar using display: none in CSS.

Hope this helps, thanks!

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now