Kleinen Grammatikfehler behoben.
[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 @required_modules = (
9   { "name" => "Class::Accessor", "url" => "http://search.cpan.org/~kasei/" },
10   { "name" => "CGI", "url" => "http://search.cpan.org/~lds/" },
11   { "name" => "CGI::Ajax", "url" => "http://search.cpan.org/~bct/" },
12   { "name" => "DBI", "url" => "http://search.cpan.org/~timb/" },
13   { "name" => "DBD::Pg", "url" => "http://search.cpan.org/~dbdpg/" },
14   { "name" => "Archive::Zip", "url" => "http://search.cpan.org/~adamk/" },
15   { "name" => "Text::Iconv", "url" => "http://search.cpan.org/~mpiotr/" },
16   { "name" => "Time::HiRes", "url" => "http://search.cpan.org/~jhi/" },
17   { "name" => "YAML", "url" => "http://search.cpan.org/~ingy/" },
18   { "name" => "IO::Wrap", "url" => "http://search.cpan.org/~dskoll/" },
19   { "name" => "Text::CSV_XS", "url" => "http://search.cpan.org/~hmbrand/" },
20   { "name" => "List::Util", "url" => "http://search.cpan.org/~gbarr/" },
21   { "name" => "Template", "url" => "http://search.cpan.org/~abw/" },
22   { "name" => "Digest::MD5", "url" => "http://search.cpan.org/~gaas/" },
23   { "name" => "PDF::API2", "url" => "http://search.cpan.org/~areibens/" },
24   );
25
26 @optional_modules = (
27   );
28
29 sub module_available {
30   my ($module) = @_;
31
32   if (!defined(eval("require $module;"))) {
33     return 0;
34   } else {
35     return 1;
36   }
37 }
38
39 my %conditional_dependencies;
40
41 sub check_for_conditional_dependencies {
42   if (!$conditional_dependencies{net_ldap}) {
43     $conditional_dependencies{net_ldap} = 1;
44
45     my $in = IO::File->new('config/authentication.pl', 'r');
46     if ($in) {
47       my $self = {};
48       my $code;
49
50       while (my $line = <$in>) {
51         $code .= $line;
52       }
53       $in->close();
54
55       eval $code;
56
57       if (! $EVAL_ERROR) {
58
59         if ($self->{module} && ($self->{module} eq 'LDAP')) {
60           push @required_modules, { 'name' => 'Net::LDAP', 'url' => 'http://search.cpan.org/~gbarr/' };
61         }
62       }
63     }
64   }
65 }
66
67 sub test_all_modules {
68   return grep { !module_available($_->{name}) } @required_modules;
69 }
70
71 1;