[Koha-cvs] koha C4/BookShelves.pm bookshelves/shelves.pl k... [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Thu Dec 14 18:22:55 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/12/14 17:22:55

Modified files:
	C4             : BookShelves.pm 
	bookshelves    : shelves.pl 
	koha-tmpl/opac-tmpl/prog/en: opac-shelves.tmpl 
	opac           : opac-shelves.pl 

Log message:
	bookshelves work perfectly with mod_perl and are cleaned.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/BookShelves.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.15.8.7&r2=1.15.8.8
http://cvs.savannah.gnu.org/viewcvs/koha/bookshelves/shelves.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.9.2.6&r2=1.9.2.7
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.4&r2=1.1.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-shelves.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.8.2.6&r2=1.8.2.7

Patches:
Index: C4/BookShelves.pm
===================================================================
RCS file: /sources/koha/koha/C4/BookShelves.pm,v
retrieving revision 1.15.8.7
retrieving revision 1.15.8.8
diff -u -b -r1.15.8.7 -r1.15.8.8
--- C4/BookShelves.pm	13 Dec 2006 19:46:41 -0000	1.15.8.7
+++ C4/BookShelves.pm	14 Dec 2006 17:22:55 -0000	1.15.8.8
@@ -3,7 +3,7 @@
 
 package C4::BookShelves;
 
-# $Id: BookShelves.pm,v 1.15.8.7 2006/12/13 19:46:41 hdl Exp $
+# $Id: BookShelves.pm,v 1.15.8.8 2006/12/14 17:22:55 toins Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -29,7 +29,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.15.8.7 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.15.8.8 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -60,6 +60,8 @@
         &ModShelf
         &ShelfPossibleAction
         &DelFromShelf &DelShelf
+        
+        &DisplayShelf
 );
 
 my $dbh = C4::Context->dbh;
@@ -380,7 +382,7 @@
     $sth->execute( $shelfnumber, $itemnumber );
 }
 
-=item DelShelf
+=head2 DelShelf
 
   $Number = DelShelf($shelfnumber);
 
@@ -397,6 +399,41 @@
         return 0;
 }
 
+=head2 DisplayShelf
+
+DisplayShelf($shelfnumber,$shelflist,innerquery,$template,$loggedinuser);
+
+=cut
+
+sub DisplayShelf {
+    my $innershelfnumber = shift;
+    my $shelflist        = shift;
+    my $innerquery       = shift;
+    my $innertemplate    = shift;
+    my $user             = shift;
+    
+    #check that the user can view the shelf
+    return
+      unless ( ShelfPossibleAction( $user, $innershelfnumber, 'view' ) );
+    my ($itemlist) = GetShelfContents($innershelfnumber);
+    my $item       = '';
+    my $color      = '';
+    my @itemsloop;
+    foreach $item ( sort { $a->{'barcode'} cmp $b->{'barcode'} } @$itemlist ) {
+        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+        $item->{'toggle'} = $color;
+        push( @itemsloop, $item );
+    }
+    $innertemplate->param(
+        itemsloop   => \@itemsloop,
+        shelfname   => $shelflist->{$innershelfnumber}->{'shelfname'},
+        shelfnumber => $innershelfnumber,
+        viewshelf   => $innerquery->param('viewshelf'),
+        manageshelf =>
+          &ShelfPossibleAction( $user, $innershelfnumber, 'manage' ),
+    );
+}
+
 END { }    # module clean-up code here (global destructor)
 
 1;
@@ -417,6 +454,9 @@
 
 #
 # $Log: BookShelves.pm,v $
+# Revision 1.15.8.8  2006/12/14 17:22:55  toins
+# bookshelves work perfectly with mod_perl and are cleaned.
+#
 # Revision 1.15.8.7  2006/12/13 19:46:41  hdl
 # Some bug fixing.
 #

