###############################################################################
# CP_ModifyAccount.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;

sub ModifyAccount {
  my ($ERROR) = @_;

  (
    my ($DB) = &DB::Query (
      TABLE   => "Groups",
      COLUMNS => ["ID", "TITLE"]
    )
  ) || &HTML::Error("Members Accounts Management / Modify member account", "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 member group</a> first!");

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

  my $Level = [
    {
      KEY   => "30",
      VALUE => $GENERAL::MEMBER_LEVEL_30." (Level 30)",
    }, {
      KEY   => "50",
      VALUE => $GENERAL::MEMBER_LEVEL_50." (Level 50)",
    }, {
      KEY   => "70",
      VALUE => $GENERAL::MEMBER_LEVEL_70." (Level 70)",
    }
  ];

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

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

  my %FORM;
  $FORM{'FORM_USERNAME'}  = $Account->{'USERNAME'};
  $FORM{'FORM_NICKNAME'}  = $UB::QUERY{'FORM_NICKNAME'} || $Account->{'NICKNAME'} || "";
  $FORM{'FORM_PASSWORD'}  = $UB::QUERY{'FORM_PASSWORD'} || "";
  $FORM{'FORM_EMAIL'}     = $UB::QUERY{'FORM_EMAIL'}    || $Account->{'EMAIL'} || "";

  $FORM{'FORM_HIDE_EMAIL'}= &HTML::Checkbox (
    NAME    => "FORM_HIDE_EMAIL",
    VALUE   => "1"              ,
    CHECKED => $UB::QUERY{'FORM_HIDE_EMAIL'} || $Account->{'HIDE_EMAIL'} || ""
  );

  $FORM{'FORM_LEVEL'}     = &HTML::Select (
    NAME      => "FORM_LEVEL",
    VALUE     => $Level      ,
    SELECTED  => ($UB::QUERY{'FORM_LEVEL'}) ? [$UB::QUERY{'FORM_LEVEL'}] : [$Account->{'LEVEL'}],
    EXTRA     => "style=\"width:100%\""
  );
  $FORM{'FORM_GROUP'}     = &HTML::Select (
    NAME      => "FORM_GROUP",
    VALUE     => $Groups     ,
    SELECTED  => ($UB::QUERY{'FORM_GROUP'}) ? [$UB::QUERY{'FORM_GROUP'}] : [$Account->{'GROUP'}],
    EXTRA     => "style=\"width:100%\""
  );

  $FORM{'FORM_STATUS-50'} = &HTML::Radio (
    NAME    => "FORM_STATUS",
    VALUE   => "50"         ,
    CHECKED => $UB::QUERY{'FORM_STATUS'} || $Account->{'STATUS'} || "50"
  );
  $FORM{'FORM_STATUS-30'} = &HTML::Radio (
    NAME    => "FORM_STATUS",
    VALUE   => "30"         ,
    CHECKED => $UB::QUERY{'FORM_STATUS'} || $Account->{'STATUS'} || "50"
  );
  $FORM{'FORM_IP_HOST'} = ($Account->{'IP'} || "n/a")." / ".($Account->{'HOST'} || "n/a");

  $FORM{'FORM_HOMEPAGE'}  = $UB::QUERY{'FORM_HOMEPAGE'}  || $Profile->{'HOMEPAGE'}   || "";
  $FORM{'FORM_LOCATION'}  = $UB::QUERY{'FORM_LOCATION'}  || $Profile->{'LOCATION'}   || "";
  $FORM{'FORM_OCCPATION'} = $UB::QUERY{'FORM_OCCPATION'} || $Profile->{'OCCPATION'}  || "";
  $FORM{'FORM_INTEREST'}  = $UB::QUERY{'FORM_INTEREST'}  || $Profile->{'INTEREST'}   || "";
  $FORM{'FORM_ICQ'}       = $UB::QUERY{'FORM_ICQ'}       || $Profile->{'ICQ'}        || "";
  $FORM{'FORM_AGE'}       = $UB::QUERY{'FORM_AGE'}       || $Profile->{'AGE'}        || "";
  $FORM{'FORM_COMMENTS'}  = $UB::QUERY{'FORM_COMMENTS'}  || $Profile->{'COMMENTS'}   || "";
  $FORM{'FORM_SIGNATURE'} = $UB::QUERY{'FORM_SIGNATURE'} || $Profile->{'SIGNATURE'}  || "";

  if ($Profile->{'PHOTO'}) {
    $FORM{'PHOTO'} = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"$SYSTEM::UPLOAD_URL/$Profile->{'PHOTO'}\" target=\"PHOTO\">$Profile->{'PHOTO'}</a><br>";
  }

  $FORM{'FORM_PHOTO_ACTION-1'} = &HTML::Radio (
    NAME    => "FORM_PHOTO_ACTION",
    VALUE   => "KEEP"             ,
    CHECKED => $UB::QUERY{'FORM_PHOTO_ACTION'} || ($Profile->{'PHOTO'} ? "KEEP" : "") || "UPLOAD",
    EXTRA     => ($Profile->{'PHOTO'} ? "" : "disabled")
  );
  $FORM{'FORM_PHOTO_ACTION-2'} = &HTML::Radio (
    NAME    => "FORM_PHOTO_ACTION",
    VALUE   => "REMOVE"           ,
    CHECKED => $UB::QUERY{'FORM_PHOTO_ACTION'} || ($Profile->{'PHOTO'} ? "KEEP" : "") || "UPLOAD",
    EXTRA     => ($Profile->{'PHOTO'} ? "" : "disabled")
  );
  $FORM{'FORM_PHOTO_ACTION-3'} = &HTML::Radio (
    NAME    => "FORM_PHOTO_ACTION",
    VALUE   => "UPLOAD"           ,
    CHECKED => $UB::QUERY{'FORM_PHOTO_ACTION'} || ($Profile->{'PHOTO'} ? "KEEP" : "") || "UPLOAD"
  );

  &Standard::PrintHTMLHeader();
  print &HTML::Header;
  print<<HTML;
<form action="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="DoModifyAccount">
<input type="hidden" name="UID" value="$FORM{'FORM_USERNAME'}">
<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> / Members Accounts Management / Modify member account
    </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 member account.<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>Nickname <font color="Red"><b>*</b></font></td>
                      <td width="100%"><input type="text" name="FORM_NICKNAME" value="$FORM{'FORM_NICKNAME'}" size="45" maxlength="32" 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 a nickname for your member. (32 chars. max.)"></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>New Password</td>
                      <td width="100%"><input type="text" name="FORM_PASSWORD" value="$FORM{'FORM_PASSWORD'}" size="45" maxlength="16" 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 a new password for your member. (16 chars. max.) (leave it blank if you don't want to be change)"></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Level <font color="Red"><b>*</b></font></td>
                      <td width="100%">$FORM{'FORM_LEVEL'}</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose a level for your member.\n\npremium members may become moderators.\n\nteam members have full access as administrator except configure system permsision."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Member Group <font color="Red"><b>*</b></font></td>
                      <td width="100%">$FORM{'FORM_GROUP'}</td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="choose a member group for your member. it may help you organize your members easily."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Email <font color="Red"><b>*</b></font></td>
                      <td width="100%"><input type="text" name="FORM_EMAIL" value="$FORM{'FORM_EMAIL'}" size="45" maxlength="64" 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 email address of your member."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>&nbsp;</td>
                      <td width="100%">$FORM{'FORM_HIDE_EMAIL'}Hide your email address?</td>
                      <td width="20" valign="top" nowrap>&nbsp;</td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Status</td>
                      <td width="100%">$FORM{'FORM_STATUS-50'}Activated $FORM{'FORM_STATUS-30'}Deactivated</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 yoru member."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>IP/Host</td>
                      <td width="100%" colspan="2">$FORM{'FORM_IP_HOST'}</td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            &nbsp;<br>
            &nbsp;&nbsp;Personal 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>Homepage</td>
                      <td width="100%"><input type="text" name="FORM_HOMEPAGE" value="$FORM{'FORM_HOMEPAGE'}" size="45" maxlength="256" style="width:100%"></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="homepage address."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Location</td>
                      <td width="100%"><input type="text" name="FORM_LOCATION" value="$FORM{'FORM_LOCATION'}" size="45" maxlength="256" style="width:100%"></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="home address. city, state, and country..."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Occupation</td>
                      <td width="100%"><input type="text" name="FORM_OCCPATION" value="$FORM{'FORM_OCCPATION'}" size="45" maxlength="256" style="width:100%"></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="occupation."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Interests</td>
                      <td width="100%"><input type="text" name="FORM_INTEREST" value="$FORM{'FORM_INTEREST'}" size="45" maxlength="256" style="width:100%"></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="interested with?"></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>ICQ Number</td>
                      <td width="100%"><input type="text" name="FORM_ICQ" value="$FORM{'FORM_ICQ'}" size="45" maxlength="16" style="width:100%"></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="icq number."></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Age</td>
                      <td width="100%"><input type="text" name="FORM_AGE" value="$FORM{'FORM_AGE'}" size="45" maxlength="2" style="width:100%"></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="age"></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Comments</td>
                      <td width="100%" valign="top"><textarea cols=45 rows=5 name="FORM_COMMENTS" wrap="virtual" style="width=100%">$FORM{'FORM_COMMENTS'}</textarea></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="comments?"></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Signature</td>
                      <td width="100%" valign="top"><textarea cols=45 rows=5 name="FORM_SIGNATURE" wrap="virtual" style="width=100%">$FORM{'FORM_SIGNATURE'}</textarea></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="signature"></td>
                    </tr>
                    <tr>
                      <td width="100" valign="top" nowrap>Photo</td>
                      <td width="100%">$FORM{'FORM_PHOTO_ACTION-1'}Keep this photo.<br>$FORM{'PHOTO'}
                      $FORM{'FORM_PHOTO_ACTION-2'}Remove this photo.<br>$FORM{'PHOTO'}
                      $FORM{'FORM_PHOTO_ACTION-3'}Upload a new photo.<br>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="FORM_PHOTO" size="30" type="file" accept="image/gif,image/jpeg,image/x-png" class="TextField"></td>
                      <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="keep it?, remove it?, or upload a new one?"></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_ModifyAccount.src file
###############################################################################