###############################################################################
# CP_ModifyBoard.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 ModifyBoard {
  my ($ERROR) = @_;

  ( # querying data from categories table
    my ($DB) = &DB::Query (
      TABLE   => "Categories",
      COLUMNS => ["ID", "TITLE"]
    )
  ) || &HTML::Error("Boards Management / Modify board", "No category available for you to choose yet.<br>Sorry, you have to <a href=\"$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=CreateCategory\" target=\"UBBODY\">create a new category</a> first!");

  my $Categories;
  # processing the data from the result
  for (my $i = 0; $i <= $#{ $DB }; $i++) {
    push (
      @{ $Categories },
      {
        KEY   => $DB->[$i]{'ID'},
        VALUE => $DB->[$i]{'TITLE'}
      }
    );
  }

  ( # querying data from groups table
    ($DB) = &DB::Query (
      TABLE   => "Groups",
      COLUMNS => ["ID", "TITLE"]
    )
  ) || &HTML::Error("Boards Management / Modify board", "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!");

  my $Groups;
  my $AllGroups;
  # processing the data from the result
  push (
    @{ $Groups },
    {
      KEY   => "*",
      VALUE => "All Groups"
    }
  );
  push (@{ $AllGroups }, "*");

  # processing the data from the result
  for (my $i = 0; $i <= $#{ $DB }; $i++) {
    push (
      @{ $Groups },
      {
        KEY   => $DB->[$i]{'ID'},
        VALUE => $DB->[$i]{'TITLE'}
      }
    );
    push (@{ $AllGroups }, $DB->[$i]{'ID'});
  }

  # querying data from accounts table
  ($DB) = &DB::Query (
    TABLE   => "Accounts",
    COLUMNS => ["USERNAME", "NICKNAME", "LEVEL"],
    WHERE   => {
      LEVEL => [50]
    }
  );

  my $Accounts = [];
  # processing the data from the result
  for (my $i = 0; $i <= $#{ $DB }; $i++) {
    push (
      @{ $Accounts },
      {
        KEY   => $DB->[$i]{'USERNAME'},
        VALUE => $DB->[$i]{'NICKNAME'}
      }
    );
  }

  (
    my ($Board) = &DB::BinarySelect (
      TABLE   => "Boards",
      KEY     => $UB::QUERY{'BID'}
    )
  ) || &HTML::Error ("Internal Database Error", $DB::Error);

  my %FORM;
  $FORM{'FORM_ID'}                = $UB::QUERY{'BID'}              || $Board->{'ID'}          || "";
  $FORM{'FORM_TITLE'}             = $UB::QUERY{'FORM_TITLE'}       || $Board->{'TITLE'}       || "";
  $FORM{'FORM_DESCRIPTION'}       = $UB::QUERY{'FORM_DESCRIPTION'} || $Board->{'DESCRIPTION'} || "";

  $FORM{'FORM_CATEGORY'}          = &HTML::Select (
    NAME      => "FORM_CATEGORY",
    VALUE     => $Categories    ,
    SELECTED  => ($UB::QUERY{'FORM_CATEGORY'}) ? [$UB::QUERY{'FORM_CATEGORY'}] : [$Board->{'CATEGORY'}],
    EXTRA     => "style=\"width:100%\""
  );

  $FORM{'FORM_MAJOR_MODERATOR'}   = &HTML::Select (
    NAME      => "FORM_MAJOR_MODERATOR",
    VALUE     => [
      {
        KEY   => "",
        VALUE => "Not Available"
      }, @{ $Accounts }
    ]                                  ,
    SELECTED  => ($UB::QUERY{'FORM_MAJOR_MODERATOR'}) ? [$UB::QUERY{'FORM_MAJOR_MODERATOR'}] : [$Board->{'MAJOR_MODERATOR'}],
    EXTRA     => "style=\"width:100%\""
  );
  $FORM{'FORM_MINOR_MODERATORS'}  = &HTML::Select (
    NAME      => "FORM_MINOR_MODERATORS",
    VALUE     => $Accounts              ,
    MULTIPLE  => 1                      ,
    SIZE      => 3                      ,
    SELECTED  => ($UB::QUERY{'FORM_MINOR_MODERATORS'}) ? [$UB::CGI->param('FORM_MINOR_MODERATORS')] : [$Board->{'MINOR_MODERATORS'}],
    EXTRA     => "style=\"width:100%\""
  );

  $FORM{'FORM_STATUS-70'} = &HTML::Radio (
    NAME    => "FORM_STATUS",
    VALUE   => "70"         ,
    CHECKED => $UB::QUERY{'FORM_STATUS'} || $Board->{'STATUS'} || "30"
  );
  $FORM{'FORM_STATUS-50'} = &HTML::Radio (
    NAME    => "FORM_STATUS",
    VALUE   => "50"         ,
    CHECKED => $UB::QUERY{'FORM_STATUS'} || $Board->{'STATUS'} || "30"
  );
  $FORM{'FORM_STATUS-30'} = &HTML::Radio (
    NAME    => "FORM_STATUS",
    VALUE   => "30"         ,
    CHECKED => $UB::QUERY{'FORM_STATUS'} || $Board->{'STATUS'} || "30"
  );

  # read permission
  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/READ-LEVEL-00.dat");
    my $READ_LEVEL_00 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_READ_LEVEL_00'}     = &HTML::Checkbox (
    NAME    => "FORM_READ_LEVEL_00",
    VALUE   => "1"                 ,
    EXTRA   => "onClick=\"Checked4Everyone('READ')\"",
    CHECKED => $UB::QUERY{'FORM_READ_LEVEL_00'} || (($READ_LEVEL_00 eq "*") ? 1 : 0) || ""
  );

  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/READ-LEVEL-30.dat");
    my $READ_LEVEL_30 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_READ_LEVEL_30'}     = &HTML::Checkbox (
    NAME    => "FORM_READ_LEVEL_30",
    VALUE   => "1"                 ,
    EXTRA   => "onClick=\"Checked ('READ', '30')\"",
    CHECKED => $UB::QUERY{'FORM_READ_LEVEL_30'} || (($READ_LEVEL_30 eq "*") ? 1 : 0) || ""
  );

  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/READ-LEVEL-50.dat");
    my $READ_LEVEL_50 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_READ_LEVEL_50'}     = &HTML::Checkbox (
    NAME    => "FORM_READ_LEVEL_50",
    VALUE   => "1"                 ,
    EXTRA   => "onClick=\"Checked ('READ', '50')\"",
    CHECKED => $UB::QUERY{'FORM_READ_LEVEL_50'} || (($READ_LEVEL_50 eq "*") ? 1 : 0) || ""
  );

  $FORM{'FORM_READ_GROUP_30'}     = &HTML::Select (
    NAME      => "FORM_READ_GROUP_30",
    VALUE     => $Groups             ,
    MULTIPLE  => 1                   ,
    SIZE      => 3                   ,
    EXTRA     => "style=\"width:100%\" onChange=\"Selected ('READ', '30')\"",
    SELECTED  => ($UB::QUERY{'FORM_READ_GROUP_30'}) ? [$UB::CGI->param('FORM_READ_GROUP_30')] : (($READ_LEVEL_30 eq "*") ? $AllGroups : [split (/\n/, $READ_LEVEL_30)])
  );

  $FORM{'FORM_READ_GROUP_50'}     = &HTML::Select (
    NAME      => "FORM_READ_GROUP_50",
    VALUE     => $Groups             ,
    MULTIPLE  => 1                   ,
    SIZE      => 3                   ,
    EXTRA     => "style=\"width:100%\" onChange=\"Selected ('READ', '50')\"",
    SELECTED  => ($UB::QUERY{'FORM_READ_GROUP_50'}) ? [$UB::CGI->param('FORM_READ_GROUP_50')] : (($READ_LEVEL_50 eq "*") ? $AllGroups : [split (/\n/, $READ_LEVEL_50)])
  );

  # reply permission
  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/REPLY-LEVEL-00.dat");
    my $REPLY_LEVEL_00 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_REPLY_LEVEL_00'}     = &HTML::Checkbox (
    NAME    => "FORM_REPLY_LEVEL_00",
    VALUE   => "1"                  ,
    EXTRA   => "onClick=\"Checked4Everyone('REPLY')\"",
    CHECKED => $UB::QUERY{'FORM_REPLY_LEVEL_00'} || (($REPLY_LEVEL_00 eq "*") ? 1 : 0) || ""
  );

  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/REPLY-LEVEL-30.dat");
    my $REPLY_LEVEL_30 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_REPLY_LEVEL_30'}     = &HTML::Checkbox (
    NAME    => "FORM_REPLY_LEVEL_30",
    VALUE   => "1"                  ,
    EXTRA   => "onClick=\"Checked ('REPLY', '30')\"",
    CHECKED => $UB::QUERY{'FORM_REPLY_LEVEL_30'} || (($REPLY_LEVEL_30 eq "*") ? 1 : 0) || ""
  );

  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/REPLY-LEVEL-50.dat");
    my $REPLY_LEVEL_50 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_REPLY_LEVEL_50'}     = &HTML::Checkbox (
    NAME    => "FORM_REPLY_LEVEL_50",
    VALUE   => "1"                  ,
    EXTRA   => "onClick=\"Checked ('REPLY', '50')\"",
    CHECKED => $UB::QUERY{'FORM_REPLY_LEVEL_50'} || (($REPLY_LEVEL_50 eq "*") ? 1 : 0) || ""
  );

  $FORM{'FORM_REPLY_GROUP_30'}     = &HTML::Select (
    NAME      => "FORM_REPLY_GROUP_30",
    VALUE     => $Groups              ,
    MULTIPLE  => 1                    ,
    SIZE      => 3                    ,
    EXTRA     => "style=\"width:100%\" onChange=\"Selected ('REPLY', '30')\"",
    SELECTED  => ($UB::QUERY{'FORM_REPLY_GROUP_30'}) ? [$UB::CGI->param('FORM_REPLY_GROUP_30')] : (($REPLY_LEVEL_30 eq "*") ? $AllGroups : [split (/\n/, $REPLY_LEVEL_30)])
  );
  $FORM{'FORM_REPLY_GROUP_50'}     = &HTML::Select (
    NAME      => "FORM_REPLY_GROUP_50",
    VALUE     => $Groups              ,
    MULTIPLE  => 1                    ,
    SIZE      => 3                    ,
    EXTRA     => "style=\"width:100%\" onChange=\"Selected ('REPLY', '50')\"",
    SELECTED  => ($UB::QUERY{'FORM_REPLY_GROUP_50'}) ? [$UB::CGI->param('FORM_REPLY_GROUP_50')] : (($REPLY_LEVEL_50 eq "*") ? $AllGroups : [split (/\n/, $REPLY_LEVEL_50)])
  );

  # post permission
  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/POST-LEVEL-00.dat");
    my $POST_LEVEL_00 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_POST_LEVEL_00'}     = &HTML::Checkbox (
    NAME    => "FORM_POST_LEVEL_00",
    VALUE   => "1"                 ,
    EXTRA   => "onClick=\"Checked4Everyone('POST')\"",
    CHECKED => $UB::QUERY{'FORM_POST_LEVEL_00'} || (($POST_LEVEL_00 eq "*") ? 1 : 0) || ""
  );

  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/POST-LEVEL-30.dat");
    my $POST_LEVEL_30 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_POST_LEVEL_30'}     = &HTML::Checkbox (
    NAME    => "FORM_POST_LEVEL_30",
    VALUE   => "1"                 ,
    EXTRA   => "onClick=\"Checked ('POST', '30')\"",
    CHECKED => $UB::QUERY{'FORM_POST_LEVEL_30'} || (($POST_LEVEL_30 eq "*") ? 1 : 0) || ""
  );

  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/POST-LEVEL-50.dat");
    my $POST_LEVEL_50 = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_POST_LEVEL_50'}     = &HTML::Checkbox (
    NAME    => "FORM_POST_LEVEL_50",
    VALUE   => "1"                 ,
    EXTRA   => "onClick=\"Checked ('POST', '50')\"",
    CHECKED => $UB::QUERY{'FORM_POST_LEVEL_50'} || (($POST_LEVEL_50 eq "*") ? 1 : 0) || ""
  );

  $FORM{'FORM_POST_GROUP_30'}     = &HTML::Select (
    NAME      => "FORM_POST_GROUP_30",
    VALUE     => $Groups             ,
    MULTIPLE  => 1                   ,
    SIZE      => 3                   ,
    EXTRA     => "style=\"width:100%\" onChange=\"Selected ('POST', '30')\"",
    SELECTED  => ($UB::QUERY{'FORM_POST_GROUP_30'}) ? [$UB::CGI->param('FORM_POST_GROUP_30')] : (($POST_LEVEL_30 eq "*") ? $AllGroups : [split (/\n/, $POST_LEVEL_30)])
  );
  $FORM{'FORM_POST_GROUP_50'}     = &HTML::Select (
    NAME      => "FORM_POST_GROUP_50",
    VALUE     => $Groups             ,
    MULTIPLE  => 1                   ,
    SIZE      => 3                   ,
    EXTRA     => "style=\"width:100%\" onChange=\"Selected ('POST', '50')\"",
    SELECTED  => ($UB::QUERY{'FORM_POST_GROUP_50'}) ? [$UB::CGI->param('FORM_POST_GROUP_50')] : (($POST_LEVEL_50 eq "*") ? $AllGroups : [split (/\n/, $POST_LEVEL_50)])
  );

  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/header.inc");
    my $HEADER = join ("", <DATA>);
  close (DATA);

  &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/footer.inc");
    my $FOOTER = join ("", <DATA>);
  close (DATA);

  $FORM{'FORM_HEADER'}            = $UB::QUERY{'FORM_HEADER'} || $HEADER || "";
  $FORM{'FORM_FOOTER'}            = $UB::QUERY{'FORM_FOOTER'} || $FOOTER || "";

  $FORM{'FORM_ULTRABOARD_CODES'}  = &HTML::Checkbox (
    NAME    => "FORM_ULTRABOARD_CODES",
    VALUE   => "1"                    ,
    EXTRA   => "onClick=\"Checked1()\"",
    CHECKED => $UB::QUERY{'FORM_ULTRABOARD_CODES'} || $Board->{'UB_CODES'} || ""
  );
  $FORM{'FORM_HTML_TAGS'}         = &HTML::Checkbox (
    NAME    => "FORM_HTML_TAGS",
    VALUE   => "1"             ,
    EXTRA   => "onClick=\"Checked2()\"",
    CHECKED => $UB::QUERY{'FORM_HTML_TAGS'} || $Board->{'HTML_TAGS'} || ""
  );
  $FORM{'FORM_FILE_ATTACH'}       = &HTML::Checkbox (
    NAME    => "FORM_FILE_ATTACH",
    VALUE   => "1"               ,
    CHECKED => $UB::QUERY{'FORM_FILE_ATTACH'} || $Board->{'FILE_ATTACH'} || ""
  );
  $FORM{'FORM_APPROVED'}          = &HTML::Checkbox (
    NAME    => "FORM_APPROVED",
    VALUE   => "1"            ,
    CHECKED => $UB::QUERY{'FORM_APPROVED'} || $Board->{'NEED_APROVED'} || ""
  );

  &Standard::PrintHTMLHeader();
  print &HTML::Header;
  print<<HTML;
