# -- # Kernel/System/RestrictedService.pm - core module - SeTIC - UFSC - http://setic.ufsc.br/ # Rodrigo Gonçalves - rodrigo.g@ufsc.br # # Version 2015-06-24 - First version # Version 2018-01-19 - Fix for updates # # Manages which services should only be allowed in the logged in interface for OTRS # # -- # This software comes with ABSOLUTELY NO WARRANTY. For details, see # the enclosed file COPYING for license information (AGPL). If you # did not receive this file, see http://www.gnu.org/licenses/agpl.txt. # -- package Kernel::System::RestrictedService; use strict; use warnings; use utf8; our @ObjectDependencies = ( "Kernel::System::DB", "Kernel::System::Log"); sub new { my ( $Type, %Param ) = @_; # allocate new hash for object my $Self = {%Param}; bless( $Self, $Type ); return $Self; } =head Returns a service form @IdsRestrictedServices =cut sub GetRestrictedServices { my ( $Self, %Param ) = @_; my $DBObject = $Kernel::OM->Get("Kernel::System::DB"); # get service form from db $DBObject->Prepare( SQL => 'SELECT service_id from restricted_service order by service_id asc' ); # fetch the result my @ServiceData; while ( my @Row = $DBObject->FetchrowArray() ) { push(@ServiceData,$Row[0]); } return @ServiceData; } =head @IdsList Sets the list of restricted services =cut sub SetRestrictedServices { my ( $Self, @Param ) = @_; my $DBObject = $Kernel::OM->Get("Kernel::System::DB"); my $idsString = join(",", @Param); # delete old services $DBObject->Do(SQL => 'DELETE FROM restricted_service where service_id NOT IN (' . $idsString . ')'); # add new services for my $id (@Param) { $DBObject->Do(SQL => 'REPLACE INTO restricted_service (service_id) VALUES (' . $id . ')'); } return 1; } 1;