home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / CHIPCD_3_98.iso / software / testsoft / exchange / webdata / usa / inbox / commands.asp next >
Text File  |  1997-08-25  |  11KB  |  259 lines

  1. <% response.buffer = true %>
  2. <!--#include file="../constant.inc"-->
  3. <!--#include file="../lib/getrend.inc"-->
  4. <!--#include file="../lib/session.inc"-->
  5. <!--#include file="../lib/pageutil.inc"-->
  6. <!--#include file="../lib/jsroot.inc"-->
  7.  
  8. <%
  9. '<!--Microsoft Outlook Web Access-->
  10. '<!--viewer commands.asp
  11. '<!--Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.-->
  12.  
  13. On Error Resume Next
  14. var objFolder
  15.  
  16. 'constants - params for doLoadEvent()
  17. iParamError         = -1
  18. iParamNone          = 0
  19. iParamGotoFolder    = 1
  20. iParamCalendarView  = 2
  21. iParamCreatedFolder = 3
  22. iParamDeletedFolder = 4
  23. iParamCheckMessages = 5
  24. iParamUpdateView    = 6
  25. iParamDeletedMarkedMessages = 7
  26.  
  27. bstrParamErrMsg     = ""
  28.  
  29. urlCommand  = lcase(Request.QueryString("command"))
  30. urlAction   = Lcase(Request.QueryString("action"))
  31. If urlCommand = "" and urlAction = "" then 'If both of these values are nothing then we were posted to
  32.     urlAction   = lcase(Request.Form("action"))
  33.     urlCommand  = lcase(Request.Form("command")) 
  34.     urlObj      = Request.Form("obj")
  35.     urlStore    = Request.Form("store")
  36.     
  37. Else
  38.     urlObj      = Request.QueryString("obj")
  39.     urlStore    = Request.QueryString("store")
  40. End If
  41.  
  42. iLoadCommand   = iParamNone 'default to do nothing
  43.  
  44. If urlStore="" Then 
  45.     iStore=1
  46. Else
  47.     iStore=cint(urlStore)
  48. End if
  49.  
  50. 'always validate the session
  51. fTimedOut = false
  52.  
  53. if Not CheckSession3("1","newwindow",urlStore) Then 
  54.     fTimedOut  = true
  55.     urlAction  = ""
  56.     urlCommand = ""
  57. end if
  58.  
  59. nAccess=-1 'full permissions default
  60.  
  61. If urlAction<>"" THEN 'performing some action on the current folder obj
  62.     iLoadCommand=iParamNone
  63.     'TODO: we are assuming the session still has the current folder here
  64.     'we must be passed in obj and store (need to check???)
  65.     If urlAction <> "newfolder" Then 'Initpage is not needed when creating new folder
  66.         InitPage iStore 'resets Session(CURRENT_FOLDER)
  67.     End If
  68.     Set objFolder  = Session(CURRENT_FOLDER)
  69.     If IsSpecialFolder(objFolder.ID) Then 
  70.         fIsSpecialFolder = true
  71.     Else
  72.         fIsSpecialFolder = false
  73.     End If
  74.  
  75.     If urlAction="newfolder" Then               '*** CREATE A NEW FOLDER
  76.         Set objFolders = Session(CURRENT_HIERARCHY)
  77.         Set objNewFolder = objFolders.Add(Request.Form("folderName"))
  78.         If Err.Number<>0 Then 
  79.             iLoadCommand = iParamError
  80.             bstrParamErrMsg = L_errFailCreateFolder_ErrorMessage
  81.         Else
  82.             iLoadCommand = iParamCreatedFolder
  83.         End If
  84.     ElseIf urlAction="deletefolder" Then        '*** DELETE CURRENT FOLDER
  85.         If fSpecialFolder<>false Then 
  86.             iLoadCommand    = iParamError
  87.             bstrParamErrMsg = L_errFailDeleteFolder_ErrorMessage
  88.         Else
  89.             OpenAllStores        
  90.             bstrParentFolderID = objFolder.FolderID
  91.             DeleteItem objFolder
  92.             If Err.Number <> 0 Then
  93.                 iLoadCommand    = iParamError
  94.                 if Err.Number = -2147219964 then
  95.                     bstrParamErrMsg = L_errFailDeleteFolder_ErrorMessage + "\n" + L_errDeletedItemExists_ErrorMessage
  96.                 else
  97.                     bstrParamErrMsg = L_errFailDeleteFolder_ErrorMessage
  98.                 end if
  99.             Else
  100.                 iLoadCommand    = iParamDeletedFolder
  101.             End If
  102.         End If
  103.     ElseIf urlAction="deleteallmessages" Then   '*** DELETE ALL MESSAGES IN DELETED ITEMS FOLDER
  104.         If (Session(bstrAuthenticated)) Then
  105.             objOMSession.getDefaultFolder(ActMsgDefaultFolderDeletedItems).Messages.Delete
  106.             objOMSession.getDefaultFolder(ActMsgDefaultFolderDeletedItems).Folders.Delete
  107.         Else
  108.             iLoadCommand = iParamError
  109.             bstrParamErrMsg = L_errFailDeleteMessage_ErrorMessage
  110.         End If
  111.     ElseIf urlAction="deletemarkedmessages" Then   '*** DELETE ALL CHECKED MESSAGES
  112.         DeleteItems
  113.         If Err.Number <> 0 Then
  114.             iLoadCommand = iParamError
  115.             bstrParamErrMsg = L_errFailDeleteMessage_ErrorMessage
  116.         Else
  117.             iLoadCommand = iParamDeletedMarkedMessages
  118.         End If
  119.     End If
  120. ELSE
  121.  
  122.     SELECT CASE urlCommand
  123.     CASE "newfolder"                            '*** GOTO ANOTHER FOLDER
  124.         set objFolder = nothing
  125.         'not passed a store then open folder and get it
  126.         if urlStore="" Then 
  127.             Set objFolder = OpenFolder(urlObj)
  128.             If objFolder is Nothing then
  129.                 iStore = -1 'error state - folder doesn't exist or something
  130.                 iLoadCommand = iParamError
  131.                 bstrParamErrMsg = L_errFolderNotReplicated_ErrorMessage
  132.             Else
  133.                 If objFolder.StoreID = Session(bstrPublicStoreID) Then
  134.                     iStore = 1
  135.                 Else
  136.                     iStore = 0
  137.                 End If
  138.             End if
  139.         end if
  140.  
  141.         If iStore > -1 Then 'we have a store!
  142.             InitPage iStore
  143.             If Err.Number=424 And iStore=1 Then 'folder not available error
  144.                 iStore = -1 'error state - folder doesn't exist or something
  145.                 iLoadCommand = iParamError
  146.                 bstrParamErrMsg = L_errFolderNotReplicated_ErrorMessage
  147.             Else
  148.                 iLoadCommand   = iParamGotoFolder
  149.                 Set objFolder  = Session(CURRENT_FOLDER)
  150.                 If IsSpecialFolder(objFolder.ID) Then 
  151.                     fIsSpecialFolder = true
  152.                 Else
  153.                     fIsSpecialFolder = false
  154.                 End If
  155.                 
  156.                 bstrFolderID   = objFolder.ID
  157.                 bstrFolderType = objFolder.Fields.Item(ActMsgPR_CONTAINER_CLASS).Value
  158.  
  159.                 If bstrFolderType="IPF.Appointment" Then
  160.                     iLoadCommand=iParamCalendarView 
  161.                 ElseIf iStore <> PRIVATE_AUTHENTICATED Then
  162.                     'check for permission (this is 0 if 'none' or 'not available')
  163.                     'err.clear
  164.                     nAccess = objFolder.Fields.Item(ActMsgPR_ACCESS) 
  165.                     'If Err.Number <> 0 Then nAccess=0
  166.                 End If
  167.             End if
  168.         Else 'no store no obj...TopOfIF for anon?
  169.             iLoadCommand   = iParamGotoFolder
  170.             iStore = 1
  171.             InitPage 1
  172.             bstrFolderID = ""
  173.         End If
  174.  
  175.     CASE "checkmessages"
  176.         InitPage cint(urlStore) 'resets Session(CURRENT_FOLDER)
  177.         Set objFolder  = Session(CURRENT_FOLDER)
  178.         bstrFolderID   = objFolder.ID
  179.         iLoadCommand    = iParamCheckMessages
  180.     
  181.     CASE "updateview"
  182.         InitPage cint(urlStore) 'resets Session(CURRENT_FOLDER)
  183.         iLoadCommand    = iParamUpdateView
  184.  
  185.     END SELECT
  186. END IF
  187. %>
  188.  
  189. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">
  190. <HTML>
  191. <HEAD>
  192. <script language='javascript'>
  193. <% IF NOT fTimedOut THEN 'drop thru if timed out%>
  194.  
  195. <% If iLoadCommand = iParamGotoFolder Then %>
  196.     <% if nAccess=0 Then %>
  197.         alert("Insufficient permissions to folder");
  198.     <% else %>
  199.         parent.fIsSpecialFolder = eval(<%=fIsSpecialFolder%>);
  200.         parent.szCurFolderID = "<%=bstrFolderID%>";
  201.         <%If iStore=1 Then %>
  202.         parent.szCurPubFID="<%=bstrFolderID%>";
  203.         parent.iCurCompose=1;
  204.         <%ElseIf iStore=0 Then%>
  205.         parent.szCurPvtFID="<%=bstrFolderID%>";
  206.         parent.iCurCompose=0;
  207.         <%End If%>
  208.         if (parent.peer_fr != null) parent.peer_fr.location  = "<%=bstrVirtRoot%>/inbox/peerfldr.asp?obj=<%=bstrFolderID%>&store=<%=iStore%>";
  209.         if (parent.title_fr!=null)  {
  210.            if (parent.fIsAnon) parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/titlea.asp?compidx="+parent.iCurCompose;
  211.            else parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/title.asp?compidx="+parent.iCurCompose+"&store=<%=iStore%>";
  212.         }
  213.         if (parent.msg_fr!=null)  parent.msg_fr.location = "<%=bstrVirtRoot%>/inbox/messages.asp?obj=<%=bstrFolderID%>&store=<%=iStore%>";
  214.     <% end if %>
  215. <% ElseIf iLoadCommand = iParamCheckMessages Then %>
  216.         if (parent.peer_fr != null) parent.peer_fr.location  = "<%=bstrVirtRoot%>/inbox/peerfldr.asp?obj=<%=bstrFolderID%>&store=<%=iStore%>";
  217.         if (parent.title_fr!=null)  {
  218.            if (parent.fIsAnon) parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/titlea.asp?compidx="+parent.iCurCompose;
  219.            else parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/title.asp?compidx="+parent.iCurCompose+"&store=<%=iStore%>";
  220.         }
  221.         if (parent.msg_fr!=null)  parent.msg_fr.location = "<%=bstrVirtRoot%>/inbox/messages.asp?obj=<%=bstrFolderID%>&store=<%=iStore%>";
  222.  
  223. <% ElseIf iLoadCommand = iParamDeletedMarkedMessages Then %>
  224.         self.location = "<%=bstrVirtRoot%>/inbox/commands.asp?command=checkmessages&obj="+parent.szCurFolderID+"&store="+parent.iCurStore;
  225.  
  226. <% ElseIf iLoadCommand = iParamCalendarView Then %>
  227.         parent.parent.RefreshNavbar(2);
  228.  
  229. <% ElseIf iLoadCommand = iParamCreatedFolder Then %>
  230.         if (parent.peer_fr != null) parent.peer_fr.location  = "<%=bstrVirtRoot%>/inbox/peerfldr.asp?obj=<%=urlObj%>&store=<%=iStore%>";
  231.  
  232. <% ElseIf iLoadCommand = iParamDeletedFolder Then 'current folder gone so redirect commands to parent folder %>
  233.         window.location  = "<%=bstrVirtRoot%>/inbox/commands.asp?command=newfolder&obj=<%=bstrParentFolderID%>&store=<%=iStore%>";
  234.  
  235. <% ElseIf iLoadCommand = iParamUpdateView Then %>
  236.         if (parent.title_fr!=null)  {
  237.            if (parent.fIsAnon) parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/titlea.asp?page=1&view=<%=Request.Querystring("view")%>";
  238.            else parent.title_fr.location = "<%=bstrVirtRoot%>/inbox/title.asp?page=1&view=<%=Request.Querystring("view")%>&compidx="+parent.iCurCompose;
  239.         }
  240.         if (parent.msg_fr!=null) parent.msg_fr.location = "<%=bstrVirtRoot%>/inbox/messages.asp?obj=<%=urlObj%>&page=1&view=<%=Request.Querystring("view")%>&compidx="+parent.iCurCompose+"&store=<%=iStore%>";
  241.  
  242. <% ElseIf iLoadCommand = iParamError Then %>
  243.     alert("<%=bstrParamErrMsg%>");
  244.  
  245. <% End If %>
  246. <% END IF 'fTimedOut%>
  247.  
  248. </script>
  249. <body>
  250. <FORM name="commandform" ACTION="commands.asp" METHOD="POST" target="command_fr">
  251.     <input type="hidden" name="action" value="newfolder">
  252.     <input type="hidden" name="foldername" value="">
  253.     <input type="hidden" name="obj" value="">
  254.     <input type="hidden" name="store" value="">
  255. </Form>
  256. </body>
  257. </HTML>
  258.  
  259.