Source code of Windows XP (NT5)
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.

239 lines
7.2 KiB

  1. <%
  2. Option explicit
  3. Response.Expires = 0
  4. Dim Conn,Comm,RS,BugID,addfn,FldLinks
  5. %>
  6. <!--
  7. Display links ( attachments, linked bugs ) for a given bug
  8. QueryString : bugid=# ( bug # )
  9. type=# ( link type: 3 = attach file, 1= related bugs, 0=duplicate, 6=dependent
  10. -->
  11. <html>
  12. <head>
  13. <style type="text/css">
  14. .act {color:menutext; background:menu; cursor:default}
  15. #bug {font-size:8pt}
  16. .vis {}
  17. .unvis {display:none}
  18. .inp {font-size:8pt; height:18; width:70; color:black; background:menu}
  19. .inpenab {font-size:8pt; height:18; width:70;}
  20. .titl {background:menu}
  21. .titlenab {}
  22. .fl {background:white; cursor:default}
  23. .hd {}
  24. .ac {width:60pt}
  25. </style>
  26. <script language="JavaScript">
  27. //
  28. // download
  29. //
  30. // download attached file
  31. //
  32. // event:
  33. // row in array of links
  34. //
  35. function download() {
  36. ix = event.srcElement.parentElement.rowIndex - 1;
  37. if ( ix > -1 ) {
  38. f = document.all.item("FileName", ix).value;
  39. if ( f.substr(f.length-1,1) == "." )
  40. f = f.substr(0, f.length-1);
  41. s = "r<%Response.Write Application("dbFileShareDir")(Session("DBSOURCE"))%>" + "/" + document.all.item("OriginalName", ix).value + "?_RAID_NAME_=" + f;
  42. window.open( s );
  43. }
  44. }
  45. //
  46. // showbug
  47. //
  48. // display details for selected bug
  49. //
  50. // event:
  51. // row in array of links
  52. //
  53. function showbug() {
  54. ix = event.srcElement.parentElement.rowIndex - 1;
  55. if ( ix > -1 ) {
  56. s = "/scripts/raid/raid3.asp?BugID=" + document.all.item("LinkedBugID", ix).value;
  57. window.open( s );
  58. }
  59. }
  60. //
  61. // upload
  62. //
  63. // upload new attached file
  64. //
  65. function upload() {
  66. v = window.showModalDialog( "upload.asp?bugid=" + document.all.up.bugid.value, "upload", "dialogWidth:300pt; dialogHeight:100pt" );
  67. //
  68. // return value will be "uploaded" if request was sent to posting acceptor,
  69. // otherwise will be LinkID generated as placeholder for result of transfer
  70. // so if not "uploaded" then we must remove new record in links table
  71. //
  72. if ( v != "uploaded" ) {
  73. document.all.up.linkid.value = v;
  74. document.all.up.action.value = "del";
  75. document.all.up.submit();
  76. }
  77. location.reload();
  78. }
  79. //
  80. // delattach
  81. //
  82. // delete file attachement ( in SQL DB & file system )
  83. //
  84. function delattach() {
  85. ix = event.srcElement.parentElement.rowIndex - 1;
  86. if ( ix > -1 ) {
  87. //document.all.dela.target = "";
  88. //document.all.dela.action = "/scripts/raid/<%=Application("dbFileShareDir")(Session("DBSOURCE"))%>/" + document.all.item("Filename", ix).value + "pac";
  89. //document.all.dela.submit();
  90. //
  91. // invoke ISAPI DLL to remove file
  92. //
  93. w = window.open( "/scripts/raid/<%=Application("dbFileShareDir")(Session("DBSOURCE"))%>/" + document.all.item("Filename", ix).value + "pac?del=", "dela", "" );
  94. //w.reload();
  95. w.close();
  96. //
  97. // invoke ASP to update RAID DB
  98. //
  99. document.all.up.linkid.value = document.all.item("LinkID", ix).value;
  100. document.all.up.action.value = "delattach";
  101. document.all.up.submit();
  102. }
  103. }
  104. function addlinkedbug( title ) {
  105. bi = prompt( title + " bug number:", "" );
  106. if ( bi != null ) {
  107. document.all.up.linkedbug.value = bi;
  108. document.all.up.action.value = "add";
  109. document.all.up.submit();
  110. }
  111. }
  112. function dellinkedbug() {
  113. ix = event.srcElement.parentElement.rowIndex - 1;
  114. if ( ix > -1 ) {
  115. document.all.up.linkid.value = document.all.item("LinkID", ix).value;
  116. document.all.up.action.value = "del";
  117. document.all.up.submit();
  118. }
  119. }
  120. </script>
  121. </head>
  122. <body bgcolor=#c0c0c0>
  123. <%
  124. ' EnumLinks: enumerate links in FldLinks array
  125. ' title: array of titles
  126. ' fld: array of field indexes in FldLinks
  127. ' onlick: client function for onclick event
  128. SUB EnumLinks(title,ondblclick,fld,ondelete)
  129. Dim i,j,mx,n
  130. Response.Write "<table id=lnk>"
  131. Response.Write "<thead><tr><th></th>"
  132. for i = 0 to UBound(title)
  133. Response.Write "<th class=hd>" & title(i) & "</th>"
  134. next
  135. Response.Write "</tr></thead><tbody>"
  136. if vbNull <> VarType(FldLinks) then
  137. mx = UBound(FldLinks,2)
  138. for i = 0 to mx
  139. Response.Write "<tr><td onclick=" & chr(34) & ondelete & chr(34) & ">Delete</td>"
  140. for j = 0 to UBound(fld)
  141. Response.Write "<td class=fl ondblclick=" & chr(34) & ondblclick & chr(34) & ">" & FldLinks(fld(j),i) & "</td>"
  142. next
  143. j = 0
  144. for each n in RS.Fields
  145. Response.Write "<td><input type=hidden id=" & chr(34) & n.Name & chr(34) & " name=" & chr(34) & n.Name & chr(34) & " value=" & chr(34) & FldLinks(j,i) & chr(34) & "></input></td>"
  146. j = j + 1
  147. next
  148. Response.Write "</tr>"
  149. next
  150. end if
  151. END SUB
  152. Set Conn = Server.CreateObject("ADODB.Connection")
  153. Set Comm = Server.CreateObject("ADODB.Command")
  154. Set RS = Server.CreateObject("ADODB.Recordset")
  155. Conn.Open Session("DSN")
  156. Set Comm.ActiveConnection = Conn
  157. rem RS.CursorType = adOpenStatic
  158. Set RS.Source = Comm
  159. Response.Write "<script language=" & chr(34) & "JavaScript" & chr(34) & ">"
  160. Response.Write "</script>"
  161. BugID = Request.QueryString("bugid")
  162. Comm.CommandText = "Select LinkID,FileName,OriginalName,LinkedBugID,TokenID from links where BugID=" & BugID & " AND fDeleted=0 AND Type=" & Request.QueryString("type")
  163. rem Response.Write Comm.CommandText
  164. RS.Open
  165. if NOT RS.EOF then
  166. FldLinks = RS.GetRows()
  167. else
  168. FldLinks = NULL
  169. end if
  170. Response.Write "<table><tbody><tr><td><form id=" & chr(34) & "link" & "name=" & chr(34) & "link" & chr(34) & ">"
  171. Response.Write "<input type=hidden name=" & chr(34) & "bugid" & chr(34) & " id=" & chr(34) & "bugid" & chr(34) & " value=" & chr(34) & BugID & chr(34) & "></input>"
  172. Select case Request.QueryString("type")
  173. case 3
  174. EnumLinks Array("Attached Files"), "download()", Array(2), "delattach()"
  175. addfn = "upload()"
  176. case 1
  177. EnumLinks Array("Related bugs"), "showbug()", Array(3), "dellinkedbug()"
  178. addfn = "addlinkedbug('Related')"
  179. case 0
  180. EnumLinks Array("Duplicate bugs"), "showbug()", Array(3), "dellinkedbug()"
  181. addfn = "addlinkedbug('Duplicate')"
  182. case 6
  183. EnumLinks Array("Dependent bugs"), "showbug()", Array(3), "dellinkedbug()"
  184. addfn = "addlinkedbug('Dependent')"
  185. end select
  186. Response.Write "</tbody></table></form></td>"
  187. RS.Close
  188. Conn.Close
  189. %>
  190. <td>
  191. <button onclick="<%=addfn%>" class="ac">Add</button><br>
  192. <button onclick="window.close()" class="ac">Close</button><br>
  193. </td></tr></table>
  194. <div style="display:none">
  195. <form id="up" action="/scripts/raid/addlink.asp" method=post>
  196. <input id="linkedbug" name="linkedbug" type=hidden>
  197. <input id="action" name="action" type=hidden>
  198. <input id="bugid" name="bugid" value="<%=BugID%>" type=hidden>
  199. <input id="linkid" name="linkid" value="" type=hidden>
  200. <input id="type" name="type" value="<%=Request.QueryString("type")%>" type=hidden>
  201. <input id="tokenid" name="tokenid" value="<%=Application("dbTokenID")(Session("DBSOURCE"))%>" type=hidden>
  202. </form>
  203. </div>
  204. </body>
  205. </html>