Class Index | File Index

Classes


Class xataface.Permissions


Defined in: Permissions.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Class to help obtain permissions information about a specific record.
Method Summary
Method Attributes Method Name and Description
 
Checks to see if the given permission is granted.
 
Returns an associative array of granted permissions.
 
Gets the query that was used to get these permissions.
 
load(callback)
Loads the permissions for the current query from the server.
 
Runs a callback function after the permissions object is ready.
 
Sets the query to be used.
Class Detail
xataface.Permissions(o)
Class to help obtain permissions information about a specific record.
//require <xataface/Permissions.js>
var Permissions = XataJax.load('xataface.Permissions');
var myperms = new Permissions({
		query: {
			'-table': 'users',
			'user_id': 10
		}
});
myperms.ready(function(){
    // We can't call any thing until the permissions are ready
    if ( myperms.checkPermission('view') ){
        alert('We have view permission');
    }

});
Parameters:
{Object} o
The config parameters.
{Object} o.query
The query parameters following Xataface URL conventions.
Method Detail
{Boolean} checkPermission(perm)
Checks to see if the given permission is granted. This method should be run after the Permissions object is ready.
Parameters:
{String} perm
The permission to check.
Returns:
{Boolean} True if the permission is granted. False otherwise.
See:
xataface.Permissions#ready

{Object} getPermissions()
Returns an associative array of granted permissions. This should only be run after the Permissions object is ready.
Returns:
{Object}
See:
xataface.Permissions#ready

{Object} getQuery()
Gets the query that was used to get these permissions.
Returns:
{Object}
See:
xataface.Permissions#setQuery

load(callback)
Loads the permissions for the current query from the server.
Parameters:
{Function} callback
Callback function called when loading is complete. This function is run in the context of this Permissions object.
See:
xataface.Permissions#ready

ready()
Runs a callback function after the permissions object is ready. All methods for checking permissions should be run inside this object.

{void} setQuery(q)
Sets the query to be used. This will clear out the current permissions cache and cause the object to need to reload the permissions.
Parameters:
{Object} q
The query.
Returns:
{void}
See:
xataface.Permissions#getQuery

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 30 2012 15:10:18 GMT-0700 (PDT)