home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / TemplateList.asp < prev    next >
Text File  |  2006-06-07  |  9KB  |  247 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 displays a list of all templates that the
  7. '                      current user has access to.  If the user is an "Admin",
  8. '                      all templates in the system are displayed.  If the user
  9. '                      has "Create" permission, all templates s/he owns, and all
  10. '                      templates that have shared edit permission are displayed.
  11. '
  12. '   COPYRIGHT NOTICE
  13. '
  14. '   See attached Software License Agreement
  15. '
  16. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  17. '***********************************************************************
  18. %>
  19. <!--#Include File="Include/Constants_inc.asp"-->
  20. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  21. <!--#Include File="Include/Utility_inc.asp"-->
  22. <!--#Include File="Include/CurrentUser_inc.asp"-->
  23. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  24. <!--#Include File="Include/Config_inc.asp"-->
  25. <!--#Include File="Include/adovbs_inc.asp"-->
  26. <%
  27.     Dim strPageTitle
  28.     Dim strSortColumn
  29.     Dim strSortOrder
  30.     Dim strTempSortOrder
  31.     Dim strTableRowColor
  32.  
  33.     'If the user does not have "Create" or "Admin" permission, redirect to the access denied page.
  34.     If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_CREATE And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  35.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
  36.     End If
  37.  
  38.     strPageTitle = "Templates"
  39.  
  40.     'Set the sort column and sort order
  41.     If Len(Request.QueryString("SortColumn")) > 0 Then
  42.         strSortColumn = Request.QueryString("SortColumn")
  43.         strSortOrder = Request.QueryString("SortOrder")
  44.     Else
  45.         strSortColumn = "template_name"
  46.         strSortOrder = SUR_SORT_ORDER_ASCENDING
  47.     End If
  48.  
  49.     'Initialize the row color
  50.     strTableRowColor = "TableRowLightColor"
  51. %>
  52. <html>
  53. <head>
  54.     <title><%=strPageTitle%></title>
  55.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  56. </head>
  57. <script language="JavaScript">
  58. function deleteTemplate(lngTemplateID)
  59. {
  60.     if (confirm("Are you sure you want to delete this template?") == true) //OK
  61.     {
  62.         window.location.href = 'DeleteTemplate.asp?TemplateID=' + lngTemplateID;
  63.     }
  64. }
  65. </script>
  66. <body class="MainBodyStyle">
  67.  
  68. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  69.  
  70. <table width="754" border="0" cellpadding="0" cellspacing="0" class="MediumBlueBackgroundColor">
  71.     <tr>
  72.         <td width="493" align="left" height="36" valign="center">
  73.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strPageTitle%></a></span> <img style="cursor:hand" alt="Help" onClick="javascript:window.open('Help/Help.htm#Templates', null, 'menubar=no,toolbar=no,titlebar=no,status=no,left=10,top=10,scrollbars=yes,resizable=yes,height=550,width=770');" border="0" src="Resources/Images/Help.gif">
  74.         </td>
  75.         <td width="254" align="right" valign="center">
  76.             <a href="CreateTemplate.asp">
  77.                 <img border="0" alt="Create new template" name="btnCreateTemplate" src="Resources/Buttons/CreateNewTemplate.gif">
  78.             </a>
  79.         </td>
  80.         <td width="7"> </td>
  81.     </tr>
  82. </table>
  83.  
  84. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  85.  
  86. <table name="tblTemplates" cellspacing="0" border="0" cellpadding="6" width="740" class="WhiteBackgroundColor" summary="This page displays a list of all templates.  If the use is an Admin, then all templates in the application are displayed.  If the user has Create permission, then only the templates that this user owns are displayed.">
  87.     <tr class="TableHeadingColor" height="40">
  88.         <th id="Active" align="center" width="45" valign="center">
  89. <%
  90.             'Determine the sort order if the user clicks this column heading
  91.             If strSortColumn = "active_yn" Then
  92.                 If strSortOrder = SUR_SORT_ORDER_ASCENDING Then
  93.                     strTempSortOrder = SUR_SORT_ORDER_DESCENDING
  94.                 Else
  95.                     strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  96.                 End If
  97.             Else
  98.                 strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  99.             End If
  100. %>
  101.             <span class="TableHeadingBold"><a href="TemplateList.asp?SortColumn=active_yn&SortOrder=<%=strTempSortOrder%>">Active</a></span>
  102.         </th>
  103.         <th id="Name" align="center" width="440" valign="center">
  104. <%
  105.             'Determine the sort order if the user clicks this column heading
  106.             If strSortColumn = "template_name" Then
  107.                 If strSortOrder = SUR_SORT_ORDER_ASCENDING Then
  108.                     strTempSortOrder = SUR_SORT_ORDER_DESCENDING
  109.                 Else
  110.                     strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  111.                 End If
  112.             Else
  113.                 strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  114.             End If
  115. %>
  116.             <span class="TableHeadingBold"><a href="TemplateList.asp?SortColumn=template_name&SortOrder=<%=strTempSortOrder%>">Template Name</a></span>
  117.         </th>
  118.         <th id="Public" align="center" width="75" valign="center">
  119.             <span class="TableHeadingBold">Public Use</span>
  120.         </th>
  121.         <th id="Preview" align="center" width="60" valign="center">
  122.             <span class="TableHeadingBold">Preview</span>
  123.         </th>
  124.         <th id="Edit" align="center" width="60" valign="center">
  125.             <span class="TableHeadingBold">Edit</span>
  126.         </th>
  127.         <th id="Delete" align="center" width="60" valign="center">
  128.             <span class="TableHeadingBold">Delete</span>
  129.         </th>
  130.     </tr>
  131. <%
  132.     Dim strSQL
  133.     Dim rsTemplates
  134.     Dim lngTemplateID
  135.     Dim strTemplateName
  136.     Dim lngCurrentUserID
  137.  
  138.     'Initialization
  139.     Set rsTemplates = Server.CreateObject("ADODB.Recordset")
  140.     lngCurrentUserID = GetUserID()
  141.  
  142.     'Select the list of all templates that the current user can edit.
  143.     strSQL = "SELECT template_id, template_name, active_yn, allow_use_yn, user_id " & _
  144.              "FROM sur_template "
  145.     'If the user has "Create" permission (as opposed to "Admin" permission), limit the list to only templates that the
  146.     'user is an owner of.
  147.     If CLng(lngUserSecurityLevel) = SUR_SECURITY_LEVEL_CREATE Then
  148.         '--**SB 6/7/2006 not showing public to create level
  149.         'strSQL = strSQL & " WHERE user_id = " & GetUserID()
  150.         strSQL = strSQL & " WHERE allow_use_yn = 'Y' or user_id = " & GetUserID()
  151.     End If
  152.     'Add the ORDER BY clause
  153.     strSQL = strSQL & " ORDER BY " & strSortColumn & " " & strSortOrder
  154.     rsTemplates.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  155.  
  156.     If rsTemplates.EOF = True Then
  157. %>
  158.         <tr>
  159.             <td class="Normal" colspan="6">
  160.                 You do not currently have any templates.
  161.                 <br><br><br><br><br><br><br><br><br>
  162.             </td>
  163.         </tr>
  164. <%
  165.     Else
  166.         rsTemplates.MoveFirst
  167.         Do While Not rsTemplates.EOF
  168.             lngTemplateID = rsTemplates("template_id")
  169.             strTemplateName = rsTemplates("template_name")
  170. %>
  171.             <tr class="<%=strTableRowColor%>">
  172.                 <td align="center" class="Normal" valign="center">
  173. <%
  174.                     'Format the Y/N flag to either Yes or No
  175.                     If rsTemplates("active_yn") = SUR_BOOLEAN_POSITIVE Then
  176. %>
  177.                         <%=SUR_BOOLEAN_POSITIVE_DISPLAY%>
  178. <%
  179.                     Else
  180. %>
  181.                         <%=SUR_BOOLEAN_NEGATIVE_DISPLAY%>
  182. <%
  183.                     End If
  184. %>
  185.                 </td>
  186.                 <td class="Normal">
  187.                     <%=strTemplateName%>
  188.                 </td>
  189.                 <td align="center" class="Normal" valign="center">
  190. <%
  191.                     'Format the Y/N flag to either Yes or No
  192.                     If rsTemplates("allow_use_yn") = SUR_BOOLEAN_POSITIVE Then
  193. %>
  194.                         <%=SUR_BOOLEAN_POSITIVE_DISPLAY%>
  195. <%
  196.                     Else
  197. %>
  198.                         <%=SUR_BOOLEAN_NEGATIVE_DISPLAY%>
  199. <%
  200.                     End If
  201. %>
  202.                 </td>
  203.                 <td align="center" class="Normal">
  204.                     <a target="_blank" href="PreviewTemplate.asp?TemplateID=<%=lngTemplateID%>"><img alt="Preview the look and feel of this template" src="Resources/Icons/Preview.gif" border="0" onMouseOver="this.style.cursor='hand'"></a>
  205.                 </td>
  206.                 <td align="center" class="Normal">
  207.                     <a href="Template.asp?State=Edit&TemplateID=<%=lngTemplateID%>"><img alt="Edit this template" src="Resources/Icons/Edit.gif" border="0" onMouseOver="this.style.cursor='hand'"></a>
  208.                 </td>
  209.                 <td align="center" class="Normal">
  210. <%
  211.                     'Only allow delete if the user is the survey owner or if the user is an admin, and there are no surveys
  212.                     'using the template, and the template ID is not equal to 1 (the permanent default)
  213.                     If (lngCurrentUserID = rsTemplates("user_id") Or lngUserSecurityLevel = SUR_SECURITY_LEVEL_ADMIN) And GetTemplateUsageCount(lngTemplateID) = 0 And lngTemplateID <> SUR_DEFAULT_TEMPLATE_ID Then
  214. %>
  215.                         <a href="javascript:deleteTemplate('<%=lngTemplateID%>');"><img alt="Delete this template" src="Resources/Icons/Delete.gif" border="0" onMouseOver="this.style.cursor='hand'"></a>
  216. <%
  217.                     End If
  218. %>
  219.                 </td>
  220.             </tr>
  221. <%
  222.             'Alternate the colors for the rows in the table
  223.             If strTableRowColor = "TableRowDarkColor" Then
  224.                 strTableRowColor = "TableRowLightColor"
  225.             Else
  226.                 strTableRowColor = "TableRowDarkColor"
  227.             End If
  228.  
  229.             rsTemplates.MoveNext
  230.         Loop
  231.     End If
  232. %>
  233. </table>
  234.  
  235. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  236.  
  237. </body>
  238. </html>
  239. <%
  240.     'Clean up
  241.     rsTemplates.Close
  242.     Set rsTemplates = Nothing
  243.  
  244.     'Ensure that the web server returns the page
  245.     Response.Flush
  246. %>
  247.