[Koha-cvs] koha/C4 Koha.pm [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Thu Nov 2 11:12:09 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/11/02 10:12:09

Modified files:
	C4             : Koha.pm 

Log message:
	reintroduce the good GetBranches function.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Koha.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.40.2.18&r2=1.40.2.19

Patches:
Index: Koha.pm
===================================================================
RCS file: /sources/koha/koha/C4/Koha.pm,v
retrieving revision 1.40.2.18
retrieving revision 1.40.2.19
diff -u -b -r1.40.2.18 -r1.40.2.19
--- Koha.pm	31 Oct 2006 17:21:58 -0000	1.40.2.18
+++ Koha.pm	2 Nov 2006 10:12:09 -0000	1.40.2.19
@@ -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.2.18 2006/10/31 17:21:58 toins Exp $
+# $Id: Koha.pm,v 1.40.2.19 2006/11/02 10:12:09 toins Exp $
 
 use strict;
 require Exporter;
@@ -25,7 +25,7 @@
 use C4::Output;
 use vars qw($VERSION @ISA @EXPORT);
 
-$VERSION = do { my @v = '$Revision: 1.40.2.18 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
+$VERSION = do { my @v = '$Revision: 1.40.2.19 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
 
@@ -139,16 +139,15 @@
 =head2 GetBranches
 
   $branches = &GetBranches();
-  returns informations about branches.
+  returns informations about ALL branches.
   Create a branch selector with the following code
-  Is branchIndependant sensitive
-   When IndependantBranches is set AND user is not superlibrarian, displays only user's branch
+  IndependantBranches Insensitive...
   
 =head3 in PERL SCRIPT
 
 my $branches = GetBranches;
 my @branchloop;
-foreach my $thisbranch (sort keys %$branches) {
+foreach my $thisbranch (keys %$branches) {
     my $selected = 1 if $thisbranch eq $branch;
     my %row =(value => $thisbranch,
                 selected => $selected,
@@ -168,30 +167,17 @@
 
 =cut
 
+
 sub GetBranches {
-# returns a reference to a hash of references to branches...
-    my ($type) = @_;
+# returns a reference to a hash of references to ALL branches...
     my %branches;
-    my $branch;
     my $dbh = C4::Context->dbh;
     my $sth;
-    if (C4::Context->preference("IndependantBranches") && (C4::Context->userenv->{flags}!=1)){
-        my $strsth ="Select * from branches ";
-        $strsth.= " WHERE branchcode = ".$dbh->quote(C4::Context->userenv->{branch});
-        $strsth.= " order by branchname";
-        $sth=$dbh->prepare($strsth);
-    } else {
         $sth = $dbh->prepare("Select * from branches order by branchname");
-    }
     $sth->execute;
-    while ($branch=$sth->fetchrow_hashref) {
+    while (my $branch=$sth->fetchrow_hashref) {
         my $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ?");
-            if ($type){
-            $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ? and categorycode = ?");
-            $nsth->execute($branch->{'branchcode'},$type);
-        } else {
             $nsth->execute($branch->{'branchcode'});
-        }
         while (my ($cat) = $nsth->fetchrow_array) {
             # FIXME - This seems wrong. It ought to be
             # $branch->{categorycodes}{$cat} = 1;
@@ -204,14 +190,8 @@
             # that aren't fields in the "branches" table.
             $branch->{$cat} = 1;
             }
-                if ($type) {
                     $branches{$branch->{'branchcode'}}=$branch;
                 }
-            }
-                if (!$type){
-            $branches{$branch->{'branchcode'}}=$branch;
-        }
-
     return (\%branches);
 }
 





More information about the Koha-cvs mailing list