home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / ReportShareAction.asp < prev    next >
Text File  |  2006-05-19  |  5KB  |  113 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.7
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page works with ReportShare.asp, and processes
  7. '                     the form for registering new report shares by writing a database
  8. '                      record to the SUR_REPORT_SHARE table.
  9. '
  10. '   COPYRIGHT NOTICE
  11. '
  12. '   See attached Software License Agreement
  13. '
  14. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  15. '***********************************************************************
  16. %>
  17. <!--#Include File="Include/Config_inc.asp"-->
  18. <!--#Include File="Include/Utility_inc.asp"-->
  19. <!--#Include File="Include/adovbs_inc.asp"-->
  20. <!--#Include File="Include/Constants_inc.asp"-->
  21. <!--#Include File="Include/ID_inc.asp"-->
  22. <!--#Include File="Include/CurrentUser_inc.asp"-->
  23. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  24. <%
  25.     Dim lngSurveyID
  26.     Dim strSQL
  27.     Dim conReportShare
  28.     Dim lngReportShareID
  29.     Dim strEmailAddresses
  30.     Dim arrEmailAddresses
  31.     Dim i
  32.  
  33.     'Initialization
  34.     lngSurveyID = Request.Form("SurveyID")
  35.  
  36.     'If the user does not either own this survey or have admin permission, deny them access to this functionality.
  37.     If IsUserOwnerOrAdmin(lngSurveyID) = False Then
  38.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_OWNER_FOR_RESULTS_SHARING
  39.     End If
  40.  
  41.     'Initialization
  42.     Set conReportShare = Server.CreateObject("ADODB.Connection")
  43.     conReportShare.Open SURVEY_APP_CONNECTION
  44.  
  45.     'Clean up the email addresses
  46.     arrEmailAddresses = Split(Request.Form("txtEmailAddresses"), ";")
  47.     For i = 0 To UBound(arrEmailAddresses)
  48.         If Len(Trim(arrEmailAddresses(i))) > 0 And Trim(arrEmailAddresses(i)) <> ";" Then
  49.             strEmailAddresses = strEmailAddresses & Trim(arrEmailAddresses(i)) & "; "
  50.         End If
  51.     Next
  52.     strEmailAddresses = Left(strEmailAddresses, Len(strEmailAddresses) - 2)
  53.  
  54.     'Create the SQL statement to either update or insert a record
  55.     If Request.Form("State") = SUR_STATE_EDIT Then
  56.         lngReportShareID = Request.Form("ReportShareID")
  57.         strSQL = "UPDATE sur_report_share " & _
  58.                     "SET email_addresses = " & SQLEncode(strEmailAddresses) & ", " & _
  59.                     "viewable_reports = " & SQLEncode(Request.Form("cboViewableReports")) & ", " & _
  60.                     "export_data_yn = " & SQLEncode(Request.Form("cboExportDataYN")) & ", " & _
  61.                     "report_filtering_yn = " & SQLEncode(Request.Form("cboReportFilteringYN")) & ", " & _
  62.                     "view_open_ended_yn = " & SQLEncode(Request.Form("cboViewOpenEndedYN")) & ", " & _
  63.                     "active_yn = " & SQLEncode(Request.Form("cboActiveYN")) & _
  64.                     " WHERE report_share_id = " & Request.Form("ReportShareID")
  65.     Else 'INSERT mode
  66.         lngReportShareID = ID_GetNextAvailableID("SurveyGenerationReportShare")
  67.  
  68.         '***5/12/2005 start:  make sure you don't insert a url that is already being used
  69.         tmpRandomID = SQLEncode(GetRandomCode(15))
  70.         Dim strRandomSQL, rsRandom, tmpRandomID, tmpRandomAlreadyUsed
  71.         tmpRandomAlreadyUsed = True
  72.         Set rsRandom = Server.CreateObject("ADODB.Recordset")
  73.  
  74.         Do while tmpRandomAlreadyUsed = True
  75.             strRandomSQL = "Select * from sur_report_share where report_share_url_id = " & tmpRandomID
  76.             rsRandom.Open ConvertSQL(strRandomSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  77.             If rsRandom.EOF = True Then
  78.                 tmpRandomAlreadyUsed = False
  79.             Else
  80.                 tmpRandomID = SQLEncode(GetRandomCode(15))
  81.                 tmpRandomAlreadyUsed =True
  82.             End If
  83.             rsRandom.Close
  84.         Loop
  85.         Set rsRandom = Nothing
  86.         '***5/12/2005 end
  87.  
  88.         strSQL = "INSERT INTO sur_report_share(report_share_id, survey_id, created_date, report_share_url_id, " & _
  89.                  "email_addresses, last_sent_date, export_data_yn, report_filtering_yn, viewable_reports, " & _
  90.                  "view_open_ended_yn, active_yn) VALUES(" & _
  91.                  lngReportShareID & ", " & _
  92.                  Request.Form("SurveyID") & ", " & _
  93.                  "GETDATE(), " & _
  94.                  tmpRandomID & ", " & _
  95.                  SQLEncode(strEmailAddresses) & ", " & _
  96.                  "Null, " & _
  97.                  SQLEncode(Request.Form("cboExportDataYN")) & ", " & _
  98.                  SQLEncode(Request.Form("cboReportFilteringYN")) & ", " & _
  99.                  SQLEncode(Request.Form("cboViewableReports")) & ", " & _
  100.                  SQLEncode(Request.Form("cboViewOpenEndedYN")) & ", " & _
  101.                  SQLEncode(Request.Form("cboActiveYN")) & ")"
  102.     End If
  103.  
  104.     'Execute the SQL
  105.     conReportShare.Execute ConvertSQL(strSQL), , adCmdText
  106.  
  107.     'Clean up
  108.     conReportShare.Close
  109.     Set conReportShare = Nothing
  110.  
  111.     'Redirect back to the list of report shares
  112.     Response.Redirect "ReportShareList.asp?SurveyID=" & Request.Form("SurveyID") & "&SurveyName=" & Request.Form("SurveyName")
  113. %>