Bug 11371 - Add a new report : Orders by fund with more options
[koha.git] / C4 / Koha.pm
index 6e8ba35..7fe07f1 100644 (file)
@@ -32,14 +32,12 @@ use DateTime::Format::MySQL;
 use Business::ISBN;
 use autouse 'Data::cselectall_arrayref' => qw(Dumper);
 use DBI qw(:sql_types);
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
+use vars qw(@ISA @EXPORT @EXPORT_OK $DEBUG);
 
 BEGIN {
-    $VERSION = 3.07.00.049;
        require Exporter;
        @ISA    = qw(Exporter);
        @EXPORT = qw(
-               &subfield_is_koha_internal_p
                &GetPrinters &GetPrinter
                &GetItemTypes &getitemtypeinfo
                 &GetItemTypesCategorized &GetItemTypesByCategory
@@ -48,7 +46,6 @@ BEGIN {
         &GetFrameworksLoop
                &getallthemes
                &getFacets
-               &displayServers
                &getnbpages
                &get_infos_of
                &get_notforloan_label_of
@@ -57,7 +54,6 @@ BEGIN {
                &getitemtypeimagelocation
                &GetAuthorisedValues
                &GetAuthorisedValueCategories
-                &IsAuthorisedValueCategory
                &GetKohaAuthorisedValues
                &GetKohaAuthorisedValuesFromField
     &GetKohaAuthorisedValuesMapping
@@ -96,17 +92,6 @@ Koha.pm provides many functions for Koha scripts.
 
 =cut
 
-# FIXME.. this should be moved to a MARC-specific module
-sub subfield_is_koha_internal_p {
-    my ($subfield) = @_;
-
-    # We could match on 'lib' and 'tab' (and 'mandatory', & more to come!)
-    # But real MARC subfields are always single-character
-    # so it really is safer just to check the length
-
-    return length $subfield != 1;
-}
-
 =head2 GetSupportName
 
   $itemtypename = &GetSupportName($codestring);
@@ -757,8 +742,7 @@ sub getFacets {
             }
             ];
 
-            unless ( C4::Context->preference("singleBranchMode")
-                || Koha::Libraries->search->count == 1 )
+            unless ( Koha::Libraries->search->count == 1 )
             {
                 my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets');
                 if (   $DisplayLibraryFacets eq 'both'
@@ -839,8 +823,7 @@ sub getFacets {
             },
             ];
 
-            unless ( C4::Context->preference("singleBranchMode")
-                || Koha::Libraries->search->count == 1 )
+            unless ( Koha::Libraries->search->count == 1 )
             {
                 my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets');
                 if (   $DisplayLibraryFacets eq 'both'
@@ -973,73 +956,6 @@ SELECT lib,
     return \%notforloan_label_of;
 }
 
-=head2 displayServers
-
-   my $servers = displayServers();
-   my $servers = displayServers( $position );
-   my $servers = displayServers( $position, $type );
-
-displayServers returns a listref of hashrefs, each containing
-information about available z3950 servers. Each hashref has a format
-like:
-
-    {
-      'checked'    => 'checked',
-      'encoding'   => 'utf8',
-      'icon'       => undef,
-      'id'         => 'LIBRARY OF CONGRESS',
-      'label'      => '',
-      'name'       => 'server',
-      'opensearch' => '',
-      'value'      => 'lx2.loc.gov:210/',
-      'zed'        => 1,
-    },
-
-=cut
-
-sub displayServers {
-    my ( $position, $type ) = @_;
-    my $dbh = C4::Context->dbh;
-
-    my $strsth = 'SELECT * FROM z3950servers';
-    my @where_clauses;
-    my @bind_params;
-
-    if ($position) {
-        push @bind_params,   $position;
-        push @where_clauses, ' position = ? ';
-    }
-
-    if ($type) {
-        push @bind_params,   $type;
-        push @where_clauses, ' type = ? ';
-    }
-
-    # reassemble where clause from where clause pieces
-    if (@where_clauses) {
-        $strsth .= ' WHERE ' . join( ' AND ', @where_clauses );
-    }
-
-    my $rq = $dbh->prepare($strsth);
-    $rq->execute(@bind_params);
-    my @primaryserverloop;
-
-    while ( my $data = $rq->fetchrow_hashref ) {
-        push @primaryserverloop,
-          { label    => $data->{description},
-            id       => $data->{name},
-            name     => "server",
-            value    => $data->{host} . ":" . $data->{port} . "/" . $data->{database},
-            encoding => ( $data->{encoding} ? $data->{encoding} : "iso-5426" ),
-            checked  => "checked",
-            icon     => $data->{icon},
-            zed        => $data->{type} eq 'zed',
-            opensearch => $data->{type} eq 'opensearch'
-          };
-    }
-    return \@primaryserverloop;
-}
-
 =head2 GetAuthValCode
 
   $authvalcode = GetAuthValCode($kohafield,$frameworkcode);
@@ -1082,35 +998,25 @@ sub GetAuthValCodeFromField {
 
 =head2 GetAuthorisedValues
 
-  $authvalues = GetAuthorisedValues([$category], [$selected]);
+  $authvalues = GetAuthorisedValues([$category]);
 
 This function returns all authorised values from the'authorised_value' table in a reference to array of hashrefs.
 
 C<$category> returns authorised values for just one category (optional).
 
-C<$selected> adds a "selected => 1" entry to the hash if the
-authorised_value matches it. B<NOTE:> this feature should be considered
-deprecated as it may be removed in the future.
-
 C<$opac> If set to a true value, displays OPAC descriptions rather than normal ones when they exist.
 
 =cut
 
 sub GetAuthorisedValues {
-    my ( $category, $selected, $opac ) = @_;
-
-    # TODO: the "selected" feature should be replaced by a utility function
-    # somewhere else, it doesn't belong in here. For starters it makes
-    # caching much more complicated. Or just let the UI logic handle it, it's
-    # what it's for.
+    my ( $category, $opac ) = @_;
 
     # Is this cached already?
     $opac = $opac ? 1 : 0;    # normalise to be safe
     my $branch_limit =
       C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
-    my $selected_key = defined($selected) ? $selected : '';
     my $cache_key =
-      "AuthorisedValues-$category-$selected_key-$opac-$branch_limit";
+      "AuthorisedValues-$category-$opac-$branch_limit";
     my $cache  = Koha::Cache->get_instance();
     my $result = $cache->get_from_cache($cache_key);
     return $result if $result;
@@ -1147,13 +1053,6 @@ sub GetAuthorisedValues {
 
     $sth->execute( @where_args );
     while (my $data=$sth->fetchrow_hashref) {
-        if ( defined $selected and $selected eq $data->{authorised_value} ) {
-            $data->{selected} = 1;
-        }
-        else {
-            $data->{selected} = 0;
-        }
-
         if ($opac && $data->{lib_opac}) {
             $data->{lib} = $data->{lib_opac};
         }
@@ -1161,9 +1060,6 @@ sub GetAuthorisedValues {
     }
     $sth->finish;
 
-    # We can't cache for long because of that "selected" thing which
-    # makes it impossible to clear the cache without iterating through every
-    # value, which sucks. This'll cover this request, and not a whole lot more.
     $cache->set_in_cache( $cache_key, \@results, { deepcopy => 1, expiry => 5 } );
     return \@results;
 }
@@ -1188,28 +1084,6 @@ sub GetAuthorisedValueCategories {
     return \@results;
 }
 
-=head2 IsAuthorisedValueCategory
-
-    $is_auth_val_category = IsAuthorisedValueCategory($category);
-
-Returns whether a given category name is a valid one
-
-=cut
-
-sub IsAuthorisedValueCategory {
-    my $category = shift;
-    my $query = '
-        SELECT category
-        FROM authorised_values
-        WHERE category=?
-        LIMIT 1
-    ';
-    my $sth = C4::Context->dbh->prepare($query);
-    $sth->execute($category);
-    $sth->fetchrow ? return 1
-                   : return 0;
-}
-
 =head2 GetAuthorisedValueByCode
 
 $authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac );