###############################################################################
# CP_ListGroups.src                                                           #
###############################################################################
# UltraBoard 2000 by UltraScripts.com, Inc.                                   #
# Scripts written by Jacky Wing Wa Yung, WebMaster@UltraScripts.com           #
# Available from http://www.UltraBoard.org/                                   #
# =========================================================================== #
# COPYRIGHT NOTICE :                                                          #
#                                                                             #
# Copyright (c) 1999-2000 UltraScripts.com, Inc. All Rights Reserved.         #
#                                                                             #
# This program is being distributed as shareware. It may be used and modified #
# free for personal, government or non-profit. Any commercial use must be     #
# registered. However, modified versions cannot be sold or distributed. You   #
# cannot alter the copyright and "powered by" notices throughout the scripts. #
# These notices must be clearly visible to the end users.                     #
#                                                                             #
# WARRANTY DISCLAIMER:                                                        #
#                                                                             #
# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT #
# ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR       #
# FITNESS FOR A PARTICULAR PURPOSE.                                           #
###############################################################################

package Source;

use strict;

sub ListGroups {

  my ($Action, $Address, $Description, $Script, $Form);
  if ($UB::QUERY{'For'} eq "ModifyGroup") {
    $Action      = "ModifyGroup";
    $Address     = "Modify a member group";
    $Description = "Please choose which member group that you want to modify.";
    $Script      = "";
    $Form        = "";
  } elsif ($UB::QUERY{'For'} eq "RemoveGroups") {
    $Action      = "DoRemoveGroups";
    $Address     = "Remove member groups";
    $Description = "Please select which member groups that you want to remove.";
    $Script      = "<SCRIPT LANGUAGE=\"JavaScript\"> function Confirm () { return confirm(\"Are you sure to remove these member groups?\"); } </SCRIPT>";
    $Form        = " onSubmit = \"return Confirm();\"";
  }

  (
    my ($Groups) = &DB::Query (
      TABLE   => "Groups"
    )
  ) || &HTML::Error("Member Group Management / $Address", "No group available for you to choose yet.<br>Sorry, you have to <a href=\"$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=CreateGroup\" target=\"UBBODY\">create a new member group</a> first!");

  &Standard::PrintHTMLHeader();
  print &HTML::Header;
  print<<HTML;
$Script
<form action="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT" method="post" name="form"$Form>
<input type="hidden" name="action" value="$Action">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr bgcolor="Gray">
    <td><font color="White"><b>
      <a href="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=body" target="UBBODY" class="address">Control Panel</a> / Member Group Management /  $Address
    </b></font></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td>
            <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
              <tr>
                <td>
                  <table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td>
                      $Description
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            &nbsp;<br>
            <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="White" bordercolorlight="Gray">
              <tr height=24>
                <td nowrap>&nbsp;</td>
                <td width="30%">&nbsp;Title&nbsp;</td>
                <td width="70%">&nbsp;Description&nbsp;</td>
                <td nowrap>&nbsp;Total members&nbsp;</td>
                <td nowrap>&nbsp;Max. file size&nbsp;</td>
              </tr>
HTML
  for (my $i = 0; $i <= $#{$Groups}; $i++) {
    my $Group = $Groups->[$i];
    my $Form;
    if ($UB::QUERY{'For'} eq "ModifyGroup") {
      $Form = &HTML::Radio (
        NAME    => "GID"         ,
        VALUE   => $Group->{'ID'},
        CHECKED => $UB::QUERY{'GID'} || ""
      );
    } elsif ($UB::QUERY{'For'} eq "RemoveGroups") {
      $Form = &HTML::Checkbox (
        NAME    => "GID_".$Group->{'ID'},
        VALUE   => "1"                  ,
        CHECKED => $UB::QUERY{"GID_".$Group->{'ID'}} || ""
      );
    }
    print<<HTML;
              <tr bgcolor="White">
                <td bgcolor="Silver" nowrap>$Form</td>
                <td width="30%" valign="middle">&nbsp;$Group->{'TITLE'}&nbsp;</td>
                <td width="70%" valign="middle">&nbsp;$Group->{'DESCRIPTION'}&nbsp;</td>
                <td nowrap align="center">&nbsp;$Group->{'TOTAL_MEMBERS'}&nbsp;</td>
                <td nowrap align="right">&nbsp;$Group->{'MAX_FILE_SIZE'} KB&nbsp;</td>
              </tr>
HTML
  }
print<<HTML;
            </table>
          </td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right"><input type="submit" value="Next &gt;">&nbsp;&nbsp;<input type="Reset" value="Cancel"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
</html>
HTML
}

###############################################################################
1; # end of CP_ListGroups.src file
###############################################################################