bug Fixing : 3640
[koha.git] / C4 / Search.pm
index 257f945..809bc87 100644 (file)
@@ -1016,14 +1016,14 @@ sub buildQuery {
     my $stopwords_removed;    # flag to determine if stopwords have been removed
 
     my $cclq;
-    my $indexes = getIndexes();
-    for my $index (@$indexes){
-        if($query =~ /($index)(,?\w)*:/){
-            $cclq = 1;
+    my $cclindexes = getIndexes();
+    if( $query !~ /\s*ccl=/ ){
+        for my $index (@$cclindexes){
+            if($query =~ /($index)(,?\w)*:/){
+                $cclq = 1;
+            }
         }
-    }
-    if($cclq){
-        $query = "ccl=$query";
+        $query = "ccl=$query" if($cclq);
     }
 
 # for handling ccl, cql, pqf queries in diagnostic mode, skip the rest of the steps
@@ -1125,11 +1125,13 @@ sub buildQuery {
                 }
 
                 if ($auto_truncation){
-                                       #FIXME only valid with LTR scripts
-                                       $operand=join(" ",map{ 
-                                                                                       "$_*" 
-                                                                            }split (/\s+/,$operand));
-                       warn $operand if $DEBUG;
+                                       unless ( $index =~ /(st-|phr|ext)/ ) {
+                                               #FIXME only valid with LTR scripts
+                                               $operand=join(" ",map{ 
+                                                                                               "$_*" 
+                                                                                        }split (/\s+/,$operand));
+                                               warn $operand if $DEBUG;
+                                       }
                                }
 
                 # Detect Truncation
@@ -1392,16 +1394,20 @@ sub searchResults {
 
     # We get the biblionumber position in MARC 
     my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber','');
-    my $fw;
+    my $fw = '';
     
     # loop through all of the records we've retrieved
     for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
         my $marcrecord = MARC::File::USMARC::decode( $marcresults[$i] );
+               my $biblionumber;
         
-        if ($bibliotag<10){
-            $fw = GetFrameworkCode($marcrecord->field($bibliotag)->data);
-        }else{
-            $fw = GetFrameworkCode($marcrecord->subfield($bibliotag,$bibliosubf));
+        if(not $scan){
+            if ($bibliotag<10){
+                $biblionumber = $marcrecord->field($bibliotag)->data;
+            }else{
+                $biblionumber = $marcrecord->subfield($bibliotag,$bibliosubf);
+            } 
+            $fw = GetFrameworkCode($biblionumber);
         }
         
         my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, $fw );