<script language="JavaScript">
<!--

function myChecked4Everyone (AnonymousObject, CheckboxObject1, CheckboxObject2, SelectObject1, SelectObject2) {
  if (AnonymousObject.checked) {
    CheckboxObject1.checked = true;
    CheckboxObject2.checked = true;

    SelectAll (SelectObject1);
    SelectAll (SelectObject2);
  }
}

function Checked4Everyone (Type) {

  var AnonymousObject   = eval ("document.form.FORM_"+Type+"_LEVEL_00");
  var CheckboxObject1   = eval ("document.form.FORM_"+Type+"_LEVEL_30");
  var CheckboxObject2   = eval ("document.form.FORM_"+Type+"_LEVEL_50");
  var SelectObject1     = eval ("document.form.FORM_"+Type+"_GROUP_30");
  var SelectObject2     = eval ("document.form.FORM_"+Type+"_GROUP_50");

  myChecked4Everyone (AnonymousObject, CheckboxObject1, CheckboxObject2, SelectObject1, SelectObject2);

  if (Type == "READ") {
    var AnonymousObject1  = eval ("document.form.FORM_REPLY_LEVEL_00");
    var CheckboxObject1a  = eval ("document.form.FORM_REPLY_LEVEL_30");
    var CheckboxObject1b  = eval ("document.form.FORM_REPLY_LEVEL_50");
    var SelectObject1a    = eval ("document.form.FORM_REPLY_GROUP_30");
    var SelectObject1b    = eval ("document.form.FORM_REPLY_GROUP_50");

    var AnonymousObject2  = eval ("document.form.FORM_POST_LEVEL_00");
    var CheckboxObject2a  = eval ("document.form.FORM_POST_LEVEL_30");
    var CheckboxObject2b  = eval ("document.form.FORM_POST_LEVEL_50");
    var SelectObject2a    = eval ("document.form.FORM_POST_GROUP_30");
    var SelectObject2b    = eval ("document.form.FORM_POST_GROUP_50");

    AnonymousObject1.checked = false;
    AnonymousObject2.checked = false;
  } else if (Type == "REPLY") {
    var AnonymousObject1  = eval ("document.form.FORM_READ_LEVEL_00");
    var CheckboxObject1a  = eval ("document.form.FORM_READ_LEVEL_30");
    var CheckboxObject1b  = eval ("document.form.FORM_READ_LEVEL_50");
    var SelectObject1a    = eval ("document.form.FORM_READ_GROUP_30");
    var SelectObject1b    = eval ("document.form.FORM_READ_GROUP_50");

    var AnonymousObject2  = eval ("document.form.FORM_POST_LEVEL_00");
    var CheckboxObject2a  = eval ("document.form.FORM_POST_LEVEL_30");
    var CheckboxObject2b  = eval ("document.form.FORM_POST_LEVEL_50");
    var SelectObject2a    = eval ("document.form.FORM_POST_GROUP_30");
    var SelectObject2b    = eval ("document.form.FORM_POST_GROUP_50");

    AnonymousObject1.checked = true;
    AnonymousObject2.checked = false;
  } else if (Type == "POST") {
    var AnonymousObject1  = eval ("document.form.FORM_READ_LEVEL_00");
    var CheckboxObject1a  = eval ("document.form.FORM_READ_LEVEL_30");
    var CheckboxObject1b  = eval ("document.form.FORM_READ_LEVEL_50");
    var SelectObject1a    = eval ("document.form.FORM_READ_GROUP_30");
    var SelectObject1b    = eval ("document.form.FORM_READ_GROUP_50");

    var AnonymousObject2  = eval ("document.form.FORM_REPLY_LEVEL_00");
    var CheckboxObject2a  = eval ("document.form.FORM_REPLY_LEVEL_30");
    var CheckboxObject2b  = eval ("document.form.FORM_REPLY_LEVEL_50");
    var SelectObject2a    = eval ("document.form.FORM_REPLY_GROUP_30");
    var SelectObject2b    = eval ("document.form.FORM_REPLY_GROUP_50");

    AnonymousObject1.checked = true;
    AnonymousObject2.checked = true;
  }

  myChecked4Everyone (AnonymousObject1, CheckboxObject1a, CheckboxObject1b, SelectObject1a, SelectObject1b);
  myChecked4Everyone (AnonymousObject2, CheckboxObject2a, CheckboxObject2b, SelectObject2a, SelectObject2b);
}

