[Koha-cvs] koha/opac opac-main.pl opac-reserve.pl opac-sea...

Henri-Damien LAURENT laurenthdl at alinto.com
Fri Jul 6 17:16:40 CEST 2007


CVSROOT:	/cvsroot/koha
Module name:	koha
Changes by:	Henri-Damien LAURENT <hdl>	07/07/06 15:16:40

Modified files:
	opac           : opac-main.pl opac-reserve.pl opac-search.pl 
	                 opac-topissues.pl opac-user.pl 
	                 opac-authoritiesdetail.pl 

Log message:
	Bug Fixing:
	Authority display hierarchy had a problem.
	
	Feature porting :
	Adding SearchMyLibraryFirst feature to OPAC 
	It select the user's library for research by default

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-main.pl?cvsroot=koha&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-reserve.pl?cvsroot=koha&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-search.pl?cvsroot=koha&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-topissues.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-user.pl?cvsroot=koha&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-authoritiesdetail.pl?cvsroot=koha&r1=1.6&r2=1.7

Patches:
Index: opac-main.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-main.pl,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- opac-main.pl	6 Jun 2007 13:07:16 -0000	1.29
+++ opac-main.pl	6 Jul 2007 15:16:40 -0000	1.30
@@ -15,7 +15,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: opac-main.pl,v 1.29 2007/06/06 13:07:16 tipaul Exp $
+# $Id: opac-main.pl,v 1.30 2007/07/06 15:16:40 hdl Exp $
 
 use strict;
 require Exporter;
@@ -34,22 +34,6 @@
 
 my $limit = $input->param('recentacqui');
 
-my @branches;
-my @select_branch;
-my %select_branches;
-my $branches = GetBranches();
-my @branchloop;
-foreach my $thisbranch ( keys %$branches ) {
-    my $selected = 1
-      if ( C4::Context->userenv
-        && ( $thisbranch eq C4::Context->userenv->{branch} ) );
-    my %row = (
-        value      => $thisbranch,
-        selected   => $selected,
-        branchname => $branches->{$thisbranch}->{'branchname'},
-    );
-    push @branchloop, \%row;
-}
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {
         template_name   => "opac-main.tmpl",
@@ -68,7 +52,31 @@
     );
 }
 
-my $borrower = GetMember( $borrowernumber,'borrowernumber' );
+# SearchMyLibraryFirst
+if (C4::Context->preference("SearchMyLibraryFirst")){
+  if (C4::Context->userenv){
+  my $branches = GetBranches();
+  my @branchloop;  
+  
+  foreach my $thisbranch (keys %$branches) {
+        my $selected = 1 if (C4::Context->userenv && ($thisbranch eq C4::Context->userenv->{branch}));
+#         warn $thisbranch;
+#         warn C4::Context->userenv;
+#         warn C4::Context->userenv->{branch};
+#         warn " => ".C4::Context->userenv && ($thisbranch eq C4::Context->userenv->{branch});
+        my %row =(value => $thisbranch,
+                                selected => $selected,
+                                branchname => $branches->{$thisbranch}->{'branchname'},
+                        );
+        push @branchloop, \%row;
+  }
+    $template->param("mylibraryfirst"=>1,branchloop=>\@branchloop);
+  } else {
+    $template->param("mylibraryfirst"=>0)
+   }
+}
+
+    my $borrower = GetMember( $borrowernumber,'borrowernumber' );
 my @languages;
 my $counter = 0;
 my $langavail = getTranslatedLanguages('opac');
@@ -85,7 +93,6 @@
 }
 
 $template->param(
-    branchloop           => \@branchloop,
     textmessaging        => $borrower->{textmessaging},
     opaclanguagesdisplay => 0,
 );
@@ -96,6 +103,7 @@
 my  $all_koha_news  = &GetNewsToDisplay( $news_lang );
 my $koha_news_count = scalar @$all_koha_news;
 
+
 $template->param(
     koha_news       => $all_koha_news,
     koha_news_count => $koha_news_count

Index: opac-reserve.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-reserve.pl,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- opac-reserve.pl	11 May 2007 16:22:03 -0000	1.35
+++ opac-reserve.pl	6 Jul 2007 15:16:40 -0000	1.36
@@ -296,12 +296,12 @@
             debarred => 1
         );
     }
-    my ( $resnum, $reserves ) = GetReservesFromBorrowernumber( $borrowernumber );
+    my $reserves = GetReservesFromBorrowernumber( $borrowernumber );
     $template->param( RESERVES => $reserves );
-    if ( $resnum >= $MAXIMUM_NUMBER_OF_RESERVES ) {
+    if ( scalar(@$reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) {
         $template->param( message => 1 );
         $noreserves = 1;
-        $template->param( too_many_reserves => $resnum );
+        $template->param( too_many_reserves => scalar(@$reserves));
     }
     foreach my $res (@$reserves) {
         if ( $res->{'biblionumber'} == $biblionumber ) {

Index: opac-search.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-search.pl,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- opac-search.pl	6 Jun 2007 13:07:16 -0000	1.44
+++ opac-search.pl	6 Jul 2007 15:16:40 -0000	1.45
@@ -3,7 +3,7 @@
 # Script to perform searching
 # For documentation try 'perldoc /path/to/search'
 #
-# $Header: /cvsroot/koha/koha/opac/opac-search.pl,v 1.44 2007/06/06 13:07:16 tipaul Exp $
+# $Header: /cvsroot/koha/koha/opac/opac-search.pl,v 1.45 2007/07/06 15:16:40 hdl Exp $
 #
 # Copyright 2006 LibLime
 #
@@ -221,13 +221,15 @@
 my $branches = GetBranches();
 my @branch_loop;
 for my $branch_hash ( keys %$branches ) {
+    my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst'));
     push @branch_loop,
       {
         value      => "branch: $branch_hash",
         branchname => $branches->{$branch_hash}->{'branchname'},
+        selected => $selected
       };
 }
-$template->param( branchloop => \@branch_loop, );
+$template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst"));
 
 # load the itemtypes (Called Collection Codes in the template -- used for circ rules )
 my $itemtypes = GetItemTypes;

Index: opac-topissues.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-topissues.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- opac-topissues.pl	24 Apr 2007 13:54:29 -0000	1.3
+++ opac-topissues.pl	6 Jul 2007 15:16:40 -0000	1.4
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: opac-topissues.pl,v 1.3 2007/04/24 13:54:29 hdl Exp $
+# $Id: opac-topissues.pl,v 1.4 2007/07/06 15:16:40 hdl Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -92,14 +92,19 @@
                 results_loop => \@results,
                 );
 
-my $branches = GetBranches;
-my @branchloop;
-foreach my $thisbranch (keys %$branches) {
-        my %row =(value => $thisbranch,
-                    branchname => $branches->{$thisbranch}->{'branchname'},
-                        );
-        push @branchloop, \%row;
+# load the branches
+my $branches = GetBranches();
+my @branch_loop;
+for my $branch_hash ( keys %$branches ) {
+    my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst'));
+    push @branch_loop,
+      {
+        value      => "branch: $branch_hash",
+        branchname => $branches->{$branch_hash}->{'branchname'},
+        selected => $selected
+      };
 }
+$template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst"));
 
 #doctype
 my $itemtypes = GetItemTypes;
@@ -112,7 +117,6 @@
 }
 
 $template->param(
-                branchloop =>\@branchloop,
                 itemtypeloop =>\@itemtypeloop,
                 );
 output_html_with_http_headers $input, $cookie, $template->output;

Index: opac-user.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-user.pl,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- opac-user.pl	23 May 2007 16:19:42 -0000	1.33
+++ opac-user.pl	6 Jul 2007 15:16:40 -0000	1.34
@@ -15,7 +15,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: opac-user.pl,v 1.33 2007/05/23 16:19:42 tipaul Exp $
+# $Id: opac-user.pl,v 1.34 2007/07/06 15:16:40 hdl Exp $
 
 use strict;
 require Exporter;
@@ -138,7 +138,19 @@
 $template->param( OVERDUES       => \@overdues );
 $template->param( overdues_count => $overdues_count );
 
+# load the branches
 my $branches = GetBranches();
+my @branch_loop;
+for my $branch_hash ( keys %$branches ) {
+    my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst'));
+    push @branch_loop,
+      {
+        value      => "branch: $branch_hash",
+        branchname => $branches->{$branch_hash}->{'branchname'},
+        selected => $selected
+      };
+}
+$template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst"));
 
 # now the reserved items....
 my @reserves  = GetReservesFromBorrowernumber( $borrowernumber );
@@ -152,8 +164,8 @@
     $res->{'reserves_title'} = $biblioData->{'title'};
 }
 
-use Data::Dumper;
-warn Dumper(@reserves);
+# use Data::Dumper;
+# warn Dumper(@reserves);
 
 $template->param( RESERVES       => \@reserves );
 $template->param( reserves_count => $#reserves+1 );

Index: opac-authoritiesdetail.pl
===================================================================
RCS file: /cvsroot/koha/koha/opac/opac-authoritiesdetail.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- opac-authoritiesdetail.pl	23 May 2007 16:19:41 -0000	1.6
+++ opac-authoritiesdetail.pl	6 Jul 2007 15:16:40 -0000	1.7
@@ -68,38 +68,29 @@
 );
 
 my $record;
-if ( C4::Context->preference("AuthDisplayHierarchy") ) {
-    my $trees = BuildUnimarcHierarchies($authid);
-
-    #   warn "trees :$trees";
-    my @trees = split /;/, $trees;
-    push @trees, $trees unless (@trees);
+if (C4::Context->preference("AuthDisplayHierarchy")){
+  my $trees=BuildUnimarcHierarchies($authid);
+  my @trees = split /;/,$trees ;
+  push @trees,$trees unless (@trees);
     my @loophierarchies;
-    foreach my $tree (@trees) {
-
-        #     warn "tree :$tree";
-
-        my @tree = split /,/, $tree;
-        push @tree, $tree unless (@tree);
-        my $cnt = 0;
+  foreach my $tree (@trees){
+    my @tree=split /,/,$tree;
+    push @tree,$tree unless (@tree);
+    my $cnt=0;
         my @loophierarchy;
-        foreach my $element (@tree) {
-
-            #       warn "tree :$element";
-            my %cell;
-            my $elementdata = GetAuthority( $element );
-            $record = $elementdata if ( $authid == $element );
-            push @loophierarchy,
-              BuildUnimarcHierarchy( $elementdata, "child" . $cnt, $authid );
+    foreach my $element (@tree){
+      my $cell;
+      my $elementdata = GetAuthority($element);
+      $record= $elementdata if ($authid==$element);
+      push @loophierarchy, BuildUnimarcHierarchy($elementdata,"child".$cnt, $authid);
             $cnt++;
         }
-        push @loophierarchies, { 'loopelement' => \@loophierarchy };
+    push @loophierarchies, { 'loopelement' =>\@loophierarchy};
+  }
         $template->param(
-            'displayhierarchy' =>
-              C4::Context->preference("AuthDisplayHierarchy"),
-            'loophierarchies' => \@loophierarchies,
+    'displayhierarchy' =>C4::Context->preference("AuthDisplayHierarchy"),
+    'loophierarchies' =>\@loophierarchies,
         );
-    }
 }
 else {
     $record = GetAuthority( $authid );





More information about the Koha-cvs mailing list