Index: bookshelves/shelves.pl
===================================================================
RCS file: /sources/koha/koha/bookshelves/shelves.pl,v
retrieving revision 1.9.2.6
retrieving revision 1.9.2.7
diff -u -b -r1.9.2.6 -r1.9.2.7
--- bookshelves/shelves.pl	13 Dec 2006 10:06:05 -0000	1.9.2.6
+++ bookshelves/shelves.pl	14 Dec 2006 17:22:55 -0000	1.9.2.7
@@ -125,11 +125,58 @@
         last SWITCH;
     }
     if ( $query->param('viewshelf') ) {
-        viewshelf( $query->param('viewshelf'),$template );
+        DisplayShelf( $query->param('viewshelf'),$shelflist,$query,$template,$loggedinuser );
         last SWITCH;
     }
     if ( $query->param('shelves') ) {
-        shelves($template);
+        if ( my $newshelf = $query->param('addshelf') ) {
+            my $shelfnumber = AddShelf(
+                $newshelf,
+                $query->param('owner'),
+                $query->param('category')
+            );
+
+            if ( $shelfnumber == -1 ) {    #shelf already exists.
+                $template->param(
+                    {
+                        shelfnumber => $shelfnumber,
+                        already     => 1
+                    }
+                );
+            }
+    }
+    my @paramsloop;
+    foreach ( $query->param() ) {
+        my %line;
+        if (/DEL-(\d+)/) {
+            my $delshelf = $1;
+            my ( $status, $count ) = DelShelf($delshelf);
+            if ($status) {
+                $line{'status'} = $status;
+                $line{'count'}  = $count;
+            }
+        }
+
+        #if the shelf is not deleted, %line points on null
+        push( @paramsloop, \%line );
+    }
+    $template->param( paramsloop => \@paramsloop );
+    my ($shelflist) = GetShelves( $loggedinuser, 2 );
+    my $color = '';
+    my @shelvesloop;
+    foreach my $element ( sort keys %$shelflist ) {
+        my %line;
+        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+        $line{'toggle'}         = $color;
+        $line{'shelf'}          = $element;
+        $line{'shelfname'}      = $shelflist->{$element}->{'shelfname'};
+        $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
+        push( @shelvesloop, \%line );
+    }
+    $template->param(
+        shelvesloop => \@shelvesloop,
+        shelves     => 1,
+    );
         last SWITCH;
     }
 }
@@ -157,6 +204,7 @@
       unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
     push( @shelvesloop, \%line );
 }
+
 $template->param(
     shelvesloop             => \@shelvesloop,
     intranetcolorstylesheet =>
@@ -219,33 +267,11 @@
     );
 }
 
-sub viewshelf {
-    my $shelfnumber = shift;
-    my $innertemplate = shift;
-    #check that the user can view the shelf
-    return
-      unless ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) );
-    my ($itemlist) = GetShelfContents($shelfnumber);
-    my $item       = '';
-    my $color      = '';
-    my @itemsloop;
-    foreach $item ( sort { $a->{'barcode'} cmp $b->{'barcode'} } @$itemlist ) {
-        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
-        $item->{'toggle'} = $color;
-        push( @itemsloop, $item );
-    }
-    $innertemplate->param(
-        itemsloop   => \@itemsloop,
-        shelfname   => $shelflist->{$shelfnumber}->{'shelfname'},
-        shelfnumber => $shelfnumber,
-        viewshelf   => $query->param('viewshelf'),
-        manageshelf =>
-          &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
-    );
-}
-
 #
 # $Log: shelves.pl,v $
+# Revision 1.9.2.7  2006/12/14 17:22:55  toins
+# bookshelves work perfectly with mod_perl and are cleaned.
+#
 # Revision 1.9.2.6  2006/12/13 10:06:05  toins
 # fix a mod_perl specific bug.
 #
@@ -261,13 +287,3 @@
 # Revision 1.9.2.2  2006/10/17 07:59:35  toins
 # ccode added.
 #
-# Revision 1.9.2.1  2006/08/30 15:59:14  toins
-# Code cleaned according to coding guide lines.
-#
-# Revision 1.9  2006/07/04 14:36:51  toins
-# Head & rel_2_2 merged
-#
-# Revision 1.5.2.5  2006/02/05 21:59:21  kados
-# Adds script support for IntranetNav ... see mail to koha-devel for
-# details
-#

Index: koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -b -r1.1.2.4 -r1.1.2.5
--- koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl	11 Dec 2006 17:10:06 -0000	1.1.2.4
+++ koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl	14 Dec 2006 17:22:55 -0000	1.1.2.5
@@ -65,7 +65,7 @@
                 <p class="error"><!-- TMPL_VAR Name="string" --></p>
             <!-- /TMPL_IF -->
         <!-- /TMPL_LOOP -->
-<form method="post" action="/cgi-bin/koha/opac-shelves.pl">
+    <form method="post" action="/cgi-bin/koha/opac-shelves.pl">
         <input type="hidden" name="shelves" value="1">
         <h3>Create a New a Virtual Shelf</h3>
         <table>

Index: opac/opac-shelves.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-shelves.pl,v
retrieving revision 1.8.2.6
retrieving revision 1.8.2.7
diff -u -b -r1.8.2.6 -r1.8.2.7
--- opac/opac-shelves.pl	14 Dec 2006 16:04:25 -0000	1.8.2.6
+++ opac/opac-shelves.pl	14 Dec 2006 17:22:55 -0000	1.8.2.7
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-#
 # Copyright 2000-2002 Katipo Communications
 #
 # This file is part of Koha.
