Created
September 14, 2010 19:02
-
-
Save dmachi/579568 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Defines the data model for the given user by request | |
pinturaConfig.getDataModel = function(request){ | |
var user = request.remoteUser; | |
if(user){ | |
if(admins.indexOf(user)>-1){ | |
return fullModel; // admin users can directly access the data model without facets | |
} | |
return getUserModel(user, publicModel); | |
} | |
return publicModel; | |
} | |
var getUserModel=function(user, publicModel){ | |
var model ={} | |
for (var i in publicModel){ | |
model[i] = upgradeFacetForUser(user, i) || publicModel[i]; | |
} | |
return model; | |
} | |
var upgradeFacetForUser=function(user, facetName){ | |
//Check if the user should have permssion to the facetName and return that facet or a user specific version of that facet if they do. Otherwise return undefined. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment