#!/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::Accounts;

# load modules
use strict;

use IT::Globals;

# ------------------------------------------------------------------------------
# Function    :
# Description :
# Usage       : &IT::App::Menu::Accounts::eraseErrorChecking($attr);
# ------------------------------------------------------------------------------

sub eraseErrorChecking {
  my $attr     = shift || die "no attr specified!";
  my $isErasingSelf = $attr->{'selectedRecordNumbers'}{ $CURRENT_USER->{'num'} };

  if ($isErasingSelf) {
    &IT::App::Menu::list($attr->{'menuName'}, "You cannot erase your account while logged in as yourself!");
  }
}
# ------------------------------------------------------------------------------
# Function    :
# Description :
# Usage       : &IT::App::Menu::Accounts::saveErrorChecking($menuName);
# ------------------------------------------------------------------------------

sub saveErrorChecking {
  my $attr     = shift || die "no attr specified!";
  my $isEditingSelf    = $FORM->{'num'} == $CURRENT_USER->{'num'};
  my $isChangingAccess = $FORM->{'accessLevel'} != $CURRENT_USER->{'accessLevel'};
  if ($isEditingSelf && $isChangingAccess) {
    &IT::App::Menu::edit($attr->{'menuName'}, "You cannot change your access level while logged in as yourself!");
  }
}

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

