#!/usr/bin/perl
# ----------------------------------------------------------------------------
# This software is Copyright (C) 2007, All Rights Reserved
# ----------------------------------------------------------------------------
# This program is protected by local and international copyright laws. Any
# use of this program is subject to the the terms of the license agreement
# included as part of this distribution archive. Any other uses are strictly
# prohibited without the written permission of the Vendor and all
# other rights are reserved.
# -----------------------------------------------------------------------------
# Warning : Modifying this program violates your license agreement!
# -----------------------------------------------------------------------------

package IT::App::Menu::UserPreferences;

# load modules
use strict;

use IT::Globals;

# ------------------------------------------------------------------------------
# Function    :
# Description :
# Usage       : &IT::App::Menu::UserPreferences::saveErrorChecking($attr);
# ------------------------------------------------------------------------------

sub saveErrorChecking {
  my $attr     = shift || die "no attr specified!";

  # error checking
  my $error;
  my $isNewPassword = $FORM->{'currentPassword'} || $FORM->{'password'} || $FORM->{'password2'};
  if ($isNewPassword) {
    if ($FORM->{'currentPassword'} ne $CURRENT_USER->{'password'}) { $error = "Current password isn't correct!"; }
    elsif ($FORM->{'password'} eq '')                          { $error = "You must specify a new password!"; }
    elsif ($FORM->{'password'} ne $FORM->{'password2'})        { $error = "New passwords don't match!"; }
  }
  if ($error) {
    &IT::App::Menu::edit($attr->{'menuName'}, $error)
  }

  # use original password if none specified
  if ($FORM->{'password'} eq '') { $FORM->{'password'} = $CURRENT_USER->{'password'}; }

}

# ----------------------------------------------------------------------------
# end of file
1;