@@ -18,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: opac-shelves.pl,v 1.8.2.6 2006/12/14 16:04:25 toins Exp $
+# $Id: opac-shelves.pl,v 1.8.2.7 2006/12/14 17:22:55 toins Exp $
 
 =head1 NAME
 
@@ -98,9 +97,10 @@
         }
     }
 }
-my ($shelflist) = GetShelves( $loggedinuser, 2 );
 
-$template->param( { loggedinuser => $loggedinuser, } );
+# getting the Shelves list
+my $shelflist = GetShelves( $loggedinuser, 2 );
+$template->param( { loggedinuser => $loggedinuser } );
 my $op = $query->param('op');
 
 SWITCH: {
@@ -125,11 +125,58 @@
         last SWITCH;
     }
     if ( $query->param('viewshelf') ) {
-        viewshelf( $query->param('viewshelf'),$template );
+        DisplayShelf( $query->param('viewshelf'),$shelflist,$query,$template,$loggedinuser );
         last SWITCH;
     }
     if ( $query->param('shelves') ) {
-        shelves($template);
+        if ( my $newshelf = $query->param('addshelf') ) {
+            my $shelfnumber = AddShelf(
+                $newshelf,
+                $query->param('owner'),
+                $query->param('category')
+            );
+
+            if ( $shelfnumber == -1 ) {    #shelf already exists.
+                $template->param(
+                    {
+                        shelfnumber => $shelfnumber,
+                        already     => 1
+                    }
+                );
+            }
+    }
+    my @paramsloop;
+    foreach ( $query->param() ) {
+        my %line;
+        if (/DEL-(\d+)/) {
+            my $delshelf = $1;
+            my ( $status, $count ) = DelShelf($delshelf);
+            if ($status) {
+                $line{'status'} = $status;
+                $line{'count'}  = $count;
+            }
+        }
+
+        #if the shelf is not deleted, %line points on null
+        push( @paramsloop, \%line );
+    }
+    $template->param( paramsloop => \@paramsloop );
+    my ($shelflist) = GetShelves( $loggedinuser, 2 );
+    my $color = '';
+    my @shelvesloop;
+    foreach my $element ( sort keys %$shelflist ) {
+        my %line;
+        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+        $line{'toggle'}         = $color;
+        $line{'shelf'}          = $element;
+        $line{'shelfname'}      = $shelflist->{$element}->{'shelfname'};
+        $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
+        push( @shelvesloop, \%line );
+    }
+    $template->param(
+        shelvesloop => \@shelvesloop,
+        shelves     => 1,
+    );
         last SWITCH;
     }
 }
@@ -157,6 +204,7 @@
           unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
         push( @shelvesloop, \%line );
     }
+
 $template->param(
     shelvesloop             => \@shelvesloop,
     intranetcolorstylesheet =>
@@ -177,7 +225,7 @@
         );
 
         if ( $shelfnumber == -1 ) {    #shelf already exists.
-            $innertemplate->param(
+            $template->param(
                 {
                     shelfnumber => $shelfnumber,
                     already     => 1
@@ -219,33 +267,12 @@
     );
 }
 
-sub viewshelf {
-    my $shelfnumber   = shift;
-    my $innertemplate = shift;
-    #check that the user can view the shelf
-    return
-      unless ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) );
-    my ($itemlist) = GetShelfContents($shelfnumber);
-    my $item       = '';
-    my $color      = '';
-    my @itemsloop;
-    foreach $item ( sort { $a->{'barcode'} cmp $b->{'barcode'} } @$itemlist ) {
-        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
-        $item->{'toggle'} = $color;
-        push( @itemsloop, $item );
-    }
-    $innertemplate->param(
-        itemsloop   => \@itemsloop,
-        shelfname   => $shelflist->{$shelfnumber}->{'shelfname'},
-        shelfnumber => $shelfnumber,
-        viewshelf   => $query->param('viewshelf'),
-        manageshelf =>
-          &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
-    );
-}
 
 #
 # $Log: opac-shelves.pl,v $
+# Revision 1.8.2.7  2006/12/14 17:22:55  toins
+# bookshelves work perfectly with mod_perl and are cleaned.
+#
 # Revision 1.8.2.6  2006/12/14 16:04:25  toins
 # sync with intranet.
 #
@@ -260,12 +287,3 @@
 # Revision 1.8.2.3  2006/11/30 18:23:51  toins
 # theses scripts don't need to use C4::Search.
 #
-# Revision 1.8.2.2  2006/11/30 17:22:19  toins
-# Cleaning Search.pm
-#
-# Revision 1.8.2.1  2006/08/30 16:03:22  toins
-# Code cleaned according to coding guide lines.
-#
-# Revision 1.8  2006/05/21 02:30:17  kados
-# syncing dev-week and HEAD
-#





More information about the Koha-cvs mailing list