use C4::ClassSource;
use C4::Log;
use C4::Output;
+use C4::Templates;
use C4::Budgets qw(GetCurrency);
use File::Spec;
use IO::File;
sub GetTab {
my ( $input, $tab ) = @_;
- my $tab_template = C4::Output::gettemplate( 'admin/preferences/' . $tab . '.pref', 'intranet', $input );
+ my $tab_template = C4::Templates::gettemplate( 'admin/preferences/' . $tab . '.pref', 'intranet', $input );
my $active_currency = GetCurrency();
my $local_currency;
}
}
- push @lines, { CHUNKS => \@chunks, NAMES => \@names };
+ push @lines, { CHUNKS => \@chunks, NAMES => \@names, is_group_title => 0 };
}
}
sub _get_pref_files {
my ( $input, $open_files ) = @_;
- my ( $htdocs, $theme, $lang, undef ) = C4::Output::_get_template_file( 'admin/preferences/admin.pref', 'intranet', $input );
+ my ( $htdocs, $theme, $lang, undef ) = C4::Templates::_get_template_file( 'admin/preferences/admin.pref', 'intranet', $input );
my %results;
my %tab_files = _get_pref_files( $input );
our @terms = split( /\s+/, $searchfield );
- sub matches {
- my ( $text ) = @_;
-
- return !grep( { $text !~ /$_/i } @terms );
- }
-
foreach my $tab_name ( keys %tab_files ) {
my $data = GetTab( $input, $tab_name );
my $title = ( keys( %$data ) )[0];
my $matched_groups;
while ( my ( $group_title, $contents ) = each %$tab ) {
- if ( matches( $group_title ) ) {
+ if ( matches( $group_title, \@terms ) ) {
$matched_groups->{$group_title} = $contents;
next;
}
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'} ) ) {
+ } elsif ( matches( $piece->{'pref'}, \@terms) ) {
$matched = 1;
- } elsif ( ref( $piece->{'choices'} ) eq 'HASH' && grep( { $_ && matches( $_ ) } values( %{ $piece->{'choices'} } ) ) ) {
+ } elsif ( ref( $piece->{'choices'} ) eq 'HASH' && grep( { $_ && matches( $_, \@terms ) } values( %{ $piece->{'choices'} } ) ) ) {
$matched = 1;
}
- } elsif ( matches( $piece ) ) {
+ } elsif ( matches( $piece, \@terms ) ) {
$matched = 1;
}
last if ( $matched );
return @tabs;
}
+sub matches {
+ my ( $text, $terms ) = @_;
+ if ( $text ) { return !grep( { $text !~ /$_/i } @$terms ); }
+}
+
my $dbh = C4::Context->dbh;
our $input = new CGI;
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => { parameters => 1 },
+ flagsrequired => { parameters => 'parameters_remaining_permissions' },
debug => 1,
}
);
if ( $op eq 'search' ) {
my $searchfield = $input->param( 'searchfield' );
- $searchfield =~ s/[^a-zA-Z0-9_ -]//g;
+ $searchfield =~ s/\p{IsC}//g;
+ $searchfield =~ s/\s+/ /;
+ $searchfield =~ s/^\s+//;
+ $searchfield =~ s/\s+$//;
$template->param( searchfield => $searchfield );