$.ajax({
type: "GET",
url: "/libs/granite/security/currentuser.json.rw.userprops.json?props=declaredMemberOf",
cache: false
}).done(function(data, textStatus, jqXHR) {
var isMember = false;
/* The Group ID for which the widget has to be disabled */
var groupId = "site-editor";
var membershipInfo = data.declaredMemberOf;
if (membershipInfo) {
for (var membershipIdx = 0; membershipIdx < membershipInfo.length; membershipIdx++) {
if (membershipInfo[membershipIdx].authorizableId == groupId) {
isMember = true;
break;
}
}
}
/*This example disables the Hide in Navigation checkbox on Page Properties dialog of the page*/
if (isMember) {
$('[name="./hideInNav"]').prop('disabled', 'true');
}
});
Ajax call should be invoked at the "dialog-ready" event of the document. You need to put the above code in a clientlibs JS file with the category "cq.authoring.dialog".
type: "GET",
url: "/libs/granite/security/currentuser.json.rw.userprops.json?props=declaredMemberOf",
cache: false
}).done(function(data, textStatus, jqXHR) {
var isMember = false;
/* The Group ID for which the widget has to be disabled */
var groupId = "site-editor";
var membershipInfo = data.declaredMemberOf;
if (membershipInfo) {
for (var membershipIdx = 0; membershipIdx < membershipInfo.length; membershipIdx++) {
if (membershipInfo[membershipIdx].authorizableId == groupId) {
isMember = true;
break;
}
}
}
/*This example disables the Hide in Navigation checkbox on Page Properties dialog of the page*/
if (isMember) {
$('[name="./hideInNav"]').prop('disabled', 'true');
}
});
Ajax call should be invoked at the "dialog-ready" event of the document. You need to put the above code in a clientlibs JS file with the category "cq.authoring.dialog".
No comments:
Post a Comment
If you have any doubts or questions, please let us know.