This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
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?
Solved! Go to Solution.
Views
Replies
Total Likes
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!
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
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!
Thank you @milind_bachani
Views
Likes
Replies