#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package AppUser::User::AccessLevelList;

use strict;
use warnings;

use lib '/app/tools/appuser/lib';
use AppUser::DB::Item::AccessLevel;
use AppUser::User::AccessLevel;

use lib '/app/tools/rps/lib';
use Common::FormObject;
use base 'Common::FormObject';

# This is a read-only XMLObject, so we don't need any
# of the accessor methods, just create the list of
# items and be on your way.
#

sub _init {
    my ( $self, %args ) = @_;

    $self->SUPER::_init(%args);

    my $accessLevel = $args{accessLevel};

    my $client = Common::Client::Current();

    $self->{AccessLevel} = [];
    my $coll = AppUser::DB::Item::AccessLevel->GetAllForClientType( $client->TypeMask() );

    while ( $coll->hasNext() ) {
        my $obj = $coll->next();

        ##
        ##  We don't need to skip these anmymore since we have the CanEditList.
        ##  That allows the template to skip them when necessary.

        # Skip the RS access levels if the user is not a RSAdmin
        #
        #my $objLevel = $obj->access_level_id;
        #if ( (AppUser::DB::Item::AccessLevel::kRSAdmin == $objLevel || AppUser::DB::Item::AccessLevel::kRSAccountRep == $objLevel)
        # &&  (AppUser::DB::Item::AccessLevel::kRSAdmin != $accessLevel))
        #{
        #    next;
        #}
        push @{ $self->{AccessLevel} }, AppUser::User::AccessLevel->new( _dbItem => $obj );
    }

    return $self;
}

1;
