Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
7.6 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' POP3 Mail Add-in - Domains - Delete
  6. ' Copyright (C) Microsoft Corporation. All rights reserved.
  7. '-------------------------------------------------------------------------
  8. %>
  9. <!-- #include virtual="/admin/inc_framework.asp" -->
  10. <!-- #include virtual="/admin/ots_main.asp" -->
  11. <!-- #include file="p3cminc.asp" -->
  12. <%
  13. '-------------------------------------------------------------------------
  14. ' Global Constants
  15. '-------------------------------------------------------------------------
  16. Dim SOURCE_FILE
  17. SOURCE_FILE = SA_GetScriptFileName()
  18. Const FLD_NAME = "fldName"
  19. '-------------------------------------------------------------------------
  20. ' Global Variables
  21. '-------------------------------------------------------------------------
  22. Dim g_page
  23. Dim g_rgFailures
  24. Dim g_nFailures
  25. '----------------------------------------------------------------------
  26. ' Global Localized Strings
  27. '----------------------------------------------------------------------
  28. Dim l_strPageTitle
  29. If (Request.Form(FLD_NAME).Count > 0) Then
  30. ' Set the title to the error title, even though we don't know
  31. ' whether an error occurred. By the time we know an error occured,
  32. ' it will be too late to update the title, and if no error occurs,
  33. ' the user will be redirected back to the OTS.
  34. l_strPageTitle = GetLocString(RES_DLL_NAME, _
  35. POP3_PAGETITLE_DOMAINS_DELETEERROR, _
  36. "")
  37. Else
  38. l_strPageTitle = GetLocString(RES_DLL_NAME, _
  39. POP3_PAGETITLE_DOMAINS_DELETE, _
  40. "")
  41. End If
  42. Dim l_strConfirmPrompt
  43. l_strConfirmPrompt = GetLocString(RES_DLL_NAME, _
  44. POP3_PROMPT_DOMAINS_DELETE, _
  45. "")
  46. Dim l_strErrorPrompt
  47. l_strErrorPrompt = GetLocString(RES_DLL_NAME, _
  48. POP3_PROMPT_DOMAINS_DELETEERROR, _
  49. "")
  50. Dim l_strRetryPrompt
  51. l_strRetryPrompt = GetLocString(RES_DLL_NAME, _
  52. POP3_PROMPT_DOMAINS_DELETERETRY, _
  53. "")
  54. '**********************************************************************
  55. '* E N T R Y P O I N T
  56. '**********************************************************************
  57. Call SA_CreatePage(l_strPageTitle, "", PT_PROPERTY, g_page)
  58. Call SA_ShowPage (g_page)
  59. '**********************************************************************
  60. '* H E L P E R S U B R O U T I N E S
  61. '**********************************************************************
  62. '---------------------------------------------------------------------
  63. ' OutputNameList
  64. '---------------------------------------------------------------------
  65. Sub OutputNameList(rgDomainsTable, nRows)
  66. '
  67. ' Sort the names.
  68. '
  69. Call SAQuickSort(rgDomainsTable, 1, nRows, 1, 0)
  70. '
  71. ' Output the names in a bulleted list.
  72. '
  73. Response.Write("<UL>" & vbCrLf)
  74. Dim iRow
  75. For iRow = 1 to nRows
  76. %>
  77. <LI><%=Server.HTMLEncode(rgDomainsTable(iRow, 0))%></LI>
  78. <INPUT TYPE="hidden" NAME="<%=FLD_NAME%>"
  79. VALUE="<%=Server.HTMLEncode(rgDomainsTable(iRow, 0))%>">
  80. <%
  81. Next
  82. Response.Write("</UL>" & vbCrLf)
  83. End Sub
  84. '---------------------------------------------------------------------
  85. ' ServeCommonJavaScript
  86. '---------------------------------------------------------------------
  87. Function ServeCommonJavaScript()
  88. %>
  89. <script language="JavaScript" src="../inc_global.js">
  90. </script>
  91. <script language="JavaScript">
  92. function Init(){}
  93. function ValidatePage(){return true;}
  94. function SetData(){}
  95. </script>
  96. <%
  97. End Function
  98. '**********************************************************************
  99. '* E V E N T H A N D L E R S
  100. '**********************************************************************
  101. '---------------------------------------------------------------------
  102. ' OnInitPage
  103. '---------------------------------------------------------------------
  104. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  105. OnInitPage = TRUE
  106. g_nFailures = 0
  107. End Function
  108. '---------------------------------------------------------------------
  109. ' OnServePropertyPage
  110. '---------------------------------------------------------------------
  111. Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  112. On Error Resume Next
  113. '
  114. ' Emit Javascript functions required by Web Framework
  115. Call ServeCommonJavaScript()
  116. If (g_nFailures > 0) Then
  117. '
  118. ' Output the error prompt and sorted list of failed templates.
  119. '
  120. Response.Write(l_strErrorPrompt & "<BR>" & vbCrLf)
  121. Call OutputNameList(g_rgFailures, g_nFailures)
  122. Response.Write("<BR>" & l_strRetryPrompt & vbCrLf)
  123. OnServePropertyPage = TRUE
  124. If (Err.number <> 0) Then
  125. Call SA_SetErrMsg( HandleUnexpectedError() )
  126. End If
  127. Exit Function
  128. End If
  129. Dim nRows
  130. nRows = OTS_GetTableSelectionCount("")
  131. '
  132. ' Get the list of selected devices.
  133. '
  134. Dim rgDomainsTable
  135. ReDim rgDomainsTable(nRows, 0)
  136. Dim strDomainName
  137. Dim iRow
  138. For iRow = 1 to nRows
  139. If (OTS_GetTableSelection("", iRow, strDomainName)) Then
  140. rgDomainsTable(iRow, 0) = strDomainName
  141. Else
  142. Call SA_SetErrMsg( HandleUnexpectedError() )
  143. Call SA_TraceErrorOut(SOURCE_FILE, _
  144. "Failed to get OTS selection.")
  145. End If
  146. Next
  147. '
  148. ' Output the confirmation prompt and sorted list of names.
  149. '
  150. Response.Write(l_strConfirmPrompt & "<BR>" & vbCrLf)
  151. Call OutputNameList(rgDomainsTable, nRows)
  152. If (Err.number <> 0) Then
  153. Call SA_SetErrMsg( HandleUnexpectedError() )
  154. End If
  155. OnServePropertyPage = TRUE
  156. End Function
  157. '---------------------------------------------------------------------
  158. ' OnPostBackPage
  159. '---------------------------------------------------------------------
  160. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  161. OnPostBackPage = TRUE
  162. End Function
  163. '---------------------------------------------------------------------
  164. ' OnSubmitPage
  165. '---------------------------------------------------------------------
  166. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  167. On Error Resume Next
  168. OnSubmitPage = FALSE
  169. Dim oConfig
  170. Set oConfig = Server.CreateObject("P3Admin.P3Config")
  171. Dim nRows
  172. nRows = Request.Form(FLD_NAME).Count
  173. ' Create an array to hold the names of any templates that could
  174. ' not be deleted.
  175. ReDim g_rgFailures(nRows, 0)
  176. g_nFailures = 0
  177. '
  178. ' Iterate over the selected templates and delete them.
  179. '
  180. Dim strDomainName
  181. Dim iRow
  182. For iRow = 1 to nRows
  183. strDomainName = Request.Form(FLD_NAME).Item(iRow)
  184. oConfig.Domains.Remove(strDomainName)
  185. If (Err.number <> 0) Then
  186. Call SA_TraceErrorOut(SOURCE_FILE, _
  187. "Failed to remove domain: " & CStr(Hex(Err.number)) & ": " & Err.Description)
  188. Err.Clear()
  189. g_nFailures = g_nFailures + 1
  190. g_rgFailures(g_nFailures, 0) = strDomainName
  191. If (Err.number <> 0) Then
  192. Call SA_SetErrMsg( HandleUnexpectedError() )
  193. Err.Clear()
  194. ' Don't return -- keep trying to delete the rest of the objects.
  195. End If
  196. End If
  197. Next
  198. If (g_nFailures > 0) Then
  199. OnSubmitPage = FALSE
  200. Exit Function
  201. End If
  202. OnSubmitPage = TRUE
  203. End Function
  204. '---------------------------------------------------------------------
  205. ' OnClosePage
  206. '---------------------------------------------------------------------
  207. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  208. OnClosePage = TRUE
  209. End Function
  210. %>