Metropoli BBS
VIEWER: commands.asp MODE: TEXT (ASCII)
<% @ LANGUAGE=VBSCRIPT CODEPAGE = 1252 %>
<% response.buffer = true %>
<!--#include file="../constant.inc"-->
<!--#include file="../lib/getrend.inc"-->
<!--#include file="../lib/session.inc"-->
<% SendHeader 0, 1%>
<!--#include file="../lib/pageutil.inc"-->
<!--#include file="../lib/jsroot.inc"-->

<%
'<!--Microsoft Outlook Web Access-->
'<!--viewer commands.asp
'<!--Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.-->

On Error Resume Next
var objFolder

'constants - params for doLoadEvent()
iParamError         = -1
iParamNone          = 0
iParamGotoFolder    = 1
iParamCalendarView  = 2
iParamCreatedFolder = 3
iParamDeletedFolder = 4
iParamCheckMessages = 5
iParamUpdateView    = 6
iParamDeletedMarkedMessages = 7
iParamContactView   = 8

bstrParamErrMsg     = ""

urlCommand  = lcase(Request.QueryString("command"))
urlAction   = Lcase(Request.QueryString("action"))
If urlCommand = "" and urlAction = "" then 'If both of these values are nothing then we were posted to
    urlAction   = lcase(Request.Form("action"))
    urlCommand  = lcase(Request.Form("command")) 
    urlObj      = Request.Form("obj")
    urlStore    = Request.Form("store")
    
Else
    urlObj      = Request.QueryString("obj")
    urlStore    = Request.QueryString("store")
End If

iLoadCommand   = iParamNone 'default to do nothing

If urlStore="" Then 
    iStore=1
Else
    iStore=cint(urlStore)
End if

'always validate the session
fTimedOut = false

if Not CheckSession3("1","newwindow",urlStore) Then 
    fTimedOut  = true
    urlAction  = ""
    urlCommand = ""
end if

nAccess=-1 'full permissions default

If urlAction<>"" THEN 'performing some action on the current folder obj
    iLoadCommand=iParamNone
    Set objFolder  = Session(CURRENT_FOLDER)
    If IsSpecialFolder(objFolder.ID) Then 
        fIsSpecialFolder = true
    Else
        fIsSpecialFolder = false
    End If

    If urlAction="newfolder" Then               '*** CREATE A NEW FOLDER
        Set objFolders = Session(CURRENT_HIERARCHY)
	    Set objNewFolder = objFolders.Add(Request.Form("folderName"))
    	If Err.Number<>0 Then 
            iLoadCommand = iParamError
            bstrParamErrMsg = L_errFailCreateFolder_ErrorMessage
        Else
            iLoadCommand = iParamCreatedFolder
        End If
    ElseIf urlAction="deletefolder" Then        '*** DELETE CURRENT FOLDER
        If fSpecialFolder<>false Then 
            iLoadCommand    = iParamError
	        bstrParamErrMsg = L_errFailDeleteFolder_ErrorMessage
        Else
            OpenAllStores	    
	        bstrParentFolderID = objFolder.FolderID
            DeleteItem objFolder
            If Err.Number <> 0 Then
                iLoadCommand    = iParamError
	            if Err.Number = -2147219964 then
                    bstrParamErrMsg = L_errFailDeleteFolder_ErrorMessage + "\n" + L_errDeletedItemExists_ErrorMessage
	            else
                    bstrParamErrMsg = L_errFailDeleteFolder_ErrorMessage
                end if
            Else
                iLoadCommand    = iParamDeletedFolder
            End If
        End If
    ElseIf urlAction="deleteallmessages" Then   '*** DELETE ALL MESSAGES IN DELETED ITEMS FOLDER
		If (Session(bstrAuthenticated)) Then
			objOMSession.getDefaultFolder(ActMsgDefaultFolderDeletedItems).Messages.Delete
			objOMSession.getDefaultFolder(ActMsgDefaultFolderDeletedItems).Folders.Delete
		Else
            iLoadCommand = iParamError
	        bstrParamErrMsg = L_errFailDeleteMessage_ErrorMessage
		End If
    ElseIf urlAction="deletemarkedmessages" Then   '*** DELETE ALL CHECKED MESSAGES
        DeleteItems
        If Err.Number <> 0 Then
            iLoadCommand = iParamError
	        bstrParamErrMsg = L_errFailDeleteMessage_ErrorMessage
        Else
            iLoadCommand = iParamDeletedMarkedMessages
        End If
    End If
