/**
 * RightsManager
 * 2008-08-28
 * @author Felix Kosmalla
 */
rcm.RightsManager = function(){
	
	// die Module mit ihren Rechten
	var modules = new Array();
	
	//administration
	modules.push({
		panelId:'accAdministration',
		rights: new Array('1')
	});
	
	//datenversorgung
	modules.push({
		panelId:'accDatenversorgung',
		rights: new Array('1','2')
	});
	
	//auswertungen
	modules.push({
		panelId:'accAuswertungen',
		rights: new Array('1','2','3')
	});
	                    

	var in_array = function(item,arr) {
		for(p=0;p<arr.length;p++) if (item == arr[p]) return true;
		return false;
	}
	
	
	// Privileged methods. Can be called from outside
    return {
		// public properties
	
		// Here comes the initialisation code
        init : function(){             
			
        },


		getAccModules:function(availableModules){
			var right = rcm.Application.state.user.berechtigungsstufe;
			
			
			var activeModules = new Array();
			
			Ext.each(modules, function(module,index){
				// console.log(module);
				
				if(!Ext.isEmpty(availableModules[module.panelId])){
					
					if(in_array(right,module.rights)){
					
						activeModules.push(availableModules[module.panelId]);	
					}
					
					
				}
				

				
				
			});
			

			
			return activeModules;
			
		},

		disableModules: function(){
			return;
			var right = rcm.Application.state.user.berechtigungsstufe;


			Ext.each(modules, function(module,index){
				// console.log(module);
				if(!in_array(right,module.rights)){
					Ext.getCmp(module.panelId).hide();
				}
			});
		}
		


    }
}();

