home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / UserListAction.asp < prev   
Text File  |  2006-10-25  |  3KB  |  76 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.11
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page works with UserList.asp, and processes
  7. '                     the form for updating the active status of all users.
  8. '
  9. '   COPYRIGHT NOTICE                                
  10. '
  11. '   See attached Software License Agreement
  12. '
  13. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  14. '***********************************************************************
  15. %>
  16. <!--#Include File="Include/Config_inc.asp"-->
  17. <!--#Include File="Include/Utility_inc.asp"-->
  18. <!--#Include File="Include/adovbs_inc.asp"-->
  19. <!--#Include File="Include/Constants_inc.asp"-->
  20. <!--#Include File="Include/ID_inc.asp"-->
  21. <!--#Include File="Include/CurrentUser_inc.asp"-->
  22. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  23. <%
  24.     'If the user does not have "Create" or "Admin" permission, redirect to the access denied page.
  25.     If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_CREATE And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  26.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
  27.     End If
  28.  
  29.     Dim strSQL
  30.     Dim conUsers
  31.     Dim rsUsers
  32.     Dim strActiveIDs
  33.     Dim strInactiveIDs
  34.     Dim strDeleteIDs
  35.                 
  36.     'Initialization
  37.     Set conUsers = Server.CreateObject("ADODB.Connection")
  38.     Set rsUsers = Server.CreateObject("ADODB.Recordset")
  39.     conUsers.Open SURVEY_APP_CONNECTION
  40.     
  41.     'Get a list of all users
  42.     strSQL = "SELECT user_id FROM sur_user"
  43.     rsUsers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  44.     rsUsers.MoveFirst
  45.  
  46.     'Loop through the users.  Add each checked user ID to the list of users to delete.
  47.     Do While Not rsUsers.EOF
  48.         'Check to see whether or not the checkbox was selected
  49.         If Request.Form("chkDelete" & CStr(rsUsers("user_id"))) = "on" Then
  50.             strDeleteIDs = strDeleteIDs & CStr(rsUsers("user_id")) & ", "
  51.         End If
  52.         rsUsers.MoveNext
  53.     Loop
  54.         
  55.     'If there are any users to be deleted, delete them
  56.     If Len(strDeleteIDs) > 0 Then
  57.         'Trim off the trailing comma
  58.         strDeleteIDs = Left(strDeleteIDs, Len(strDeleteIDs) - 2)
  59.             
  60.         'Create SQL statements to delete the users and execute
  61.         strSQL = "DELETE FROM sur_user " & _
  62.                  "WHERE user_id IN (" & strDeleteIDs & ")"
  63.         conUsers.Execute ConvertSQL(strSQL), , adCmdText
  64.         
  65.         strSQL = "DELETE FROM sur_user_to_role_mapping " & _
  66.                  "WHERE user_id in (" & strDeleteIDs +")" 
  67.         conUsers.Execute ConvertSQL(strSQL), , adCmdText        
  68.     End If
  69.  
  70.     'Clean up
  71.     conUsers.Close
  72.     Set conUsers = Nothing
  73.  
  74.     'Redirect back to the list of users
  75.     Response.Redirect "UserList.asp"
  76. %>