home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / ins.cab / nngrphd.asp < prev    next >
Encoding:
Text File  |  1997-08-26  |  10.9 KB  |  379 lines

  1. <% Response.Expires = 0 %>
  2.  
  3. <%
  4. REM LOCALIZATION
  5.  
  6. L_MENU_TITLETXT = "MCIS-NS Administration"
  7. L_ERRORTXT = "Error is: "
  8. L_ALERT_ENTER_VALUETXT = "Please enter a newsgroup name."
  9. L_CONFIRM_DELETETXT = "Are you sure you want to remove this newsgroup?"
  10. L_HEAD_TITLETXT = "Newsgroups on"
  11. L_NEWSGROUP_NAMETXT = "Newsgroup name:"
  12. L_FIND_BUTTONTXT = "Find"
  13. L_DISPLAY_RESULTSTXT = "Displaying newsgroups "
  14. L_MATCHING_NEWSGROUPSTXT = " matching newsgroups."
  15. L_TITLE_MATCHING_NEWSGROUPTXT = "Matching Newsgroup"
  16. L_TITLE_MATCHING_NEWSGROUPSTXT = "Matching Newsgroups"
  17.  
  18. REM END LOCALIZATION
  19. %>
  20. <SCRIPT LANGUAGE="javascript">
  21.  
  22. <% REM Get starting number for groups to show %>
  23. <% startNum = Request("startNum") %>
  24. <% REM if startNum has a value then use it, otherwise use start value of 1 %>
  25. <% if (startNum = "") then %>
  26.     <% startNum = 1 %>
  27. <% end if %>
  28.  
  29. <% startNumClean = startNum %>
  30.     
  31. <% REM Set number of groups to display per page %>
  32. <% GroupsPerPage = 10 %>
  33.  
  34. <% REM GET ACTION VARIABLE %>
  35. <% REM VALUE IS "remove" OR NOTHING %>
  36. <% a = Request("a") %>
  37. <% svr = Session("svr") %>
  38.  
  39. <% REM create nntp admin object %>
  40.  
  41. <% On Error Resume Next %>
  42. <% Set GroupAdm = Server.CreateObject("nntpadm.groups") %>
  43. <% if Err <> 0 then %>
  44.         <p>
  45.         Error: Access is Denied.
  46.         alert(' <% = L_ERRORTXT %><% = Err.description %> ');
  47. <% end if %>
  48.  
  49. <% REM get server name %>
  50. <% GroupAdm.Server = svr %>
  51.  
  52. <% REM set service instance %>
  53. <% GroupAdm.ServiceInstance = Session("ServiceInstance") %>
  54.  
  55. <% Session("find") = Request("find") %>
  56.  
  57. <% if (Session("find") <> "") then %>
  58.     <% FindNewsgroup = Session("Find") %>
  59. <% else %>
  60.     <% FindNewsgroup = Request("find") %>
  61. <% end if %>
  62.  
  63. <% if (FindNewsgroup = "") then %>
  64.     <% FindNewsgroup = "*" %>
  65. <% end if %>
  66.  
  67. <% REM set Newsgroup to current value of "group" %>
  68. <% Newsgroup = Request("group") %>
  69.  
  70. <% REM Remove Group if "a" == "remove" %>
  71. <% if (a = "remove") then %>
  72.  
  73.     <% NewsgroupToDelete = Request("NewsgroupToDelete") %>
  74.  
  75.     <% On Error Resume Next %>
  76.     <% GroupAdm.Remove(NewsgroupToDelete) %>
  77.     <% if Err <> 0 then %>
  78.             alert ( "<% = L_ERRORTXT %><% = Err.description %>" );
  79.     <% end if %>
  80. <% end if %>
  81.  
  82. <!--#include file="_cnst.asp" -->
  83.  
  84. <% if (cont = true) then %>
  85. </script>
  86. <% REM START OF HTML %>
  87. <HTML>
  88. <HEAD>
  89. <script language="javascript">
  90. <% REM Determine browser to set pop-up window size %>
  91.  
  92. <% if Instr(Request.ServerVariables("HTTP_USER_AGENT"), "IE 4", 1) then %>
  93.     winstr = "width=430,height=380,directories=no,status=no,scrollbars=no,resize=no";
  94.  
  95. <% elseif Instr(Request.ServerVariables("HTTP_USER_AGENT"),"MSIE") then %>
  96.     winstr = "width=390,height=280,directories=no,status=no,scrollbars=no,resize=no";
  97.  
  98. <% else %>
  99.     winstr = "width=420,height=350,menubar=no,directories=no,status=no,scrollbars=no,resize=no";
  100. <% end if %>
  101.  
  102. <% REM Create uForm object and methods %>
  103.  
  104.     var uForm = new Object();
  105.     uForm.itemList = new Array();
  106.     uForm.startNum = "<% = startNum %>";
  107.     uForm.GroupsPerPage = <% = GroupsPerPage %>;
  108.     uForm.selectedItem = uForm.startNum - 1;
  109.     uForm.editItem = editItem;
  110.     uForm.selectItem = selectItem;
  111.     uForm.loadList = loadList;
  112.     uForm.removeItem = removeItem;
  113.     uForm.addItem = addItem;
  114.     uForm.next = next;
  115.     uForm.previous = previous;
  116.     uForm.refresh = refresh;
  117.     uForm.FindNewsgroup = top.menu.document.hiddenform.txtFindNewsgroup.value;
  118.     uForm.startNumClean = "<% = startNumClean %>";
  119.  
  120. <% maxReturn = 1000    %>
  121.  
  122. <% groupadm.server = svr %>
  123. <% groupadm.serviceinstance = Session("ServiceInstance") %>
  124.  
  125. <% On Error Resume Next %>
  126. <% GroupAdm.Find findnewsgroup, maxReturn %>
  127. <% if Err <> 0 then %>
  128.         alert( "GroupAdm.Find error is: <% = Err.description %> ");
  129. <% end if %>
  130.  
  131. <% numGroups = GroupAdm.Count %>
  132.  
  133. uForm.numGroups = "<% = numGroups %>";
  134.  
  135. //alert( 'numGroups: <% = numGroups %>\nstartNum is: <% = startNum %>\nGroupsPerPage is: <% = GroupsPerPage %>');
  136.  
  137. top.menu.document.hiddenform.nNewsgroupListStart.value = "<% = startNum %>";
  138.  
  139. <% i = startNum - 1 %>
  140.  
  141. <% while( (i < numGroups) AND ( i < (startNum + GroupsPerPage - 1) ) ) %>
  142.  
  143.     <% On Error Resume Next %>
  144.     <% x = GroupAdm.MatchingGroup( i ) %>
  145.     <% do while ( Err <> 0 ) %>            
  146.         alert ( "<% = L_ERRORTXT %><% = Err.description %>" );            
  147.         <% exit do %>
  148.     <% loop %>
  149.     
  150.     <% On Error Resume Next %>
  151.     <% GroupAdm.Get(x) %>
  152.     <% if ( Err <> 0 ) then %>            
  153.         alert ( "<% = L_ERRORTXT %><% = Err.description %>" );            
  154.     <% end if %>
  155.     
  156.     uForm.itemList[<% = i %>] = new Object();
  157.     uForm.itemList[<% = i %>].newsgroup = "<% = GroupAdm.Newsgroup %>";
  158.     uForm.itemList[<% = i %>].description = "<% = Server.URLEncode( GroupAdm.Description ) %>";
  159.     uForm.itemList[<% = i %>].readOnly = "<% = GroupAdm.ReadOnly %>";
  160.     uForm.itemList[<% = i %>].moderator = "<% = GroupAdm.Moderator %>";
  161.     
  162.     if( uForm.itemList[<% = i %>].moderator != "" )
  163.     {
  164.         uForm.itemList[<% = i %>].moderated = "1";
  165.     }
  166.     else
  167.     {
  168.         uForm.itemList[<% = i %>].moderated = "0";
  169.     }
  170.     <% i = i + 1 %>
  171. <% Wend %>
  172.  
  173. <% startNum = startNum + GroupsPerPage %>
  174.  
  175. top.menu.document.hiddenform.nNewsgroupListStart.value = "<% = startNum %>";
  176.  
  177. function next()
  178. {
  179.     if( parseInt(top.menu.document.hiddenform.nNewsgroupListStart.value) <= parseInt(uForm.numGroups) )
  180.     {
  181.         parent.head.location = "nngrphd.asp?svr=<% = svr %>&startNum=" + top.menu.document.hiddenform.nNewsgroupListStart.value + "&find=" + top.menu.document.hiddenform.txtFindNewsgroup.value;
  182.     }
  183. }
  184.  
  185. function previous()
  186. {
  187.     sum = uForm.GroupsPerPage + 1;
  188.     if( sum != parseInt(top.menu.document.hiddenform.nNewsgroupListStart.value) )
  189.     {
  190.         parent.head.location = "nngrphd.asp?svr=<% = svr %>&startNum=" + (top.menu.document.hiddenform.nNewsgroupListStart.value - ( uForm.GroupsPerPage * 2 ) ) + "&find=" + top.menu.document.hiddenform.txtFindNewsgroup.value;
  191.     }
  192. }    
  193.  
  194. function refresh()
  195. {
  196.     parent.head.location = "nngrphd.asp?svr=<% = svr %>&startNum=&find=" + top.menu.document.hiddenform.txtFindNewsgroup.value;
  197. }
  198.  
  199. function onUpdateList(nDirection)
  200. {
  201.     var oldvalue = parseInt ( top.menu.document.hiddenform.nNewsgroupListStart.value );
  202.     var newvalue = nDirection * 5 + oldvalue;
  203.     if ( nDirection == 0 )
  204.     {
  205.         newvalue = 0;
  206.     }
  207.     top.menu.document.hiddenform.nNewsgroupListStart.value = newvalue;
  208.     
  209.     
  210.  
  211.     parent.head.location = "nngrphd.asp?svr=<% = svr %>&startNum=" + top.menu.document.hiddenform.nNewsgroupListStart.value + "&find=" + top.menu.document.hiddenform.txtFindNewsgroup.value;
  212. }
  213.  
  214. function checkValue()
  215. {
  216.     if (document.userform.txtFindNewsgroup.value==""){
  217.         alert("<% = L_ALERT_ENTER_VALUETXT %>");
  218.         document.userform.txtFindNewsgroup.focus();
  219.         return false;
  220.     }
  221.     else {
  222.         return true;
  223.     }
  224. }
  225.  
  226. <% REM when the find href receives a mouseDown %>
  227. function onFind()
  228. {
  229.     if (checkValue())
  230.     {
  231.                top.menu.document.hiddenform.txtFindNewsgroup.value = document.userform.txtFindNewsgroup.value;
  232.                uForm.refresh();
  233.     }
  234. }
  235.  
  236. <% REM Javascript function selectItem (if IE, reloads list at specified position -- broken in Netscape) %>
  237. function selectItem(index)
  238.     {
  239.         uForm.selectedItem = index;
  240.         <% if Instr(Request.ServerVariables("HTTP_USER_AGENT"),"IE") then %>
  241.         if (index == 0)
  242.         {
  243.             parent.list.location = "nngrpls.asp"
  244.         }
  245.         else
  246.         {
  247.             parent.list.location = "nngrpls.asp#" + (index-1);
  248.         }            
  249.         <% else %>
  250.             parent.list.location = "nngrpls.asp"
  251.         <% end if %>
  252.     }
  253.  
  254. <% REM Javascript function addItem %>
  255.  
  256. function addItem()
  257.     {
  258.         win = window.open("nngrped.asp?svr=<% = svr %>&a=new","PropWindow",winstr);
  259.         if (win.opener == null)
  260.         {
  261.                win.opener = self;
  262.            }
  263. }
  264.  
  265. <% REM Javascript function editItem %>
  266. function editItem()
  267. {
  268.     if(uForm.numGroups > 0)
  269.     {
  270.         index = uForm.selectedItem;
  271.         Newsgroup = uForm.itemList[index].newsgroup;
  272.         Description = uForm.itemList[index].description;
  273.         readOnly = uForm.itemList[index].readOnly;
  274.         Moderator = uForm.itemList[index].moderator;
  275.         Moderated = uForm.itemList[index].moderated;
  276.         win = window.open("nngrped.asp?svr=<% = svr %>&a=edit&Group=" + Newsgroup + "&txtDescription=" + Description + "&hdnReadOnly=" + readOnly + "&txtModerator=" + Moderator + "&hdnModerated=" + Moderated + "&index=" + index,"PropWindow",winstr);
  277.         if (win.opener == null)
  278.         {
  279.             win.opener = self;
  280.         }
  281.     }
  282. }
  283.  
  284. <% REM Javascript function removeItem %>
  285.  
  286. function removeItem()
  287. {
  288.     if (confirm("<% = L_CONFIRM_DELETETXT %>"))
  289.     {
  290.         index = uForm.selectedItem;
  291.         NewsgroupToDelete = uForm.itemList[index].newsgroup;
  292.         self.location = "nngrphd.asp?svr=<% = svr %>&a=remove&NewsgroupToDelete=" + NewsgroupToDelete;
  293.     }
  294. }
  295.  
  296. function onLoad() {
  297.     document.userform.txtFindNewsgroup.value = top.menu.document.hiddenform.txtFindNewsgroup.value;
  298. }
  299.  
  300. <% REM Javascript function loadList loads list frame after header is completed %>
  301. function loadList() {
  302.     parent.list.location = "nngrpls.asp?svr=<% = svr %>";
  303. }    
  304.  
  305. </SCRIPT>
  306. <TITLE><% = L_MENU_TITLETXT %></TITLE>
  307. </HEAD>
  308.  
  309. <BODY TEXT="#000000" LINK="#FFFFFF" ALINK="#FFFFFF" BGCOLOR="#CCCCCC" TOPMARGIN=10 VLINK="#FFFFFF">
  310. <FORM NAME="userform" ACTION="" onSubmit = "onFind(); return false;" METHOD="post">
  311. <TABLE BORDER="0">
  312.     <TR>
  313.         <TD COLSPAN=2>
  314.             <P><IMG SRC="images/gnicttl.gif" ALIGN="textmiddle" HEIGHT=10 WIDTH=10> <FONT SIZE=2 FACE="Arial"><B><% = L_HEAD_TITLETXT %>  </B></FONT><FONT SIZE=3 FACE="Times New Roman"><I><% = svr %></I><BR> </FONT>
  315.         </TD>
  316.     </TR>
  317.     <TR>
  318.         <TD WIDTH=25> </TD>
  319.         <TD><FONT SIZE=2 FACE="Arial">
  320.             <% = L_NEWSGROUP_NAMETXT %>  <INPUT TYPE = "text" NAME = "txtFindNewsgroup">
  321.         </TD>
  322.         <TD>
  323.         <TABLE BORDER="0" CELLPADDING=5 CELLSPACING=2>
  324.             <TR>        
  325.                 <TD VALIGN="bottom" BGCOLOR="#555555">
  326.                     <FONT FACE="Arial" SIZE=2>
  327.                     <B><A HREF="javascript:onFind();">
  328.                     <% = L_FIND_BUTTONTXT %></A></B>
  329.                     </FONT>
  330.                 </TD>    
  331.             </TR>
  332.         </TABLE>
  333.         </TD>
  334.     </TR>
  335.     <TR>
  336.         <TD WIDTH=25> </TD>
  337.         <TD COLSPAN = 2>
  338.             <FONT SIZE=2 FACE="Arial">
  339.                  <BR>
  340. <% if (numGroups = 0) then %>
  341.     No matching groups<br>
  342. <% else %>
  343.             Results: <b><% = startNumClean %></b> - <b><% if( (startNumClean + GroupsPerPage - 1) < numGroups ) then %>
  344.             <% = startNumClean + GroupsPerPage - 1 %><% else %><% = numGroups %><% end if %></b> out of <b><% = numGroups %></b></br>
  345. <% end if %>
  346.             </FONT>        
  347.         </TD>
  348.     </TR>
  349.     <TR>
  350.         <TD COLSPAN=2 HEIGHT=4></TD>
  351.     </TR>
  352. </TABLE>
  353.  
  354. </FORM>
  355.  
  356. <TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0 WIDTH=400>
  357.     <TR>
  358.     <TD WIDTH=10>
  359.     </TD>
  360.     <TD WIDTH=390>
  361.     <B><FONT SIZE=2 FACE="Arial"><% = L_TITLE_MATCHING_NEWSGROUPSTXT %></FONT></B>
  362.     </TD>
  363.     </TR>
  364. </TABLE>
  365. <% REM Load list page after head has completely loaded %>
  366. <% if ( (a = "open") OR (a = "remove") ) then %>
  367.     <SCRIPT LANGUAGE="javascript">
  368.         parent.head.location = "nngrphd.asp?svr=<% = svr %>&find=" + top.menu.document.hiddenform.txtFindNewsgroup.value;
  369.     </SCRIPT>
  370. <% else %>
  371.     <SCRIPT LANGUAGE="javascript">
  372.         timeList = setTimeout('loadList()',500);
  373.         onLoad();
  374.     </SCRIPT>
  375. <% end if %>
  376. </BODY>
  377. </HTML>
  378. <% end if %>
  379.