ELSE

    SELECT CASE urlCommand
    CASE "newfolder"                            '*** GOTO ANOTHER FOLDER
        set objFolder = nothing
        'not passed a store then open folder and get it
        if urlStore="" Then 
            Set objFolder = OpenFolder(urlObj)
            If objFolder is Nothing then
                iStore = -1 'error state - folder doesn't exist or something
                iLoadCommand = iParamError
                bstrParamErrMsg = L_errFolderNotReplicated_ErrorMessage
            Else
                If objFolder.StoreID = Session(bstrPublicStoreID) Then
                    iStore = 1
                Else
                    iStore = 0
                End If
            End if
        end if

        If iStore > -1 Then 'we have a store!
            InitPage iStore
            If Err.Number=424 And iStore=1 Then 'folder not available error
                iStore = -1 'error state - folder doesn't exist or something
                iLoadCommand = iParamError
                bstrParamErrMsg = L_errFolderNotReplicated_ErrorMessage
            Else
                iLoadCommand   = iParamGotoFolder
                Set objFolder  = Session(CURRENT_FOLDER)
                If IsSpecialFolder(objFolder.ID) Then 
                    fIsSpecialFolder = true
                Else
                    fIsSpecialFolder = false
                End If
                
                bstrFolderID   = objFolder.ID
                bstrFolderType = objFolder.Fields.Item(ActMsgPR_CONTAINER_CLASS).Value

                If       bstrFolderType="IPF.Appointment" Then
                    iLoadCommand=iParamCalendarView 
                ElseIf   bstrFolderType = "IPF.Contact" Then
                    iLoadCommand = iParamContactView                
                ElseIf iStore <> PRIVATE_AUTHENTICATED Then
		            'check for permission (this is 0 if 'none' or 'not available')
		            'err.clear
                    nAccess = objFolder.Fields.Item(ActMsgPR_ACCESS) 
                    'If Err.Number <> 0 Then nAccess=0
                End If
            End if
        Else 'no store no obj...TopOfIF for anon?
            iLoadCommand   = iParamGotoFolder
            iStore = 1
            InitPage 1
            bstrFolderID = ""
        End If

    CASE "checkmessages"
        InitPage cint(urlStore) 'resets Session(CURRENT_FOLDER)
        Set objFolder  = Session(CURRENT_FOLDER)
        bstrFolderID   = objFolder.ID
        iLoadCommand    = iParamCheckMessages
    
    CASE "updateview"
        InitPage cint(urlStore) 'resets Session(CURRENT_FOLDER)
        iLoadCommand    = iParamUpdateView

    END SELECT
END IF
%>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<script language='javascript'>
<% IF NOT fTimedOut THEN 'drop thru if timed out%>
var L_CalFolderNotSupported_Message = "This version of Outlook Web Access only supports your primary calendar folder.";
var L_ConFolderNotSupported_Message = "This version of Outlook Web Access only supports your primary contact folder.";

<% If iLoadCommand = iParamGotoFolder Then %>
    <% if nAccess=0 Then %>
        alert("<%=L_errInsufficientPermissions_ErrorMessage%>");
    <% else %>
        parent.currentPage=1;
        parent.iCurView = <%=Session(CURRENT_VIEW)%>;
        parent.fIsSpecialFolder = eval(<% if fIsSpecialFolder then %> true <% else %> false <% end if %>);
        parent.szCurFolderID = "<%=bstrFolderID%>";
        <%If iStore=1 Then %>
        parent.szCurPubFID="<%=bstrFolderID%>";
        parent.iCurCompose=1;
        <%ElseIf iStore=0 Then%>
        parent.szCurPvtFID="<%=bstrFolderID%>";
        parent.iCurCompose=0;
        <%End If%>
        if (parent.peer_fr != null) parent.peer_fr.location  = "<%=bstrVirtRoot%>/inbox/peerfldr.asp?obj=<%=bstrFolderID%>&store=<%=iStore%>&timedout="+parent.fTimedOut;
        if (parent.title_fr!=null)  {
           if (parent.fIsAnon) parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/titlea.asp?compidx="+parent.iCurCompose;
           else parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/title.asp?compidx="+parent.iCurCompose+"&store=<%=iStore%>";
        }
        if (parent.msg_fr!=null)  parent.msg_fr.location = "<%=bstrVirtRoot%>/inbox/messages.asp?obj=<%=bstrFolderID%>&store=<%=iStore%>";
    <% end if %>
