adding seealso feature in MARC searches
[koha.git] / C4 / Security.pm
1 package C4::Security;
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 # FIXME - As far as I can tell, this module is only used by the CDK
23 # stuff, which appears to be stillborn. In other words, this module
24 # isn't used.
25
26 use strict;
27 require Exporter;
28 use DBI;
29 use C4::Context;
30 use C4::Format;
31 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
32
33 # set the version for version checking
34 $VERSION = 0.01;
35
36 @ISA = qw(Exporter);
37 @EXPORT = qw(&Login &CheckAccess);
38
39 sub Login {
40   my ($env)=@_;
41   my $dbh = C4::Context->dbh;
42   my @branches;
43   my $query = "select * from branches order by branchname";
44   my $sth=$dbh->prepare($query);
45   $sth->execute;
46   while (my $branchrec=$sth->fetchrow_hashref) {
47     my $branchdet =
48      fmtstr($env,$branchrec->{'branchcode'},"L2")." ".$branchrec->{'branchname'};
49     push @branches,$branchdet;
50   }
51   $sth->finish;
52   my $valid = "f";
53   &startint($env,"Logging In");
54   until ($valid eq "t") {
55     my ($reason,$username,$password,$branch) = logondialog ($env,"Logon to System",\@branches);
56     $username = uc $username;
57     $password = uc $password;
58     my $query = "select * from users where usercode = '$username' and password ='$password'";
59     $sth=$dbh->prepare($query);
60     $sth->execute;
61 #          debug_msg("",$query);
62     if (my $userrec = $sth->fetchrow_hashref) {
63     if ($userrec->{'usercode'} ne ''){
64       if ($branch ne "") {
65         $valid = "t";
66         my @dummy = split ' ', $branch;
67         $branch = $dummy[0];
68         $env->{'usercode'} = $username;
69         $env->{'branchcode'} = $branch;
70       }
71
72     } else {
73       debug_msg("","not found");
74     }
75     }
76     $sth->finish;
77   }
78   &endint();
79 }
80
81 sub CheckAccess {
82   my ($env)=@_;
83   }