[Koha-cvs] koha C4/Koha.pm C4/Members.pm opac/opac-main.pl [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Tue Aug 29 09:27:13 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/08/29 07:27:13

Modified files:
	C4             : Koha.pm Members.pm 
	opac           : opac-main.pl 

Log message:
	opac-main.pl: code cleaned. some unused code has been deleted.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Koha.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.40&r2=1.40.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Members.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.32&r2=1.32.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-main.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.23&r2=1.23.2.1

Patches:
Index: C4/Koha.pm
===================================================================
RCS file: /sources/koha/koha/C4/Koha.pm,v
retrieving revision 1.40
retrieving revision 1.40.2.1
diff -u -b -r1.40 -r1.40.2.1
--- C4/Koha.pm	10 Aug 2006 12:54:45 -0000	1.40
+++ C4/Koha.pm	29 Aug 2006 07:27:13 -0000	1.40.2.1
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Koha.pm,v 1.40 2006/08/10 12:54:45 toins Exp $
+# $Id: Koha.pm,v 1.40.2.1 2006/08/29 07:27:13 toins Exp $
 
 use strict;
 require Exporter;
@@ -25,7 +25,7 @@
 
 use vars qw($VERSION @ISA @EXPORT);
 
-$VERSION = do { my @v = '$Revision: 1.40 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
+$VERSION = do { my @v = '$Revision: 1.40.2.1 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
 
@@ -55,8 +55,8 @@
                         get_itemtypeinfos_of
             &getframeworks &getframeworkinfo
             &getauthtypes &getauthtype
-            &getallthemes &getalllanguages
-            &getallbranches &getletters
+            &getallthemes &GetLanguages
+            &GetBranches &getletters
             &getbranchname
                         getnbpages
                         getitemtypeimagedir
@@ -175,16 +175,16 @@
     return($branchname);
 }
 
-=head2 getallbranches
+=head2 GetBranches
 
-  $branches = &getallbranches();
+  $branches = &GetBranches();
   returns informations about ALL branches.
   Create a branch selector with the following code
   IndependantBranches Insensitive...
   
 =head3 in PERL SCRIPT
 
-my $branches = getallbranches;
+my $branches = GetBranches;
 my @branchloop;
 foreach my $thisbranch (keys %$branches) {
     my $selected = 1 if $thisbranch eq $branch;
@@ -207,7 +207,7 @@
 =cut
 
 
-sub getallbranches {
+sub GetBranches {
 # returns a reference to a hash of references to ALL branches...
     my %branches;
     my $dbh = C4::Context->dbh;
@@ -339,7 +339,6 @@
     return (\%itemtypes);
 }
 
-# FIXME this function is better and should replace GetItemTypes everywhere
 sub get_itemtypeinfos_of {
     my @itemtypes = @_;
 
@@ -594,16 +593,16 @@
     return $printer;
 }
 
-=item getalllanguages
+=item GetLanguages
 
-  (@languages) = &getalllanguages($type);
-  (@languages) = &getalllanguages($type,$theme);
+  (@languages) = &GetLanguages($type);
+  (@languages) = &GetLanguages($type,$theme);
 
 Returns an array of all available languages.
 
 =cut
 
-sub getalllanguages {
+sub GetLanguages {
     my $type=shift;
     my $theme=shift;
     my $htdocs;
@@ -620,6 +619,7 @@
                 next if $language=~ /CVS$/;
                 next if $language=~ /itemtypeimg$/;
 		next if $language=~ /\.txt$/i; #Don't read the readme.txt !
+		        next if $language eq 'images';
                 push @languages, $language;
             }
             return sort @languages;
@@ -635,6 +635,7 @@
                     next if $language=~ /CVS$/;
                     next if $language=~ /itemtypeimg$/;
 		    next if $language=~ /\.txt$/i; #Don't read the readme.txt !
+		            next if $language eq 'images';
                     $lang->{$language}=1;
                 }
             }
@@ -653,6 +654,7 @@
                 next if $language=~ /CVS$/;
                 next if $language=~ /itemtypeimg$/;
                 next if $language=~ /\.txt$/i; #Don't read the readme.txt !
+                next if $language eq 'images';
                 push @languages, $language;
             }
             return sort @languages;
@@ -668,6 +670,7 @@
                     next if $language=~ /CVS$/;
                     next if $language=~ /itemtypeimg$/;
 		    next if $language=~ /\.txt$/i; #Don't read the readme.txt !
+		            next if $language eq 'images';
                     $lang->{$language}=1;
                 }
             }