<% ElseIf iLoadCommand = iParamCheckMessages Then %>
        if (parent.peer_fr != null) parent.peer_fr.location  = "<%=bstrVirtRoot%>/inbox/peerfldr.asp?obj=<%=bstrFolderID%>&store=<%=iStore%>";
        if (parent.title_fr!=null)  {
           if (parent.fIsAnon) parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/titlea.asp?compidx="+parent.iCurCompose;
           else parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/title.asp?compidx="+parent.iCurCompose+"&store=<%=iStore%>";
        }
        if (parent.msg_fr!=null)  parent.msg_fr.location = "<%=bstrVirtRoot%>/inbox/messages.asp?obj=<%=bstrFolderID%>&store=<%=iStore%>";

<% ElseIf iLoadCommand = iParamDeletedMarkedMessages Then %>
        parent.CheckNewMail();

<% ElseIf iLoadCommand = iParamCalendarView Then 
       If bstrFolderID = objOMSession.GetDefaultFolder(0).ID Then 'is the default calendar folder
          If Err.Number<>0 Then %>
             alert(L_CalFolderNotSupported_Message);
<%        Else %>
             parent.parent.RefreshNavbar(2);
<%        End If %>
<%     Else %>
          alert(L_CalFolderNotSupported_Message);
<%     End If %>
<% ElseIf iLoadCommand = iParamContactView Then 
       If bstrFolderID = objOMSession.GetDefaultFolder(5).ID Then 'is the default contact folder
          If Err.Number<>0 Then %>
             alert(L_ConFolderNotSupported_Message);
<%        Else %>
             parent.parent.RefreshNavbar(3);
<%        End If %>
<%     Else %>
          alert(L_ConFolderNotSupported_Message);
<%     End If %>
<% ElseIf iLoadCommand = iParamCreatedFolder Then %>
        if (parent.peer_fr != null) parent.peer_fr.location  = "<%=bstrVirtRoot%>/inbox/peerfldr.asp?obj=<%=urlObj%>&store=<%=iStore%>";

<% ElseIf iLoadCommand = iParamDeletedFolder Then 'current folder gone so redirect commands to parent folder %>
        window.location  = "<%=bstrVirtRoot%>/inbox/commands.asp?command=newfolder&obj=<%=bstrParentFolderID%>&store=<%=iStore%>";

<% ElseIf iLoadCommand = iParamUpdateView Then %>
        if (parent.title_fr!=null)  {
           if (parent.fIsAnon) parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/titlea.asp?page=1&view=<%=Request.Querystring("view")%>";
           else parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/title.asp?page=<%=Request.Querystring("page")%>&view=<%=Request.Querystring("view")%>&compidx="+parent.iCurCompose;
        }
        if (parent.msg_fr!=null) parent.msg_fr.location = "<%=bstrVirtRoot%>/inbox/messages.asp?obj=<%=urlObj%>&page=<%=Request.Querystring("page")%>&view=<%=Request.Querystring("view")%>&compidx="+parent.iCurCompose+"&store=<%=iStore%>";

<% ElseIf iLoadCommand = iParamError Then %>
    alert("<%=bstrParamErrMsg%>");

<% End If %>
<% END IF 'fTimedOut%>
<%IF lcase(urlCommand) <> "nothing" then%>
parent.fTimedOut = eval(<% if fTimedOut then %> true <% else %> false <% end if %>); //must be set last
<%End If%>
</script>
<body>
<FORM name="commandform" ACTION="commands.asp" METHOD="POST" target="command_fr">
    <input type="hidden" name="action" value="newfolder">
    <input type="hidden" name="foldername" value="">
    <input type="hidden" name="obj" value="">
    <input type="hidden" name="store" value="">
</Form>
</body>
</HTML>

[ RETURN TO DIRECTORY ]