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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
# --
# Copyright (C) 2001-2017 OTRS AG, http://otrs.com/
# --
# 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.
# --
use strict;
use warnings;
use vars (qw($Self));
use Kernel::System::ObjectManager;
local $Kernel::OM = Kernel::System::ObjectManager->new(
'Kernel::System::PostMaster' => {
Email => [],
},
);
$Self->True( $Kernel::OM, 'Could build object manager' );
# get config object
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
my $SkipCryptSMIME;
if ( !$ConfigObject->Get('SMIME') ) {
$SkipCryptSMIME = 1;
}
my $SkipCryptPGP;
if ( !$ConfigObject->Get('PGP') ) {
$SkipCryptPGP = 1;
}
my $SkipChat;
if ( !$ConfigObject->Get('ChatEngine::Active') ) {
$SkipChat = 1;
}
my $SkipCalendar;
if ( !$Kernel::OM->Get('Kernel::System::Main')->Require( 'Kernel::System::Calendar', Silent => 1 ) ) {
$SkipCalendar = 1;
}
my $SkipTeam;
if ( !$Kernel::OM->Get('Kernel::System::Main')->Require( 'Kernel::System::Calendar::Team', Silent => 1 ) ) {
$SkipTeam = 1;
}
my $Home = $ConfigObject->Get('Home');
# get main object
my $MainObject = $Kernel::OM->Get('Kernel::System::Main');
my %OperationChecked;
my @DirectoriesToSearch = (
'/bin',
'/Custom/Kernel/Output',
'/Custom/Kernel/System',
'/Kernel/GenericInterface',
'/Kernel/Output',
'/Kernel/System',
'/var/packagesetup'
);
for my $Directory ( sort @DirectoriesToSearch ) {
my @FilesInDirectory = $MainObject->DirectoryRead(
Directory => $Home . $Directory,
Filter => [ '*.pm', '*.pl' ],
Recursive => 1,
);
LOCATION:
for my $Location (@FilesInDirectory) {
my $ContentSCALARRef = $MainObject->FileRead(
Location => $Location,
);
my $Module = $Location;
$Module =~ s{$Home\/+}{}msx;
# check if file contains a call to another module using Object manager
# for example: $Kernel::OM->Get('Kernel::Config')->Get('Home');
# the regular expression will match until $Kernel::OM->Get('Kernel::Config')->Get(
# including possible line returns
# for this example:
# $1 will contain Kernel::Config
# $2 will contain Get
OPERATION:
while (
${$ContentSCALARRef}
=~ m{ \$Kernel::OM \s* -> \s* Get\( \s* '([^']+)'\) \s* -> \s* ([a-zA-Z1-9]+)\( }msxg
)
{
# skip if the function for the object was already checked before
next OPERATION if $OperationChecked{"$1->$2()"};
# skip crypt object if it is not configured
next OPERATION if $1 eq 'Kernel::System::Crypt::SMIME' && $SkipCryptSMIME;
next OPERATION if $1 eq 'Kernel::System::Crypt::PGP' && $SkipCryptPGP;
next OPERATION if $1 eq 'Kernel::System::Chat' && $SkipChat;
next OPERATION if $1 eq 'Kernel::System::ChatChannel' && $SkipChat;
next OPERATION if $1 eq 'Kernel::System::VideoChat' && $SkipChat;
next OPERATION if $1 eq 'Kernel::System::Calendar' && $SkipCalendar;
next OPERATION if $1 eq 'Kernel::System::Calendar::Appointment' && $SkipCalendar;
next OPERATION if $1 eq 'Kernel::System::Calendar::Team' && $SkipTeam;
# load object
my $Object = $Kernel::OM->Get("$1");
my $Success = $Object->can($2);
$Self->True(
$Success,
"$Module | $1->$2()",
);
# remember the already checked operation
$OperationChecked{"$1->$2()"} = 1;
}
}
}
# cleanup cache
$Kernel::OM->Get('Kernel::System::Cache')->CleanUp();
1;
|