<cfif form.Type EQ "Patch">
	<cfinclude template="patch_13.5.04.cfm">
</cfif>

<!--- Bug 8277: Add app setting if it does not exist --->
<cfquery datasource="#application.config.DSN#">
IF NOT EXISTS (SELECT Value FROM AppSetting WHERE Name = 'ELASTIC_SEARCH_TIMEOUT')
BEGIN
	INSERT INTO AppSetting (Name,Value)
	VALUES ('ELASTIC_SEARCH_TIMEOUT','8')
END
</cfquery>
<!--- Bug 8398: remove xlsx from valid extensions list --->
<cfquery datasource="#application.config.DSN#">
UPDATE AppSetting
SET Value = 'csv,txt,pdf,doc,docx,ppt,pptx,xls,rtf,xml,html'
WHERE Name = 'ELASTIC_SEARCH_VALID_EXTENSIONS'
</cfquery>

<cfquery name="appsetting" datasource="#application.config.DSN#">
SELECT Value AS IntranetRoot FROM AppSetting
WHERE Name = <cfqueryparam cfsqltype="cf_sql_varchar" value="IntranetRoot">
</cfquery>

<cfquery name="ADConnection" datasource="#application.config.DSN#">
SELECT ID FROM ADConnection
WHERE Enabled = <cfqueryparam cfsqltype="cf_sql_bit" value="1">
</cfquery>

<cfscript>
// create the Webservices task	
variables.taskName = application.properties.applicationname & "_WEBSERVICE";
variables.port = ( Find("https",appsetting.intranetRoot) != 0 ? 443 : 80 );	
variables.taskUrl = appsetting.IntranetRoot & "/Scheduled/webservices.cfm";
variables.startTime = "12:12 AM";
variables.interval = 86400;
schedule operation="HTTPRequest"
					action="update"
					task=variables.taskName
					URL=variables.taskUrl
					startDate=DateFormat(DateAdd("d",-1,now()),"M/d/YY")
					startTime=variables.startTime
					interval=variables.interval
					port=variables.port;

if (ADConnection.recordcount > 0) {
	// create the ad sync task	
	variables.taskName = application.properties.applicationname & "_ADSYNC2";
	variables.port = ( Find("https",appsetting.intranetRoot) != 0 ? 443 : 80 );	
	variables.taskUrl = appsetting.IntranetRoot & "/Scheduled/ad.cfm";
	variables.startTime = "12:19 AM";
	variables.interval = 3600;
	schedule operation="HTTPRequest"
					action="update"
					task=variables.taskName
					URL=variables.taskUrl
					startDate=DateFormat(DateAdd("d",-1,now()),"M/d/YY")
					startTime=variables.startTime
					interval=variables.interval
					port=variables.port;
		

}
</cfscript>