koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Biblio.pm,1.38,1.39 Koha.pm,1.11,1.12 SearchMarc


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/C4 Biblio.pm,1.38,1.39 Koha.pm,1.11,1.12 SearchMarc.pm,1.1,1.2 Search.pm,1.59,1.60
Date: Fri, 07 Mar 2003 08:35:52 -0800

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1:/tmp/cvs-serv13613/C4

Modified Files:
        Biblio.pm Koha.pm SearchMarc.pm Search.pm 
Log Message:
* moving generic functions to Koha.pm
* improvement of SearchMarc.pm
* bugfixes
* code cleaning

Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -r1.38 -r1.39
*** Biblio.pm   27 Feb 2003 16:51:59 -0000      1.38
--- Biblio.pm   7 Mar 2003 16:35:42 -0000       1.39
***************
*** 2,5 ****
--- 2,11 ----
  # $Id$
  # $Log$
+ # Revision 1.39  2003/03/07 16:35:42  tipaul
+ # * moving generic functions to Koha.pm
+ # * improvement of SearchMarc.pm
+ # * bugfixes
+ # * code cleaning
+ #
  # Revision 1.38  2003/02/27 16:51:59  tipaul
  # * moving prepare / execute to ? form.
***************
*** 1280,1293 ****
  
  sub OLDmodsubtitle {
!   my ($dbh,$bibnum, $subtitle) = @_;
! #  my $dbh   = C4Connect;
!   my $query = "update bibliosubtitle set
! subtitle = '$subtitle'
! where biblionumber = $bibnum";
!   my $sth   = $dbh->prepare($query);
! 
!   $sth->execute;
!   $sth->finish;
! #  $dbh->disconnect;
  } # sub modsubtitle
  
--- 1286,1294 ----
  
  sub OLDmodsubtitle {
!       my ($dbh,$bibnum, $subtitle) = @_;
!       my $query = "update bibliosubtitle set subtitle = ? where biblionumber 
= ?";
!       my $sth   = $dbh->prepare($query);
!       $sth->execute($subtitle,$bibnum);
!       $sth->finish;
  } # sub modsubtitle
  
***************
*** 1304,1312 ****
      if ($author ne '') {
          $query = "Insert into additionalauthors set
!                         author       = '$author',
!                         biblionumber = '$bibnum'";
          $sth   = $dbh->prepare($query);
  
!         $sth->execute;
  
          $sth->finish;
--- 1305,1313 ----
      if ($author ne '') {
          $query = "Insert into additionalauthors set
!                         author       = ?,
!                         biblionumber = ?";
          $sth   = $dbh->prepare($query);
  
!         $sth->execute($author,$bibnum);
  
          $sth->finish;

Index: Koha.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Koha.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** Koha.pm     3 Feb 2003 18:46:02 -0000       1.11
--- Koha.pm     7 Mar 2003 16:35:43 -0000       1.12
***************
*** 56,59 ****
--- 56,61 ----
             &ethnicitycategories
             &subfield_is_koha_internal_p
+               &getbranches &getprinters
+               &getbranch &getprinter
             $DEBUG);
  
***************
*** 162,165 ****
--- 164,257 ----
      return length $subfield != 1;
  }
