Bug 29541: Prevent users from another group to access patron's images
[srvgit] / labels / label-item-search.pl
index 57f3ff3..161fca4 100755 (executable)
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
-use vars qw($debug $cgi_debug);
 
 use CGI qw ( -utf8 );
-use List::Util qw( max min );
-use POSIX qw(ceil);
+use POSIX qw( ceil );
 
-use C4::Auth qw(get_template_and_user);
-use C4::Output qw(output_html_with_http_headers);
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
 use C4::Context;
-use C4::Search qw(SimpleSearch);
-use C4::Biblio qw(TransformMarcToKoha);
-use C4::Creators::Lib qw(html_table);
-use C4::Debug;
+use C4::Search qw( new_record_from_zebra );
+use C4::Biblio qw( TransformMarcToKoha );
+use C4::Creators::Lib qw( html_table );
 
-use Koha::DateUtils;
+use Koha::Logger;
+use Koha::DateUtils qw( dt_from_string output_pref );
 use Koha::Items;
 use Koha::ItemTypes;
 use Koha::SearchEngine::Search;
 
-BEGIN {
-    $debug = $debug || $cgi_debug;
-    if ($debug) {
-        require Data::Dumper;
-        import Data::Dumper qw(Dumper);
-    }
-}
-
-my $query = new CGI;
+my $query = CGI->new;
 
 my $type      = $query->param('type');
 my $op        = $query->param('op') || '';
@@ -67,8 +57,6 @@ my $display_columns = [ {_add                   => {label => "Add Item", link_fi
                       ];
 
 if ( $op eq "do_search" ) {
-    my $QParser;
-    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
     $idx         = $query->param('idx');
     $ccl_textbox = $query->param('ccl_textbox');
     if ( $ccl_textbox && $idx ) {
@@ -82,14 +70,8 @@ if ( $op eq "do_search" ) {
         $datefrom = eval { dt_from_string ( $datefrom ) };
         if ($datefrom) {
             $datefrom = output_pref( { dt => $datefrom, dateonly => 1, dateformat => 'iso' } );
-            if ($QParser) {
-                $ccl_query .= ' && ' if $ccl_textbox;
-                $ccl_query .=
-                    "acqdate(" . $datefrom . '-)';
-            } else {
-                $ccl_query .= ' and ' if $ccl_textbox;
-                $ccl_query .= "acqdate,st-date-normalized,ge=" . $datefrom;
-            }
+            $ccl_query .= ' and ' if $ccl_textbox;
+            $ccl_query .= "acqdate,ge,st-date-normalized=" . $datefrom;
         }
     }
 
@@ -97,13 +79,8 @@ if ( $op eq "do_search" ) {
         $dateto = eval { dt_from_string ( $dateto ) };
         if ($dateto) {
            $dateto = output_pref( { dt => $dateto, dateonly => 1, dateformat => 'iso' } );
-            if ($QParser) {
-                $ccl_query .= ' && ' if ( $ccl_textbox || $datefrom );
-                $ccl_query .= "acqdate(-" . $dateto . ')';
-            } else {
-                $ccl_query .= ' and ' if ( $ccl_textbox || $datefrom );
-                $ccl_query .= "acqdate,st-date-normalized,le=" . $dateto;
-            }
+            $ccl_query .= ' and ' if ( $ccl_textbox || $datefrom );
+            $ccl_query .= "acqdate,le,st-date-normalized=" . $dateto;
         }
     }
 
@@ -115,7 +92,7 @@ if ( $op eq "do_search" ) {
         $show_results = @{$marcresults};
     }
     else {
-        $debug and warn "ERROR label-item-search: no results from simple_search_compat";
+        Koha::Logger->get->warn("ERROR label-item-search: no results from simple_search_compat");
 
         # leave $show_results undef
     }
@@ -159,10 +136,8 @@ if ($show_results) {
             template_name   => "labels/result.tt",
             query           => $query,
             type            => "intranet",
-            authnotrequired => 0,
             flagsrequired   => { borrowers => 'edit_borrowers' },
             flagsrequired   => { catalogue => 1 },
-            debug           => 1,
         }
     );
 
@@ -239,9 +214,7 @@ else {
             template_name   => "labels/search.tt",
             query           => $query,
             type            => "intranet",
-            authnotrequired => 0,
             flagsrequired   => { catalogue => 1 },
-            debug           => 1,
         }
     );
     my $itemtypes = Koha::ItemTypes->search;