var retIDlist = ""; var storyIDlist = ""; var globalIDlist = ""; var textStrSearchFields = "title,lead_in"; var textStrSearchValue = ""; var searchArray = ArrayNew(1); var storyArray = ArrayNew(1); var s = 1; var r = 1; var i = 1; var a = 1; var b = 1; var c = 1; var d = 1; var gsid = 0; var storyTempArray = ArrayNew(1); var autherUserID = ""; var tagID = ""; // Change spaces between terms in the arguments.searchStr to commas // to allow terms to be seperated in to individual searchable values textStrSearchValue = ListChangeDelims(arguments.searchStr," ",","); //application.npsStory.utils.doDump(textStrSearchValue,"textStrSearchValue",0); // Search the story element for records have the text value in the search fields if ( LEN(TRIM(textStrSearchValue)) ) { searchArray = application.npsStory.storyDAO.getStoryDataBySearch( searchFields=textStrSearchFields, searchValues=textStrSearchValue ); } // Or just get all of the story records else { searchArray = application.npsStory.storyDAO.getStory(); } //application.npsStory.utils.doDump(searchArray,"searchArray",0); //application.npsStory.utils.doDump(arguments.authorIDlist,"arguments.authorIDlist",1); // Search the the returned searchArray for items that contain authorIDs from the authorIDlist if ( LEN(TRIM(arguments.authorIDlist)) ) { storyTempArray = ArrayNew(1); for ( a=1; a LTE ArrayLen(searchArray); a=a+1 ) { for ( b=1; b LTE listLen(arguments.authorIDlist); b=b+1 ) { autherUserID = ListGetAt(arguments.authorIDlist,b); if ( StructKeyExists(searchArray[a],"values") AND StructKeyExists(searchArray[a].values,application.npsStory.appConfig.story.fieldNames.authorEditHistory) AND ListFindNoCase(searchArray[a].values[application.npsStory.appConfig.story.fieldNames.authorEditHistory],autherUserID) NEQ 0 ) { ArrayAppend(storyTempArray,searchArray[a]); break; } } } searchArray = storyTempArray; } // Search the the returned searchArray for items that contain tagIDs from the tagIDlist if ( LEN(TRIM(arguments.tagIDlist)) ) { storyTempArray = ArrayNew(1); for ( c=1; c LTE ArrayLen(searchArray); c=c+1 ) { for ( d=1; d LTE listLen(arguments.tagIDlist); d=d+1 ) { tagID = ListGetAt(arguments.tagIDlist,d); if ( StructKeyExists(searchArray[c],"values") AND StructKeyExists(searchArray[c].values,application.npsStory.appConfig.story.fieldNames.tags) AND ListFindNoCase(searchArray[c].values[application.npsStory.appConfig.story.fieldNames.tags],tagID) NEQ 0 ) { ArrayAppend(storyTempArray,searchArray[c]); break; } } } searchArray = storyTempArray; } // Search the the returned searchArray for items that contain the Park ID Code if ( LEN(TRIM(arguments.parkID)) ) { storyTempArray = ArrayNew(1); for ( c=1; c LTE ArrayLen(searchArray); c=c+1 ) { if ( StructKeyExists(searchArray[c],"values") AND StructKeyExists(searchArray[c].values,application.npsStory.appConfig.story.fieldNames.parkCode) AND ListFindNoCase(searchArray[c].values[application.npsStory.appConfig.story.fieldNames.parkCode],arguments.parkID) NEQ 0 ) { ArrayAppend(storyTempArray,searchArray[c]); } } searchArray = storyTempArray; } //application.npsStory.utils.doDump(searchArray,"searchArray",0); // Get the GlobalStoryIDs for the story records returned in the search Array for ( s=1; s LTE ArrayLen(searchArray); s=s+1 ) { //if ( StructKeyExists(searchArray[s],"values") AND StructKeyExists(searchArray[s].values,application.npsStory.appConfig.story.fieldNames.storyID) AND ListFindNoCase(storyIDlist,searchArray[s].values[application.npsStory.appConfig.story.fieldNames.storyID]) EQ 0 ) //storyIDlist = ListAppend(storyIDlist,searchArray[s].values[application.npsStory.appConfig.story.fieldNames.storyID]); if ( StructKeyExists(searchArray[s],"values") AND StructKeyExists(searchArray[s].values,application.npsStory.appConfig.story.fieldNames.storyID) AND ListFindNoCase(globalIDlist,searchArray[s].values[application.npsStory.appConfig.story.fieldNames.globalStoryID]) EQ 0 ) globalIDlist = ListAppend(globalIDlist,searchArray[s].values[application.npsStory.appConfig.story.fieldNames.globalStoryID]); } //application.npsStory.utils.doDump(globalIDlist,"globalIDlist",0); // Use the GlobalStoryID list and build an Array based on selected search states newStoryArray = ArrayNew(1); for ( i=1; i LTE ListLen(globalIDlist); i=i+1 ) { gsid = ListGetAt(globalIDlist,i); storyTempArray = ArrayNew(1); if ( LEN(TRIM(gsid)) AND gsid NEQ 0 ) { // Conditions for STATE filtering: // - ARCHIVED (Archived - ALL WIP and ACTIVE) if ( ListLen(arguments.storyState) EQ 1 AND ListFindNoCase(arguments.storyState,"archived") ) { storyTempArray = application.npsStory.storyDAO.getStoryVerisonsByGlobalStoryID(globalStoryID=gsid,version="MAX",state="archived"); } else if ( ListFindNoCase(arguments.storyState,"archived") AND ListFindNoCase(arguments.storyState,"WIP") AND ListFindNoCase(arguments.storyState,"active") ) { storyTempArray = application.npsStory.storyDAO.getStoryVerisonsByGlobalStoryID(globalStoryID=gsid,version="MAX",state="archived"); } // - ARCHIVED & WIP (Archived NO active - max version) else if ( ListFindNoCase(arguments.storyState,"archived") AND ListFindNoCase(arguments.storyState,"WIP") ) { storyTempArray = application.npsStory.storyDAO.getStoryVerisonsByGlobalStoryID(globalStoryID=gsid,version="MAX",state="archived",excludeStates="active"); } // - ARCHIVED & ACTIVE (Archived NO WIP - max version) else if ( ListFindNoCase(arguments.storyState,"archived") AND ListFindNoCase(arguments.storyState,"active") ) { storyTempArray = application.npsStory.storyDAO.getStoryVerisonsByGlobalStoryID(globalStoryID=gsid,version="MAX",state="archived",excludeStates="WIP"); } // - WIP (WIP only but NO Archived - max version) // - PUBLISHED (Active only but NO Archived - max version) else if ( ListLen(arguments.storyState) EQ 1 ) { storyTempArray = application.npsStory.storyDAO.getStoryVerisonsByGlobalStoryID(globalStoryID=gsid,version="MAX",state=arguments.storyState,excludeStates="archived"); } // - WIP & PUBLISHED (ALL but NO Archived - max version) else { storyTempArray = application.npsStory.storyDAO.getStoryVerisonsByGlobalStoryID(globalStoryID=gsid,version="MAX",excludeStates="archived"); } } // Combine the search arrays in to a final combined array if ( ArrayLen(storyTempArray) ) ArrayAppend(newStoryArray,storyTempArray[1]); } //application.npsStory.utils.doDump(newStoryArray,"newStoryArray",0); // Take the final array and build a StoryID list for ( r=1; r LTE ArrayLen(newStoryArray); r=r+1 ) { //if ( StructKeyExists(newStoryArray[r],"values") AND StructKeyExists(newStoryArray[r].values,application.npsStory.appConfig.story.fieldNames.storyID) AND ListFindNoCase(storyIDlist,newStoryArray[r].values[application.npsStory.appConfig.story.fieldNames.storyID]) EQ 0 ) retIDlist = ListAppend(retIDlist,newStoryArray[r].values[application.npsStory.appConfig.story.fieldNames.storyID]); } return retIDlist;