+ 
+ =item getbranches
+ 
+   $branches = &getbranches();
+   @branch_codes = keys %$branches;
+   %main_branch_info = %{$branches->{"MAIN"}};
+ 
+ Returns information about existing library branches.
+ 
+ C<$branches> is a reference-to-hash. Its keys are the branch codes for
+ all of the existing library branches, and its values are
+ references-to-hash describing that particular branch.
+ 
+ In each branch description (C<%main_branch_info>, above), there is a
+ key for each field in the branches table of the Koha database. In
+ addition, there is a key for each branch category code to which the
+ branch belongs (the category codes are taken from the branchrelations
+ table).
+ 
+ =cut
+ 
+ sub getbranches {
+ # returns a reference to a hash of references to branches...
+       my %branches;
+       my $dbh = C4::Context->dbh;
+       my $sth=$dbh->prepare("select * from branches");
+       $sth->execute;
+       while (my $branch=$sth->fetchrow_hashref) {
+               my $query = "select categorycode from branchrelations where 
branchcode = ?";
+               my $nsth = $dbh->prepare($query);
+               $nsth->execute($branch->{'branchcode'});
+               while (my ($cat) = $nsth->fetchrow_array) {
+                       # FIXME - This seems wrong. It ought to be
+                       # $branch->{categorycodes}{$cat} = 1;
+                       # otherwise, there's a namespace collision if there's a
+                       # category with the same name as a field in the 
'branches'
+                       # table (i.e., don't create a category called 
"issuing").
+                       # In addition, the current structure doesn't really 
allow
+                       # you to list the categories that a branch belongs to:
+                       # you'd have to list keys %$branch, and remove those 
keys
+                       # that aren't fields in the "branches" table.
+                       $branch->{$cat} = 1;
+                       }
+                       $branches{$branch->{'branchcode'}}=$branch;
+       }
+       return (\%branches);
+ }
+ 
+ =item getprinters
+ 
+   $printers = &getprinters($env);
+   @queues = keys %$printers;
+ 
+ Returns information about existing printer queues.
+ 
+ C<$env> is ignored.
+ 
+ C<$printers> is a reference-to-hash whose keys are the print queues
+ defined in the printers table of the Koha database. The values are
+ references-to-hash, whose keys are the fields in the printers table.
+ 
+ =cut
+ 
+ sub getprinters {
+     my ($env) = @_;
+     my %printers;
+     my $dbh = C4::Context->dbh;
+     my $sth=$dbh->prepare("select * from printers");
+     $sth->execute;
+     while (my $printer=$sth->fetchrow_hashref) {
+       $printers{$printer->{'printqueue'}}=$printer;
+     }
+     return (\%printers);
+ }
+ sub getbranch ($$) {
+     my($query, $branches) = @_; # get branch for this query from branches
+     my $branch = $query->param('branch');
+     ($branch) || ($branch = $query->cookie('branch'));
+     ($branches->{$branch}) || ($branch=(keys %$branches)[0]);
+     return $branch;
+ }
+ 
+ sub getprinter ($$) {
+     my($query, $printers) = @_; # get printer for this query from printers
+     my $printer = $query->param('printer');
+     ($printer) || ($printer = $query->cookie('printer'));
+     ($printers->{$printer}) || ($printer = (keys %$printers)[0]);
+     return $printer;
+ }
+ 
  
  1;

Index: SearchMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/SearchMarc.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SearchMarc.pm       28 Jan 2003 14:56:40 -0000      1.1
--- SearchMarc.pm       7 Mar 2003 16:35:44 -0000       1.2
***************
*** 71,95 ****
        my $sql_where2; # will contain m1.bibid=m2.bibid
        my $nb=1;
!       for(my $i=0; $i<address@hidden;$i++) {
!               if (@$tags[$i] && @$value[$i]) {
!                       $sql_tables .= "marc_subfield_table as m$nb,";
                        if ($nb==1) {
                                if (@$operator[$i] eq "starts") {
!                                       $sql_where1 .= 
"@$excluding[$i](m1.subfieldvalue like '@$value[$i] %' and address@hidden and 
m1.subfieldcode='@$subfields[$i]')";
                                } elsif (@$operator[$i] eq "contains") {
!                                       $sql_where1 .= 
"@$excluding[$i](m1.subfieldvalue like 'address@hidden' and address@hidden and 
m1.subfieldcode='@$subfields[$i]')";
                                } else {
!                                       $sql_where1 .= 
"@$excluding[$i](m1.subfieldvalue @$operator[$i] '@$value[$i]' and 
address@hidden and m1.subfieldcode='@$subfields[$i]')";
                                }
                        } else {
                                if (@$operator[$i] eq "starts") {
!                                       $sql_where1 .= "@$and_or[$i] 
@$excluding[$i](m$nb.subfieldvalue like '@$value[$i]%' and address@hidden and 
m$nb.subfieldcode='@$subfields[$i]')";
                                        $sql_where2 .= "m1.bibid=m$nb.bibid";
                                } elsif (@$operator[$i] eq "contains") {
!                                       $sql_where1 .= "@$and_or[$i] 
@$excluding[$i](m$nb.subfieldvalue like 'address@hidden' and address@hidden and 
m$nb.subfieldcode='@$subfields[$i]')";
                                        $sql_where2 .= "m1.bibid=m$nb.bibid";
                                } else {
!                                       $sql_where1 .= "@$and_or[$i] 
@$excluding[$i](m$nb.subfieldvalue @$operator[$i] '@$value[$i]' and 
address@hidden and m$nb.subfieldcode='@$subfields[$i]')";
                                        $sql_where2 .= "m1.bibid=m$nb.bibid";
                                }
                        }
--- 71,125 ----
        my $sql_where2; # will contain m1.bibid=m2.bibid
        my $nb=1;
