[Koha-cvs] CVS: koha/C4 Auth.pm,1.9.2.1,1.9.2.2 Database.pm,1.2.2.3,1.2.2.4 Koha.pm,1.4.2.2,1.4.2.3 Output.pm,1.6.2.13,1.6.2.14

Steve Tonnesen tonnesen at users.sourceforge.net
Thu Jul 11 21:43:12 CEST 2002


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv27664

Modified Files:
      Tag: rel-1-2
	Auth.pm Database.pm Koha.pm Output.pm 
Log Message:
Created a subroutine for loading /etc/koha.conf settings.  Auth.pm will now
accept the user and pass values from /etc/koha.conf as valid authentication.


Index: Auth.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Auth.pm,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -C2 -r1.9.2.1 -r1.9.2.2
*** Auth.pm	11 Jul 2002 18:05:29 -0000	1.9.2.1
--- Auth.pm	11 Jul 2002 19:43:10 -0000	1.9.2.2
***************
*** 7,10 ****
--- 7,11 ----
  require Exporter;
  use C4::Database;
+ use C4::Koha;
  
  use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
***************
*** 163,167 ****
--- 164,170 ----
  # as well as local authentication through the borrowers tables passwd field
  #
+ 
      my ($dbh, $userid, $password) = @_;
+     warn "Checking $userid $password";
      my $sth=$dbh->prepare("select password from borrowers where userid=?");
      $sth->execute($userid);
***************
*** 179,182 ****
--- 182,191 ----
  	    return 1;
  	}
+     }
+     my $configfile=configfile();
+     warn "$userid $configfile->{'user'} $password $configfile->{'pass'}";
+     if ($userid eq $configfile->{'user'} && $password eq $configfile->{'pass'}) {
+         # Koha superuser account
+ 	return 1;
      }
      return 0;

Index: Database.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Database.pm,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -C2 -r1.2.2.3 -r1.2.2.4
*** Database.pm	14 Jun 2002 06:13:59 -0000	1.2.2.3
--- Database.pm	11 Jul 2002 19:43:10 -0000	1.2.2.4
***************
*** 6,9 ****
--- 6,10 ----
  require Exporter;
  use DBI;
+ use C4::Koha;
  use vars qw($VERSION @ISA @EXPORT);
    
***************
*** 18,41 ****
  sub C4Connect  {
    my $dbname="c4"; 
!    my ($database,$hostname,$user,$pass,%configfile);
!    open (KC, "/etc/koha.conf");
!    while (<KC>) {
!      chomp;
!      (next) if (/^\s*#/);
!      if (/(.*)\s*=\s*(.*)/) {
!        my $variable=$1;
!        my $value=$2;
!        # Clean up white space at beginning and end
!        $variable=~s/^\s*//g;
!        $variable=~s/\s*$//g;
!        $value=~s/^\s*//g;
!        $value=~s/\s*$//g;
!        $configfile{$variable}=$value;
!      }
!    }
!    $database=$configfile{'database'};
!    $hostname=$configfile{'hostname'};
!    $user=$configfile{'user'};
!    $pass=$configfile{'pass'};
      
     my $dbh=DBI->connect("DBI:mysql:$database:$hostname",$user,$pass);
--- 19,28 ----
  sub C4Connect  {
    my $dbname="c4"; 
!    my ($database,$hostname,$user,$pass);
!    my $configfile=configfile();
!    $database=$configfile->{'database'};
!    $hostname=$configfile->{'hostname'};
!    $user=$configfile->{'user'};
!    $pass=$configfile->{'pass'};
      
     my $dbh=DBI->connect("DBI:mysql:$database:$hostname",$user,$pass);

Index: Koha.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Koha.pm,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -C2 -r1.4.2.2 -r1.4.2.3
*** Koha.pm	23 May 2002 10:05:11 -0000	1.4.2.2
--- Koha.pm	11 Jul 2002 19:43:10 -0000	1.4.2.3
***************
*** 14,17 ****
--- 14,18 ----
  	     &borrowercategories
  	     &ethnicitycategories
+ 	     &configfile
  	     $DEBUG); 
  
***************
*** 20,23 ****
--- 21,44 ----
  my $DEBUG = 0;
  
+ sub configfile {
+     my $configfile;
+     open (KC, "/etc/koha.conf");
+     while (<KC>) {
+ 	chomp;
+ 	(next) if (/^\s*#/);
+ 	if (/(.*)\s*=\s*(.*)/) {
+ 	    my $variable=$1;
+ 	    my $value=$2;
+ 	    # Clean up white space at beginning and end
+ 	    $variable=~s/^\s*//g;
+ 	    $variable=~s/\s*$//g;
+ 	    $value=~s/^\s*//g;
+ 	    $value=~s/\s*$//g;
+ 	    $configfile->{$variable}=$value;
+ 	}
+     }
+     return $configfile;
+ }
+ 
  sub slashifyDate {
      # accepts a date of the form xx-xx-xx[xx] and returns it in the 
***************
*** 30,34 ****
  
      my $ethnicity = shift;
!     my $dbh=C4Connect;
      my $sth=$dbh->prepare("Select name from ethnicity where code = ?");
      $sth->execute($ethnicity);
--- 51,55 ----
  
      my $ethnicity = shift;
!     my $dbh=C4Connect();
      my $sth=$dbh->prepare("Select name from ethnicity where code = ?");
      $sth->execute($ethnicity);
***************
*** 40,44 ****
  
  sub borrowercategories {
!     my $dbh=C4Connect;
      my $sth=$dbh->prepare("Select categorycode,description from categories order by description");
      $sth->execute;
--- 61,65 ----
  
  sub borrowercategories {
!     my $dbh=C4Connect();
      my $sth=$dbh->prepare("Select categorycode,description from categories order by description");
      $sth->execute;
***************
*** 55,59 ****
  
  sub ethnicitycategories {
!     my $dbh=C4Connect;
      my $sth=$dbh->prepare("Select code,name from ethnicity order by name");
      $sth->execute;
--- 76,80 ----
  
  sub ethnicitycategories {
!     my $dbh=C4Connect();
      my $sth=$dbh->prepare("Select code,name from ethnicity order by name");
      $sth->execute;

Index: Output.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Output.pm,v
retrieving revision 1.6.2.13
retrieving revision 1.6.2.14
diff -C2 -r1.6.2.13 -r1.6.2.14
*** Output.pm	11 Jul 2002 18:05:29 -0000	1.6.2.13
--- Output.pm	11 Jul 2002 19:43:10 -0000	1.6.2.14
***************
*** 54,76 ****
  # Change this value to reflect where you will store your includes
  #
! my %configfile;
! open (KC, "/etc/koha.conf");
! while (<KC>) {
!     chomp;
!     (next) if (/^\s*#/);
!     if (/(.*)\s*=\s*(.*)/) {
!         my $variable=$1;
!         my $value=$2;
  
!         $variable =~ s/^\s*//g;
!         $variable =~ s/\s*$//g;
!         $value    =~ s/^\s*//g;
!         $value    =~ s/\s*$//g;
!         $configfile{$variable}=$value;
!     } # if
! } # while
! close(KC);
! 
! my $path=$configfile{'includes'};
  ($path) || ($path="/usr/local/www/hdl/htdocs/includes");
  
--- 54,60 ----
  # Change this value to reflect where you will store your includes
  #
! my $configfile=configfile();
  
! my $path=$configfile->{'includes'};
  ($path) || ($path="/usr/local/www/hdl/htdocs/includes");
  





More information about the Koha-cvs mailing list