<commit_before><cfcomponent extends="eventHandler">

<cffunction name="onApplicationStart">
	<!--- setup data directory (if needed for xml data storage) --->
	<cfset checkDataRoot()>
</cffunction>

<cffunction name="onRequestStart">
	<!--- code to execute at the beginning of each request --->
	<cfscript>
		var appTitle = getSetting("applicationTitle", application.applicationName);
		var event = getEvent();
		var hostName = CreateObject("java", "java.net.InetAddress").getLocalHost().getHostName();
		var versionTag = getSetting("versionTag");
		var lstFreeEvents = "ehGeneral.doLogin,ehGeneral.dspLogin,ehGeneral.doRegister,ehGeneral.dspRegister";
		var firstRunDate = "";
		var ls = "";
		var isAllowed = true;
		var oUser = 0;
		var oContext = getService("sessionContext").getContext();
	
		// get user object in session (if exists)
		if(oContext.hasUser())
			oUser = oContext.getUser();
		else {
			oUser = createObject("component","ColdBricks.components.model.userBean").init();
			oContext.setUser(oUser);
		}
		

		try {
			// check for data directory
			checkDataRoot();
			
		} catch(any e) {
			writeOutput("Fatal Error. Cannot continue: " & e.message);
			getService("bugTracker").notifyService(e.message, e);
			abort();
		}
			
		try {
			// check login
			if(not listFindNoCase(lstFreeEvents,event) and (oUser.getID() eq 0 or oUser.getID() eq "")) {
				setMessage("Warning","Please enter your username and password");
				setNextEvent("ehGeneral.dspLogin");
			}

			// check authorization
			isAllowed = getService("permissions").isAllowed(event, oUser.getRole());
			if(not isAllowed) {
				setMessage("Warning","The requested action is restricted.");
				setNextEvent("ehGeneral.dspMain");
			}

			// set generally available values on the request context
			setValue("hostName", hostName);
			setValue("applicationTitle", appTitle);
			setValue("oUser", oUser);
			setValue("versionTag", versionTag);
			setValue("oContext", oContext);

		} catch(any e) {
			setMessage("error",e.message);
			getService("bugTracker").notifyService(e.message, e);
		}
	</cfscript>
</cffunction>

<cffunction name="onRequestEnd">
	<!--- code to execute at the end of each request --->
</cffunction>


<cffunction name="dspLogin">
	<cfscript>
		setView("vwLogin");
		setLayout("layout.clean");
	</cfscript>
</cffunction>

<cffunction name="dspMain">
	<cfscript>
		var oSiteDAO = 0;
		var oUserDAO = 0;
		var qrySites = 0;
		var oUser = getValue("oUser");
		var aPlugins = arrayNew(1);

		try {
			// if this is a regular user then go to sites screen
			if(not oUser.getIsAdministrator()) 	setNextEvent("ehSites.dspMain");

			oSiteDAO = getService("DAOFactory").getDAO("site");
			oUserSiteDAO = getService("DAOFactory").getDAO("userSite");
			
			qrySites = oSiteDAO.getAll();
			qryUserSites = oUserSiteDAO.search(userID = oUser.getID());

			aPlugins = getService("plugins").getPluginsByType("admin");

			setValue("qrySites",qrySites);<commit_msg>added code to discard site data in context when returning to the admin dashboard<commit_after><cfcomponent extends="eventHandler">

<cffunction name="onApplicationStart">
	<!--- setup data directory (if needed for xml data storage) --->
	<cfset checkDataRoot()>
</cffunction>

<cffunction name="onRequestStart">
	<!--- code to execute at the beginning of each request --->
	<cfscript>
		var appTitle = getSetting("applicationTitle", application.applicationName);
		var event = getEvent();
		var hostName = CreateObject("java", "java.net.InetAddress").getLocalHost().getHostName();
		var versionTag = getSetting("versionTag");
		var lstFreeEvents = "ehGeneral.doLogin,ehGeneral.dspLogin,ehGeneral.doRegister,ehGeneral.dspRegister";
		var firstRunDate = "";
		var ls = "";
		var isAllowed = true;
		var oUser = 0;
		var oContext = getService("sessionContext").getContext();
	
		// get user object in session (if exists)
		if(oContext.hasUser())
			oUser = oContext.getUser();
		else {
			oUser = createObject("component","ColdBricks.components.model.userBean").init();
			oContext.setUser(oUser);
		}
		

		try {
			// check for data directory
			checkDataRoot();
			
		} catch(any e) {
			writeOutput("Fatal Error. Cannot continue: " & e.message);
			getService("bugTracker").notifyService(e.message, e);
			abort();
		}
			
		try {
			// check login
			if(not listFindNoCase(lstFreeEvents,event) and (oUser.getID() eq 0 or oUser.getID() eq "")) {
				setMessage("Warning","Please enter your username and password");
				setNextEvent("ehGeneral.dspLogin");
			}

			// check authorization
			isAllowed = getService("permissions").isAllowed(event, oUser.getRole());
			if(not isAllowed) {
				setMessage("Warning","The requested action is restricted.");
				setNextEvent("ehGeneral.dspMain");
			}

			// set generally available values on the request context
			setValue("hostName", hostName);
			setValue("applicationTitle", appTitle);
			setValue("oUser", oUser);
			setValue("versionTag", versionTag);
			setValue("oContext", oContext);

		} catch(any e) {
			setMessage("error",e.message);
			getService("bugTracker").notifyService(e.message, e);
		}
	</cfscript>
</cffunction>

<cffunction name="onRequestEnd">
	<!--- code to execute at the end of each request --->
</cffunction>


<cffunction name="dspLogin">
	<cfscript>
		setView("vwLogin");
		setLayout("layout.clean");
	</cfscript>
</cffunction>

<cffunction name="dspMain">
	<cfscript>
		var oSiteDAO = 0;
		var oUserDAO = 0;
		var qrySites = 0;
		var oUser = getValue("oUser");
		var aPlugins = arrayNew(1);

		try {
			// clear site from context (releases memory allocated to the site context)
			getService("sessionContext").getContext().clearSiteContext();
			
			// if this is a regular user then go to sites screen
			if(not oUser.getIsAdministrator()) 	setNextEvent("ehSites.dspMain");

			oSiteDAO = getService("DAOFactory").getDAO("site");
			oUserSiteDAO = getService("DAOFactory").getDAO("userSite");
			
			qrySites = oSiteDAO.getAll();
			qryUserSites = oUserSiteDAO.search(userID = oUser.getID());

			aPlugins = getService("plugins").getPluginsByType("admin");

			setValue("qrySites",qrySites);
{'fraction_non_alphanumeric': 0.14647289353363815, 'fraction_numerical': 0.001959503592423253, 'mean_word_length': 4.406001765225066, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7353910', 'n_tokens_mistral': 2230, 'n_tokens_neox': 1969, 'n_words': 444}