!       warn "value : "address@hidden;
!       for(my $i=0; $i<address@hidden;$i++) {
!               if (@$value[$i]) {
                        if ($nb==1) {
                                if (@$operator[$i] eq "starts") {
!                                       $sql_tables .= "marc_subfield_table as 
m$nb,";
!                                       $sql_where1 .= 
"@$excluding[$i](m1.subfieldvalue like '@$value[$i]%'";
!                                       if (@$tags[$i]) {
!                                               $sql_where1 .=" and 
address@hidden and m1.subfieldcode='@$subfields[$i]'";
!                                       }
!                                       $sql_where1.=")";
                                } elsif (@$operator[$i] eq "contains") {
!                                       $sql_tables .= "marc_word as m$nb,";
!                                       $sql_where1 .= "@$excluding[$i](m1.word 
='@$value[$i]'";
!                                       if (@$tags[$i]) {
!                                                $sql_where1 .=" and 
address@hidden and m1.subfieldid='@$subfields[$i]'";
!                                       }
!                                       $sql_where1.=")";
                                } else {
!                                       $sql_tables .= "marc_subfield_table as 
m$nb,";
!                                       $sql_where1 .= 
"@$excluding[$i](m1.subfieldvalue @$operator[$i] '@$value[$i]' ";
!                                       if (@$tags[$i]) {
!                                                $sql_where1 .=" and 
address@hidden and m1.subfieldcode='@$subfields[$i]'";
!                                       }
!                                       $sql_where1.=")";
                                }
                        } else {
                                if (@$operator[$i] eq "starts") {
!                                       $sql_tables .= "marc_subfield_table as 
m$nb,";
!                                       $sql_where1 .= "@$and_or[$i] 
@$excluding[$i](m$nb.subfieldvalue like '@$value[$i]%'";
!                                       if (@$tags[$i]) {
!                                                $sql_where1 .=" and 
address@hidden and m$nb.subfieldcode='@$subfields[$i])";
!                                       }
!                                       $sql_where1.=")";
                                        $sql_where2 .= "m1.bibid=m$nb.bibid";
                                } elsif (@$operator[$i] eq "contains") {
!                                       $sql_tables .= "marc_word as m$nb,";
!                                       $sql_where1 .= "@$and_or[$i] 
@$excluding[$i](m$nb.word='@$value[$i]'";
!                                       if (@$tags[$i]) {
!                                                $sql_where1 .="  and 
address@hidden and m$nb.subfieldid='@$subfields[$i]'";
!                                       }
!                                       $sql_where1.=")";
                                        $sql_where2 .= "m1.bibid=m$nb.bibid";
                                } else {
!                                       $sql_tables .= "marc_subfield_table as 
m$nb,";
!                                       $sql_where1 .= "@$and_or[$i] 
@$excluding[$i](m$nb.subfieldvalue @$operator[$i] '@$value[$i]'";
!                                       if (@$tags[$i]) {
!                                                $sql_where1 .="  and 
address@hidden and m$nb.subfieldcode='@$subfields[$i]'";
!                                       }
                                        $sql_where2 .= "m1.bibid=m$nb.bibid";
+                                       $sql_where1.=")";
                                }
                        }

Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -r1.59 -r1.60
*** Search.pm   3 Mar 2003 17:36:32 -0000       1.59
--- Search.pm   7 Mar 2003 16:35:44 -0000       1.60
***************
*** 1444,1459 ****
      left join bibliosubtitle on
      biblio.biblionumber = bibliosubtitle.biblionumber
!     where biblio.biblionumber = $bibnum
!     and biblioitems.biblionumber = $bibnum";
      my $sth   = $dbh->prepare($query);
      my $data;
- 
-     $sth->execute;
      $data  = $sth->fetchrow_hashref;
      $sth->finish;
! 
!     $query = "Select * from bibliosubject where biblionumber = '$bibnum'";
      $sth   = $dbh->prepare($query);
!     $sth->execute;
      while (my $dat = $sth->fetchrow_hashref){
          $data->{'subject'} .= " , $dat->{'subject'}";
--- 1444,1457 ----
      left join bibliosubtitle on
      biblio.biblionumber = bibliosubtitle.biblionumber
!     where biblio.biblionumber = ?
!     and biblioitems.biblionumber = biblio.biblionumber";
      my $sth   = $dbh->prepare($query);
+     $sth->execute($bibnum);
      my $data;
      $data  = $sth->fetchrow_hashref;
      $sth->finish;
!     $query = "Select * from bibliosubject where biblionumber = ?";
      $sth   = $dbh->prepare($query);
!     $sth->execute($bibnum);
      while (my $dat = $sth->fetchrow_hashref){
          $data->{'subject'} .= " , $dat->{'subject'}";
***************
*** 1507,1513 ****
    my ($bibnum)address@hidden;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from bibliosubject where biblionumber=$bibnum";
    my $sth=$dbh->prepare($query);
!   $sth->execute;
    my @results;
    my $i=0;
--- 1505,1511 ----
    my ($bibnum)address@hidden;
    my $dbh = C4::Context->dbh;
!   my $query="Select * from bibliosubject where biblionumber=?";
    my $sth=$dbh->prepare($query);
!   $sth->execute($bibnum);
    my @results;
    my $i=0;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]