function myChecked (AnonymousObject, CheckboxObject, SelectObject) {
  if (CheckboxObject.checked) {
    SelectAll  (SelectObject);
  } else {
    AnonymousObject.checked = false;
    UnselectAll(SelectObject);
  }
}

function Checked (Type, Level) {
  var SelectObject      = eval ("document.form.FORM_"+Type+"_GROUP_"+Level);
  var CheckboxObject    = eval ("document.form.FORM_"+Type+"_LEVEL_"+Level);
  var AnonymousObject   = eval ("document.form.FORM_"+Type+"_LEVEL_00");

  myChecked (AnonymousObject, CheckboxObject, SelectObject);

  if (Type == "READ") {
    var SelectObject1     = eval ("document.form.FORM_REPLY_GROUP_"+Level);
    var CheckboxObject1   = eval ("document.form.FORM_REPLY_LEVEL_"+Level);
    var AnonymousObject1  = eval ("document.form.FORM_REPLY_LEVEL_00");

    var SelectObject2     = eval ("document.form.FORM_POST_GROUP_"+Level);
    var CheckboxObject2   = eval ("document.form.FORM_POST_LEVEL_"+Level);
    var AnonymousObject2  = eval ("document.form.FORM_POST_LEVEL_00");

    CheckboxObject1.checked = false;
    CheckboxObject2.checked = false;
  } else if (Type == "REPLY") {
    var SelectObject1     = eval ("document.form.FORM_READ_GROUP_"+Level);
    var CheckboxObject1   = eval ("document.form.FORM_READ_LEVEL_"+Level);
    var AnonymousObject1  = eval ("document.form.FORM_READ_LEVEL_00");

    var SelectObject2     = eval ("document.form.FORM_POST_GROUP_"+Level);
    var CheckboxObject2   = eval ("document.form.FORM_POST_LEVEL_"+Level);
    var AnonymousObject2  = eval ("document.form.FORM_POST_LEVEL_00");

    CheckboxObject1.checked = true;
    CheckboxObject2.checked = false;
  } else if (Type == "POST") {
    var SelectObject1     = eval ("document.form.FORM_READ_GROUP_"+Level);
    var CheckboxObject1   = eval ("document.form.FORM_READ_LEVEL_"+Level);
    var AnonymousObject1  = eval ("document.form.FORM_READ_LEVEL_00");

    var SelectObject2     = eval ("document.form.FORM_REPLY_GROUP_"+Level);
    var CheckboxObject2   = eval ("document.form.FORM_REPLY_LEVEL_"+Level);
    var AnonymousObject2  = eval ("document.form.FORM_REPLY_LEVEL_00");

    CheckboxObject1.checked = true;
    CheckboxObject2.checked = true;
  }

  myChecked (AnonymousObject1, CheckboxObject1, SelectObject1);
  myChecked (AnonymousObject2, CheckboxObject2, SelectObject2);
}

