// Make sure we have an attributes.elemtID value cfparam(name="Attributes.elemtID", default=0); cfparam(name="Attributes.resetFormIdMap", default=false); // Attributes.resetFormIdMap = true; // Uncomment to reset formid map enableLogging = false; // set to true for debug logging dumpLogFileName = "_ptCalendar_inc-hook-common.html"; // ptCalendar - custom element formIds must be dynamic... // !! DO NOT HARD CODE the ptCalendr FormIDs, they could be different on each CS server !! // Data changes to the following CE/Forms should force the associated cache var to be deleted // ----------------------------------------------------------------------------- ptCalGceCacheMap = { 'Calendar Event Details': { 'cacheVars': ['calCache'] }, 'Calendar Event DateTime': { 'cacheVars': ['calCache'] }, 'Calendar Event Recurrence': { 'cacheVars': ['calCache'] } }; formCacheName = 'ptCalAppGceFormCache'; // Build the Memory Struct to hold GCE name to FormID name/key pairs // -------------------------------------------------------------------- if ( NOT StructKeyExists(application,formCacheName) OR Attributes.resetFormIdMap ) application[formCacheName] = {}; if ( NOT StructKeyExists(application[formCacheName],'IdMap') OR NOT StructKeyExists(application[formCacheName],'dt') ) { application[formCacheName].IdMap = {}; application[formCacheName].dt = Now(); } cacheExpiresDays = 7; expireDT = dateAdd('d',cacheExpiresDays,application[formCacheName].dt); // Create a FormName/FormID map for each form in the ptCalGceCacheMap struct and cache it if ( structIsEmpty(application[formCacheName].IdMap) OR StructCount(ptCalGceCacheMap) NEQ StructCount(application[formCacheName].IdMap) OR Now() GTE expireDT ) { // Do the formid look up once and store it in a mem var for ( ceKey IN ptCalGceCacheMap ) { // Get the FormID for the ce_form_id = Application.ADF.ceData.getFormIDByCEName(ceKey); application[formCacheName].IdMap[ceKey] = ce_form_id; } // End FormID Look-up if ( enableLogging ) application.ADF.log.logAppend(msg=application[formCacheName], label='rebuilding application.#formCacheName#', logfile=dumpLogFileName); } // Clear the Memory Cache for CE Elements if the elements are updated // -------------------------------------------------------------------- for ( ceKey IN ptCalGceCacheMap ) { ptCalGceCacheSpecs = ptCalGceCacheMap[ceKey]; if ( IsStruct(ptCalGceCacheSpecs) AND NOT structIsEmpty(ptCalGceCacheSpecs) ) { // Get the FormID for the ptCalendar GCE ceFormId = 0; if ( StructKeyExists(application[formCacheName].IdMap,ceKey) ) ceFormId = application[formCacheName].IdMap[ceKey]; // Clear the Application variable for the ptCalendar form if it matches if ( ceFormId GT 0 AND Attributes.elemtID EQ ceFormId ) { if ( StructKeyExists(ptCalGceCacheSpecs,'cacheVars') ) { ceCacheVarsArr = ptCalGceCacheSpecs.cacheVars; for ( cv=1; cv <= ArrayLen(ceCacheVarsArr); cv++ ) { StructDelete(Application,ceCacheVarsArr[cv]); if ( enableLogging ) application.ADF.log.logAppend(msg="ptCalendar memory cache var: #ceCacheVarsArr[cv]# for formid: #ceFormId# was deleted!
", label='', logfile=dumpLogFileName); } break; } } } } // End ptCalendar memory var cache delete