Paketiinformationen und UPDAGRE aktualisiert.
[kivitendo-erp.git] / SL / InstallationCheck.pm
1 package SL::InstallationCheck;
2
3 use English '-no_match_vars';
4 use IO::File;
5
6 use vars qw(@required_modules @optional_modules);
7
8 use strict;
9
10 @required_modules = (
11   { name => "Archive::Zip",    url => "http://search.cpan.org/~adamk/" },
12   { name => "Class::Accessor", url => "http://search.cpan.org/~kasei/" },
13   { name => "CGI::Ajax",       url => "http://search.cpan.org/~bct/" },
14   { name => "DBI",             url => "http://search.cpan.org/~timb/" },
15   { name => "DBD::Pg",         url => "http://search.cpan.org/~dbdpg/" },
16   { name => "Email::Address",  url => "http://search.cpan.org/~rjbs/" },
17   { name => "IO::Wrap",        url => "http://search.cpan.org/~dskoll/" },
18   { name => "List::MoreUtils", url => "http://search.cpan.org/~vparseval/" },
19   { name => "PDF::API2",       url => "http://search.cpan.org/~areibens/" },
20   { name => "Template",        url => "http://search.cpan.org/~abw/" },
21   { name => "Text::CSV_XS",    url => "http://search.cpan.org/~hmbrand/" },
22   { name => "Text::Iconv",     url => "http://search.cpan.org/~mpiotr/" },
23   { name => "URI",             url => "http://search.cpan.org/~gaas/" },
24   { name => "XML::Writer",     url => "http://search.cpan.org/~josephw/" },
25   { name => "YAML",            url => "http://search.cpan.org/~ingy/" },
26 );
27
28 @optional_modules = ();
29
30 sub module_available {
31   my ($module) = @_;
32
33   if (!defined(eval("require $module;"))) {
34     return 0;
35   } else {
36     return 1;
37   }
38 }
39
40 my %conditional_dependencies;
41
42 sub check_for_conditional_dependencies {
43   if (!$conditional_dependencies{net_ldap}) {
44     $conditional_dependencies{net_ldap} = 1;
45
46     my $in = IO::File->new('config/authentication.pl', 'r');
47     if ($in) {
48       my $self = {};
49       my $code;
50
51       while (my $line = <$in>) {
52         $code .= $line;
53       }
54       $in->close();
55
56       eval $code;
57
58       if (! $EVAL_ERROR) {
59
60         if ($self->{module} && ($self->{module} eq 'LDAP')) {
61           push @required_modules, { 'name' => 'Net::LDAP', 'url' => 'http://search.cpan.org/~gbarr/' };
62         }
63       }
64     }
65   }
66 }
67
68 sub test_all_modules {
69   return grep { !module_available($_->{name}) } @required_modules;
70 }
71
72 1;