Bug 8377 [ENH] Show HTML5 video/ audio for media files in OPAC and staff client
[koha_fer] / C4 / Search.pm
index 7c20780..1e850d9 100644 (file)
@@ -532,9 +532,9 @@ sub getRecords {
                             || ( $facets_info->{$link_value}->{'expanded'} ) )
                         {
 
-                      # Sanitize the link value ), ( will cause errors with CCL,
+                      # Sanitize the link value : parenthesis, question and exclamation mark will cause errors with CCL
                             my $facet_link_value = $one_facet;
-                            $facet_link_value =~ s/(\(|\))/ /g;
+                            $facet_link_value =~ s/[()!?¡¿؟]/ /g;
 
                             # fix the length that will display in the label,
                             my $facet_label_value = $one_facet;
@@ -1799,7 +1799,7 @@ sub searchResults {
             else {
 
                 # item is on order
-                if ( $item->{notforloan} == -1 ) {
+                if ( $item->{notforloan} < 0 ) {
                     $ordered_count++;
                 }
 
@@ -1837,7 +1837,7 @@ sub searchResults {
                 if (   $item->{wthdrawn}
                     || $item->{itemlost}
                     || $item->{damaged}
-                    || $item->{notforloan} > 0
+                    || $item->{notforloan}
                    || $reservestatus eq 'Waiting'
                     || ($transfertwhen ne ''))
                 {
@@ -1849,13 +1849,23 @@ sub searchResults {
                     $item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan};
 
                     # can place hold on item ?
-                    if ((!$item->{damaged} || C4::Context->preference('AllowHoldsOnDamagedItems'))
-                      && !$item->{itemlost}
-                      && !$item->{withdrawn}
-                    ) {
-                        $can_place_holds = 1;
+                    if ( !$item->{itemlost} ) {
+                        if ( !$item->{wthdrawn} ){
+                            if ( $item->{damaged} ){
+                                if ( C4::Context->preference('AllowHoldsOnDamagedItems') ){
+                                    # can place a hold on a damaged item if AllowHoldsOnDamagedItems is true
+                                    if ( ( !$item->{notforloan} || $item->{notforloan} < 0 ) ){
+                                        # item is either for loan or has notforloan < 0
+                                        $can_place_holds = 1;
+                                    }
+                                }
+                            } elsif ( $item->{notforloan} < 0 ) {
+                                # item is not damaged and notforloan is < 0
+                                $can_place_holds = 1;
+                            }
+                        }
                     }
-                    
+
                     $other_count++;
 
                     my $key = $prefix . $item->{status};