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.

790 lines
29 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' quota_prop.asp: change quota entry properties
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 17-Jan-01 Creation date
  11. ' 15-Mar-01 Ported to 2.0
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual = "/admin/inc_framework.asp" -->
  15. <!-- #include file="loc_quotas.asp" -->
  16. <!-- #include file="inc_quotas.asp" -->
  17. <%
  18. '-------------------------------------------------------------------------
  19. ' Global Variables
  20. '-------------------------------------------------------------------------
  21. Dim G_nRadioChecked ' to set radioButton values - contains 1 or 2 only
  22. Dim SOURCE_FILE ' the source file name used while Tracing
  23. SOURCE_FILE = SA_GetScriptFileName()
  24. Dim L_QUOTAUSERNOTFOUND_ERRORMESSAGE
  25. Dim arrVarReplacementStrings(1)
  26. '-------------------------------------------------------------------------
  27. ' Global Form Variables
  28. '-------------------------------------------------------------------------
  29. Dim F_strVolName ' Volume Name
  30. Dim F_strUsername ' to display user Name
  31. Dim F_ThresholdSize ' the warning level set for the user - textBox value
  32. Dim F_ThresholdUnits ' the units for the warning level set - comboBox Value
  33. Dim F_LimitSize ' Disk limit size
  34. Dim F_LimitUnits ' Disk limit size units
  35. Dim F_bIsAdmin ' Whether user is in Administrators group
  36. '======================================================
  37. ' Entry point
  38. '======================================================
  39. Dim page
  40. DIM L_TASKTITLE_QUOTAPROPERTY_TEXT
  41. ' get the user name to be appended to the title
  42. Call getUserName()
  43. ' append the user name to the title
  44. arrVarReplacementStrings(0) = F_strUserName
  45. ' check if the user is in admin group
  46. F_bIsAdmin = IsUserInAdministratorsGroup(F_strUserName)
  47. L_TASKTITLE_QUOTAPROPERTY_TEXT = SA_GetLocString("diskmsg.dll", "403E0097", arrVarReplacementStrings)
  48. Dim aPageTitle(2)
  49. aPageTitle(0) = L_BROWSERCAPTION_QUOTAPROPERTY_TEXT
  50. aPageTitle(1) = L_TASKTITLE_QUOTAPROPERTY_TEXT
  51. '
  52. ' Create a Property Page
  53. Call SA_CreatePage( aPageTitle, "", PT_PROPERTY, page )
  54. '
  55. ' Serve the page
  56. Call SA_ShowPage( page )
  57. '======================================================
  58. ' Web Framework Event Handlers
  59. '======================================================
  60. '---------------------------------------------------------------------
  61. ' Function name: OnInitPage
  62. ' Description: Called to signal first time processing for this page
  63. ' Input Variables: Out: PageIn
  64. ' Out: EventArg
  65. ' Output Variables: None
  66. ' Return Values: TRUE to indicate initialization was successful.
  67. ' FALSE to indicate errors. Returning FALSE will
  68. ' cause the page to be abandoned.
  69. ' Global Variables: None
  70. ' Functions Called: getValuesForUser
  71. '
  72. ' Get ALL the initial form field settings
  73. '---------------------------------------------------------------------
  74. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  75. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  76. Dim sValue ' to get the parent selection
  77. ' get the volume name from the parent OTS
  78. Call OTS_GetTableSelection("", 1, sValue )
  79. F_strVolName = sValue
  80. ' Call the function to get other the default values
  81. OnInitPage = getValuesForUser ' True /False
  82. End Function
  83. '---------------------------------------------------------------------
  84. ' Function name: OnServePropertyPage
  85. ' Description: Called when the page needs to be served
  86. ' Input Variables: Out: PageIn
  87. ' Out: EventArg
  88. ' Output Variables: None
  89. ' Return Values: TRUE to indicate no problems occured. FALSE to
  90. ' indicate errors. Returning FALSE will cause the
  91. ' page to be abandoned.
  92. ' Global Variables: In: F_(*) - Form field values
  93. ' In: L_(*) - Text display strings
  94. ' In: G_nRadioChecked - radio to be selected
  95. ' Functions Called: (i)ServeCommonJavaScript, (ii)setUnits
  96. '
  97. ' The UI is served here.
  98. '---------------------------------------------------------------------
  99. Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  100. Call SA_TraceOut(SOURCE_FILE, "OnServePropertyPage")
  101. '
  102. ' Emit Javascript functions required by Web Framework
  103. Call ServeCommonJavaScript()
  104. %>
  105. <table border="0" cellspacing="0" cellpadding="0">
  106. <tr>
  107. <td nowrap colspan="2" class="TasksBody">
  108. <%If F_bIsAdmin Then%>
  109. <input type="radio" class="FormRadioButton" name="donotlimit" value="1" <% If G_nRadioChecked = 1 Then Response.Write "CHECKED" Else Response.write "UNCHECKED" End If %> onClick="JavaScript:DisableWarnLevel(warndisksize,warndisksizeunits); DisableLimitLevelForAdmin(limitdisksize,limitdisksizeunits)">&nbsp;<% =L_DONOTLIMITDISKUSAGE_TEXT %>
  110. <%Else%>
  111. <input type="radio" class="FormRadioButton" name="donotlimit" value="1" <% If G_nRadioChecked = 1 Then Response.Write "CHECKED" Else Response.write "UNCHECKED" End If %> onClick="JavaScript:DisableWarnLevel(warndisksize,warndisksizeunits); DisableLimitLevel(limitdisksize,limitdisksizeunits)">&nbsp;<% =L_DONOTLIMITDISKUSAGE_TEXT %>
  112. <%End If%>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td nowrap class="TasksBody">
  117. <%If F_bIsAdmin Then%>
  118. <input type="radio" class="FormRadioButton" name="donotlimit" value="2" <% If G_nRadioChecked = 2 Then Response.Write "CHECKED" Else Response.write "UNCHECKED" End If %> onClick="JavaScript:EnableWarnDiskSpace(warndisksize,warndisksizeunits)">&nbsp;<% =L_SETLIMITDISKSPACE_TEXT %>
  119. <%Else%>
  120. <input type="radio" class="FormRadioButton" name="donotlimit" value="2" <% If G_nRadioChecked = 2 Then Response.Write "CHECKED" Else Response.write "UNCHECKED" End If %> onClick="JavaScript:EnableWarnDiskSpace(warndisksize,warndisksizeunits); EnableLimitDiskSpace(limitdisksize,limitdisksizeunits) ">&nbsp;<% =L_SETLIMITDISKSPACE_TEXT %>
  121. <%End If%>
  122. </td>
  123. <td nowrap class="TasksBody">
  124. <%If F_bIsAdmin Then%>
  125. <input disabled type="text" name="limitdisksize" value="<% =server.HTMLEncode(SA_EscapeQuotes(F_LimitSize)) %>" size="14" maxlength = "11" class="FormField" onFocus="this.select()" onKeyPress="allownumbers( this )" onChange="validatedisklimit( this, document.frmTask.limitdisksizeunits.value )" >
  126. <select disabled name="limitdisksizeunits" size="1" class="FormField" onChange="ClearErr();validatedisklimit( document.frmTask.limitdisksize, this.value )">
  127. <% setUnits(F_LimitUnits) %>
  128. </select>
  129. <%Else%>
  130. <input type="text" name="limitdisksize" value="<% =server.HTMLEncode(SA_EscapeQuotes(F_LimitSize)) %>" size="14" maxlength = "11" class="FormField" onFocus="this.select()" onKeyPress="allownumbers( this )" onChange="validatedisklimit( this, document.frmTask.limitdisksizeunits.value )" >
  131. <select name="limitdisksizeunits" size="1" class="FormField" onChange="ClearErr();validatedisklimit( document.frmTask.limitdisksize, this.value )">
  132. <% setUnits(F_LimitUnits) %>
  133. </select>
  134. <%End If%>
  135. </td>
  136. </tr>
  137. <tr>
  138. <td nowrap class="TasksBody">
  139. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<% =L_SETWARNINGLEVEL_TEXT %>
  140. </td>
  141. <td nowrap class="TasksBody">
  142. <input type="text" name="warndisksize" value="<% =server.HTMLEncode(SA_EscapeQuotes(F_ThresholdSize)) %>" size="14" maxlength = "11" class="FormField" onFocus="this.select()" onKeyPress="allownumbers( this )" onChange="validatedisklimit( this, document.frmTask.warndisksizeunits.value )" >
  143. <select name="warndisksizeunits" size="1" class="FormField" onChange="ClearErr();validatedisklimit(document.frmTask.warndisksize, this.value)">
  144. <% setUnits(F_ThresholdUnits) %>
  145. </select>
  146. </td>
  147. </tr>
  148. </table>
  149. <input name="user" type="hidden" value="<% =F_strUsername %>">
  150. <input name="volume" type="hidden" value="<% =F_strVolName %>">
  151. <%
  152. OnServePropertyPage = TRUE
  153. End Function
  154. '---------------------------------------------------------------------
  155. ' Function name: OnPostBackPage
  156. ' Description: Called to signal that the page has been posted-back
  157. ' Input Variables: Out: PageIn
  158. ' Out: EventArg
  159. ' Output Variables: None
  160. ' Return Values: TRUE to indicate success. FALSE to indicate errors.
  161. ' Returning FALSE will cause the page to be abandoned.
  162. ' Global Variables: Out: F_(*) - Form values
  163. ' Out: G_nRadioChecked - the selected radio value
  164. '
  165. ' Collect the form data vales.
  166. '---------------------------------------------------------------------
  167. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  168. Call SA_TraceOut(SOURCE_FILE, "OnPostBackPage")
  169. ' Get form data value
  170. F_strVolName = Request.Form("volume")
  171. F_strUsername = Request.Form("user")
  172. ' radioButton selected
  173. G_nRadioChecked = Request.Form("donotlimit")
  174. ' get the DiskLimit size and its units
  175. F_LimitSize = Request.Form("limitdisksize")
  176. F_LimitUnits = Request.Form("limitdisksizeunits")
  177. ' get the WarningLimit size and its units
  178. F_ThresholdSize = Request.Form("warndisksize")
  179. F_ThresholdUnits = Request.Form("warndisksizeunits")
  180. If Len(Trim(F_strVolName)) = 0 OR Len(Trim(F_strUsername)) = 0 Then
  181. ' volume or user info not obtained. Cannot process further.
  182. OnPostBackPage = FALSE
  183. Else
  184. OnPostBackPage = TRUE
  185. End If
  186. End Function
  187. '---------------------------------------------------------------------
  188. ' Function name: OnSubmitPage
  189. ' Description: To process the submit request
  190. ' Input Variables: Out: PageIn
  191. ' Out: EventArg
  192. ' Output Variables: None
  193. ' Return Values: TRUE if the submit was successful, FALSE to indicate error(s).
  194. ' Returning FALSE will cause the page to be served again using
  195. ' a call to OnServePropertyPage.
  196. ' Returning FALSE will display error message.
  197. ' Global Variables: None
  198. ' Functions Called: updateValuesForUser
  199. '
  200. ' Updates the Quota Properties for the given user
  201. '---------------------------------------------------------------------
  202. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  203. Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage")
  204. ' Call updateValuesForUser to update the values.
  205. ' If any error occurs,the error message is set in the function.
  206. OnSubmitPage = updateValuesForUser 'returns: True/ False
  207. End Function
  208. '---------------------------------------------------------------------
  209. ' Function name: OnClosePage
  210. ' Description: to perform clean-up processing
  211. ' Input Variables: Out: PageIn
  212. ' Out: EventArg
  213. ' Output Variables: None
  214. ' Return Values: TRUE to allow close, FALSE to prevent close. Returning FALSE
  215. ' will result in a call to OnServePropertyPage.
  216. ' Global Variables: None
  217. '
  218. ' Called when the page is about to be closed.
  219. '---------------------------------------------------------------------
  220. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  221. Call SA_TraceOut(SOURCE_FILE, "OnClosePage")
  222. ' no processing required here. Return True
  223. OnClosePage = TRUE
  224. End Function
  225. '======================================================
  226. ' Private Functions
  227. '======================================================
  228. '---------------------------------------------------------------------
  229. ' Function name: ServeCommonJavaScript
  230. ' Description: Serve JavaScript that is required for this page type
  231. ' Input Variables: None
  232. ' Output Variables: None
  233. ' Return Values: None
  234. ' Global Variables: L_(*) - Error messages displayed on the client side
  235. '
  236. ' This contains the Client-Side script required for the page.
  237. '---------------------------------------------------------------------
  238. Function ServeCommonJavaScript()
  239. %>
  240. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  241. </script>
  242. <script language="JavaScript" src="inc_quotas.js">
  243. </script>
  244. <script language="JavaScript">
  245. //
  246. // Microsoft Server Appliance Web Framework Support Functions
  247. // Copyright (c) Microsoft Corporation. All rights reserved.
  248. //
  249. // to perform first time initialization.
  250. function Init()
  251. {
  252. // enable cancel in case of any server side error
  253. EnableCancel() ;
  254. if ( document.frmTask.donotlimit[0].checked )
  255. {
  256. document.frmTask.warndisksize.disabled = true;
  257. document.frmTask.limitdisksize.disabled = true;
  258. document.frmTask.warndisksizeunits.disabled = true;
  259. document.frmTask.limitdisksizeunits.disabled = true;
  260. }
  261. else
  262. {
  263. if ( document.frmTask.donotlimit[1].checked )
  264. {
  265. document.frmTask.limitdisksize.select()
  266. }
  267. else
  268. {
  269. // disable all except cancel button
  270. DisableOK() ;
  271. document.frmTask.donotlimit[0].disabled = true;
  272. document.frmTask.donotlimit[1].disabled = true;
  273. document.frmTask.warndisksize.disabled = true;
  274. document.frmTask.limitdisksize.disabled = true;
  275. document.frmTask.warndisksizeunits.disabled = true;
  276. document.frmTask.limitdisksizeunits.disabled = true;
  277. }
  278. }
  279. } // end of Init()
  280. // to validate user input. Returning false will cause the submit to abort.
  281. // Returns: True if the page is OK, false if error(s) exist.
  282. function ValidatePage()
  283. {
  284. var objlimitSize = document.frmTask.limitdisksize ;
  285. var objwarnSize = document.frmTask.warndisksize ;
  286. var objlimitUnits = document.frmTask.limitdisksizeunits ;
  287. var objwarnUnits = document.frmTask.warndisksizeunits ;
  288. if ( document.frmTask.donotlimit[1].checked )
  289. {
  290. if( !objlimitSize.disabled)
  291. {
  292. // validate the LimitSize value
  293. if(!isSizeValidDataType(objlimitSize.value) )
  294. {
  295. SA_DisplayErr('<% =Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDDATATYPE_ERRORMESSAGE))%>');
  296. document.frmTask.onkeypress = ClearErr;
  297. selectFocus( objlimitSize );
  298. return false;
  299. }
  300. // validate the LimitSize and its Units
  301. if (!checkSizeAndUnits(objlimitSize.value, objlimitUnits.value) )
  302. {
  303. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_SIZEOUTOFBOUND_ERRORMESSAGE))%>');
  304. document.frmTask.onkeypress = ClearErr;
  305. selectFocus( objlimitSize );
  306. return false;
  307. }
  308. }
  309. // validate the WarningLimit size value
  310. if(!isSizeValidDataType(objwarnSize.value) )
  311. {
  312. SA_DisplayErr('<% =Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDDATATYPE_ERRORMESSAGE))%>');
  313. document.frmTask.onkeypress = ClearErr;
  314. selectFocus(objwarnSize);
  315. return false;
  316. }
  317. // validate the WarningLimit size and its units
  318. if (!checkSizeAndUnits(objwarnSize.value, objwarnUnits.value) )
  319. {
  320. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_SIZEOUTOFBOUND_ERRORMESSAGE))%>');
  321. document.frmTask.onkeypress = ClearErr;
  322. selectFocus( objwarnSize );
  323. return false;
  324. }
  325. if( !objlimitSize.disabled)
  326. {
  327. // verify the warning level. Must be less than limit.
  328. if(isWarningMoreThanLimit(objlimitSize,objlimitUnits,objwarnSize,objwarnUnits))
  329. {
  330. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_WARNING_MORETHAN_LIMIT_ERRORMESSAGE))%>');
  331. document.frmTask.onkeypress = ClearErr;
  332. selectFocus( objwarnSize );
  333. return false;
  334. }
  335. }
  336. }
  337. // if the Limit values are Less than 1 KB, set them to 1 KB
  338. validatedisklimit( objlimitSize,objlimitUnits.value);
  339. validatedisklimit( objwarnSize,objwarnUnits.value);
  340. return true;
  341. }
  342. // to modify hidden form fields.
  343. function SetData()
  344. {
  345. // no updations required here
  346. }
  347. </script>
  348. <%
  349. End Function
  350. '---------------------------------------------------------------------
  351. ' Function Name: getValuesForUser
  352. ' Description: gets the Default Quota entry values for the User
  353. ' Input Variables: None
  354. ' Output Variables: None
  355. ' Returns: None
  356. ' Global Variables: In: F_strVolName - the volume quota is on
  357. ' In: F_strUserName - the quota user
  358. ' Out: F_ThresholdSize - the warning limit set
  359. ' Out: F_ThresholdUnits - the warning limit Units
  360. ' Out: F_LimitSize - the disk Limit
  361. ' Out: F_LimitUnits - the disk Limit Units
  362. ' Out: G_nRadioChecked - the radio selected
  363. ' In: L_(*) - localization content
  364. ' Functions Called:
  365. ' (i) getQuotaLimitRadioForUser (iv) getLimitSizeForUser
  366. ' (ii) getThresholdSizeForUser (v) getLimitUnitsForUser
  367. ' (iii)getThresholdSizeUnitsForUser
  368. '---------------------------------------------------------------------
  369. Function getValuesForUser
  370. On Error Resume Next
  371. Err.Clear
  372. Dim objQuotas ' the quotas object
  373. Dim objUser ' the user for which quota is updated
  374. Dim blnUserFound ' to verify if the user is found
  375. ' create the quota object and initialize for the required Volume
  376. Set objQuotas = CreateObject("Microsoft.DiskQuota.1")
  377. objQuotas.Initialize F_strVolName & "\", 1
  378. objQuotas.UserNameResolution = 1 'wait for names
  379. If Err.number <> 0 Then
  380. ' cannot proceed. Display failure page.
  381. Call SA_ServeFailurePage(L_OBJECTNOTCREATED_ERRORMESSAGE)
  382. End If
  383. ' check if user already has an entry
  384. blnUserFound = False
  385. For Each objUser In objQuotas
  386. If LCase(Trim(F_strUsername)) = LCase(Trim(objUser.LogonName)) Then
  387. ' user found
  388. blnUserFound = True
  389. End If
  390. Next
  391. If NOT blnUserFound Then
  392. arrVarReplacementStrings(0) = F_strUsername
  393. L_QUOTAUSERNOTFOUND_ERRORMESSAGE = SA_GetLocString("diskmsg.dll", "C03E0069", arrVarReplacementStrings)
  394. ' user entry NOT found. display error message and exit
  395. SA_SetErrMsg L_QUOTAUSERNOTFOUND_ERRORMESSAGE
  396. getValuesForUser = False
  397. Exit Function
  398. End If
  399. ' get the user quota object
  400. Set objUser = objQuotas.FindUser( F_strUserName )
  401. ' get the radio button to be selected - 1 or 2
  402. G_nRadioChecked = getQuotaLimitRadioForUser(objUser)
  403. ' Compute user Warning Limit and its units (say, 1 KB)
  404. F_ThresholdSize = getThresholdSizeForUser(objUser)
  405. F_ThresholdUnits = getThresholdSizeUnitsForUser(objUser)
  406. ' Compute user Disk Limit and its units (say, 1 KB)
  407. F_LimitSize = getLimitSizeForUser(objUser)
  408. F_LimitUnits = getLimitUnitsForUser(objUser)
  409. If Err.number <> 0 Then
  410. ' an error has occured
  411. getValuesForUser = False
  412. Else
  413. getValuesForUser = True
  414. End If
  415. ' clean up
  416. Set objUser = Nothing
  417. Set objQuotas = Nothing
  418. End Function
  419. '---------------------------------------------------------------------
  420. ' Function Name: updateValuesForUser
  421. ' Description: Set the quota values for the given user
  422. ' Input Variables: None
  423. ' Output Variables: None
  424. ' Returns: True - if the values are updated
  425. ' False - if values could not be updated
  426. ' Global Variables: In: F_strVolName - the volume quota is on
  427. ' In: F_strUserName - the quota user
  428. ' In: F_ThresholdSize - the warning limit set
  429. ' In: F_ThresholdUnits - the warning limit Units
  430. ' In: F_LimitSize - the disk Limit
  431. ' In: F_LimitUnits - the disk Limit Units
  432. ' In: G_nRadioChecked - the radio selected
  433. ' In: L_(*) - localization content
  434. ' Functions Called: (i) setUserQuotaLimit
  435. ' (ii) setUserThreshold
  436. '---------------------------------------------------------------------
  437. Function updateValuesForUser
  438. On Error Resume Next
  439. Dim objQuotas ' the quota object
  440. Dim objUser ' the user for which the quota is updated
  441. Dim blnUserFound ' to verify if the user is found
  442. ' create the quota object and initialize for the required Volume
  443. Set objQuotas = CreateObject("Microsoft.DiskQuota.1")
  444. objQuotas.Initialize F_strVolName & "\", 1
  445. objQuotas.UserNameResolution = 1 'wait for names
  446. If Err.number <> 0 Then
  447. ' cannot proceed. Display failure page.
  448. Call SA_ServeFailurePage(L_OBJECTNOTCREATED_ERRORMESSAGE)
  449. End If
  450. ' check if user exists
  451. blnUserFound = False
  452. For Each objUser In objQuotas
  453. If LCase(Trim(F_strUsername)) = LCase(Trim(objUser.LogonName)) Then
  454. ' user found
  455. blnUserFound = True
  456. End If
  457. Next
  458. If NOT blnUserFound Then
  459. arrVarReplacementStrings(0) = F_strUsername
  460. L_QUOTAUSERNOTFOUND_ERRORMESSAGE = SA_GetLocString("diskmsg.dll", "C03E0069", arrVarReplacementStrings)
  461. ' user not found. display error message and exit
  462. SA_SetErrMsg L_QUOTAUSERNOTFOUND_ERRORMESSAGE
  463. updateValuesForUser = False
  464. Exit Function
  465. End If
  466. ' get the user
  467. Set objUser = objQuotas.FindUser( F_strUserName )
  468. ' verify the limit settings
  469. If CInt(G_nRadioChecked) = CInt(CONST_RADIO_DONOT_LIMIT_DISKUSAGE) Then
  470. ' "Do not limit disk usage" - radio is checked. Set the DiskLimit
  471. ' and WarningLimit values to "No Limit"
  472. F_LimitSize = CONST_NO_LIMIT
  473. F_ThresholdSize = CONST_NO_LIMIT
  474. End If
  475. 'Disable Admin
  476. If Not F_bIsAdmin Then
  477. ' set the quota limit by calling the function
  478. If NOT setUserQuotaLimit(objUser, F_LimitSize, F_LimitUnits) then
  479. ' quota limit could not be set. Display error message and exit
  480. SA_SetErrMsg L_MAXLIMITNOTSET_ERRORMESSAGE & " ( " & Hex(Err.number) & " )"
  481. Err.Clear ' stop the error propagation
  482. updateValuesForUser = False
  483. Exit Function
  484. End If
  485. End If
  486. ' set the warning limit for the user, by calling the function
  487. If NOT setUserThreshold(objUser, F_ThresholdSize, F_ThresholdUnits) Then
  488. ' warning limit could not be set. display error and exit
  489. SA_SetErrMsg L_WARNINGLIMITNOTSET_ERRORMESSAGE & " ( " & Hex(Err.number) & " )"
  490. Err.Clear ' stop the error propagation
  491. updateValuesForUser = False
  492. Exit Function
  493. End If
  494. ' all values updated. return true
  495. updateValuesForUser = True
  496. ' clean up
  497. Set objUser = Nothing
  498. Set objQuotas = Nothing
  499. End Function
  500. '---------------------------------------------------------------------
  501. ' Function name: getQuotaLimitRadioForUser
  502. ' Description: to get QuotaLimit settings for the user
  503. ' Input Variables: objQuotasUser - the quota user object
  504. ' Output Variables: None
  505. ' Returns: 1 - if disk limit is NOT set
  506. ' 2 - if some limit is set for disk usage
  507. ' Global Variables: None
  508. '
  509. ' The return value corresponds to radio button in the gui
  510. '---------------------------------------------------------------------
  511. Function getQuotaLimitRadioForUser(objQuotasUser)
  512. On Error Resume Next
  513. Err.Clear
  514. Dim nRadioToCheck ' the radio button to be CHECKED
  515. If ((objQuotasUser.QuotaThreshold = CONST_NO_LIMIT) AND (objQuotasUser.QuotaLimit = CONST_NO_LIMIT)) Then
  516. ' DiskLimit and WarningLimit is NOT set. Select the first radio
  517. nRadioToCheck = 1
  518. Else
  519. ' some limit is set. Select the second radio
  520. nRadioToCheck = 2
  521. End If
  522. ' return the selected radio value
  523. getQuotaLimitRadioForUser = nRadioToCheck
  524. End Function
  525. '---------------------------------------------------------------------
  526. ' Function name: getThresholdSizeForUser
  527. ' Description: to get default Warning Limit for the user quota
  528. ' Input Variables: objQuotasUser - the user quota object
  529. ' Output Variables: None
  530. ' Returns: Default thresholdSize for the user quota
  531. ' Global Variables: None
  532. ' Functions Called: getLimitFromText
  533. '
  534. ' This returns the WarningLimit set for the user quota
  535. '---------------------------------------------------------------------
  536. Function getThresholdSizeForUser(objQuotasUser)
  537. On Error Resume Next
  538. Err.Clear
  539. Dim nThresholdSize ' the WarningLimit to be returned
  540. Dim strTemp
  541. If objQuotasUser.QuotaThreshold = CONST_NO_LIMIT Then
  542. ' No Warning Limit is set. The text contains "No Limit"
  543. nThresholdSize = L_NOLIMIT_TEXT
  544. Else
  545. ' some limit is set(say, 1 KB). Get the size part from this(say, 1)
  546. ' Following will not localize
  547. 'nThresholdSize = getLimitFromText(objQuotasUser.QuotaThresholdText)
  548. ' first convert bytes to text.
  549. strTemp = ChangeToText(objQuotasUser.QuotaThreshold)
  550. ' get the size (number) portion
  551. nThresholdSize = getLimitFromText(strTemp)
  552. End If
  553. ' return the Warning Limit
  554. getThresholdSizeForUser = nThresholdSize
  555. End Function
  556. '---------------------------------------------------------------------
  557. ' Function name: getThresholdSizeUnitsForUser
  558. ' Description: to get default WarningLimit Units for the user quota
  559. ' Input Variables: objQuotasUser - the user quota object
  560. ' Output Variables: None
  561. ' Returns: Default thresholdSize Units for the user quota
  562. ' Global Variables: None
  563. ' Functions Called: getUnitsFromText
  564. '
  565. ' This returns the default WarningLimit Units for the user quota.
  566. '---------------------------------------------------------------------
  567. Function getThresholdSizeUnitsForUser(objQuotasUser)
  568. On Error Resume Next
  569. Err.Clear
  570. Dim strThresholdUnits ' the thresholdSize Units to return
  571. Dim strTemp
  572. If objQuotasUser.QuotaThreshold = CONST_NO_LIMIT Then
  573. ' No warning limit is set. Return KB for default display
  574. strThresholdUnits = L_TEXT_KB
  575. Else
  576. ' some limit is set(say, 1 KB). Get the units part from this(say, KB)
  577. ' Following will not localize
  578. 'strThresholdUnits = getUnitsFromText(objQuotasUser.QuotaThresholdText)
  579. ' first convert bytes to text.
  580. strTemp = ChangeToText(objQuotasUser.QuotaThreshold)
  581. ' get the units portion
  582. strThresholdUnits = getUnitsFromText(strTemp)
  583. End If
  584. ' return the WarningLimit units
  585. getThresholdSizeUnitsForUser = strThresholdUnits
  586. End Function
  587. '---------------------------------------------------------------------m
  588. ' Function name: getLimitSizeForUser
  589. ' Description: to get Quota Limit for the user quota
  590. ' Input Variables: objQuotasUser - the user quota object
  591. ' Output Variables: None
  592. ' Returns: Default QuotaLimit for the user quota
  593. ' Global Variables: None
  594. ' Functions Called: getLimitFromText, ChangeToText
  595. '
  596. ' This returns the QuotaLimit set for the user quota
  597. '---------------------------------------------------------------------
  598. Function getLimitSizeForUser(objQuotasUser)
  599. On Error Resume Next
  600. Err.Clear
  601. Dim nLimitSize ' the quota limit to return
  602. Dim strTemp
  603. If objQuotasUser.QuotaLimit = CONST_NO_LIMIT Then
  604. ' No Quota Limit is set. The text contains "No Limit"
  605. nLimitSize = L_NOLIMIT_TEXT
  606. Else
  607. ' some limit is set(say, 1 KB). Get the size part from this(say, 1)
  608. strTemp = ChangeToText(objQuotasUser.QuotaLimit)
  609. nLimitSize = getLimitFromText(strTemp)
  610. End If
  611. ' return the QuotaLimit
  612. getLimitSizeForUser = nLimitSize
  613. End Function
  614. '---------------------------------------------------------------------
  615. ' Function name: getLimitUnitsForUser
  616. ' Description: to get QuotaLimit Units for the user quota
  617. ' Input Variables: objQuotasUser - the user quota object
  618. ' Output Variables: None
  619. ' Returns: Default QuotaLimitSize Units for the user quota
  620. ' Global Variables: None
  621. ' Functions Called: getUnitsFromText
  622. '
  623. ' This returns the QuotaLimit Units for the user quota.
  624. '---------------------------------------------------------------------
  625. Function getLimitUnitsForUser(objQuotasUser)
  626. On Error Resume Next
  627. Err.Clear
  628. Dim strLimitUnits ' the limit units to be returned
  629. Dim strTemp
  630. If objQuotasUser.QuotaLimit = CONST_NO_LIMIT Then
  631. ' No QuotaLimit is set. Return KB for default display
  632. strLimitUnits = L_KB_TEXT
  633. Else
  634. ' some limit is set(say, 1 KB). Get the units part from this(say, KB)
  635. 'strLimitUnits = getUnitsFromText(objQuotasUser.QuotaLimitText)
  636. ' first convert bytes to text.
  637. strTemp = ChangeToText(objQuotasUser.QuotaLimit)
  638. ' get the units portion
  639. strLimitUnits = getUnitsFromText(strTemp)
  640. End If
  641. ' return the QuotaLimit units
  642. getLimitUnitsForUser = strLimitUnits
  643. End Function
  644. '---------------------------------------------------------------------
  645. ' Procedure name: getUserName
  646. ' Description: to get the user name for display in the title
  647. ' Input Variables: None
  648. ' Output Variables: None
  649. ' Returns: None
  650. ' Global Variables: F_strUserName - the QuotaUser name
  651. '---------------------------------------------------------------------
  652. Sub getUserName()
  653. Dim i
  654. Dim iCount
  655. Dim sValue
  656. iCount = OTS_GetTableSelectionCount("QuotaUsers")
  657. For i = 1 to iCount
  658. Call OTS_GetTableSelection("QuotaUsers", i, sValue )
  659. Next
  660. F_strUserName = UnescapeChars(sValue)
  661. End Sub
  662. %>