lib/permissions/PermissionDefinitionProcessor.js
function insertSettingsPluginsPermission(app, next) {
    var pluginsHome = utils.getRootPath() + "/plugins",
        settingsPlugins = Object.keys(plugins.getSettingsPlugins());
    var dbActionInstance = DBActions.getSimpleInstance(app, "SchemaPermissions");
    var pluginInstanceHandler = require(utils.getLibPath() + "/PluginInstanceHandler"),
        Roles  = require(utils.getLibPath() + "/permissions/Roles"),
        guestRoleId = Roles.getGuestRole().roleId,
        userRoleId = Roles.getUserRole().roleId;

    var mapFunction = function (pluginId, next) {
        var permissions = pluginInstanceHandler.Permissions;
        var model = {
            actionsValue: permissions.actionsValue,
            permissionSchemaKey: utils.getSettingsPluginPermissionSchemaKey(pluginId)
        };
        var rolePermissions = _.clone(permissions.rolePermissions);
        //guest has nothing to do with settings plugin as its a non logged in user
        delete  rolePermissions[guestRoleId];

        //user role only have permission to show user manage plugin, to modify his profile
        if(pluginId !=  "userManage"){
            rolePermissions[userRoleId] = [];
        }

        model.rolePermissions = rolePermissions;
        Cache.store(model);
        dbActionInstance.save(model, next);
    };

    async.eachSeries(settingsPlugins, mapFunction, function (err, results) {
        next(err, true);
    });


}
function insertSettingsPluginsPermission(app, next) {
    var pluginsHome = utils.getRootPath() + "/plugins",
        settingsPlugins = Object.keys(plugins.getSettingsPlugins());
    var dbActionInstance = DBActions.getSimpleInstance(app, "SchemaPermissions");
    var pluginInstanceHandler = require(utils.getLibPath() + "/PluginInstanceHandler"),
        Roles  = require(utils.getLibPath() + "/permissions/Roles"),
        guestRoleId = Roles.getGuestRole().roleId,
        userRoleId = Roles.getUserRole().roleId;

    var mapFunction = function (pluginId, next) {
        var permissions = pluginInstanceHandler.Permissions;
        var model = {
            actionsValue: permissions.actionsValue,
            permissionSchemaKey: utils.getSettingsPluginPermissionSchemaKey(pluginId)
        };
        var rolePermissions = _.clone(permissions.rolePermissions);
        //guest has nothing to do with settings plugin as its a non logged in user
        delete  rolePermissions[guestRoleId];

        //user role only have permission to show user manage plugin, to modify his profile
        if(pluginId !=  "userManage"){
            rolePermissions[userRoleId] = [];
        }

        model.rolePermissions = rolePermissions;
        Cache.store(model);
        dbActionInstance.save(model, next);
    };

    async.eachSeries(settingsPlugins, mapFunction, function (err, results) {
        next(err, true);
    });


}
function insertSettingsPluginsPermission ( app , next ) { var pluginsHome = utils . getRootPath ( ) + "/plugins" , settingsPlugins = Object . keys ( plugins . getSettingsPlugins ( ) ) ; var dbActionInstance = DBActions . getSimpleInstance ( app , "SchemaPermissions" ) ; var pluginInstanceHandler = require ( utils . getLibPath ( ) + "/PluginInstanceHandler" ) , Roles = require ( utils . getLibPath ( ) + "/permissions/Roles" ) , guestRoleId = Roles . getGuestRole ( ) . roleId , userRoleId = Roles . getUserRole ( ) . roleId ; var mapFunction = function ( pluginId , next ) { var permissions = pluginInstanceHandler . Permissions ; var model = { actionsValue : permissions . actionsValue , permissionSchemaKey : utils . getSettingsPluginPermissionSchemaKey ( pluginId ) } ; var rolePermissions = _ . clone ( permissions . rolePermissions ) ; //guest has nothing to do with settings plugin as its a non logged in user delete rolePermissions [ guestRoleId ] ; //user role only have permission to show user manage plugin, to modify his profile if ( pluginId != "userManage" ) { rolePermissions [ userRoleId ] = [ ] ; } model . rolePermissions = rolePermissions ; Cache . store ( model ) ; dbActionInstance . save ( model , next ) ; } ; async . eachSeries ( settingsPlugins , mapFunction , function ( err , results ) { next ( err , true ) ; } ) ; }
Function used to insert settings plugin schema permissions
@param app
@param next
Function used to insert settings plugin schema permissions