#! /srvtools/http/bin/perl
#############################################################################
#  
#   File: SelectBoard.pl 
#
#   Author:        Paul Coddington and Jungmin Kim
#
#   Version:       09-May-96
#
#   Input:         username and directory
#   Output:        HTML text showing list of forums for the WebBoard 
#                  (or forum category) for that directory.
#
#   Description:   Print out HTML page of index of conferences 
#               
#   Usage:         "http://.../WeBBoard/select:(NULL):(NULL):user"
#                  'user' should be "username:email_address".
#
#   Created:       March 5  1995
#   Modified:      March 23 1995 by Paul Coddington 
#
#############################################################################

require "Entry2.pl";  

sub SelectBoard {
   local($user, $subdir) = @_;		      # user information
   local($key);

if ($user) {

   # Convert $user info to take out spaces and special Web characters 

   &PrintContentType();

   # Print Select header file for this WeBBoard
   &PrintFile("$subdir/HTML/SelectHeader.html", $webboardhome);
    
   # Print list of Forums 
   print "<UL>\n";

   foreach $key (sort keys %conference) {
      if ($key eq "") { next;}
      print "<LI>\n";
      if ($subdir eq "") { # Upper level - show all the WebBoards
	  # print "<A HREF=\"${action}\/$key\:select\:\:\:$user\">";
	  print "<A HREF=\"${action}\/$key\">";
	  print " $conference{$key} </A>\n";
      }
      # Check to see whether there is another level of heirarchy, i.e.
      # should we directly point to a forum of messages to be read, or
      # should we point to a collection of forums?
      else {  
        $fconffile = "$webboardhome\/$subdir\/$key\/$conffile";
#DEBUG
# print " fconffile = $fconffile <P>\n";
        if (-e $fconffile) {
#DEBUG
# print " found $fconffile <P>\n";
            # &ReadConf(*conference);		# read conference names
	    print "<A HREF=\"${action}\/$subdir\/$key\:select\:\:\:$user\">";
	    print " $conference{$key} </A>\n";
	}
        else {
#DEBUG
# print " didn't find $fconffile <P>\n";
	    print "<A HREF=\"${action}\/$subdir\:read\:$key\:\:$user\">";
	    print " $conference{$key} </A>\n";
	}
      }
   }

   # End list of Forums 
   print "</UL>\n";

   # Print Select footer file for this WeBBoard
   &PrintFile("$subdir/HTML/SelectFooter.html", $webboardhome);

    ### if user name is administrator, print out options to change configuration
}
else {
     # Make them register
     &Entry2($subdir);
}

    if($user =~/^administrator\:/) {

    if ($subdir) {
       $conftype = "forum";
    }
    else {
       $conftype = "WebBoard";
    }

    print "<P><HR>\n";
    # print "<P><HR><BR>\n";
    print "Choose one of the following to make changes to the WebBoard setup\:\n";
    print "<DL><DD>\n";
    print "<B>\n";
    print "<FORM METHOD=\"POST\" ACTION=\"$change\/$subdir\:\:${user}\">\n";
    print "<INPUT TYPE=\"radio\" NAME=\"subject\" VALUE=\"addconf\"\n";
    print " CHECKED>\n";
    print " Add a $conftype<BR>\n";
    print "<INPUT TYPE=\"radio\" NAME=\"subject\" VALUE=\"delconf\">\n";
    print " Delete a $conftype<BR>\n";
    # FIX this after it is implemented
    # print "<INPUT TYPE=\"radio\" NAME=\"subject\" VALUE=\"editconf\">\n";
    # print " Edit a $conftype<BR>\n";
    if ($subdir) {
       print "<INPUT TYPE=\"radio\" NAME=\"subject\" VALUE=\"option\">\n";
       print " Change preferences for this WebBoard <BR>\n";
       # FIX or forum?
    }
    if ($allow ne "yes") {
      print "<INPUT TYPE=\"radio\" NAME=\"subject\" VALUE=\"adduser\">\n";
      print " Add a new user name<BR>\n";
      print "<INPUT TYPE=\"radio\" NAME=\"subject\" VALUE=\"deluser\">\n";
      print " Delete a user name<BR>\n";
    }
    print "</B></DL>\n";
    print "<INPUT TYPE=\"submit\" VALUE=\"SUBMIT\">\n";
    print " Click on this button to submit your request. <BR>\n";    
    print "<HR>\n";

    }

   # Print address and copyright information
   &Address($subdir);

}
1;

