Unable to get UserID

Moderator: crythias

Post Reply
jff
Znuny newbie
Posts: 52
Joined: 23 Mar 2016, 14:17
Znuny Version: 6.0.8
Real Name: Jeff
Company: M

Unable to get UserID

Post by jff »

Hello,

I'm having a really hard time getting the UserID for a module I'm working, I've never programmed on OTRS before so I feel I'm missing something very basic here.

This is the code I'm working:

Code: Select all

    
GROUP: for my $Group (@Groups) {
		next GROUP if !$Kernel::OM->Get('Kernel::System::Group')->PermissionCheck(
                UserID    => $Self->{UserID},
                GroupName => $Group,
                Type      => 'rw',
            );
        $Access = 1;
        last GROUP;
}
I'm using $Self->{UserID} because when I check every other module this is the way it's done, however, when I run this I get the error "Need UsedID!".

This is my object dependencies:

Code: Select all

our @ObjectDependencies = (
    'Kernel::Config',
    'Kernel::Language',
    'Kernel::Output::HTML::Layout',
    'Kernel::System::Log',
    'Kernel::System::Web::Request',
	'Kernel::System::User'
);
And my sub new()

Code: Select all

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {};
    bless( $Self, $Type );

    $Self->{ConfigObject}   = $Kernel::OM->Get('Kernel::Config');
    $Self->{LanguageObject} = $Kernel::OM->Get('Kernel::Language');
    $Self->{LayoutObject}   = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
    $Self->{LogObject}      = $Kernel::OM->Get('Kernel::System::Log');
    $Self->{ParamObject}    = $Kernel::OM->Get('Kernel::System::Web::Request');
	$Self->{UserObject}     = $Kernel::OM->Get('Kernel::System::User');

    return $Self;
}
Any guidance here is very much appreciated.
Thank you.
jff
Znuny newbie
Posts: 52
Joined: 23 Mar 2016, 14:17
Znuny Version: 6.0.8
Real Name: Jeff
Company: M

Re: Unable to get UserID

Post by jff »

Hi,

I just got this working by adding the following line to sub new {}:

Code: Select all

$Self->{UserID} = $Param{UserID};
Post Reply