@@ -687,6 +690,7 @@
                 next if $language=~ /CVS$/;
                 next if $language=~ /itemtypeimg$/;
 		next if $language=~ /\.txt$/i; #Don't read the readme.txt !
+		        next if $language eq 'images';
                 $lang->{$language}=1;
             }
         }
@@ -701,6 +705,7 @@
             next if $language=~ /CVS$/;
             next if $language=~ /itemtypeimg$/;
 	    next if $language=~ /\.txt$/i; #Don't read the readme.txt !
+	        next if $language eq 'images';
             $lang->{$language}=1;
             }
         }

Index: C4/Members.pm
===================================================================
RCS file: /sources/koha/koha/C4/Members.pm,v
retrieving revision 1.32
retrieving revision 1.32.2.1
diff -u -b -r1.32 -r1.32.2.1
--- C4/Members.pm	27 Jul 2006 13:48:02 -0000	1.32
+++ C4/Members.pm	29 Aug 2006 07:27:13 -0000	1.32.2.1
@@ -19,7 +19,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Members.pm,v 1.32 2006/07/27 13:48:02 toins Exp $
+# $Id: Members.pm,v 1.32.2.1 2006/08/29 07:27:13 toins Exp $
 
 use strict;
 require Exporter;
@@ -31,7 +31,7 @@
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
 
-$VERSION = do { my @v = '$Revision: 1.32 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.32.2.1 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -56,7 +56,7 @@
 @ISA    = qw(Exporter);
 
 @EXPORT = qw(
- &BornameSearch &getmember &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch &NewBorrowerNumber   &modmember &newmember &changepassword &borrissues &allissues
+ &BornameSearch &GetMember &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch &NewBorrowerNumber   &modmember &newmember &changepassword &borrissues &allissues
   &checkuniquemember &getzipnamecity &getidcity &getguarantordata &getcategorytype
   &calcexpirydate &checkuserpassword
   &getboracctrecord
@@ -153,19 +153,6 @@
     return ( $cnt, \@results );
 }
 
-=item getmember
-
-  $borrower = &getmember($cardnumber, $borrowernumber);
-
-Looks up information about a patron (borrower) by either card number
-or borrower number. If $borrowernumber is specified, C<&borrdata>
-searches by borrower number; otherwise, it searches by card number.
-
-C<&getmember> returns a reference-to-hash whose keys are the fields of
-the C<borrowers> table in the Koha database.
-
-=cut
-
 =head3 GetFlagsAndBranchFromBorrower
 
 =over 4
@@ -197,8 +184,20 @@
 }
 
 
