Created
July 20, 2015 17:32
-
-
Save ravinsinghd/567c5479a264c9e5536d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function FetchFilePermission(FileColl, callback) { | |
$.each(FileColl, function (key, value) { | |
var requestHeaders = { "accept": "application/json;odata=verbose" }; | |
$.ajax({ | |
url: value.MetadataURI + "/RoleAssignments/GetByPrincipalId(" + CurrentUserID + ")/RoleDefinitionBindings", | |
contentType: "application/json;odata=verbose", | |
headers: requestHeaders, | |
async: false, | |
success: function (data) { | |
var FullControlTest = $.grep(data.d.results, function (element, index) { if (element.Id == 1073741829) { return element; } }); | |
if (FullControlTest.length > 0) { | |
FileColl[key].CurrentUserPermission = 'Full Control'; | |
} | |
else { | |
FileColl[key].CurrentUserPermission = 'Edit'; | |
} | |
}, | |
error: function (data) { | |
FileColl[key].CurrentUserPermission = 'Read'; | |
} | |
}); | |
}); | |
return callback(FileColl); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment