<% '!--Microsoft Outlook Web Access--> '!--pageutil.inc - functions that help with page processing --> '!--Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.--> Sub DeleteItem(obj) Dim objMoveObj Dim bIsAuthenticated Dim strDeletedItemsID Dim strPublicStoreID If (Not obj Is Nothing) Then bIsAuthenticated = Session(bstrAuthenticated) 'Check to make sure user is authenticated. If not authenticated then delete the object. If bIsAuthenticated then 'Get the deleted items entry id from the session. strDeletedItemsID = Session(bstrDeletedItemsID) strPublicStoreID = Session(bstrPublicStoreEntryID) 'If the object is not in the public store or in the Deleted items folder then 'the object is moved to the deleted items folder. If obj.StoreID <> strPublicStoreID and obj.FolderID <> strDeletedItemsID then obj.Delete True If (Err.Number <> 0) Then ReportError1 L_errFailDeleteMessage_ErrorMessage Else Set objMoveObj = Nothing End If Else 'The object is deleted if it is already in the deleted items folder obj.Delete If (Err.Number <> 0) Then ReportError1 L_errFailDeleteMessage_ErrorMessage End If End If Else obj.Delete If (Err.Number <> 0) Then ReportError1 L_errFailDeleteMessage_ErrorMessage End If End If End If Set obj = Nothing End Sub '======================= ' DeleteItemByID ' ' szObj - EntryID for Object ' bIsFolder - Default is false. If it is a folder then pass in True. ' Deletes items in private or public store. Items are actually moved to deleted items ' folder if they are in the private store. ' Dependencies: The session objects must be instantiated before calling this sub. '======================= Sub DeleteItemByID(szObj, bIsFolder) Dim obj If bIsFolder then Set obj = OpenFolder(szObj) Else Set obj = OpenMessage(szObj) End If If (obj Is Nothing) Then ReportError1 L_errFailDeleteAccess_ErrorMessage Else DeleteItem obj End If End Sub '======================= ' DeleteItems ' ' Delete list of items '======================= Public Sub DeleteItems For Each szElement In Request.Form If IsNumeric(szElement) Then szEntryID = Request.Form(szElement) Set objMessage = OpenMessage(szEntryID) If (objMessage Is Nothing) Then ReportError1 L_errFailDeleteAccess_ErrorMessage Else DeleteItem objMessage Set objMessage = Nothing End If End If Next End Sub '======================= ' CheckIndex ' ' Check index returned and assign to session '======================= Public Sub CheckIndex strIndex = Request.QueryString("index") If Len(strIndex) > 0 Then iIndex = CInt(strIndex) Session(CURRENT_INDEX) = iIndex End If End Sub '======================= ' CheckPage ' ' Check state returned and assign to session '======================= Public Sub CheckPage(objRenderer) On Error Resume Next If (Not objRenderer Is Nothing) Then iCurrentView = CInt(Request.QueryString("view")) If iCurrentView > 0 Then ' set up the view objRenderer.CurrentView = iCurrentView ' set up page count Set objMessages = Session(CURRENT_CONTENTS) cMessages = objMessages.Count If cMessages < 1 Then cPages = 1 Else cRows = Session(CURRENT_ROWS) cPages = (cMessages - 1) \ cRows cPages = cPages + 1 End If Session(CURRENT_COUNT) = cMessages Session(CURRENT_INDEX) = 1 Session(CURRENT_PAGES) = cPages Session(CURRENT_VIEW) = iCurrentView End If iPage = CInt(Request.QueryString("page")) If iPage > 0 Then cPages = Session(CURRENT_PAGES) If iPage > cPages Then Session(CURRENT_PAGE) = cPages Else Session(CURRENT_PAGE) = iPage End If End If End If 'objRender <> nothing End Sub '======================= ' InitPage ' ' Initialise page state - parses URL '======================= Public Sub InitPage(nType) On Error Resume Next If Not Session(bstrAuthenticated) Then nType = PUBLIC_ANONYMOUS End If ' set up the folder object szObj = Request.QueryString("obj") If nType = PRIVATE_AUTHENTICATED Then OpenPrivateStore If szObj = "" Then Set objFolder = objOMSession.Inbox If (objFolder Is Nothing) Then ReportError1 L_errFailedToGetInbox_ErrorMessage End If szObj = objFolder.ID Else Set objFolder = OpenFolder(szObj) End If If (objFolder Is Nothing) Then ReportError1 L_errFailedToGetInbox_ErrorMessage End If ElseIf nType = PUBLIC_AUTHENTICATED Then OpenPublicStore If szObj = "" Then szObj = Session(bstrPublicStoreRootID) End If Set objFolder = OpenFolder(szObj) If (objFolder Is Nothing) Then ReportError1 L_errFailGetPubFolder_ErrorMessage End If ElseIf nType = PUBLIC_ANONYMOUS Then OpenPublicStore If szObj = "" Then Set objFolder = Nothing Else Set objFolder = OpenFolder(szObj) End If End If 'set up the messages renderer If nType = PUBLIC_ANONYMOUS And objFolder Is Nothing Then ' We're rendering the hierarchy for the anonymous root. ' set up the hierarchy renderer Set objHRenderer = GetPublicHierarchyRenderer(fNew) ' This is not a real folder, but a list of folder IDs defined ' by the administrator and stored with our DS config information. Set objApplication = Application( bstrRenderApp ) aPubFolders = objApplication.ConfigParameter("Published Public Folders") If Not IsEmpty(aPubFolders) Then i = UBound(aPubFolders) If i >= LBound(aPubFolders) Then ReDim Preserve aPubFolders(i+2) ' To the list of folders, add two things: ' ...a name for the pseudo-folder we're making up aPubFolders(i+1) = L_PublicFolders_Text ' ...and a store interface so the renderer can get stuff from the folders Set aPubFolders(i+2) = Session(bstrObjPublicStore) ' Now give it to the renderer Err.Clear objHRenderer.DataSource = aPubFolders If (Err.Number <> 0) Then ReportError1 L_errFailGetAnonPubFolders_ErrorMessage End If End If End If Set Session(CURRENT_FOLDER) = Nothing Set Session(CURRENT_CONTENTS) = Nothing Set Session(CURRENT_HIERARCHY) = Nothing SetPageDefaults Else Set objCRenderer = GetMessagesRenderer(fNew) Set objCur = objCRenderer.DataSource If objCur Is Nothing Then Err.Clear Set objMessages = objFolder.Messages ' Traps the case where the folder is there but either not yet ' replicated or the folders server is down. If objMessages Is Nothing Then Exit Sub 'let caller handle err.number Else objCRenderer.DataSource = objMessages ApplyCheckBoxColumn(objCRenderer) End If Else If Not objFolder.IsSameAs(objCur.Parent) Then Err.Clear Set objMessages = objFolder.Messages ' Traps the case where the folder is there but either not yet ' replicated or the folders server is down. If objMessages Is Nothing Then Exit Sub 'let caller handle err.number Else objCRenderer.DataSource = objMessages ApplyCheckBoxColumn(objCRenderer) End If Else Set objMessages = objCur End If End If If (Err.Number <> 0) Then ReportError1 L_errInternalErrorRendObj_ErrorMessage End If ' apply checkbox column to a new renderer ApplyStockCheckBoxColumn( objCRenderer) ' set up the view iCurrentView = CInt(Request.QueryString("view")) If iCurrentView > 0 Then objCRenderer.CurrentView = iCurrentView Else iCurrentView = objCRenderer.CurrentView.Index End If ' set up the rows per page cRows = CInt(Request.QueryString("rows")) If cRows < 1 Then cRows = iDefaultNumRows End If objCRenderer.RowsPerPage = cRows ' set up page count If objMessages Is Nothing Then cMessages = 0 Else cMessages = objMessages.Count End If If cMessages < 1 Then cPages = 1 Else cPages = (cMessages - 1) \ cRows cPages = cPages + 1 End If ' set up the hierarchy renderer If nType > PRIVATE_AUTHENTICATED Then Set objHRenderer = GetPublicHierarchyRenderer(fNew) Else Set objHRenderer = GetPrivateHierarchyRenderer(fNew) End If Set objCur = objHRenderer.DataSource If objCur Is Nothing Then Err.Clear Set objFolders = objFolder.Folders objHRenderer.DataSource = objFolders Else If Not objFolder.IsSameAs(objCur.Parent) Then Err.Clear Set objFolders = objFolder.Folders objHRenderer.DataSource = objFolders Else Set objFolders = objCur End If End If If (Err.Number <> 0) Then ReportError1 L_errInternalErrorDataSrc_ErrorMessage End If iPage = CInt(Request.QueryString("page")) If iPage < 1 Then iPage = 1 End If Set Session(CURRENT_FOLDER) = objFolder Set Session(CURRENT_CONTENTS) = objMessages Set Session(CURRENT_HIERARCHY) = objFolders Session(CURRENT_INDEX) = 1 Session(CURRENT_COUNT) = cMessages Session(CURRENT_PAGES) = cPages Session(CURRENT_ROWS) = cRows Session(CURRENT_VIEW) = iCurrentView Session(CURRENT_PAGE) = iPage End If End Sub '======================= ' IsSpecialFolder ' ' checks for special folders '======================= Public Function IsSpecialFolder(szObj) IsSpecialFolder = False Set objStore = Session(bstrObjPrivateStore) If Not objStore Is Nothing Then If (szObj = objOMSession.Inbox.ID) Or _ (szObj = objStore.Fields.Item(ActMsgPR_IPM_OUTBOX_ENTRYID).Value) Or _ (szObj = objStore.Fields.Item(ActMsgPR_IPM_WASTEBASKET_ENTRYID).Value) Or _ (szObj = objStore.Fields.Item(ActMsgPR_IPM_SENTMAIL_ENTRYID).Value) Or _ (szObj = objStore.Fields.Item(ActMsgPR_IPM_SUBTREE_ENTRYID).Value) Then IsSpecialFolder = True End If End If End Function '======================= ' FolderAction ' ' Execute requested folder action ' Returns TRUE if action was delete '======================= Public Function FolderAction(objFolder) On Error Resume Next FolderAction = 0 ' deal with any special actions Action = Request.QueryString("action") If (Err.Number <> 0) Then ReportErrorLoad L_errGeneralErr_ErrorMessage, bstrVirtRoot + "/root.asp?obj=" + objFolder.ID End If If Action="newFolder" Then Set objFolders = Session(CURRENT_HIERARCHY) Set objNewFolder = objFolders.Add(Request.QueryString("folderName")) FolderAction = Err.Number 'let the caller handle this ElseIf Action="deleteFolder" Then OpenAllStores If IsSpecialFolder(objFolder.ID) Then ReportErrorLoad L_errFailDeleteFolder_ErrorMessage, bstrVirtRoot + "/root.asp?obj=" + objFolder.ID End If DeleteItem objFolder If (Err.Number <> 0) Then ReportErrorLoad L_errFailDeleteFolder_ErrorMessage, bstrVirtRoot + "/root.asp?obj=" + objFolder.ID End If FolderAction = -1 End If End Function Public Sub EmptyDeletedItemsFldr If (Session(bstrAuthenticated)) Then objOMSession.getDefaultFolder(ActMsgDefaultFolderDeletedItems).Messages.Delete objOMSession.getDefaultFolder(ActMsgDefaultFolderDeletedItems).Folders.Delete Else ReportError1 L_errFailDeleteMessage_ErrorMessage End If End Sub %>