var retStruct = { 'events': [], 'error_msg': '' }; var dataQry = QueryNew('tmp'); var startDT = ''; var endDT = ''; var item = {}; var eData = {}; var curPageId = 0; var usersGroupList = 0; var feedData = {}; var filterData = {}; var allowedUserGroups = ''; var allOrgsSelectedValue = getAllOrganizationsDefaultValue(); var linkedCalendarPageUrl = ''; var linkedCalendarPageID = ""; var linkedCalendarSubsiteID = ''; var qParamDelimiter = "?"; var viewLinkData = {}; var calOptions = { useAdminTools: false, detailsLink: '', eventBackgroundColor: '', eventBorderColor: '', eventTextColor: '' }; //sleep(2000); // TRIM the filter arguments arguments.keywordsFilter = TRIM(arguments.keywordsFilter); arguments.orgFilter = TRIM(arguments.orgFilter); arguments.catFilter = TRIM(arguments.catFilter); arguments.locFilter = TRIM(arguments.locFilter); arguments.statusFilter = TRIM(arguments.statusFilter); // Session userFeedSpecs is set by the page where events_json_feed_calendar_rh.cfm is used // ----------------------------------------------------------------------------------------- lock scope="session" timeout="10" type ="ReadOnly" { if ( StructKeyExists(session,'ptCalendar') AND StructKeyExists(session.ptCalendar,'userFeedSpecs') ) { if ( StructKeyExists(session.ptCalendar.userFeedSpecs,'PageId') ) curPageId = session.ptCalendar.userFeedSpecs.PageId; if ( StructKeyExists(session.ptCalendar.userFeedSpecs,'GroupList') ) usersGroupList = session.ptCalendar.userFeedSpecs.GroupList; } } // End: session readonly lock // Application jsonFeedConfig is set by the 'Calendar Events JSON Feed Properties' LCE Options selected // ----------------------------------------------------------------------------------------------------- if ( StructKeyExists(Application.ptCalendar,'jsonFeedConfig') AND StructKeyExists(Application.ptCalendar.jsonFeedConfig,curPageId) ) { // Get the feedData from the jsonFeedConfig[pageid]; // --------------------------------------------------------------------------------------- feedData = Application.ptCalendar.jsonFeedConfig[curPageId]; if ( StructKeyExists(feedData,"linkedCalendarPage_csURL") AND StructKeyExists(feedData.linkedCalendarPage_csURL,"ResolvedURL") AND StructKeyExists(feedData.linkedCalendarPage_csURL.ResolvedURL,"ServerRelative") AND TRIM(feedData.linkedCalendarPage_csURL.ResolvedURL.ServerRelative) NEQ '' ) { linkedCalendarPageUrl = feedData.linkedCalendarPage_csURL.ResolvedURL.ServerRelative; } else if ( StructKeyExists(feedData,"linkedCalendarPage") AND TRIM(feedData.linkedCalendarPage) NEQ '') { linkedCalendarPageUrl = Application.ADF.csData.parseCSURL(str=feedData.linkedCalendarPage,useLogging=false); } allowedUserGroups = ''; if ( StructKeyExists(feedData,'allowedGroups') AND TRIM(feedData.allowedGroups) NEQ '' ) allowedUserGroups = application.ADF.data.listUnion(list1=allowedUserGroups,list2=feedData.allowedGroups,removeDups=true); if ( StructKeyExists(feedData,'allowedUsers') AND TRIM(feedData.allowedUsers) NEQ '' ) allowedUserGroups = application.ADF.data.listUnion(list1=allowedUserGroups,list2=feedData.allowedUsers,removeDups=true); if ( StructKeyExists(feedData,'enableAdminTools') AND IsBoolean(feedData.enableAdminTools) AND feedData.enableAdminTools EQ 1 ) calOptions.useAdminTools = true; // Get non-AdminTools specific settings if ( NOT calOptions.useAdminTools ) { if ( StructKeyExists(feedData,'eventBackgroundColor') AND TRIM(feedData.eventBackgroundColor) NEQ '' ) calOptions.eventBackgroundColor = UCASE(TRIM(feedData.eventBackgroundColor)); if ( StructKeyExists(feedData,'eventBorderColor') AND TRIM(feedData.eventBorderColor) NEQ '' ) calOptions.eventBorderColor = UCASE(TRIM(feedData.eventBorderColor)); if ( StructKeyExists(feedData,'eventTextColor') AND TRIM(feedData.eventTextColor) NEQ '' ) calOptions.eventTextColor = UCASE(TRIM(feedData.eventTextColor)); } // Get the FilterData = Fields and Values from feedData to be used in the filterEvents method // --------------------------------------------------------------------------------------- filterData = application.ptCalendar.calEventsService.buildCleanFilterStruct(feedData); } // if AllowUsersGroups is not empty, then check if any IDs in the current users GroupList are in the Allowed Groups List // - If no return error_msg and an empty events array if ( TRIM(allowedUserGroups) NEQ '' AND ListLen(application.ADF.data.listInCommon(list1=usersGroupList,list2=allowedUserGroups)) EQ 0 ) { retStruct['error_msg'] = 'The current user does not have permissions to view these events'; return retStruct; } /* ********** */ // start=2025-02-23T00:00:00-05:00 // end=2025-04-15T00:00:00-04:00 if ( TRIM(arguments.start) NEQ '' ) startDT = dateFormat(dateConvert('utc2Local', arguments.start),'yyyy-mm-dd') & ' 00:00:00'; if ( TRIM(arguments.end) NEQ '' ) endDT = dateFormat(dateConvert('utc2Local', arguments.end),'yyyy-mm-dd') & ' 00:00:00'; // Get Events based on the start/end date dataQry = application.ptCalendar.calEventsDAO.getEvents( startDate = startDT ,endDate = endDT ,useCache = arguments.useCache ); // Data Filtering Stage 1: // - Event filtering from Element Config Data filtering options // -------------------------------------------------------------------------- if ( dataQry.recordCount GT 0 AND NOT StructIsEmpty(filterData) ) { // Filter the query by fields and values from the JSON feed properties // - eventApproved = 1/[empty] // - organization ids // - category ids dataQry = application.ptCalendar.calEventsService.filterEvents(eventsQuery=dataQry,filterStruct=filterData); } // Data Filtering Stage 2: // - Event filtering from Filter Bar user selections // -------------------------------------------------------------------------- // - Keyword String Filtering if ( dataQry.recordCount GT 0 AND arguments.keywordsFilter NEQ '' ) { dataQry = _eventsKeywordFilter(eventsQuery=dataQry,filter=arguments.keywordsFilter); } // - Organization ID Filtering if ( dataQry.recordCount GT 0 AND arguments.orgFilter NEQ '' ) { dataQry = _eventsOrganizationFilter(eventsQuery=dataQry,filter=arguments.orgFilter); // filterData cleanup - to make sure organization is not in the filterData struct StructDelete(filterData,'organization'); } // - Category ID Filtering if ( dataQry.recordCount GT 0 AND arguments.catFilter NEQ '' ) { dataQry = _eventsCategoryFilter(eventsQuery=dataQry,filter=arguments.catFilter); // filterData cleanup - to make sure category is not in the filterData struct StructDelete(filterData,'category'); } // - Location String Filtering if ( dataQry.recordCount GT 0 AND arguments.locFilter NEQ '' ) { dataQry = _eventsLocationFilter(eventsQuery=dataQry,filter=arguments.locFilter); } // - Event Status Filtering if ( dataQry.recordCount GT 0 AND arguments.statusFilter NEQ '' ) { dataQry = _eventsStatusFilter(eventsQuery=dataQry,filter=arguments.statusFilter); // filterData cleanup - to make sure StructDelete(filterData,'eventApproved'); } // Get the view link data structure // ---------------------------------------------------------------- if ( application.ptCalendar.viewPageMode EQ "Single" ) { if ( LEN(TRIM(linkedCalendarPageUrl)) ) viewLinkData = application.ptCalendar.calRenderViewService.getCalViewPageStruct(pageURL=linkedCalendarPageUrl); else viewLinkData = application.ptCalendar.calRenderViewService.getCalViewPageStruct(); qParamDelimiter = "&"; } else { if ( IsNumeric(linkedCalendarSubsiteID) ) viewLinkData = application.ptCalendar.calPageMapDAO.getCalPageMapStruct(subsiteID=linkedCalendarSubsiteID); else viewLinkData = application.ptCalendar.calPageMapDAO.getCalPageMapStruct(); } if ( structKeyExists(viewLinkData, "detailPage") and len(trim(viewLinkData.detailPage)) ) calOptions.detailsLink = viewLinkData.detailPage; if ( calOptions.useAdminTools ) { // Do NOT show AdminTools if allowedUserGroups is Empty or if no allowed users NOT are part of this Pages's Security Group list if ( TRIM(allowedUserGroups) EQ '' OR ListLen(application.ADF.data.listInCommon(list1=usersGroupList,list2=allowedUserGroups)) EQ 0 ) { retStruct['error_msg'] = "The current user does not permissions to view these events!"; return retStruct; } retStruct['events'] = _buildAdminEvents(eventsQuery=dataQry,calOptions=calOptions); } else retStruct['events'] = _buildEvents(eventsQuery=dataQry,calOptions=calOptions); return retStruct;; var dataQry = arguments.eventsQuery; arguments.filter = TRIM(arguments.filter); if ( dataQry.RecordCount AND arguments.filter NEQ '' ) { dataQry = queryExecute( "SELECT * FROM dataQry WHERE LOWER(title) LIKE :title OR LOWER(description) LIKE :description OR LOWER(location) LIKE :location ORDER BY eventDate, AllDay DESC, StartTime", { title = "%#lcase(arguments.filter)#%", cfsqltype="cf_sql_varchar", description = "%#lcase(arguments.filter)#%", cfsqltype="cf_sql_varchar", location = "%#lcase(arguments.filter)#%", cfsqltype="cf_sql_varchar" }, { dbtype="query" } ); } return dataQry; var dataQry = arguments.eventsQuery; var allOrgsSelectedValue = getAllOrganizationsDefaultValue(); var idx = ''; arguments.filter = TRIM(arguments.filter); SELECT * FROM dataQry WHERE organization LIKE OR OR organization = ORDER BY eventDate, AllDay DESC, StartTime return dataQry; var dataQry = arguments.eventsQuery; var allOrgsSelectedValue = getAllOrganizationsDefaultValue(); var idx = ''; arguments.filter = TRIM(arguments.filter); SELECT * FROM dataQry WHERE category LIKE OR ORDER BY eventDate, AllDay DESC, StartTime return dataQry; var dataQry = arguments.eventsQuery; var idx = ''; arguments.filter = TRIM(arguments.filter); SELECT * FROM dataQry WHERE location = ORDER BY eventDate, AllDay DESC, StartTime return dataQry; var dataQry = arguments.eventsQuery; var status = ''; arguments.filter = TRIM(arguments.filter); if ( dataQry.RecordCount AND arguments.filter NEQ '' ) { if ( arguments.filter EQ 'approved' ) status = 1; else if ( arguments.filter EQ 'pending' ) status = ''; else if ( arguments.filter EQ 'denied' ) status = 0; if ( status NEQ '' ) { dataQry = queryExecute( "SELECT * FROM dataQry WHERE eventApproved = :eventStatus", { eventStatus = status, cfsqltype="cf_sql_varchar" }, { dbtype="query" } ); } else { dataQry = queryExecute( "SELECT * FROM dataQry WHERE eventApproved != 1 AND eventApproved != 0", {}, { dbtype="query" } ); } } return dataQry; var retArr = []; var dataQry = arguments.eventsQuery; var eData = {}; var item = {}; var linkParamsData = {}; var calOpts = { useAdminTools: false, detailsLink: '', eventBackgroundColor: '', eventBorderColor: '', eventTextColor: '' }; var titleMaxWordCnt = 25; var tooltipDescMaxWordCnt = getToolTipDescriptionMaxWordCount(); // Convert the calOptions to calOpts to make sure we have defaults structAppend(calOpts, arguments.calOptions, true); for ( var i=1; i <= dataQry.RecordCount; i++ ) { eData = QueryGetRow(dataQry, i); item = {}; item['id'] = i; item['groupId'] = eData.calEventID; // Events that have the same Event Details GCE ID item['title'] = encodeForHTML(trimStringByWordCount(str=eData.title,words=titleMaxWordCnt,useEllipsis=1,stripHTML=0)); item['title_text'] = trimStringByWordCount(str=eData.title,words=titleMaxWordCnt,useEllipsis=1,stripHTML=1,stripTagsList=""); item['allDay'] = false; // Add colors from Element Config if set if ( TRIM(calOpts.eventBackgroundColor) NEQ '' ) item['backgroundColor'] = calOpts.eventBackgroundColor; if ( TRIM(calOpts.eventBorderColor) NEQ '' ) item['borderColor'] = calOpts.eventBorderColor; if ( TRIM(calOpts.eventTextColor) NEQ '' ) item['textColor'] = calOpts.eventTextColor; if ( VAL(eData.allDay) GT 0 ) { item['start'] = DateFormat(eData.eventDate,'yyyy-mm-dd'); item['allDay'] = true; } else { item['start'] = DateFormat(eData.eventDate,'yyyy-mm-dd') & 'T' & TimeFormat(eData.startTime,'HH:mm:ss'); item['end'] = DateFormat(eData.eventDate,'yyyy-mm-dd') & 'T' & TimeFormat(eData.endTime,'HH:mm:ss'); } item['description'] = ''; if ( TRIM(eData.description) NEQ '' ) item['description'] = sanitizeHtmlStr(eData.description); // automagically get moved to 'extendedProps' item['eventid'] = eData.calEventID; item['datetimeid'] = eData.datetimeID; item['dthashid'] = eData.dtHashID; if ( TRIM(eData.dateTimeID) NEQ '' AND TRIM(eData.dthashID) NEQ '' ) item['title'] = item['title'] & ''; else if ( TRIM(eData.dthashID) NEQ '' AND TRIM(eData.dateTimeID) EQ '' ) item['title'] = item['title'] & ''; // Set the Tooltip Title and description item['tooltip_title'] = item['title']; item['tooltip_desc'] = ''; if ( TRIM(item['description']) NEQ '' ) { item['tooltip_desc'] = trimStringByWordCount(str=item['description'],words=tooltipDescMaxWordCnt,useEllipsis=1,stripHTML=1,stripTagsList=""); item['tooltip_desc'] = '