function mySelected (AnonymousObject, SelectObject, CheckboxObject) {
  var selected1 = false;
  var selected2 = true ;

  if (SelectObject.options[0].selected) {
    SelectAll (SelectObject);
    CheckboxObject.checked = true ;
    return;
  }

  for (var i = 0; i < SelectObject.length; i++) {
    if (SelectObject.options[i].selected) {
      selected1 = true ;
    } else {
      selected2 = false;
    }
  }

  if (selected1) {
    CheckboxObject.checked  = true ;
  } else {
    CheckboxObject.checked  = false;
  }

  if (!selected2) {
    AnonymousObject.checked = false;
  }
}

function Selected (Type, Level) {
  var SelectObject      = eval ("document.form.FORM_"+Type+"_GROUP_"+Level);
  var CheckboxObject    = eval ("document.form.FORM_"+Type+"_LEVEL_"+Level);
  var AnonymousObject   = eval ("document.form.FORM_"+Type+"_LEVEL_00");

  mySelected (AnonymousObject, SelectObject, CheckboxObject);

  if (Type == "READ") {
    var SelectObject1     = eval ("document.form.FORM_REPLY_GROUP_"+Level);
    var CheckboxObject1   = eval ("document.form.FORM_REPLY_LEVEL_"+Level);
    var AnonymousObject1  = eval ("document.form.FORM_REPLY_LEVEL_00");

    var SelectObject2     = eval ("document.form.FORM_POST_GROUP_"+Level);
    var CheckboxObject2   = eval ("document.form.FORM_POST_LEVEL_"+Level);
    var AnonymousObject2  = eval ("document.form.FORM_POST_LEVEL_00");

    for (var i = SelectObject.length-1; i >= 0; i--) {
      if (!SelectObject.options[i].selected) {
        SelectObject1.options[i].selected = false;
        SelectObject2.options[i].selected = false;
      }
    }
  } else if (Type == "REPLY") {
    var SelectObject1     = eval ("document.form.FORM_READ_GROUP_"+Level);
    var CheckboxObject1   = eval ("document.form.FORM_READ_LEVEL_"+Level);
    var AnonymousObject1  = eval ("document.form.FORM_READ_LEVEL_00");

    var SelectObject2     = eval ("document.form.FORM_POST_GROUP_"+Level);
    var CheckboxObject2   = eval ("document.form.FORM_POST_LEVEL_"+Level);
    var AnonymousObject2  = eval ("document.form.FORM_POST_LEVEL_00");

    for (var i = SelectObject.length-1; i >= 0; i--) {
      if (SelectObject.options[i].selected) {
        SelectObject1.options[i].selected = true;
      }
    }

    for (var i = SelectObject.length-1; i >= 0; i--) {
      if (!SelectObject.options[i].selected) {
        SelectObject2.options[i].selected = false;
      }
    }
  } else if (Type == "POST") {
    var SelectObject1     = eval ("document.form.FORM_READ_GROUP_"+Level);
    var CheckboxObject1   = eval ("document.form.FORM_READ_LEVEL_"+Level);
    var AnonymousObject1  = eval ("document.form.FORM_READ_LEVEL_00");

    var SelectObject2     = eval ("document.form.FORM_REPLY_GROUP_"+Level);
    var CheckboxObject2   = eval ("document.form.FORM_REPLY_LEVEL_"+Level);
    var AnonymousObject2  = eval ("document.form.FORM_REPLY_LEVEL_00");

    for (var i = SelectObject.length-1; i >= 0; i--) {
      if (SelectObject.options[i].selected) {
        SelectObject1.options[i].selected = true;
        SelectObject2.options[i].selected = true;
      }
    }
  }

  mySelected (AnonymousObject1, SelectObject1, CheckboxObject1);
  mySelected (AnonymousObject2, SelectObject2, CheckboxObject2);
}

