Bug 10572: Add phone to message_transport_types table for new installs
[koha.git] / admin / preferences.pl
index e24657e..8bcdb0a 100755 (executable)
@@ -33,8 +33,8 @@ use C4::Budgets qw(GetCurrency);
 use File::Spec;
 use IO::File;
 use YAML::Syck qw();
+use List::MoreUtils qw(any);
 $YAML::Syck::ImplicitTyping = 1;
-$YAML::Syck::ImplicitUnicode = 1; # force utf-8 for preference encoding
 our $lang;
 
 # use Smart::Comments;
@@ -121,6 +121,13 @@ sub TransformPrefsToHTML {
     my $tab = $data->{ $title };
     $tab = { '' => $tab } if ( ref( $tab ) eq 'ARRAY' );
 
+    my @override_syspref_names;
+    if ( exists($ENV{OVERRIDE_SYSPREF_NAMES}) &&
+         defined($ENV{OVERRIDE_SYSPREF_NAMES})
+       ) {
+        @override_syspref_names = split /,/, $ENV{OVERRIDE_SYSPREF_NAMES};
+    }
+
     foreach my $group ( sort keys %$tab ) {
         if ( $group ) {
             push @lines, { is_group_title => 1, title => $group };
@@ -157,6 +164,7 @@ sub TransformPrefsToHTML {
                                 $name_entry->{'highlighted'} = 1;
                             }
                         }
+                        $name_entry->{'overridden'} = 1 if ( any { $name eq $_ } @override_syspref_names );
                         push @names, $name_entry;
                     } else {
                         push @chunks, $piece;
@@ -165,7 +173,6 @@ sub TransformPrefsToHTML {
                     push @chunks, { type_text => 1, contents => $piece };
                 }
             }
-
             push @lines, { CHUNKS => \@chunks, NAMES => \@names, is_group_title => 0 };
         }
     }
@@ -217,12 +224,10 @@ sub SearchPrefs {
 
                 foreach my $piece ( @$line ) {
                     if ( ref( $piece ) eq 'HASH' ) {
-                        if ( !$piece->{'pref'} ){ next; }
-                        if ( $piece->{'pref'} =~ /^$searchfield$/i ) {
-                            my ( undef, $LINES ) = TransformPrefsToHTML( $data, $searchfield );
-
-                            return { search_jumped => 1, tab => $tab_name, tab_title => $title, LINES => $LINES };
-                        } elsif ( matches( $piece->{'pref'}, \@terms) ) {
+                        if ( !$piece->{'pref'} ){
+                            next;
+                        }
+                        if ( matches( $piece->{'pref'}, \@terms) ) {
                             $matched = 1;
                         } elsif ( ref( $piece->{'choices'} ) eq 'HASH' && grep( { $_ && matches( $_, \@terms ) } values( %{ $piece->{'choices'} } ) ) ) {
                             $matched = 1;