From 8af76042d82e2034061087e9b78df038e3b2a403 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Thu, 9 Aug 2007 09:22:17 -0500 Subject: [PATCH] new virtual shelves changes, keyed by biblionumber -- approved --- C4/Auth.pm | 53 ++--- C4/{VirtualShelves.pm => BookShelves.pm} | 190 ++++++++++++------ C4/Branch.pm | 3 +- Makefile.PL | 1 - .../addbookbybiblionumber.pl | 99 +++++---- {virtualshelves => bookshelves}/shelves.pl | 115 ++++++----- help.pl | 82 +++++--- installer/kohastructure.sql | 20 +- koha-tmpl/intranet-tmpl/prog/en/about.tmpl | 2 +- koha-tmpl/intranet-tmpl/prog/en/auth.tmpl | 11 +- .../addbookbybiblionumber.tmpl} | 12 +- .../shelves.tmpl | 89 ++++---- .../prog/en/help/admin/systempreferences.tmpl | 4 +- .../intranet-tmpl/prog/en/help/nohelp.tmpl | 15 +- .../prog/en/includes/action-catalogue.inc | 2 +- .../prog/en/includes/error-top.inc | 2 +- .../prog/en/includes/menu-bookshelves.inc | 5 + .../prog/en/includes/menu-virtualshelves.inc | 5 - .../intranet-tmpl/prog/en/includes/menus.inc | 2 +- .../intranet-tmpl/prog/en/tools/export.tmpl | 7 +- .../opac-tmpl/prog/en/includes/basket.js | 2 +- .../opac-tmpl/prog/en/opac-ISBDdetail.tmpl | 2 +- .../opac-tmpl/prog/en/opac-MARCdetail.tmpl | 2 +- ...r.tmpl => opac-addbookbybiblionumber.tmpl} | 18 +- koha-tmpl/opac-tmpl/prog/en/opac-detail.tmpl | 2 +- koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl | 62 ++---- ...umber.pl => opac-addbookbybiblionumber.pl} | 16 +- opac/opac-main.pl | 2 +- opac/opac-shelves.pl | 20 +- t/{VirtualShelves.t => BookShelves.t} | 18 +- tools/export.pl | 3 +- updater/updatedatabase | 2 +- 32 files changed, 430 insertions(+), 438 deletions(-) rename C4/{VirtualShelves.pm => BookShelves.pm} (58%) rename virtualshelves/addbybiblionumber.pl => bookshelves/addbookbybiblionumber.pl (60%) rename {virtualshelves => bookshelves}/shelves.pl (75%) rename koha-tmpl/intranet-tmpl/prog/en/{virtualshelves/addbybiblionumber.tmpl => bookshelves/addbookbybiblionumber.tmpl} (71%) rename koha-tmpl/intranet-tmpl/prog/en/{virtualshelves => bookshelves}/shelves.tmpl (74%) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/menu-bookshelves.inc delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/menu-virtualshelves.inc rename koha-tmpl/opac-tmpl/prog/en/{opac-addbybiblionumber.tmpl => opac-addbookbybiblionumber.tmpl} (73%) rename opac/{opac-addbybiblionumber.pl => opac-addbookbybiblionumber.pl} (87%) rename t/{VirtualShelves.t => BookShelves.t} (91%) diff --git a/C4/Auth.pm b/C4/Auth.pm index 9a349b5c13..14ae8da1a9 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -223,17 +223,18 @@ sub get_template_and_user { if ( $in->{'type'} eq "intranet" ) { $template->param( intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), - intranetuserjs => C4::Context->preference("intranetuserjs"), - TemplateEncoding => C4::Context->preference("TemplateEncoding"), - AmazonContent => C4::Context->preference("AmazonContent"), - LibraryName => C4::Context->preference("LibraryName"), - LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"), - LoginBranchname => (C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"), - AutoLocation => C4::Context->preference("AutoLocation"), - hide_marc => C4::Context->preference("hide_marc"), - patronimages => C4::Context->preference("patronimages"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + intranetuserjs => C4::Context->preference("intranetuserjs"), + TemplateEncoding => C4::Context->preference("TemplateEncoding"), + AmazonContent => C4::Context->preference("AmazonContent"), + LibraryName => C4::Context->preference("LibraryName"), + LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"), + LoginBranchname => (C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"), + LoginBranchnameShort => substr((C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"),0,10), + AutoLocation => C4::Context->preference("AutoLocation"), + hide_marc => C4::Context->preference("hide_marc"), + patronimages => C4::Context->preference("patronimages"), "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), suggestion => C4::Context->preference("suggestion"), @@ -345,7 +346,7 @@ has authenticated. sub checkauth { my $query = shift; - # warn "Checking Auth"; + # $authnotrequired will be set for scripts which will run without authentication my $authnotrequired = shift; my $flagsrequired = shift; @@ -388,7 +389,7 @@ sub checkauth { # state variables my $loggedin = 0; my %info; - my ( $userid, $cookie, $sessionID, $flags ); + my ( $userid, $cookie, $sessionID, $flags, $envcookie ); my $logout = $query->param('logout.x'); if ( $userid = $ENV{'REMOTE_USER'} ) { @@ -430,7 +431,7 @@ sub checkauth { close L; } if ($userid) { - # warn "here $userid"; + warn "here $userid"; if ( $lasttime < time() - $timeout ) { # timed logout @@ -550,14 +551,10 @@ sub checkauth { # new op dev : # launch a sequence to check if we have a ip for the branch, if we have one we replace the branchcode of the userenv by the branch bound in the ip. my $ip = $ENV{'REMOTE_ADDR'}; - # if they specify at login, use that - if ($query->param('branch')) { - $branchcode = $query->param('branch'); - $branchname = GetBranchName($branchcode); - } my $branches = GetBranches(); my @branchesloop; foreach my $br ( keys %$branches ) { + # now we work with the treatment of ip my $domain = $branches->{$br}->{'branchip'}; if ( $domain && $ip =~ /^$domain/ ) { @@ -596,17 +593,7 @@ sub checkauth { $session->param('ip',$session->remote_addr()); $session->param('lasttime',time()); } - if ($session){ - C4::Context::set_userenv( - $session->param('number'), $session->param('id'), - $session->param('cardnumber'), $session->param('firstname'), - $session->param('surname'), $session->param('branch'), - $session->param('branchname'), $session->param('flags'), - $session->param('emailaddress'), $session->param('branchprinter') - ); - } } - else { if ($userid) { $info{'invalid_username_or_password'} = 1; @@ -636,16 +623,8 @@ sub checkauth { my $value = $query->param($name); push @inputs, { name => $name, value => $value }; } - # get the branchloop, which we need for authetication - use C4::Branch; - my $branches = GetBranches(); - my @branch_loop; - for my $branch_hash (keys %$branches) { - push @branch_loop, {branchcode => "$branch_hash", branchname => $branches->{$branch_hash}->{'branchname'}, }; - } my $template = gettemplate( $template_name, $type, $query ); - $template->param(branchloop => \@branch_loop,); $template->param( INPUTS => \@inputs, suggestion => C4::Context->preference("suggestion"), diff --git a/C4/VirtualShelves.pm b/C4/BookShelves.pm similarity index 58% rename from C4/VirtualShelves.pm rename to C4/BookShelves.pm index 06bddb1874..ce8810c9e7 100755 --- a/C4/VirtualShelves.pm +++ b/C4/BookShelves.pm @@ -1,7 +1,7 @@ # -*- tab-width: 8 -*- # Please use 8-character tabs for this file (indents are every 4 characters) -package C4::VirtualShelves; +package C4::BookShelves; # $Id$ @@ -33,17 +33,17 @@ $VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v) . "." . join( "_", map =head1 NAME -C4::VirtualShelves - Functions for manipulating Koha virtual virtualshelves +C4::BookShelves - Functions for manipulating Koha virtual bookshelves =head1 SYNOPSIS - use C4::VirtualShelves; + use C4::BookShelves; =head1 DESCRIPTION -This module provides functions for manipulating virtual virtualshelves, -including creating and deleting virtualshelves, and adding and removing -items to and from virtualshelves. +This module provides functions for manipulating virtual bookshelves, +including creating and deleting bookshelves, and adding and removing +items to and from bookshelves. =head1 FUNCTIONS @@ -69,13 +69,13 @@ my $dbh = C4::Context->dbh; $shelflist = &GetShelves($owner, $mincategory); ($shelfnumber, $shelfhash) = each %{$shelflist}; -Looks up the virtual virtualshelves, and returns a summary. C<$shelflist> -is a reference-to-hash. The keys are the virtualshelves numbers +Looks up the virtual bookshelves, and returns a summary. C<$shelflist> +is a reference-to-hash. The keys are the bookshelf numbers (C<$shelfnumber>, above), and the values (C<$shelfhash>, above) are themselves references-to-hash, with the following keys: -C : 2 if the list is for "look". 3 if the list is for "Select virtualshelves for adding a virtual". -virtualshelves of the owner are always selected, whatever the category +C : 2 if the list is for "look". 3 if the list is for "Select bookshelf for adding a book". +bookshelves of the owner are always selected, whatever the category =over 4 @@ -85,7 +85,7 @@ A string. The name of the shelf. =item C<$shelfhash-E{count}> -The number of virtuals on that virtualshelves. +The number of books on that bookshelf. =back @@ -100,14 +100,14 @@ sub GetShelves { my ( $owner, $mincategory ) = @_; my $query = qq( - SELECT virtualshelves.shelfnumber, virtualshelves.shelfname,owner,surname,firstname,virtualshelves.category, - count(virtualshelfcontents.biblionumber) as count - FROM virtualshelves - LEFT JOIN virtualshelfcontents ON virtualshelves.shelfnumber = virtualshelfcontents.shelfnumber - LEFT JOIN borrowers ON virtualshelves.owner = borrowers.borrowernumber + SELECT bookshelf.shelfnumber, bookshelf.shelfname,owner,surname,firstname,bookshelf.category, + count(shelfcontents.itemnumber) as count + FROM bookshelf + LEFT JOIN shelfcontents ON bookshelf.shelfnumber = shelfcontents.shelfnumber + LEFT JOIN borrowers ON bookshelf.owner = borrowers.borrowernumber WHERE owner=? OR category>=? - GROUP BY virtualshelves.shelfnumber - ORDER BY virtualshelves.category, virtualshelves.shelfname, borrowers.firstname, borrowers.surname + GROUP BY bookshelf.shelfnumber + ORDER BY bookshelf.category, bookshelf.shelfname, borrowers.firstname, borrowers.surname ); my $sth = $dbh->prepare($query); $sth->execute( $owner, $mincategory ); @@ -134,10 +134,10 @@ sub GetShelves { (shelfnumber,shelfname,owner,category) = &GetShelf($shelfnumber); -Looks up information about the contents of virtual virtualshelves number +Looks up information about the contents of virtual bookshelf number C<$shelfnumber> -Returns the database's information on 'virtualshelves' table. +Returns the database's information on 'bookshelf' table. =cut @@ -145,7 +145,7 @@ sub GetShelf { my ($shelfnumber) = @_; my $query = qq( SELECT shelfnumber,shelfname,owner,category - FROM virtualshelves + FROM bookshelf WHERE shelfnumber=? ); my $sth = $dbh->prepare($query); @@ -157,7 +157,7 @@ sub GetShelf { $itemlist = &GetShelfContents($shelfnumber); -Looks up information about the contents of virtual virtualshelves number +Looks up information about the contents of virtual bookshelf number C<$shelfnumber>. Returns a reference-to-array, whose elements are references-to-hash, @@ -170,22 +170,23 @@ sub GetShelfContents { my ( $shelfnumber ) = @_; my @itemlist; my $query = - " SELECT biblionumber - FROM virtualshelfcontents + " SELECT itemnumber + FROM shelfcontents WHERE shelfnumber=? - ORDER BY biblionumber + ORDER BY itemnumber "; my $sth = $dbh->prepare($query); $sth->execute($shelfnumber); my $sth2 = $dbh->prepare(" - SELECT biblio.*,biblioitems.* FROM biblio - LEFT JOIN biblioitems on biblio.biblionumber=biblioitems.biblionumber - WHERE biblio.biblionumber=?" + SELECT biblio.*,biblioitems.* FROM items + LEFT JOIN biblio on items.biblionumber=biblio.biblionumber + LEFT JOIN biblioitems on items.biblionumber=biblioitems.biblionumber + WHERE items.itemnumber=?" ); - while ( my ($biblionumber) = $sth->fetchrow ) { - $sth2->execute($biblionumber); + while ( my ($itemnumber) = $sth->fetchrow ) { + $sth2->execute($itemnumber); my $item = $sth2->fetchrow_hashref; - $item->{'biblionumber'}=$biblionumber; + $item->{'itemnumber'}=$itemnumber; push( @itemlist, $item ); } return ( \@itemlist ); @@ -195,11 +196,11 @@ sub GetShelfContents { $shelfnumber = &AddShelf( $shelfname, $owner, $category); -Creates a new virtual virtualshelves with name C<$shelfname>, owner C<$owner> and category +Creates a new virtual bookshelf with name C<$shelfname>, owner C<$owner> and category C<$category>. Returns a code to know what's happen. - * -1 : if this virtualshelves already exist. + * -1 : if this bookshelf already exist. * $shelfnumber : if success. =cut @@ -208,7 +209,7 @@ sub AddShelf { my ( $shelfname, $owner, $category ) = @_; my $query = qq( SELECT * - FROM virtualshelves + FROM bookshelf WHERE shelfname=? AND owner=? ); my $sth = $dbh->prepare($query); @@ -218,7 +219,7 @@ sub AddShelf { } else { my $query = qq( - INSERT INTO virtualshelves + INSERT INTO bookshelf (shelfname,owner,category) VALUES (?,?,?) ); @@ -231,35 +232,35 @@ sub AddShelf { =item AddToShelf - &AddToShelf($biblionumber, $shelfnumber); + &AddToShelf($itemnumber, $shelfnumber); -Adds item number C<$biblionumber> to virtual virtualshelves number +Adds item number C<$itemnumber> to virtual bookshelf number C<$shelfnumber>, unless that item is already on that shelf. =cut #' sub AddToShelf { - my ( $biblionumber, $shelfnumber ) = @_; - return unless $biblionumber; + my ( $itemnumber, $shelfnumber ) = @_; + return unless $itemnumber; my $query = qq( SELECT * - FROM virtualshelfcontents - WHERE shelfnumber=? AND biblionumber=? + FROM shelfcontents + WHERE shelfnumber=? AND itemnumber=? ); my $sth = $dbh->prepare($query); - $sth->execute( $shelfnumber, $biblionumber ); + $sth->execute( $shelfnumber, $itemnumber ); unless ( $sth->rows ) { # already on shelf my $query = qq( - INSERT INTO virtualshelfcontents - (shelfnumber, biblionumber, flags) + INSERT INTO shelfcontents + (shelfnumber, itemnumber, flags) VALUES (?, ?, 0) ); $sth = $dbh->prepare($query); - $sth->execute( $shelfnumber, $biblionumber ); + $sth->execute( $shelfnumber, $itemnumber ); } } @@ -267,7 +268,7 @@ sub AddToShelf { &AddToShelfFromBiblio($biblionumber, $shelfnumber) - this function allow to add a virtual into the shelf number $shelfnumber + this function allow to add a book into the shelf number $shelfnumber from biblionumber. =cut @@ -276,21 +277,30 @@ sub AddToShelfFromBiblio { my ( $biblionumber, $shelfnumber ) = @_; return unless $biblionumber; my $query = qq( - SELECT * - FROM virtualshelfcontents - WHERE shelfnumber=? AND biblionumber=? + SELECT itemnumber + FROM items + WHERE biblionumber=? ); my $sth = $dbh->prepare($query); - $sth->execute( $shelfnumber, $biblionumber ); + $sth->execute($biblionumber); + my ($itemnumber) = $sth->fetchrow; + $query = qq( + SELECT * + FROM shelfcontents + WHERE shelfnumber=? AND itemnumber=? + ); + $sth = $dbh->prepare($query); + $sth->execute( $shelfnumber, $itemnumber ); unless ( $sth->rows ) { + # "already on shelf"; my $query =qq( - INSERT INTO virtualshelfcontents - (shelfnumber, biblionumber, flags) + INSERT INTO shelfcontents + (shelfnumber, itemnumber, flags) VALUES (?, ?, 0) ); $sth = $dbh->prepare($query); - $sth->execute( $shelfnumber, $biblionumber ); + $sth->execute( $shelfnumber, $itemnumber ); } } @@ -298,14 +308,14 @@ sub AddToShelfFromBiblio { ModShelf($shelfnumber, $shelfname, $owner, $category ) -Modify the value into virtualshelves table with values given on input arg. +Modify the value into bookshelf table with values given on input arg. =cut sub ModShelf { my ( $shelfnumber, $shelfname, $owner, $category ) = @_; my $query = qq( - UPDATE virtualshelves + UPDATE bookshelf SET shelfname=?,owner=?,category=? WHERE shelfnumber=? ); @@ -317,7 +327,7 @@ sub ModShelf { ($status) = &DelShelf($shelfnumber); -Deletes virtual virtualshelves number C<$shelfnumber>. The virtualshelves must +Deletes virtual bookshelf number C<$shelfnumber>. The bookshelf must be empty. Returns a two-element array, where C<$status> is 0 if the operation @@ -344,7 +354,7 @@ sub ShelfPossibleAction { my ( $user, $shelfnumber, $action ) = @_; my $query = qq( SELECT owner,category - FROM virtualshelves + FROM bookshelf WHERE shelfnumber=? ); my $sth = $dbh->prepare($query); @@ -357,23 +367,23 @@ sub ShelfPossibleAction { =item DelFromShelf - &DelFromShelf( $biblionumber, $shelfnumber); + &DelFromShelf( $itemnumber, $shelfnumber); -Removes item number C<$biblionumber> from virtual virtualshelves number -C<$shelfnumber>. If the item wasn't on that virtualshelves to begin with, +Removes item number C<$itemnumber> from virtual bookshelf number +C<$shelfnumber>. If the item wasn't on that bookshelf to begin with, nothing happens. =cut #' sub DelFromShelf { - my ( $biblionumber, $shelfnumber ) = @_; + my ( $itemnumber, $shelfnumber ) = @_; my $query = qq( - DELETE FROM virtualshelfcontents - WHERE shelfnumber=? AND biblionumber=? + DELETE FROM shelfcontents + WHERE shelfnumber=? AND itemnumber=? ); my $sth = $dbh->prepare($query); - $sth->execute( $shelfnumber, $biblionumber ); + $sth->execute( $shelfnumber, $itemnumber ); } =head2 DelShelf @@ -387,7 +397,7 @@ sub DelFromShelf { #' sub DelShelf { my ( $shelfnumber ) = @_; - my $sth = $dbh->prepare("DELETE FROM virtualshelves WHERE shelfnumber=?"); + my $sth = $dbh->prepare("DELETE FROM bookshelf WHERE shelfnumber=?"); $sth->execute($shelfnumber); return 0; } @@ -409,3 +419,53 @@ Koha Developement team C4::Circulation::Circ2(3) =cut + +# +# $Log$ +# Revision 1.21 2007/04/04 16:46:22 tipaul +# HUGE COMMIT : code cleaning circulation. +# +# some stuff to do, i'll write a mail on koha-devel NOW ! +# +# Revision 1.20 2007/03/09 14:31:47 tipaul +# rel_3_0 moved to HEAD +# +# Revision 1.15.8.10 2007/01/25 13:18:15 tipaul +# checking that a bookshelf with the same name AND OWNER does not exist before creating it +# +# Revision 1.15.8.9 2006/12/15 17:37:52 toins +# removing a function used only once. +# +# 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. +# +# Revision 1.15.8.6 2006/12/11 17:10:06 toins +# fixing some bugs on bookshelves. +# +# Revision 1.15.8.5 2006/12/07 16:45:43 toins +# removing warn compilation. (perl -wc) +# +# Revision 1.15.8.4 2006/11/23 09:05:01 tipaul +# enable removal of a bookshelf even if there are items inside +# +# Revision 1.15.8.3 2006/10/30 09:50:20 tipaul +# removing getiteminformations (using direct SQL, as we are in a .pm, so it's "legal") +# +# Revision 1.15.8.2 2006/08/31 16:03:52 toins +# Add Pod to DelShelf +# +# Revision 1.15.8.1 2006/08/30 15:59:14 toins +# Code cleaned according to coding guide lines. +# +# Revision 1.15 2004/12/16 11:30:58 tipaul +# adding bookshelf features : +# * create bookshelf on the fly +# * modify a bookshelf name & status +# +# Revision 1.14 2004/12/15 17:28:23 tipaul +# adding bookshelf features : +# * create bookshelf on the fly +# * modify a bookshelf (this being not finished, will commit the rest soon) diff --git a/C4/Branch.pm b/C4/Branch.pm index 79d4d54a4b..4a540be3f4 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -91,7 +91,8 @@ foreach my $thisbranch (keys %$branches) { =cut sub GetBranches { - my ($onlymine)=@_; + + my $onlymine=@_; # returns a reference to a hash of references to ALL branches... my %branches; my $dbh = C4::Context->dbh; diff --git a/Makefile.PL b/Makefile.PL index bb5e56a8f3..611f8b70d1 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -86,7 +86,6 @@ WriteMakefile( PREREQ_PM => { 'CGI' => 3.15, 'CGI::Carp' => 1.29, -'CGI::Session' => '4.10', 'Class::Accessor' => 0.30, 'DBD::mysql' => 3.0008, 'DBI' => 1.53, diff --git a/virtualshelves/addbybiblionumber.pl b/bookshelves/addbookbybiblionumber.pl similarity index 60% rename from virtualshelves/addbybiblionumber.pl rename to bookshelves/addbookbybiblionumber.pl index 1ad57753d0..787a13b7fa 100755 --- a/virtualshelves/addbybiblionumber.pl +++ b/bookshelves/addbookbybiblionumber.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -#script to provide virtual shelf management +#script to provide bookshelf management # # # Copyright 2000-2002 Katipo Communications @@ -24,11 +24,11 @@ =head1 NAME - addbybiblionumber.pl + addbookbybiblionumber.pl =head1 DESCRIPTION - This script allow to add a virtual in a virtual shelf from a biblionumber. + This script allow to add a book in a virtual shelf from a biblionumber. =head1 CGI PARAMETERS @@ -40,9 +40,9 @@ =item shelfnumber - the shelfnumber where to add the virtual. + the shelfnumber where to add the book. -=item newvirtualshelf +=item newbookshelf if this parameter exists, then it must be equals to the name of the shelf to add. @@ -59,68 +59,63 @@ use strict; use C4::Biblio; use CGI; use C4::Output; -use C4::VirtualShelves; +use C4::BookShelves; use C4::Circulation; use C4::Auth; + #use it only to debug ! use CGI::Carp qw/fatalsToBrowser/; use warnings; -my $query = new CGI; -my $biblionumber = $query->param('biblionumber'); -my $shelfnumber = $query->param('shelfnumber'); -my $newvirtualshelf = $query->param('newvirtualshelf'); -my $category = $query->param('category'); - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "virtualshelves/addbybiblionumber.tmpl", - query => $query, - type => "intranet", - authnotrequired => 0, - flagsrequired => { catalogue => 1 }, - } -); - -$shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category ) - if $newvirtualshelf; -if ( $shelfnumber || ( $shelfnumber == -1 ) ) { # the shelf already exist. - &AddToShelfFromBiblio( $biblionumber, $shelfnumber ); - print -"Content-Type: text/html\n\n"; +my $query = new CGI; +my $biblionumber = $query->param('biblionumber'); +my $shelfnumber = $query->param('shelfnumber'); +my $newbookshelf = $query->param('newbookshelf'); +my $category = $query->param('category'); + +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bookshelves/addbookbybiblionumber.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + }); + +$shelfnumber = AddShelf($newbookshelf,$loggedinuser,$category) if $newbookshelf; + +if ($shelfnumber || ($shelfnumber == -1)) { # the shelf already exist. + &AddToShelfFromBiblio($biblionumber, $shelfnumber); + print "Content-Type: text/html\n\n"; exit; -} -else { # this shelf doesn't already exist. - my ( $bibliocount, @biblios ) = GetBiblio($biblionumber); +} else { # this shelf doesn't already exist. + my ( $bibliocount, @biblios ) = GetBiblio($biblionumber); - my ($shelflist) = GetShelves( $loggedinuser, 3 ); + my ($shelflist) = GetShelves($loggedinuser,3); my @shelvesloop; my %shelvesloop; - foreach my $element ( sort keys %$shelflist ) { - push( @shelvesloop, $element ); + foreach my $element (sort keys %$shelflist) { + push (@shelvesloop, $element); $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'}; } - my $CGIvirtualshelves = CGI::scrolling_list( - -name => 'shelfnumber', - -values => \@shelvesloop, - -labels => \%shelvesloop, - -size => 1, - -tabindex => '', - -multiple => 0 - ); + my $CGIbookshelves=CGI::scrolling_list( + -name => 'shelfnumber', + -values => \@shelvesloop, + -labels => \%shelvesloop, + -size => 1, + -tabindex=>'', + -multiple => 0 ); $template->param( - biblionumber => $biblionumber, - title => $biblios[0]->{'title'}, - author => $biblios[0]->{'author'}, - CGIvirtualshelves => $CGIvirtualshelves, - intranetcolorstylesheet => - C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), - ); + biblionumber => $biblionumber, + title => $biblios[0]->{'title'}, + author => $biblios[0]->{'author'}, + CGIbookshelves => $CGIbookshelves, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + ); output_html_with_http_headers $query, $cookie, $template->output; } @@ -153,7 +148,7 @@ else { # this shelf doesn't already exist. # theses scripts don't need to use C4::Search. # # Revision 1.4.2.3 2006/10/30 09:48:19 tipaul -# samll bugfix to create a virtualshelf correctly +# samll bugfix to create a bookshelf correctly # # Revision 1.4.2.2 2006/08/30 16:13:54 toins # correct an error in the "if condition". diff --git a/virtualshelves/shelves.pl b/bookshelves/shelves.pl similarity index 75% rename from virtualshelves/shelves.pl rename to bookshelves/shelves.pl index ad2dce6c33..4062e38b81 100755 --- a/virtualshelves/shelves.pl +++ b/bookshelves/shelves.pl @@ -24,7 +24,7 @@ =head1 DESCRIPTION - this script is used to script to provide virtualshelf management + this script is used to script to provide bookshelf management =head1 CGI PARAMETERS @@ -65,7 +65,7 @@ use strict; use CGI; -use C4::VirtualShelves; +use C4::BookShelves; use C4::Biblio; use C4::Auth; use C4::Output; @@ -74,7 +74,7 @@ my $query = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "virtualshelves/shelves.tmpl", + template_name => "bookshelves/shelves.tmpl", query => $query, type => "intranet", authnotrequired => 0, @@ -86,14 +86,12 @@ if ( $query->param('modifyshelfcontents') ) { my $shelfnumber = $query->param('viewshelf'); my $barcode = $query->param('addbarcode'); my ($item) = GetItem( 0, $barcode ); - my ($biblio) = GetBiblioFromItemNumber($item->{'itemnumber'}); - if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ) ) { - AddToShelf( $biblio->{'biblionumber'}, $shelfnumber ); + AddToShelf( $item->{'itemnumber'}, $shelfnumber ); foreach ( $query->param ) { if (/REM-(\d*)/) { - my $biblionumber = $1; - DelFromShelf( $biblionumber, $shelfnumber ); + my $itemnumber = $1; + DelFromShelf( $itemnumber, $shelfnumber ); } } } @@ -126,7 +124,6 @@ SWITCH: { last SWITCH; } if ( $query->param('viewshelf') ) { - #check that the user can view the shelf my $shelfnumber = $query->param('viewshelf'); if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) { @@ -135,9 +132,8 @@ SWITCH: { shelfname => $shelflist->{$shelfnumber}->{'shelfname'}, shelfnumber => $shelfnumber, viewshelf => $query->param('viewshelf'), - manageshelf => - &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ), - itemsloop => $items, + manageshelf => &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ), + itemsloop => $items, ); } last SWITCH; @@ -158,44 +154,47 @@ SWITCH: { } ); } - } - 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; - } + } + 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{'shelfvirtualcount'} = $shelflist->{$element}->{'count'}; - push( @shelvesloop, \%line ); - } - $template->param( - shelvesloop => \@shelvesloop, - shelves => 1, - ); + + #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; } } -my $shelflist = GetShelves( $loggedinuser, 2 ); +($shelflist) = + GetShelves( $loggedinuser, 2 ) + ; # rebuild shelflist in case a shelf has been added + my $color = ''; my @shelvesloop; my $numberCanManage = 0; @@ -206,22 +205,22 @@ foreach my $element ( sort keys %$shelflist ) { $line{'toggle'} = $color; $line{'shelf'} = $element; $line{'shelfname'} = $shelflist->{$element}->{'shelfname'}; - $line{"viewcategory$shelflist->{$element}->{'category'}"} = 1; + $line{ "category" . $shelflist->{$element}->{'category'} } = 1; $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser; - $line{'shelfvirtualcount'} = $shelflist->{$element}->{'count'}; - $line{'canmanage'} = - ShelfPossibleAction( $loggedinuser, $element, 'manage' ); + $line{'shelfbookcount'} = $shelflist->{$element}->{'count'}; + $line{'canmanage'} = ShelfPossibleAction( $loggedinuser, $element, 'manage' ); $line{'firstname'} = $shelflist->{$element}->{'firstname'} - unless $shelflist->{$element}->{'owner'} eq $loggedinuser; + unless $shelflist->{$element}->{'owner'} eq $loggedinuser; $line{'surname'} = $shelflist->{$element}->{'surname'} - unless $shelflist->{$element}->{'owner'} eq $loggedinuser; + unless $shelflist->{$element}->{'owner'} eq $loggedinuser; + $numberCanManage++ if $line{'canmanage'}; - push( @shelvesloop, \%line ); + + push( @shelvesloop, \%line ); } $template->param( shelvesloop => \@shelvesloop, - numberCanManage => $numberCanManage, ); @@ -267,10 +266,10 @@ sub shelves { 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{'shelfvirtualcount'} = $shelflist->{$element}->{'count'}; + $line{'toggle'} = $color; + $line{'shelf'} = $element; + $line{'shelfname'} = $shelflist->{$element}->{'shelfname'}; + $line{'shelfbookcount'} = $shelflist->{$element}->{'count'}; push( @shelvesloop, \%line ); } $innertemplate->param( @@ -305,13 +304,13 @@ sub shelves { # - adding syspref: BiblioDefaultView. # # Revision 1.9.2.7 2006/12/14 17:22:55 toins -# virtualshelves work perfectly with mod_perl and are cleaned. +# 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. # # Revision 1.9.2.5 2006/12/11 17:10:06 toins -# fixing some bugs on virtualshelves. +# fixing some bugs on bookshelves. # # Revision 1.9.2.4 2006/11/30 18:23:51 toins # theses scripts don't need to use C4::Search. diff --git a/help.pl b/help.pl index 7c0743df09..0a76f6eb17 100755 --- a/help.pl +++ b/help.pl @@ -1,8 +1,27 @@ #!/usr/bin/perl -use HTML::Template; + +# Copyright 2006 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + use strict; require Exporter; -use C4::Output; # contains gettemplate +use C4::Output; # contains gettemplate +use C4::Output; + # use C4::Auth; use C4::Context; use CGI; @@ -10,45 +29,46 @@ use CGI; my $query = new CGI; # find the script that called the online help using the CGI referer() -my $refer = $query->referer(); + +my $refer = $query->referer(); + # workaround for popup not functioning correctly in IE my $referurl = $query->param('url'); -if($referurl){ +if ($referurl) { $refer = $query->param('url'); } $refer =~ /.*koha\/(.*)\.pl.*/; my $from = "help/$1.tmpl"; -my $template = gethelptemplate($from,"intranet"); +my $template = gethelptemplate( $from, "intranet" ); + # my $template output_html_with_http_headers $query, "", $template->output; - sub gethelptemplate { - my ($tmplbase) = @_; - - my $htdocs; - $htdocs = C4::Context->config('intrahtdocs'); - my ($theme, $lang) = themelanguage($htdocs, $tmplbase, "intranet"); - unless (-e "$htdocs/$theme/$lang/$tmplbase") { - $tmplbase="help/nohelp.tmpl"; - ($theme, $lang) = themelanguage($htdocs, $tmplbase, "intranet"); - } - my $template = HTML::Template->new(filename => "$htdocs/$theme/$lang/$tmplbase", - die_on_bad_params => 0, - global_vars => 1, - path => ["$htdocs/$theme/$lang/includes"]); - - # XXX temporary patch for Bug 182 for themelang - $template->param(themelang => '/intranet-tmpl' . "/$theme/$lang", - interface => '/intranet-tmpl', - theme => $theme, - lang => $lang, - intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - IntranetNav => C4::Context->preference("IntranetNav"), - referer => $refer, - ); - return $template; + my ($tmplbase) = @_; + + my $htdocs; + $htdocs = C4::Context->config('intrahtdocs'); + my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, "intranet" ); + unless ( -e "$htdocs/$theme/$lang/$tmplbase" ) { + $tmplbase = "help/nohelp.tmpl"; + ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, "intranet" ); + } + my $template = HTML::Template->new( + filename => "$htdocs/$theme/$lang/$tmplbase", + die_on_bad_params => 0, + global_vars => 1, + path => ["$htdocs/$theme/$lang/includes"] + ); + + # XXX temporary patch for Bug 182 for themelang + $template->param( + themelang => '/intranet-tmpl' . "/$theme/$lang", + interface => '/intranet-tmpl', + theme => $theme, + lang => $lang + ); + return $template; } diff --git a/installer/kohastructure.sql b/installer/kohastructure.sql index adbd4c7a31..144e7d5bb9 100644 --- a/installer/kohastructure.sql +++ b/installer/kohastructure.sql @@ -447,11 +447,11 @@ CREATE TABLE `biblioitems` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- --- Table structure for table `virtualshelves` +-- Table structure for table `bookshelf` -- -DROP TABLE IF EXISTS `virtualshelves`; -CREATE TABLE `virtualshelves` ( +DROP TABLE IF EXISTS `bookshelf`; +CREATE TABLE `bookshelf` ( `shelfnumber` int(11) NOT NULL auto_increment, `shelfname` char(255) default NULL, `owner` char(80) default NULL, @@ -1382,19 +1382,19 @@ CREATE TABLE sessions ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- --- Table structure for table `virtualshelfcontents` +-- Table structure for table `shelfcontents` -- -DROP TABLE IF EXISTS `virtualshelfcontents`; -CREATE TABLE `virtualshelfcontents` ( +DROP TABLE IF EXISTS `shelfcontents`; +CREATE TABLE `shelfcontents` ( `shelfnumber` int(11) NOT NULL default '0', - `biblionumber` int(11) NOT NULL default '0', + `itemnumber` int(11) NOT NULL default '0', `flags` int(11) default NULL, `dateadded` timestamp NULL default NULL, KEY `shelfnumber` (`shelfnumber`), - KEY `biblionumber` (`biblionumber`), - CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE + KEY `itemnumber` (`itemnumber`), + CONSTRAINT `shelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `bookshelf` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/koha-tmpl/intranet-tmpl/prog/en/about.tmpl b/koha-tmpl/intranet-tmpl/prog/en/about.tmpl index d0a53a5799..ff0642972b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/about.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/about.tmpl @@ -5,7 +5,7 @@
-

About Koha

+

Data about the current version of Koha for bug reports (or general interest).

diff --git a/koha-tmpl/intranet-tmpl/prog/en/auth.tmpl b/koha-tmpl/intranet-tmpl/prog/en/auth.tmpl index 69c6c4b511..b91d737dfe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/auth.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/auth.tmpl @@ -43,17 +43,10 @@

-

-

- - -

+

+
Server information