function SelectAll (SelectObject) {
  for (var i = SelectObject.length - 1; i >= 0; i--) {
    SelectObject.options[i].selected = true ;
  }
}

function UnselectAll (SelectObject) {
  for (var i = SelectObject.length - 1; i >= 0; i--) {
    SelectObject.options[i].selected = false;
  }
}

function Checked1 () {
  if (!document.form.FORM_ULTRABOARD_CODES.checked) {
    document.form.FORM_HTML_TAGS.checked = false;
  }
}

function Checked2 () {
  if (document.form.FORM_HTML_TAGS.checked) {
    document.form.FORM_ULTRABOARD_CODES.checked = true;
  }
}

// -->
</script>
<form action="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT" method="post" name="form">
<input type="hidden" name="action" value="DoModifyBoard">
<input type="hidden" name="BID" value="$FORM{'FORM_ID'}">
<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> / Boards Management / Modify board
    </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>
HTML

  if ($ERROR ne "") {
    print<<HTML;
                        There were the following errors during modifying board.<br>
                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
                          <tr>
                            <td><font color="#FF0000">$ERROR</font></td>
                          </tr>
                        </table>
                        Please make any changes and try again!<br>
HTML
  }

print<<HTML;
                        Please fill out all required (<font color="Red"><b>*</b></font>) fields.
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            &nbsp;<br>
            &nbsp;&nbsp;General Information
            <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 width="100" valign="top" nowrap>Title <font color="Red"><b>*</b></font></td>
                      <td width="100%"><input type="text" name="FORM_TITLE" value="$FORM{'FORM_TITLE'}" size="45" style="width:100%"></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="enter the name of board that you want to call. (128 chars. max.)"></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Description</td>
                      <td width="100%"><textarea cols=45 rows=3 name="FORM_DESCRIPTION" style="width:100%" wrap="virtual">$FORM{'FORM_DESCRIPTION'}</textarea></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="write some words about this board that you want to say to your visitors. (512 chars. max.)"></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Category <font color="Red"><b>*</b></font></td>
                      <td width="100%">$FORM{'FORM_CATEGORY'}</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose a category that this board will belong to."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Major Moderator</td>
                      <td width="100%">$FORM{'FORM_MAJOR_MODERATOR'}</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose a major moderator to help you to moderate this board. he will have more power than other minor moderators, and he can log into the control panel with full power of this board."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Minor Moderators</td>
                      <td width="100%">$FORM{'FORM_MINOR_MODERATORS'}</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose some minor moderators to help you and major moderator to moderate this board. they will have less power than major moderator, and they cannot log into the control panel.\n\ntip:\nselecting mult-moderators by pressing [shift] or [ctrl] key."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Status</td>
                      <td width="100%">$FORM{'FORM_STATUS-70'}Activated to everyone<br>
                      $FORM{'FORM_STATUS-50'}Only activated to permited members<br>
                      $FORM{'FORM_STATUS-30'}Deactivated to everyone</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose the status of this board.\n\nactivated to everyone:\nthe board will visable to everyone.\n\nonly activated to permited members:\nthe board will only visable to everyone that you set their reading permission.\n\ndeactivated to everyone:\nthe board will invisable to everyone."></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            &nbsp;<br>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="33%">
                  &nbsp;&nbsp;Permission of Reading
                  <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 colspan="2">$FORM{'FORM_READ_LEVEL_00'}Anonymous members.</td>
                            <td rowspan="5" width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose what level and member groups of members that can read this board.\n\nthe level and member groups of members that you didn\'t choose, then they cannot read, post replies, and post topics in this board.\n\ntip:\nif you choose \'all groups\', then all the member groups that you create in future will also have this permission to read this board."></td>
                          </tr>
                          <tr>
                            <td colspan="2">$FORM{'FORM_READ_LEVEL_30'}Normal members that in</td>
                          </tr>
                          <tr>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="100%">$FORM{'FORM_READ_GROUP_30'}</td>
                          </tr>

                          <tr>
                            <td colspan="2">$FORM{'FORM_READ_LEVEL_50'}Premium members that in</td>
                          </tr>
                          <tr>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="100%">$FORM{'FORM_READ_GROUP_50'}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
                <td>&nbsp;</td>
                <td width="33%">
                  &nbsp;&nbsp;Permission of Posting Replies
                  <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 colspan="2">$FORM{'FORM_REPLY_LEVEL_00'}Anonymous members.</td>
                            <td rowspan="5" width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose what level and member groups of members that can read, and post replies in this board.\n\nthe level and member groups of members that you didn\'t choose, then they cannot post replies, and post topics in this board.\n\ntip:\nif you choose \'all groups\', then all the member groups that you create in future will also have this permission to read, and post replies in this board."></td>
                          </tr>
                          <tr>
                            <td colspan="2">$FORM{'FORM_REPLY_LEVEL_30'}Normal members that in</td>
                          </tr>
                          <tr>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="100%">$FORM{'FORM_REPLY_GROUP_30'}</td>
                          </tr>

                          <tr>
                            <td colspan="2">$FORM{'FORM_REPLY_LEVEL_50'}Premium members that in</td>
                          </tr>
                          <tr>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="100%">$FORM{'FORM_REPLY_GROUP_50'}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
                <td>&nbsp;</td>
                <td width="33%">
                  &nbsp;&nbsp;Permission of Posting Topics
                  <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 colspan="2">$FORM{'FORM_POST_LEVEL_00'}Anonymous members.</td>
                            <td rowspan="5" width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose what level and member groups of members that can read, post replies, and post topics in this board.\n\nthe level and member groups of members that you didn\'t choose, then they cannot post topics in this board.\n\ntip:\nif you choose \'all groups\', then all the member groups that you create in future will also have this permission to read, post replies, and post topics in this board."></td>
                          </tr>
                          <tr>
                            <td colspan="2">$FORM{'FORM_POST_LEVEL_30'}Normal members that in</td>
                          </tr>
                          <tr>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="100%">$FORM{'FORM_POST_GROUP_30'}</td>
                          </tr>

                          <tr>
                            <td colspan="2">$FORM{'FORM_POST_LEVEL_50'}Premium members that in</td>
                          </tr>
                          <tr>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="100%">$FORM{'FORM_POST_GROUP_50'}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            &nbsp;<br>
            &nbsp;&nbsp;Preferences
            <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 width="100" valign="top" nowrap>Header text</td>
                      <td width="100%"><textarea cols=45 rows=3 name="FORM_HEADER" style="width:100%" wrap="virtual">$FORM{'FORM_HEADER'}</textarea></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="write some header text that you want to display at the top of this board page."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Footer text</td>
                      <td width="100%"><textarea cols=45 rows=3 name="FORM_FOOTER" style="width:100%" wrap="virtual">$FORM{'FORM_FOOTER'}</textarea></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="write some footer text that you want to display at the bottom of this board page."></td>
                    </tr>
                    <tr>
                      <td colspan="2">$FORM{'FORM_ULTRABOARD_CODES'}Allow members to use UltraBoard code in messages.</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="if you allow your visitors to use ultraboard codes in their message, then check it."></td>
                    </tr>
                    <tr>
                      <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$FORM{'FORM_HTML_TAGS'}Allow members to use HTML tags in their messages.</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="if you allow your visitors to use html tags between [html] and [/html] in their message, then check it."></td>
                    </tr>
                    <tr>
                      <td colspan="2">$FORM{'FORM_FILE_ATTACH'}Allow files to be attached to messages within this board.</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="if you allow your members attach file during they posting message to this board, then check it."></td>
                    </tr>
                    <tr>
                      <td colspan="2">$FORM{'FORM_APPROVED'}All messages must be approved first.</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="if you want to verify all messages before they post on this board, then check it."></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right"><input type="submit" value="Modify it">&nbsp;&nbsp;<input type="Reset" value="Cancel"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
</html>
HTML
}

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