Most of these merges are just removing unused parts of the perl modules.
[koha.git] / C4 / Security.pm
1 package C4::Security; #assumes C4/Security
2
3 use strict;
4 require Exporter;
5 use DBI;
6 use C4::Database;
7 use C4::Format;
8 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
9
10 # set the version for version checking
11 $VERSION = 0.01;
12
13 @ISA = qw(Exporter);
14 @EXPORT = qw(&Login &CheckAccess);
15
16 sub Login {
17   my ($env)=@_;
18   my $dbh=C4Connect;
19   my @branches;
20   my $query = "select * from branches order by branchname";
21   my $sth=$dbh->prepare($query);
22   $sth->execute;
23   while (my $branchrec=$sth->fetchrow_hashref) {
24     my $branchdet = 
25      fmtstr($env,$branchrec->{'branchcode'},"L2")." ".$branchrec->{'branchname'};
26     push @branches,$branchdet;
27   }
28   $sth->finish;
29   my $valid = "f";
30   &startint($env,"Logging In");
31   until ($valid eq "t") {
32     my ($reason,$username,$password,$branch) = logondialog ($env,"Logon to System",\@branches);
33     $username = uc $username;
34     $password = uc $password;
35     my $query = "select * from users where usercode = '$username' and password ='$password'";
36     $sth=$dbh->prepare($query);
37     $sth->execute;
38 #          debug_msg("",$query);
39     if (my $userrec = $sth->fetchrow_hashref) {
40     if ($userrec->{'usercode'} ne ''){
41       if ($branch ne "") {
42         $valid = "t";
43         my @dummy = split ' ', $branch;
44         $branch = $dummy[0];
45         $env->{'usercode'} = $username;
46         $env->{'branchcode'} = $branch;
47       }
48      
49     } else {
50       debug_msg("","not found");
51     }
52     }
53     $sth->finish;
54   }
55   $dbh->disconnect;
56   &endint();
57 }
58   
59 sub CheckAccess {
60   my ($env)=@_;
61   }
62     
63 END { }       # module clean-up code here (global destructor)
64