' & item['tooltip_desc'] & '

'; } item['detailsLink'] = ''; if ( StructKeyExists(calOpts,"detailsLink") ) { linkParamsData = application.ptCalendar.calRenderService.buildEventDetailsLinksParams(eventDataStruct=eData); //item['linkParamsData'] = linkParamsData; //item['calOptions'] = calOpts; item['detailsLink'] = application.ptCalendar.calRenderService.buildLinkParamURL( linkURL=calOpts.detailsLink ,linkParamName=linkParamsData.UIDvarName ,linkParamValue=linkParamsData.UIDvalue ,urlParams="" ); } ArrayAppend(retArr, item); } return retArr; var retArr = []; var dataQry = arguments.eventsQuery; var eData = {}; var item = {}; var linkParamsData = {}; var approvedLabel = getEventApprovedLabel(); var deniedLabel = getEventDeniedLabel(); var pendingLabel = getEventPendingLabel(); var titleIconColor = ''; var calOpts = { useAdminTools: false, detailsLink: '' }; var titleMaxWordCnt = 25; var tooltipDescMaxWordCnt = getToolTipDescriptionMaxWordCount(); // Convert the calOptions to calOpts to make sure we have defaults structAppend(calOpts, arguments.calOptions, true); for ( var i=1; i <= dataQry.RecordCount; i++ ) { eData = QueryGetRow(dataQry, i); item = {}; item['id'] = i; item['groupId'] = eData.calEventID; // Events that have the same Event Details GCE ID item['title'] = encodeForHTML(trimStringByWordCount(str=eData.title,words=titleMaxWordCnt,useEllipsis=1,stripHTML=0)); item['title_text'] = trimStringByWordCount(str=eData.title,words=titleMaxWordCnt,useEllipsis=1,stripHTML=1,stripTagsList=""); item['allDay'] = false; if ( VAL(eData.allDay) GT 0 ) { item['start'] = DateFormat(eData.eventDate,'yyyy-mm-dd'); item['allDay'] = true; } else { item['start'] = DateFormat(eData.eventDate,'yyyy-mm-dd') & 'T' & TimeFormat(eData.startTime,'HH:mm:ss'); item['end'] = DateFormat(eData.eventDate,'yyyy-mm-dd') & 'T' & TimeFormat(eData.endTime,'HH:mm:ss'); } item['description'] = ''; if ( TRIM(eData.description) NEQ '' ) item['description'] = sanitizeHtmlStr(eData.description); // automagically moved to 'extendedProps' item['datetimeid'] = eData.datetimeID; item['dthashid'] = eData.dtHashID; item['eventapproved'] = eData.eventApproved; item['eventstatus'] = ''; // Set Event Management Colors item['backgroundColor'] = '##337AB7'; // blue item['textColor'] = '##000000'; titleIconColor = ''; // 1: approved, 0: denied, '': pending if ( eData.eventApproved EQ 1 ) { item['eventstatus'] = 'approved'; item['backgroundColor'] = '##337ab7'; // Default Event Blue item['textColor'] = '##FFFFFF'; titleIconColor = "color:##4eb305;"; // Approved green item['title'] = ' ' & item['title']; } else if ( eData.eventApproved EQ 0 ) { item['eventstatus'] = 'denied'; item['backgroundColor'] = '##F6D5D5'; // Denied Light Red item['textColor'] = '##000000'; titleIconColor = 'color:##CC0204'; // Denied Red item['title'] = '' & item['title']; } else { item['eventstatus'] = 'pending'; item['backgroundColor'] = '##FFFADf'; // Pending Light Yellow item['textColor'] = '##000000'; titleIconColor = "color:##FCBE04;"; // Pending Yellow item['title'] = '' & item['title']; } if ( TRIM(eData.dateTimeID) NEQ '' AND TRIM(eData.dthashID) NEQ '' ) item['title'] = item['title'] & ''; else if ( TRIM(eData.dthashID) NEQ '' AND TRIM(eData.dateTimeID) EQ '' ) item['title'] = item['title'] & ''; // Set the Tooltip Title and description item['tooltip_title'] = item['title']; item['tooltip_desc'] = ''; if ( TRIM(item['description']) NEQ '' ) { item['tooltip_desc'] = trimStringByWordCount(str=item['description'],words=tooltipDescMaxWordCnt,useEllipsis=1,stripHTML=1,stripTagsList=""); item['tooltip_desc'] = '

' & item['tooltip_desc'] & '

'; } item['detailsLink'] = ''; if ( StructKeyExists(calOpts,"detailsLink") ) { linkParamsData = application.ptCalendar.calRenderService.buildEventDetailsLinksParams(eventDataStruct=eData); //item['linkParamsData'] = linkParamsData; //item['calOptions'] = calOpts; item['detailsLink'] = application.ptCalendar.calRenderService.buildLinkParamURL( linkURL=calOpts.detailsLink ,linkParamName=linkParamsData.UIDvarName ,linkParamValue=linkParamsData.UIDvalue ,urlParams="" ); } // Add item to the return Array ArrayAppend(retArr, item); } return retArr;