RestrictedService.pm
1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# --
# 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;