-#'
-sub getmember {
+=item GetMember
+
+  $borrower = &GetMember($cardnumber, $borrowernumber);
+
+Looks up information about a patron (borrower) by either card number
+or borrower number. If $borrowernumber is specified, C<&borrdata>
+searches by borrower number; otherwise, it searches by card number.
+
+C<&GetMember> returns a reference-to-hash whose keys are the fields of
+the C<borrowers> table in the Koha database.
+
+=cut
+
+sub GetMember {
     my ( $cardnumber, $bornum ) = @_;
     $cardnumber = uc $cardnumber;
     my $dbh = C4::Context->dbh;

Index: opac/opac-main.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-main.pl,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -u -b -r1.23 -r1.23.2.1
--- opac/opac-main.pl	4 Jul 2006 14:36:52 -0000	1.23
+++ opac/opac-main.pl	29 Aug 2006 07:27:13 -0000	1.23.2.1
@@ -1,10 +1,24 @@
 #!/usr/bin/perl
+
+# 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 CGI;
 use HTML::Template;
-
-use C4::Context;
 use C4::Auth;       # get_template_and_user
 use C4::Interface::CGI::Output;
 use C4::BookShelves;
@@ -12,25 +26,12 @@
 use C4::Members;
 
 my $input = new CGI;
-my $kohaVersion = C4::Context->config("kohaversion");
 my $dbh = C4::Context->dbh;
-my $query="Select itemtype,description from itemtypes order by description";
-my $sth=$dbh->prepare($query);
-$sth->execute;
-my  @itemtypeloop;
-my %itemtypes;
-while (my ($value,$lib) = $sth->fetchrow_array) {
-	my %row =(	value => $value,
-				description => $lib,
-			);
-	push @itemtypeloop, \%row;
-}
-$sth->finish;
 
 my @branches;
 my @select_branch;
 my %select_branches;
-my $branches = getallbranches();
+my $branches = GetBranches();
 my @branchloop;
 foreach my $thisbranch (keys %$branches) {
         my $selected = 1 if (C4::Context->userenv && ($thisbranch eq C4::Context->userenv->{branch}));
@@ -40,7 +41,6 @@
                         );
         push @branchloop, \%row;
 }
-
 my ($template, $borrowernumber, $cookie)
     = get_template_and_user({template_name => "opac-main.tmpl",
 			     type => "opac",
@@ -48,50 +48,24 @@
 			     authnotrequired => 1,
 			     flagsrequired => {borrow => 1},
 			 });
-my $borrower = getmember('',$borrowernumber);
+
+my $borrower = GetMember('',$borrowernumber);
 my @options;
 my $counter=0;
-foreach my $language (getalllanguages()) {
-	next if $language eq 'images';
-	next if $language eq 'CVS';
-	next if $language=~ /png$/;
-	next if $language=~ /css$/;
+foreach my $language (GetLanguages()) {
 	my $selected='0';
 #                            next if $currently_selected_languages->{$language};
 	push @options, { language => $language, counter => $counter };
 	$counter++;
 }
-my $languages_count = @options;
-if($languages_count > 1){
-		$template->param(languages => \@options);
-}
 
-my $branchinfo = getbranchinfo();
-my @loop_data =();
-foreach my $branch (@$branchinfo) {
-        my %row =();
-        $row{'branch_name'} = $branch->{'branchname'};
-        $row{'branch_hours'} = $branch->{'branchhours'};
-        $row{'branch_hours'} =~ s^\n^<br />^g;
-        push (@loop_data, \%row);
-    }
-
-sub getbranchinfo {
-        my $dbh = C4::Context->dbh;
-        my $sth;
-        $sth = $dbh->prepare("Select * from branches order by branchcode");
-        $sth->execute();
-    
-        my @results;
-        while(my $data = $sth->fetchrow_hashref) {
-	            push(@results, $data);
-	        }
-        $sth->finish;
-        return \@results;
+# Template params
+if( (scalar @options) > 1){
+		$template->param(languages => \@options);
 }
-
-
-$template->param(		suggestion => C4::Context->preference("suggestion"),
+$template->param(
+				branchloop=>\@branchloop,
+				suggestion => C4::Context->preference("suggestion"),
 				virtualshelves => C4::Context->preference("virtualshelves"),
 				textmessaging => $borrower->{textmessaging},
 				opaclargeimage => C4::Context->preference("opaclargeimage"),
@@ -103,9 +77,8 @@
 				opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
 				opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
 				opaclanguagesdisplay => C4::Context->preference("opaclanguagesdisplay"),
-                                branches => \@loop_data,
-);
 
+);
 $template->param('Disable_Dictionary'=>C4::Context->preference("Disable_Dictionary")) if (C4::Context->preference("Disable_Dictionary"));
 
 output_html_with_http_headers $input, $cookie, $template->output;





More information about the Koha-cvs mailing list